mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-10 14:46:14 +01:00
DDS support for legacy bumpmap formats D3DFMT_V8U8, D3DFMT_Q8W8V8U8, and D3DFMT_V16U16
This commit is contained in:
@@ -58,6 +58,7 @@ struct DDS_PIXELFORMAT
|
||||
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
|
||||
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
|
||||
#define DDS_PAL8 0x00000020 // DDPF_PALETTEINDEXED8
|
||||
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
|
||||
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
@@ -140,6 +141,15 @@ extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8L8 =
|
||||
extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0x00, 0x00, 0x00, 0xff };
|
||||
|
||||
extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_V8U8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0x0000, 0x0000 };
|
||||
|
||||
extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_Q8W8V8U8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
|
||||
|
||||
extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_V16U16 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 };
|
||||
|
||||
// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
|
||||
|
||||
// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
|
||||
|
||||
@@ -126,6 +126,10 @@ const LegacyDDS g_LegacyDDSMap[] =
|
||||
|
||||
{ DXGI_FORMAT_YUY2, CONV_FLAGS_NONE, DDSPF_YUY2 }, // D3DFMT_YUY2 (uses DXGI 1.2 format)
|
||||
{ DXGI_FORMAT_YUY2, CONV_FLAGS_SWIZZLE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0 } }, // D3DFMT_UYVY (uses DXGI 1.2 format)
|
||||
|
||||
{ DXGI_FORMAT_R8G8_SNORM, CONV_FLAGS_NONE, DDSPF_V8U8 }, // D3DFMT_V8U8
|
||||
{ DXGI_FORMAT_R8G8B8A8_SNORM, CONV_FLAGS_NONE, DDSPF_Q8W8V8U8 }, // D3DFMT_Q8W8V8U8
|
||||
{ DXGI_FORMAT_R16G16_SNORM, CONV_FLAGS_NONE, DDSPF_V16U16 }, // D3DFMT_V16U16
|
||||
};
|
||||
|
||||
// Note that many common DDS reader/writers (including D3DX) swap the
|
||||
@@ -135,7 +139,7 @@ const LegacyDDS g_LegacyDDSMap[] =
|
||||
// header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly
|
||||
|
||||
// We do not support the following legacy Direct3D 9 formats:
|
||||
// BumpDuDv D3DFMT_V8U8, D3DFMT_Q8W8V8U8, D3DFMT_V16U16, D3DFMT_A2W10V10U10
|
||||
// BumpDuDv D3DFMT_A2W10V10U10
|
||||
// BumpLuminance D3DFMT_L6V5U5, D3DFMT_X8L8V8U8
|
||||
// FourCC 117 D3DFMT_CxV8U8
|
||||
// ZBuffer D3DFMT_D16_LOCKABLE
|
||||
@@ -483,6 +487,9 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
case DXGI_FORMAT_BC5_SNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT) ); break;
|
||||
case DXGI_FORMAT_B5G6R5_UNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT) ); break;
|
||||
case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT) ); break;
|
||||
case DXGI_FORMAT_R8G8_SNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT) ); break;
|
||||
case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT) ); break;
|
||||
case DXGI_FORMAT_R16G16_SNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT) ); break;
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT) ); break; // DXGI 1.1
|
||||
case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT) ); break; // DXGI 1.1
|
||||
case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy_s( &ddpf, sizeof(ddpf), &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT) ); break; // DXGI 1.2
|
||||
|
||||
Reference in New Issue
Block a user