mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-24 13:20:13 +00:00
NVTT 1.x wrote L8/L16 as RGB instead of LUMINANCE
This commit is contained in:
parent
d13f66af05
commit
5f22c7cc39
@ -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
|
||||
|
@ -781,21 +781,48 @@ 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)
|
||||
switch (ddpf.RGBBitCount)
|
||||
{
|
||||
case 16:
|
||||
if (ISBITMASK(0xffff, 0, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R16_UNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
|
||||
{
|
||||
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
|
||||
@ -807,18 +834,7 @@ namespace
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_UNORM; // Some DDS writers assume the bitcount should be 8 instead of 16
|
||||
}
|
||||
}
|
||||
|
||||
if (16 == ddpf.RGBBitCount)
|
||||
{
|
||||
if (ISBITMASK(0xffff,0,0,0))
|
||||
{
|
||||
return DXGI_FORMAT_R16_UNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
if (ISBITMASK(0x00ff,0,0,0xff00))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_UNORM; // D3DX10/11 writes this out as DX10 extension
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ddpf.flags & DDS_ALPHA)
|
||||
@ -830,16 +846,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
|
||||
@ -850,6 +859,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
|
||||
|
@ -585,9 +585,15 @@ namespace
|
||||
{
|
||||
return D3DFMT_A8R3G3B2;
|
||||
}
|
||||
|
||||
// NVTT versions 1.x wrote these as RGB instead of LUMINANCE
|
||||
if (ISBITMASK(0xffff, 0, 0, 0))
|
||||
{
|
||||
return D3DFMT_L16;
|
||||
}
|
||||
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
|
||||
{
|
||||
return D3DFMT_A8L8; // NVTT versions 1.x wrote this as RGB instead of LUMINANCE
|
||||
return D3DFMT_A8L8;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -597,14 +603,32 @@ namespace
|
||||
return D3DFMT_R3G3B2;
|
||||
}
|
||||
|
||||
// NVTT versions 1.x wrote these as RGB instead of LUMINANCE
|
||||
if (ISBITMASK(0xff, 0, 0, 0))
|
||||
{
|
||||
return D3DFMT_L8;
|
||||
}
|
||||
|
||||
// Paletted texture formats are typically not supported on modern video cards aka D3DFMT_P8, D3DFMT_A8P8
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ddpf.flags & DDS_LUMINANCE)
|
||||
{
|
||||
if (8 == ddpf.RGBBitCount)
|
||||
switch (ddpf.RGBBitCount)
|
||||
{
|
||||
case 16:
|
||||
if (ISBITMASK(0xffff, 0, 0, 0))
|
||||
{
|
||||
return D3DFMT_L16;
|
||||
}
|
||||
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
|
||||
{
|
||||
return D3DFMT_A8L8;
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if (ISBITMASK(0x0f, 0, 0, 0xf0))
|
||||
{
|
||||
return D3DFMT_A4L4;
|
||||
@ -617,19 +641,7 @@ namespace
|
||||
{
|
||||
return D3DFMT_A8L8; // Some DDS writers assume the bitcount should be 8 instead of 16
|
||||
}
|
||||
}
|
||||
|
||||
if (16 == ddpf.RGBBitCount)
|
||||
{
|
||||
if (ISBITMASK(0xffff, 0, 0, 0))
|
||||
{
|
||||
return D3DFMT_L16;
|
||||
}
|
||||
if (ISBITMASK(0x00ff, 0, 0, 0xff00))
|
||||
{
|
||||
return D3DFMT_A8L8;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ddpf.flags & DDS_ALPHA)
|
||||
@ -641,16 +653,9 @@ namespace
|
||||
}
|
||||
else if (ddpf.flags & DDS_BUMPDUDV)
|
||||
{
|
||||
if (16 == ddpf.RGBBitCount)
|
||||
{
|
||||
if (ISBITMASK(0x00ff, 0xff00, 0, 0))
|
||||
{
|
||||
return D3DFMT_V8U8;
|
||||
}
|
||||
}
|
||||
|
||||
if (32 == ddpf.RGBBitCount)
|
||||
switch (ddpf.RGBBitCount)
|
||||
{
|
||||
case 32:
|
||||
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
|
||||
{
|
||||
return D3DFMT_Q8W8V8U8;
|
||||
@ -663,24 +668,33 @@ namespace
|
||||
{
|
||||
return D3DFMT_A2W10V10U10;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if (ISBITMASK(0x00ff, 0xff00, 0, 0))
|
||||
{
|
||||
return D3DFMT_V8U8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ddpf.flags & DDS_BUMPLUMINANCE)
|
||||
{
|
||||
if (16 == ddpf.RGBBitCount)
|
||||
{
|
||||
if (ISBITMASK(0x001f, 0x03e0, 0xfc00, 0))
|
||||
{
|
||||
return D3DFMT_L6V5U5;
|
||||
}
|
||||
}
|
||||
|
||||
if (32 == ddpf.RGBBitCount)
|
||||
switch (ddpf.RGBBitCount)
|
||||
{
|
||||
case 32:
|
||||
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0))
|
||||
{
|
||||
return D3DFMT_X8L8V8U8;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if (ISBITMASK(0x001f, 0x03e0, 0xfc00, 0))
|
||||
{
|
||||
return D3DFMT_L6V5U5;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ddpf.flags & DDS_FOURCC)
|
||||
|
@ -160,6 +160,12 @@ DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 =
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x00ff, 0, 0, 0xff00 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8_NVTT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xff, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16_NVTT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xffff, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00ff, 0, 0, 0xff00 };
|
||||
|
||||
|
@ -104,7 +104,11 @@ namespace
|
||||
{ DXGI_FORMAT_R16_UNORM, CONV_FLAGS_NONE, DDSPF_L16 }, // D3DFMT_L16
|
||||
{ DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8 }, // D3DFMT_A8L8
|
||||
{ DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8_ALT }, // D3DFMT_A8L8 (alternative bitcount)
|
||||
{ DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8_NVTT1 }, // D3DFMT_A8L8 (NVTT v1 wrote it with RGB instead of LUMINANCE)
|
||||
|
||||
// NVTT v1 wrote these with RGB instead of LUMINANCE
|
||||
{ DXGI_FORMAT_R8_UNORM, CONV_FLAGS_NONE, DDSPF_L8_NVTT1 }, // D3DFMT_L8
|
||||
{ DXGI_FORMAT_R16_UNORM, CONV_FLAGS_NONE, DDSPF_L16_NVTT1 }, // D3DFMT_L16
|
||||
{ DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8_NVTT1 }, // D3DFMT_A8L8
|
||||
|
||||
{ DXGI_FORMAT_A8_UNORM, CONV_FLAGS_NONE, DDSPF_A8 }, // D3DFMT_A8
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user