mirror of
https://github.com/Vita3K/Vita3K.git
synced 2026-07-11 01:34:23 +02:00
renderer/texture: Fix importing and exporting BCn mips
This commit is contained in:
Vendored
+17
-3
@@ -1018,19 +1018,33 @@ namespace ddspp
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned long long mipChainSize = 0;
|
unsigned long long mipChainSize = 0;
|
||||||
|
unsigned int width = desc.width;
|
||||||
|
unsigned int height = desc.height;
|
||||||
|
|
||||||
for (unsigned int m = 0; m < desc.numMips; ++m)
|
for (unsigned int m = 0; m < desc.numMips; ++m)
|
||||||
{
|
{
|
||||||
unsigned long long mipSize = mip0Size >> 2 * m; // Divide by 2 in width and height
|
unsigned long long blocksX = (width + desc.blockWidth - 1) / desc.blockWidth;
|
||||||
mipChainSize += mipSize > desc.bitsPerPixelOrBlock ? mipSize : desc.bitsPerPixelOrBlock;
|
unsigned long long blocksY = (height + desc.blockHeight - 1) / desc.blockHeight;
|
||||||
|
unsigned long long mipSize = blocksX * blocksY * desc.bitsPerPixelOrBlock;
|
||||||
|
mipChainSize += mipSize;
|
||||||
|
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += mipChainSize * slice;
|
offset += mipChainSize * slice;
|
||||||
|
|
||||||
|
width = desc.width;
|
||||||
|
height = desc.height;
|
||||||
for (unsigned int m = 0; m < mip; ++m)
|
for (unsigned int m = 0; m < mip; ++m)
|
||||||
{
|
{
|
||||||
unsigned long long mipSize = mip0Size >> 2 * m; // Divide by 2 in width and height
|
unsigned long long blocksX = (width + desc.blockWidth - 1) / desc.blockWidth;
|
||||||
|
unsigned long long blocksY = (height + desc.blockHeight - 1) / desc.blockHeight;
|
||||||
|
unsigned long long mipSize = blocksX * blocksY * desc.bitsPerPixelOrBlock;
|
||||||
offset += mipSize > desc.bitsPerPixelOrBlock ? mipSize : desc.bitsPerPixelOrBlock;
|
offset += mipSize > desc.bitsPerPixelOrBlock ? mipSize : desc.bitsPerPixelOrBlock;
|
||||||
|
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user