Branimir Karadžić 7 年之前
父節點
當前提交
5d6a946fb0
共有 2 個文件被更改,包括 7 次插入31 次删除
  1. 0 12
      src/renderer_d3d11.cpp
  2. 7 19
      src/renderer_d3d12.cpp

+ 0 - 12
src/renderer_d3d11.cpp

@@ -4383,16 +4383,8 @@ namespace bgfx { namespace d3d11
 
 
 			for (uint16_t side = 0; side < numSides; ++side)
 			for (uint16_t side = 0; side < numSides; ++side)
 			{
 			{
-				uint32_t width  = textureWidth;
-				uint32_t height = textureHeight;
-				uint32_t depth  = imageContainer.m_depth;
-
 				for (uint8_t lod = 0, num = numMips; lod < num; ++lod)
 				for (uint8_t lod = 0, num = numMips; lod < num; ++lod)
 				{
 				{
-					width  = bx::uint32_max(1, width);
-					height = bx::uint32_max(1, height);
-					depth  = bx::uint32_max(1, depth);
-
 					bimg::ImageMip mip;
 					bimg::ImageMip mip;
 					if (bimg::imageGetRawData(imageContainer, side, lod+startLod, _mem->data, _mem->size, mip) )
 					if (bimg::imageGetRawData(imageContainer, side, lod+startLod, _mem->data, _mem->size, mip) )
 					{
 					{
@@ -4420,10 +4412,6 @@ namespace bgfx { namespace d3d11
 						srd[kk].SysMemSlicePitch = mip.m_height*srd[kk].SysMemPitch;
 						srd[kk].SysMemSlicePitch = mip.m_height*srd[kk].SysMemPitch;
 						++kk;
 						++kk;
 					}
 					}
-
-					width  >>= 1;
-					height >>= 1;
-					depth  >>= 1;
 				}
 				}
 			}
 			}
 
 

+ 7 - 19
src/renderer_d3d12.cpp

@@ -4497,24 +4497,16 @@ namespace bgfx { namespace d3d12
 
 
 			for (uint8_t side = 0; side < numSides; ++side)
 			for (uint8_t side = 0; side < numSides; ++side)
 			{
 			{
-				uint32_t width  = textureWidth;
-				uint32_t height = textureHeight;
-				uint32_t depth  = imageContainer.m_depth;
-
 				for (uint8_t lod = 0; lod < numMips; ++lod)
 				for (uint8_t lod = 0; lod < numMips; ++lod)
 				{
 				{
-					width  = bx::uint32_max(blockWidth,  width);
-					height = bx::uint32_max(blockHeight, height);
-					depth  = bx::uint32_max(1, depth);
-
 					bimg::ImageMip mip;
 					bimg::ImageMip mip;
 					if (bimg::imageGetRawData(imageContainer, side, lod+startLod, _mem->data, _mem->size, mip) )
 					if (bimg::imageGetRawData(imageContainer, side, lod+startLod, _mem->data, _mem->size, mip) )
 					{
 					{
 						if (convert)
 						if (convert)
 						{
 						{
-							const uint32_t pitch = bx::strideAlign(bx::max<uint32_t>(width,  4)*bpp/8, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
-							const uint32_t slice = bx::strideAlign(bx::max<uint32_t>(height, 4)*pitch, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
-							const uint32_t size  = slice*depth;
+							const uint32_t pitch = bx::strideAlign(bx::max<uint32_t>(mip.m_width,  4)*bpp/8, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
+							const uint32_t slice = bx::strideAlign(bx::max<uint32_t>(mip.m_height, 4)*pitch, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
+							const uint32_t size  = slice*mip.m_depth;
 
 
 							uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, size);
 							uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, size);
 							bimg::imageDecodeToBgra8(
 							bimg::imageDecodeToBgra8(
@@ -4535,13 +4527,13 @@ namespace bgfx { namespace d3d12
 						{
 						{
 							const uint32_t pitch = bx::strideAlign( (mip.m_width /blockInfo.blockWidth )*mip.m_blockSize, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
 							const uint32_t pitch = bx::strideAlign( (mip.m_width /blockInfo.blockWidth )*mip.m_blockSize, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
 							const uint32_t slice = bx::strideAlign( (mip.m_height/blockInfo.blockHeight)*pitch,           D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
 							const uint32_t slice = bx::strideAlign( (mip.m_height/blockInfo.blockHeight)*pitch,           D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
-							const uint32_t size  = slice*depth;
+							const uint32_t size  = slice*mip.m_depth;
 
 
 							uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, size);
 							uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, size);
 							bimg::imageCopy(temp
 							bimg::imageCopy(temp
 									,  mip.m_height/blockInfo.blockHeight
 									,  mip.m_height/blockInfo.blockHeight
 									, (mip.m_width /blockInfo.blockWidth )*mip.m_blockSize
 									, (mip.m_width /blockInfo.blockWidth )*mip.m_blockSize
-									, depth
+									, mip.m_depth
 									, mip.m_data
 									, mip.m_data
 									, pitch
 									, pitch
 									);
 									);
@@ -4555,11 +4547,11 @@ namespace bgfx { namespace d3d12
 							const uint32_t pitch = bx::strideAlign(mip.m_width*mip.m_bpp / 8, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
 							const uint32_t pitch = bx::strideAlign(mip.m_width*mip.m_bpp / 8, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
 							const uint32_t slice = bx::strideAlign(mip.m_height*pitch,        D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
 							const uint32_t slice = bx::strideAlign(mip.m_height*pitch,        D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
 
 
-							uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, slice*depth);
+							uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, slice*mip.m_depth);
 							bimg::imageCopy(temp
 							bimg::imageCopy(temp
 									, mip.m_height
 									, mip.m_height
 									, mip.m_width*mip.m_bpp/8
 									, mip.m_width*mip.m_bpp/8
-									, depth
+									, mip.m_depth
 									, mip.m_data
 									, mip.m_data
 									, pitch
 									, pitch
 									);
 									);
@@ -4571,10 +4563,6 @@ namespace bgfx { namespace d3d12
 
 
 						++kk;
 						++kk;
 					}
 					}
-
-					width  >>= 1;
-					height >>= 1;
-					depth  >>= 1;
 				}
 				}
 			}
 			}