mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
DirectXTex: fixed wide-image issue with CPU Compress
This commit is contained in:
parent
f3ef3dcbf5
commit
4233e222e3
@ -67,6 +67,9 @@ namespace DirectX
|
||||
CP_FLAGS_NONE = 0x0, // Normal operation
|
||||
CP_FLAGS_LEGACY_DWORD = 0x1, // Assume pitch is DWORD aligned instead of BYTE aligned
|
||||
CP_FLAGS_PARAGRAPH = 0x2, // Assume pitch is 16-byte aligned instead of BYTE aligned
|
||||
CP_FLAGS_YMM = 0x4, // Assume pitch is 32-byte aligned instead of BYTE aligned
|
||||
CP_FLAGS_ZMM = 0x8, // Assume pitch is 64-byte aligned instead of BYTE aligned
|
||||
CP_FLAGS_PAGE4K = 0x200, // Assume pitch is 4096-byte aligned instead of BYTE aligned
|
||||
CP_FLAGS_24BPP = 0x10000, // Override with a legacy 24 bits-per-pixel format size
|
||||
CP_FLAGS_16BPP = 0x20000, // Override with a legacy 16 bits-per-pixel format size
|
||||
CP_FLAGS_8BPP = 0x40000, // Override with a legacy 8 bits-per-pixel format size
|
||||
|
@ -110,7 +110,7 @@ static HRESULT _CompressBC( _In_ const Image& image, _In_ const Image& result, _
|
||||
uint8_t* dptr = pDest;
|
||||
size_t ph = std::min<size_t>( 4, image.height - h );
|
||||
size_t w = 0;
|
||||
for( size_t count = 0; count < rowPitch; count += sbpp*4, w += 4 )
|
||||
for( size_t count = 0; count < result.rowPitch; count += blocksize, w += 4 )
|
||||
{
|
||||
size_t pw = std::min<size_t>( 4, image.width - w );
|
||||
assert( pw > 0 && ph > 0 );
|
||||
|
@ -654,20 +654,39 @@ void ComputePitch( DXGI_FORMAT fmt, size_t width, size_t height,
|
||||
else
|
||||
bpp = BitsPerPixel( fmt );
|
||||
|
||||
if ( flags & CP_FLAGS_LEGACY_DWORD )
|
||||
if ( flags & ( CP_FLAGS_LEGACY_DWORD | CP_FLAGS_PARAGRAPH | CP_FLAGS_YMM | CP_FLAGS_ZMM | CP_FLAGS_PAGE4K ) )
|
||||
{
|
||||
// Special computation for some incorrectly created DDS files based on
|
||||
// legacy DirectDraw assumptions about pitch alignment
|
||||
rowPitch = ( ( width * bpp + 31 ) / 32 ) * sizeof(uint32_t);
|
||||
slicePitch = rowPitch * height;
|
||||
}
|
||||
else if ( flags & CP_FLAGS_PARAGRAPH )
|
||||
{
|
||||
rowPitch = ( ( width * bpp + 127 ) / 128 ) * 16;
|
||||
slicePitch = rowPitch * height;
|
||||
if ( flags & CP_FLAGS_PAGE4K )
|
||||
{
|
||||
rowPitch = ( ( width * bpp + 32767 ) / 32768 ) * 4096;
|
||||
slicePitch = rowPitch * height;
|
||||
}
|
||||
else if ( flags & CP_FLAGS_ZMM )
|
||||
{
|
||||
rowPitch = ( ( width * bpp + 511 ) / 512 ) * 64;
|
||||
slicePitch = rowPitch * height;
|
||||
}
|
||||
else if ( flags & CP_FLAGS_YMM )
|
||||
{
|
||||
rowPitch = ( ( width * bpp + 255 ) / 256) * 32;
|
||||
slicePitch = rowPitch * height;
|
||||
}
|
||||
else if ( flags & CP_FLAGS_PARAGRAPH )
|
||||
{
|
||||
rowPitch = ( ( width * bpp + 127 ) / 128 ) * 16;
|
||||
slicePitch = rowPitch * height;
|
||||
}
|
||||
else // DWORD alignment
|
||||
{
|
||||
// Special computation for some incorrectly created DDS files based on
|
||||
// legacy DirectDraw assumptions about pitch alignment
|
||||
rowPitch = ( ( width * bpp + 31 ) / 32 ) * sizeof(uint32_t);
|
||||
slicePitch = rowPitch * height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default byte alignment
|
||||
rowPitch = ( width * bpp + 7 ) / 8;
|
||||
slicePitch = rowPitch * height;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user