mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-09 14:30:05 +00:00
NVTT 1.x wrote L8/L16 as RGB instead of LUMINANCE
This commit is contained in:
parent
d13f66af05
commit
5f22c7cc39
@ -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
|
||||
|
@ -49,7 +49,7 @@ using namespace DirectX;
|
||||
// Macros
|
||||
//--------------------------------------------------------------------------------------
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
|
||||
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
|
||||
#endif /* defined(MAKEFOURCC) */
|
||||
@ -407,9 +407,9 @@ namespace
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Return the BPP for a particular format
|
||||
//--------------------------------------------------------------------------------------
|
||||
size_t BitsPerPixel( _In_ DXGI_FORMAT fmt ) noexcept
|
||||
size_t BitsPerPixel(_In_ DXGI_FORMAT fmt) noexcept
|
||||
{
|
||||
switch( fmt )
|
||||
switch (fmt)
|
||||
{
|
||||
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
|
||||
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
||||
@ -708,7 +708,7 @@ namespace
|
||||
//--------------------------------------------------------------------------------------
|
||||
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
|
||||
|
||||
DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf ) noexcept
|
||||
DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf) noexcept
|
||||
{
|
||||
if (ddpf.flags & DDS_RGB)
|
||||
{
|
||||
@ -717,17 +717,17 @@ namespace
|
||||
switch (ddpf.RGBBitCount)
|
||||
{
|
||||
case 32:
|
||||
if (ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0xff000000))
|
||||
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
|
||||
{
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
|
||||
if (ISBITMASK(0x00ff0000,0x0000ff00,0x000000ff,0xff000000))
|
||||
if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000))
|
||||
{
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
}
|
||||
|
||||
if (ISBITMASK(0x00ff0000,0x0000ff00,0x000000ff,0))
|
||||
if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0))
|
||||
{
|
||||
return DXGI_FORMAT_B8G8R8X8_UNORM;
|
||||
}
|
||||
@ -741,19 +741,19 @@ namespace
|
||||
// header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly
|
||||
|
||||
// For 'correct' writers, this should be 0x000003ff,0x000ffc00,0x3ff00000 for RGB data
|
||||
if (ISBITMASK(0x3ff00000,0x000ffc00,0x000003ff,0xc0000000))
|
||||
if (ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000))
|
||||
{
|
||||
return DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
}
|
||||
|
||||
// No DXGI format maps to ISBITMASK(0x000003ff,0x000ffc00,0x3ff00000,0xc0000000) aka D3DFMT_A2R10G10B10
|
||||
|
||||
if (ISBITMASK(0x0000ffff,0xffff0000,0,0))
|
||||
if (ISBITMASK(0x0000ffff, 0xffff0000, 0, 0))
|
||||
{
|
||||
return DXGI_FORMAT_R16G16_UNORM;
|
||||
}
|
||||
|
||||
if (ISBITMASK(0xffffffff,0,0,0))
|
||||
if (ISBITMASK(0xffffffff, 0, 0, 0))
|
||||
{
|
||||
// Only 32-bit color channel format in D3D9 was R32F
|
||||
return DXGI_FORMAT_R32_FLOAT; // D3DX writes this out as a FourCC of 114
|
||||
@ -765,38 +765,65 @@ namespace
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if (ISBITMASK(0x7c00,0x03e0,0x001f,0x8000))
|
||||
if (ISBITMASK(0x7c00, 0x03e0, 0x001f, 0x8000))
|
||||
{
|
||||
return DXGI_FORMAT_B5G5R5A1_UNORM;
|
||||
}
|
||||
if (ISBITMASK(0xf800,0x07e0,0x001f,0))
|
||||
if (ISBITMASK(0xf800, 0x07e0, 0x001f, 0))
|
||||
{
|
||||
return DXGI_FORMAT_B5G6R5_UNORM;
|
||||
}
|
||||
|
||||
// No DXGI format maps to ISBITMASK(0x7c00,0x03e0,0x001f,0) aka D3DFMT_X1R5G5B5
|
||||
|
||||
if (ISBITMASK(0x0f00,0x00f0,0x000f,0xf000))
|
||||
if (ISBITMASK(0x0f00, 0x00f0, 0x000f, 0xf000))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (ISBITMASK(0xff,0,0,0))
|
||||
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,80 +859,88 @@ 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
|
||||
}
|
||||
else if (ddpf.flags & DDS_FOURCC)
|
||||
{
|
||||
if (MAKEFOURCC( 'D', 'X', 'T', '1' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('D', 'X', 'T', '1') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC1_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'D', 'X', 'T', '3' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('D', 'X', 'T', '3') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC2_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'D', 'X', 'T', '5' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('D', 'X', 'T', '5') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC3_UNORM;
|
||||
}
|
||||
|
||||
// While pre-multiplied alpha isn't directly supported by the DXGI formats,
|
||||
// they are basically the same as these BC formats so they can be mapped
|
||||
if (MAKEFOURCC( 'D', 'X', 'T', '2' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('D', 'X', 'T', '2') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC2_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'D', 'X', 'T', '4' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('D', 'X', 'T', '4') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC3_UNORM;
|
||||
}
|
||||
|
||||
if (MAKEFOURCC( 'A', 'T', 'I', '1' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('A', 'T', 'I', '1') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC4_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'B', 'C', '4', 'U' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('B', 'C', '4', 'U') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC4_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'B', 'C', '4', 'S' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('B', 'C', '4', 'S') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC4_SNORM;
|
||||
}
|
||||
|
||||
if (MAKEFOURCC( 'A', 'T', 'I', '2' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('A', 'T', 'I', '2') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC5_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'B', 'C', '5', 'U' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('B', 'C', '5', 'U') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC5_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'B', 'C', '5', 'S' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('B', 'C', '5', 'S') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_BC5_SNORM;
|
||||
}
|
||||
|
||||
// BC6H and BC7 are written using the "DX10" extended header
|
||||
|
||||
if (MAKEFOURCC( 'R', 'G', 'B', 'G' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('R', 'G', 'B', 'G') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_R8G8_B8G8_UNORM;
|
||||
}
|
||||
if (MAKEFOURCC( 'G', 'R', 'G', 'B' ) == ddpf.fourCC)
|
||||
if (MAKEFOURCC('G', 'R', 'G', 'B') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_G8R8_G8B8_UNORM;
|
||||
}
|
||||
|
||||
if (MAKEFOURCC('Y','U','Y','2') == ddpf.fourCC)
|
||||
if (MAKEFOURCC('Y', 'U', 'Y', '2') == ddpf.fourCC)
|
||||
{
|
||||
return DXGI_FORMAT_YUY2;
|
||||
}
|
||||
|
||||
// Check for D3DFORMAT enums being set here
|
||||
switch( ddpf.fourCC )
|
||||
switch (ddpf.fourCC)
|
||||
{
|
||||
case 36: // D3DFMT_A16B16G16R16
|
||||
return DXGI_FORMAT_R16G16B16A16_UNORM;
|
||||
@ -960,9 +977,9 @@ namespace
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
DXGI_FORMAT MakeSRGB( _In_ DXGI_FORMAT format ) noexcept
|
||||
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept
|
||||
{
|
||||
switch( format )
|
||||
switch (format)
|
||||
{
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
|
@ -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)
|
||||
|
@ -149,7 +149,7 @@ DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4L4 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0f, 0, 0, 0xf0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 };
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 };
|
||||
@ -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 };
|
||||
|
||||
|
@ -100,11 +100,15 @@ namespace
|
||||
{ DXGI_FORMAT_B5G6R5_UNORM, CONV_FLAGS_EXPAND
|
||||
| CONV_FLAGS_332, DDSPF_R3G3B2 }, // D3DFMT_R3G3B2
|
||||
|
||||
{ DXGI_FORMAT_R8_UNORM, CONV_FLAGS_NONE, DDSPF_L8 }, // D3DFMT_L8
|
||||
{ DXGI_FORMAT_R16_UNORM, CONV_FLAGS_NONE, DDSPF_L16 }, // D3DFMT_L16
|
||||
{ DXGI_FORMAT_R8_UNORM, CONV_FLAGS_NONE, DDSPF_L8 }, // D3DFMT_L8
|
||||
{ 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