summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/tools/texturec/texturec.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/tools/texturec/texturec.cpp')
-rw-r--r--3rdparty/bgfx/tools/texturec/texturec.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/3rdparty/bgfx/tools/texturec/texturec.cpp b/3rdparty/bgfx/tools/texturec/texturec.cpp
index 35983dc9849..12a5bda84bf 100644
--- a/3rdparty/bgfx/tools/texturec/texturec.cpp
+++ b/3rdparty/bgfx/tools/texturec/texturec.cpp
@@ -472,7 +472,12 @@ int main(int _argc, const char* _argv[])
if (normalMap)
{
- uint32_t size = imageGetSize(TextureFormat::RGBA32F, mip.m_width, mip.m_height);
+ output = imageAlloc(imageContainer, format, mip.m_width, mip.m_height, 0, false, mips);
+
+ ImageMip dstMip;
+ imageGetRawData(imageContainer, 0, 0, NULL, 0, dstMip);
+
+ uint32_t size = imageGetSize(TextureFormat::RGBA32F, dstMip.m_width, dstMip.m_height);
temp = BX_ALLOC(&allocator, size);
float* rgba = (float*)temp;
float* rgbaDst = (float*)BX_ALLOC(&allocator, size);
@@ -502,19 +507,13 @@ int main(int _argc, const char* _argv[])
}
}
- output = imageAlloc(imageContainer, format, mip.m_width, mip.m_height, 0, false, mips);
-
- imageRgba32f11to01(rgbaDst, mip.m_width, mip.m_height, mip.m_width*16, rgba);
- imageEncodeFromRgba32f(&allocator, output->data, rgbaDst, mip.m_width, mip.m_height, format);
+ imageRgba32f11to01(rgbaDst, dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba);
+ imageEncodeFromRgba32f(&allocator, output->data, rgbaDst, dstMip.m_width, dstMip.m_height, format);
for (uint8_t lod = 1; lod < numMips; ++lod)
{
- imageRgba32fDownsample2x2NormalMap(mip.m_width, mip.m_height, mip.m_width*16, rgba, rgba);
- imageRgba32f11to01(rgbaDst, mip.m_width, mip.m_height, mip.m_width*16, rgba);
- mip.m_width = bx::uint32_max(1, mip.m_width >> 1);
- mip.m_height = bx::uint32_max(1, mip.m_height >> 1);
-
- ImageMip dstMip;
+ imageRgba32fDownsample2x2NormalMap(dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba, rgba);
+ imageRgba32f11to01(rgbaDst, dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba);
imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip);
uint8_t* data = const_cast<uint8_t*>(dstMip.m_data);
imageEncodeFromRgba32f(&allocator, data, rgbaDst, dstMip.m_width, dstMip.m_height, format);
@@ -524,8 +523,14 @@ int main(int _argc, const char* _argv[])
}
else
{
- uint32_t size = imageGetSize(TextureFormat::RGBA8, mip.m_width, mip.m_height);
+ output = imageAlloc(imageContainer, format, mip.m_width, mip.m_height, 0, false, mips);
+
+ ImageMip dstMip;
+ imageGetRawData(imageContainer, 0, 0, NULL, 0, dstMip);
+
+ uint32_t size = imageGetSize(TextureFormat::RGBA8, dstMip.m_width, dstMip.m_height);
temp = BX_ALLOC(&allocator, size);
+ memset(temp, 0, size);
uint8_t* rgba = (uint8_t*)temp;
imageDecodeToRgba8(rgba
@@ -536,17 +541,11 @@ int main(int _argc, const char* _argv[])
, mip.m_format
);
- output = imageAlloc(imageContainer, format, mip.m_width, mip.m_height, 0, false, mips);
-
- imageEncodeFromRgba8(output->data, rgba, mip.m_width, mip.m_height, format);
+ imageEncodeFromRgba8(output->data, rgba, dstMip.m_width, dstMip.m_height, format);
for (uint8_t lod = 1; lod < numMips; ++lod)
{
- imageRgba8Downsample2x2(mip.m_width, mip.m_height, mip.m_width*4, rgba, rgba);
- mip.m_width = bx::uint32_max(1, mip.m_width >> 1);
- mip.m_height = bx::uint32_max(1, mip.m_height >> 1);
-
- ImageMip dstMip;
+ imageRgba8Downsample2x2(dstMip.m_width, dstMip.m_height, dstMip.m_width*4, rgba, rgba);
imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip);
uint8_t* data = const_cast<uint8_t*>(dstMip.m_data);
imageEncodeFromRgba8(data, rgba, dstMip.m_width, dstMip.m_height, format);