Branimir Karadžić 10 years ago
parent
commit
0ed78a0753
2 changed files with 78 additions and 90 deletions
  1. 1 7
      src/bgfx_p.h
  2. 77 83
      src/renderer_d3d9.cpp

+ 1 - 7
src/bgfx_p.h

@@ -450,13 +450,7 @@ namespace bgfx
 				const uint32_t width  = (bx::uint32_min(m_width,  _width +_x)-_x)*2;
 				const uint32_t width  = (bx::uint32_min(m_width,  _width +_x)-_x)*2;
 				const uint32_t height =  bx::uint32_min(m_height, _height+_y)-_y;
 				const uint32_t height =  bx::uint32_min(m_height, _height+_y)-_y;
 				const uint32_t dstPitch = m_width*2;
 				const uint32_t dstPitch = m_width*2;
-
-				for (uint32_t yy = 0; yy < height; ++yy)
-				{
-					memcpy(dst, src, width);
-					dst += dstPitch;
-					src += _pitch;
-				}
+				bx::memcpy(dst, src, width, height, _pitch, dstPitch);
 			}
 			}
 		}
 		}
 
 

+ 77 - 83
src/renderer_d3d9.cpp

@@ -603,85 +603,85 @@ namespace bgfx { namespace d3d9
 				s_textureFormat[TextureFormat::BC5].m_fmt = s_extendedFormats[ExtendedFormat::Ati2].m_supported ? D3DFMT_ATI2 : D3DFMT_UNKNOWN;
 				s_textureFormat[TextureFormat::BC5].m_fmt = s_extendedFormats[ExtendedFormat::Ati2].m_supported ? D3DFMT_ATI2 : D3DFMT_UNKNOWN;
 
 
 				g_caps.supported |= m_instancingSupport ? BGFX_CAPS_INSTANCING : 0;
 				g_caps.supported |= m_instancingSupport ? BGFX_CAPS_INSTANCING : 0;
+			}
 
 
-				for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
-				{
-					uint8_t support = 0;
+			for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
+			{
+				uint8_t support = 0;
 
 
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, 0
-						, D3DRTYPE_TEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_2D : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, D3DUSAGE_QUERY_SRGBREAD
-						, D3DRTYPE_TEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, 0
-						, D3DRTYPE_VOLUMETEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_3D : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, D3DUSAGE_QUERY_SRGBREAD
-						, D3DRTYPE_VOLUMETEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, 0
-						, D3DRTYPE_CUBETEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_CUBE : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, D3DUSAGE_QUERY_SRGBREAD
-						, D3DRTYPE_CUBETEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, D3DUSAGE_QUERY_VERTEXTEXTURE
-						, D3DRTYPE_TEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_VERTEX : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
-						, m_deviceType
-						, adapterFormat
-						, isDepth(TextureFormat::Enum(ii) ) ? D3DUSAGE_DEPTHSTENCIL : D3DUSAGE_RENDERTARGET
-						, D3DRTYPE_TEXTURE
-						, s_textureFormat[ii].m_fmt
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER : BGFX_CAPS_FORMAT_TEXTURE_NONE;
-
-					support |= SUCCEEDED(m_d3d9->CheckDeviceMultiSampleType(m_adapter
-						, m_deviceType
-						, s_textureFormat[ii].m_fmt
-						, true
-						, D3DMULTISAMPLE_2_SAMPLES
-						, NULL
-						) ) ? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, 0
+					, D3DRTYPE_TEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_2D : BGFX_CAPS_FORMAT_TEXTURE_NONE;
 
 
-					g_caps.formats[ii] = support;
-				}
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, D3DUSAGE_QUERY_SRGBREAD
+					, D3DRTYPE_TEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, 0
+					, D3DRTYPE_VOLUMETEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_3D : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, D3DUSAGE_QUERY_SRGBREAD
+					, D3DRTYPE_VOLUMETEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, 0
+					, D3DRTYPE_CUBETEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_CUBE : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, D3DUSAGE_QUERY_SRGBREAD
+					, D3DRTYPE_CUBETEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, D3DUSAGE_QUERY_VERTEXTEXTURE
+					, D3DRTYPE_TEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_VERTEX : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter
+					, m_deviceType
+					, adapterFormat
+					, isDepth(TextureFormat::Enum(ii) ) ? D3DUSAGE_DEPTHSTENCIL : D3DUSAGE_RENDERTARGET
+					, D3DRTYPE_TEXTURE
+					, s_textureFormat[ii].m_fmt
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				support |= SUCCEEDED(m_d3d9->CheckDeviceMultiSampleType(m_adapter
+					, m_deviceType
+					, s_textureFormat[ii].m_fmt
+					, true
+					, D3DMULTISAMPLE_2_SAMPLES
+					, NULL
+					) ) ? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA : BGFX_CAPS_FORMAT_TEXTURE_NONE;
+
+				g_caps.formats[ii] = support;
 			}
 			}
 
 
 			m_fmtDepth = D3DFMT_D24S8;
 			m_fmtDepth = D3DFMT_D24S8;
@@ -2913,13 +2913,7 @@ namespace bgfx { namespace d3d9
 										, mip.m_format
 										, mip.m_format
 										);
 										);
 
 
-								uint32_t dstpitch = pitch;
-								for (uint32_t yy = 0; yy < height; ++yy)
-								{
-									uint8_t* src = &temp[yy*srcpitch];
-									uint8_t* dst = &bits[yy*dstpitch];
-									memcpy(dst, src, dstpitch);
-								}
+								bx::memcpy(bits, temp, pitch, height, srcpitch, pitch);
 
 
 								BX_FREE(g_allocator, temp);
 								BX_FREE(g_allocator, temp);
 							}
 							}