mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-08 13:56:13 +01:00
NVTT 1.x wrote L8/L16 as RGB instead of LUMINANCE
This commit is contained in:
@@ -122,7 +122,7 @@ namespace
|
||||
|
||||
using ScopedHandle = std::unique_ptr<void, handle_closer>;
|
||||
|
||||
inline HANDLE safe_handle( HANDLE h ) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
|
||||
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
|
||||
|
||||
template<UINT TNameLength>
|
||||
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char (&name)[TNameLength]) noexcept
|
||||
@@ -701,36 +701,37 @@ namespace
|
||||
return DXGI_FORMAT_B4G4R4A4_UNORM;
|
||||
}
|
||||
|
||||
// NVTT versions 1.x wrote this as RGB instead of LUMINANCE
|
||||
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_UNORM; // NVTT versions 1.x wrote this as RGB instead of LUMINANCE
|
||||
return DXGI_FORMAT_R8G8_UNORM;
|
||||
}
|
||||
if (ISBITMASK(0xffff, 0, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R16_UNORM;
|
||||
}
|
||||
|
||||
// No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0) aka D3DFMT_X4R4G4B4
|
||||
|
||||
// No 3:3:2, 3:3:2:8, or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_R3G3B2, D3DFMT_P8, D3DFMT_A8P8, etc.
|
||||
// No 3:3:2:8 or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_A8P8, etc.
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// NVTT versions 1.x wrote this as RGB instead of LUMINANCE
|
||||
if (ISBITMASK(0xff, 0, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R8_UNORM;
|
||||
}
|
||||
|
||||
// No 3:3:2 or paletted DXGI formats aka D3DFMT_R3G3B2, D3DFMT_P8
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ddpf.flags & DDS_LUMINANCE)
|
||||
{
|
||||
if (8 == ddpf.RGBBitCount)
|
||||
{
|
||||
if (ISBITMASK(0xff, 0, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R8_UNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
|
||||
// No DXGI format maps to ISBITMASK(0x0f,0x00,0x00,0xf0) aka D3DFMT_A4L4
|
||||
|
||||
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_UNORM; // Some DDS writers assume the bitcount should be 8 instead of 16
|
||||
}
|
||||
}
|
||||
|
||||
if (16 == ddpf.RGBBitCount)
|
||||
switch (ddpf.RGBBitCount)
|
||||
{
|
||||
case 16:
|
||||
if (ISBITMASK(0xffff, 0, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R16_UNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
@@ -739,6 +740,21 @@ namespace
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_UNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if (ISBITMASK(0xff, 0, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R8_UNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
|
||||
// No DXGI format maps to ISBITMASK(0x0f,0,0,0xf0) aka D3DFMT_A4L4
|
||||
|
||||
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_UNORM; // Some DDS writers assume the bitcount should be 8 instead of 16
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ddpf.flags & DDS_ALPHA)
|
||||
@@ -750,16 +766,9 @@ namespace
|
||||
}
|
||||
else if (ddpf.flags & DDS_BUMPDUDV)
|
||||
{
|
||||
if (16 == ddpf.RGBBitCount)
|
||||
{
|
||||
if (ISBITMASK(0x00ff, 0xff00, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
}
|
||||
|
||||
if (32 == ddpf.RGBBitCount)
|
||||
switch (ddpf.RGBBitCount)
|
||||
{
|
||||
case 32:
|
||||
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8B8A8_SNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
@@ -770,6 +779,14 @@ namespace
|
||||
}
|
||||
|
||||
// No DXGI format maps to ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000) aka D3DFMT_A2W10V10U10
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if (ISBITMASK(0x00ff, 0xff00, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// No DXGI format maps to DDPF_BUMPLUMINANCE aka D3DFMT_L6V5U5, D3DFMT_X8L8V8U8
|
||||
|
||||
Reference in New Issue
Block a user