280
280
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
281
281
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
283
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
284
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
285
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
286
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
287
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
289
DXGI_FORMAT_BC6H_TYPELESS = 94,
290
DXGI_FORMAT_BC6H_UF16 = 95,
291
DXGI_FORMAT_BC6H_SF16 = 96,
293
DXGI_FORMAT_BC7_TYPELESS = 97,
294
DXGI_FORMAT_BC7_UNORM = 98,
295
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
283
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
284
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
285
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
286
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
287
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
289
DXGI_FORMAT_BC6H_TYPELESS = 94,
290
DXGI_FORMAT_BC6H_UF16 = 95,
291
DXGI_FORMAT_BC6H_SF16 = 96,
293
DXGI_FORMAT_BC7_TYPELESS = 97,
294
DXGI_FORMAT_BC7_UNORM = 98,
295
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
298
298
enum D3D10_RESOURCE_DIMENSION
499
struct FormatDescriptor
509
static const FormatDescriptor s_d3dFormats[] =
511
{ D3DFMT_R8G8B8, 24, 0xFF0000, 0xFF00, 0xFF, 0 },
512
{ D3DFMT_A8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000 }, // DXGI_FORMAT_B8G8R8A8_UNORM
513
{ D3DFMT_X8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0 }, // DXGI_FORMAT_B8G8R8X8_UNORM
514
{ D3DFMT_R5G6B5, 16, 0xF800, 0x7E0, 0x1F, 0 }, // DXGI_FORMAT_B5G6R5_UNORM
515
{ D3DFMT_X1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0 },
516
{ D3DFMT_A1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0x8000 }, // DXGI_FORMAT_B5G5R5A1_UNORM
517
{ D3DFMT_A4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0xF000 },
518
{ D3DFMT_R3G3B2, 8, 0xE0, 0x1C, 0x3, 0 },
519
{ D3DFMT_A8, 8, 0, 0, 0, 8 }, // DXGI_FORMAT_A8_UNORM
520
{ D3DFMT_A8R3G3B2, 16, 0xE0, 0x1C, 0x3, 0xFF00 },
521
{ D3DFMT_X4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0 },
522
{ D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 }, // DXGI_FORMAT_R10G10B10A2
523
{ D3DFMT_A8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000 }, // DXGI_FORMAT_R8G8B8A8_UNORM
524
{ D3DFMT_X8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0 },
525
{ D3DFMT_G16R16, 32, 0xFFFF, 0xFFFF0000, 0, 0 }, // DXGI_FORMAT_R16G16_UNORM
526
{ D3DFMT_A2R10G10B10, 32, 0x3FF00000, 0xFFC00, 0x3FF, 0xC0000000 },
527
{ D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 },
529
{ D3DFMT_L8, 8, 8, 0, 0, 0 }, // DXGI_FORMAT_R8_UNORM
530
{ D3DFMT_L16, 16, 16, 0, 0, 0 }, // DXGI_FORMAT_R16_UNORM
533
static const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
499
struct FormatDescriptor
509
static const FormatDescriptor s_d3dFormats[] =
511
{ D3DFMT_R8G8B8, 24, 0xFF0000, 0xFF00, 0xFF, 0 },
512
{ D3DFMT_A8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000 }, /* DXGI_FORMAT_B8G8R8A8_UNORM */
513
{ D3DFMT_X8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0 }, /* DXGI_FORMAT_B8G8R8X8_UNORM */
514
{ D3DFMT_R5G6B5, 16, 0xF800, 0x7E0, 0x1F, 0 }, /* DXGI_FORMAT_B5G6R5_UNORM */
515
{ D3DFMT_X1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0 },
516
{ D3DFMT_A1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0x8000 }, /* DXGI_FORMAT_B5G5R5A1_UNORM */
517
{ D3DFMT_A4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0xF000 },
518
{ D3DFMT_R3G3B2, 8, 0xE0, 0x1C, 0x3, 0 },
519
{ D3DFMT_A8, 8, 0, 0, 0, 8 }, /* DXGI_FORMAT_A8_UNORM */
520
{ D3DFMT_A8R3G3B2, 16, 0xE0, 0x1C, 0x3, 0xFF00 },
521
{ D3DFMT_X4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0 },
522
{ D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 }, /* DXGI_FORMAT_R10G10B10A2 */
523
{ D3DFMT_A8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000 }, /* DXGI_FORMAT_R8G8B8A8_UNORM */
524
{ D3DFMT_X8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0 },
525
{ D3DFMT_G16R16, 32, 0xFFFF, 0xFFFF0000, 0, 0 }, /* DXGI_FORMAT_R16G16_UNORM */
526
{ D3DFMT_A2R10G10B10, 32, 0x3FF00000, 0xFFC00, 0x3FF, 0xC0000000 },
527
{ D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 },
529
{ D3DFMT_L8, 8, 8, 0, 0, 0 }, /* DXGI_FORMAT_R8_UNORM */
530
{ D3DFMT_L16, 16, 16, 0, 0, 0 }, /* DXGI_FORMAT_R16_UNORM */
533
static const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
537
uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
537
static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
539
for (int i = 0; i < s_d3dFormatCount; i++)
541
if (s_d3dFormats[i].bitcount == bitcount &&
542
s_d3dFormats[i].rmask == rmask &&
543
s_d3dFormats[i].gmask == gmask &&
544
s_d3dFormats[i].bmask == bmask &&
545
s_d3dFormats[i].amask == amask)
547
return s_d3dFormats[i].format;
539
for (int i = 0; i < s_d3dFormatCount; i++)
541
if (s_d3dFormats[i].bitcount == bitcount &&
542
s_d3dFormats[i].rmask == rmask &&
543
s_d3dFormats[i].gmask == gmask &&
544
s_d3dFormats[i].bmask == bmask &&
545
s_d3dFormats[i].amask == amask)
547
return s_d3dFormats[i].format;
837
837
uint DDSHeader::signature() const
839
return this->reserved[9];
839
return this->reserved[9];
842
842
uint DDSHeader::toolVersion() const
844
return this->reserved[10];
844
return this->reserved[10];
847
847
uint DDSHeader::userVersion() const
849
if (this->reserved[7] == FOURCC_UVER) {
850
return this->reserved[8];
849
if (this->reserved[7] == FOURCC_UVER) {
850
return this->reserved[8];
855
855
bool DDSHeader::isNormalMap() const
857
return (pf.flags & DDPF_NORMAL) != 0;
857
return (pf.flags & DDPF_NORMAL) != 0;
860
860
bool DDSHeader::isSrgb() const
862
return (pf.flags & DDPF_SRGB) != 0;
862
return (pf.flags & DDPF_SRGB) != 0;
865
865
bool DDSHeader::hasAlpha() const
867
return (pf.flags & DDPF_ALPHAPIXELS) != 0;
867
return (pf.flags & DDPF_ALPHAPIXELS) != 0;
870
870
uint DDSHeader::d3d9Format() const
872
if (pf.flags & DDPF_FOURCC) {
876
return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
872
if (pf.flags & DDPF_FOURCC) {
876
return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
880
880
DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
1445
1472
if (header.pf.flags & DDPF_ALPHAPREMULT) printf("\t\tDDPF_ALPHAPREMULT\n");
1446
1473
if (header.pf.flags & DDPF_NORMAL) printf("\t\tDDPF_NORMAL\n");
1448
if (header.pf.fourcc != 0) {
1449
// Display fourcc code even when DDPF_FOURCC flag not set.
1450
printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
1451
((header.pf.fourcc >> 0) & 0xFF),
1452
((header.pf.fourcc >> 8) & 0xFF),
1453
((header.pf.fourcc >> 16) & 0xFF),
1454
((header.pf.fourcc >> 24) & 0xFF),
1475
if (header.pf.fourcc != 0) {
1476
// Display fourcc code even when DDPF_FOURCC flag not set.
1477
printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
1478
((header.pf.fourcc >> 0) & 0xFF),
1479
((header.pf.fourcc >> 8) & 0xFF),
1480
((header.pf.fourcc >> 16) & 0xFF),
1481
((header.pf.fourcc >> 24) & 0xFF),
1458
if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0))
1485
if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0))
1460
printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n",
1461
(header.pf.bitcount >> 0) & 0xFF,
1462
(header.pf.bitcount >> 8) & 0xFF,
1463
(header.pf.bitcount >> 16) & 0xFF,
1464
(header.pf.bitcount >> 24) & 0xFF,
1465
header.pf.bitcount);
1487
printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n",
1488
(header.pf.bitcount >> 0) & 0xFF,
1489
(header.pf.bitcount >> 8) & 0xFF,
1490
(header.pf.bitcount >> 16) & 0xFF,
1491
(header.pf.bitcount >> 24) & 0xFF,
1492
header.pf.bitcount);