diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index f1009d47..70b00aef 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -4894,6 +4894,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); : 0 ; + bool depth = isDepth(TextureFormat::Enum(src.m_textureFormat) ); deviceCtx->CopySubresourceRegion(dst.m_ptr , dstZ*dst.m_numMips+blit.m_dstMip , blit.m_dstX @@ -4901,7 +4902,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); , 0 , src.m_ptr , srcZ*src.m_numMips+blit.m_srcMip - , isDepth((TextureFormat::Enum)src.m_textureFormat) ? NULL : &box + , depth ? NULL : &box ); } } diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index b253315f..30347818 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -4614,12 +4614,13 @@ data.NumQualityLevels = 0; D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { dstZ*dst.m_numMips+blit.m_dstMip } }; D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { srcZ*src.m_numMips+blit.m_srcMip } }; + bool depth = isDepth(TextureFormat::Enum(src.m_textureFormat) ); m_commandList->CopyTextureRegion(&dstLocation , blit.m_dstX , blit.m_dstY , 0 , &srcLocation - , &box + , depth ? NULL : &box ); } } diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 951edf3f..676ba9f4 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -3648,10 +3648,11 @@ namespace bgfx { namespace d3d9 // // GetRenderTargetData (dst must be SYSTEMMEM) + bool depth = isDepth(TextureFormat::Enum(src.m_textureFormat) ); HRESULT hr = m_device->StretchRect(srcSurface - , isDepth((TextureFormat::Enum)src.m_textureFormat) ? NULL : &srcRect + , depth ? NULL : &srcRect , dstSurface - , isDepth((TextureFormat::Enum)src.m_textureFormat) ? NULL : &dstRect + , depth ? NULL : &dstRect , D3DTEXF_NONE ); if (FAILED(hr) ) diff --git a/tools/texturec/texturec.cpp b/tools/texturec/texturec.cpp index 06e79280..aa225d80 100644 --- a/tools/texturec/texturec.cpp +++ b/tools/texturec/texturec.cpp @@ -18,6 +18,7 @@ using namespace bgfx; #endif // DEBUG #include +#include #include #include @@ -70,6 +71,13 @@ int main(int _argc, const char* _argv[]) return EXIT_FAILURE; } + const char* outputFileName = cmdLine.findOption('o'); + if (NULL == outputFileName) + { + help("Output file must be specified."); + return EXIT_FAILURE; + } + bx::CrtFileReader reader; if (0 != bx::open(&reader, inputFileName) ) { @@ -84,6 +92,21 @@ int main(int _argc, const char* _argv[]) ImageContainer imageContainer; + if (imageParse(imageContainer, mem->data, mem->size) ) + { + bx::CrtFileWriter writer; + if (0 == bx::open(&writer, outputFileName) ) + { + if (NULL != bx::stristr(outputFileName, ".ktx") ) + { + imageWriteKtx(&writer, imageContainer, mem->data, mem->size); + } + + bx::close(&writer); + } + } + +#if 0 if (imageParse(imageContainer, mem->data, mem->size) ) { bool decompress = cmdLine.hasArg('d'); @@ -93,12 +116,12 @@ int main(int _argc, const char* _argv[]) { for (uint8_t side = 0, numSides = imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side) { - uint32_t width = imageContainer.m_width; + uint32_t width = imageContainer.m_width; uint32_t height = imageContainer.m_height; for (uint32_t lod = 0, num = imageContainer.m_numMips; lod < num; ++lod) { - width = bx::uint32_max(1, width); + width = bx::uint32_max(1, width); height = bx::uint32_max(1, height); ImageMip mip; @@ -107,7 +130,7 @@ int main(int _argc, const char* _argv[]) uint32_t dstpitch = width*4; uint8_t* bits = (uint8_t*)malloc(dstpitch*height); - if (width != mip.m_width + if (width != mip.m_width || height != mip.m_height) { uint8_t* temp = (uint8_t*)realloc(NULL, mip.m_width*mip.m_height*4); @@ -195,6 +218,7 @@ int main(int _argc, const char* _argv[]) } } } +#endif // 0 release(mem);