Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DDS.h
Go to the documentation of this file.
1 //--------------------------------------------------------------------------------------
2 // dds.h
3 //
4 // This header defines constants and structures that are useful when parsing
5 // DDS files. DDS files were originally designed to use several structures
6 // and constants that are native to DirectDraw and are defined in ddraw.h,
7 // such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar
8 // (compatible) constants and structures so that one can use DDS files
9 // without needing to include ddraw.h.
10 //
11 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
12 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 //
16 // Copyright (c) Microsoft Corporation. All rights reserved.
17 //
18 // http://go.microsoft.com/fwlink/?LinkId=248926
19 //--------------------------------------------------------------------------------------
20 
21 #if defined(_MSC_VER) && (_MSC_VER > 1000)
22 #pragma once
23 #endif
24 
25 #if defined(_XBOX_ONE) && defined(_TITLE) && MONOLITHIC
26 #include <d3d11_x.h>
27 #else
28 #include <dxgiformat.h>
29 #endif
30 
31 // VS 2010's stdint.h conflicts with intsafe.h
32 #pragma warning(push)
33 #pragma warning(disable : 4005)
34 #include <stdint.h>
35 #pragma warning(pop)
36 
37 namespace DirectX
38 {
39 
40 #pragma pack(push,1)
41 
42 const uint32_t DDS_MAGIC = 0x20534444; // "DDS "
43 
45 {
46  uint32_t dwSize;
47  uint32_t dwFlags;
48  uint32_t dwFourCC;
49  uint32_t dwRGBBitCount;
50  uint32_t dwRBitMask;
51  uint32_t dwGBitMask;
52  uint32_t dwBBitMask;
53  uint32_t dwABitMask;
54 };
55 
56 #define DDS_FOURCC 0x00000004 // DDPF_FOURCC
57 #define DDS_RGB 0x00000040 // DDPF_RGB
58 #define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
59 #define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
60 #define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
61 #define DDS_ALPHA 0x00000002 // DDPF_ALPHA
62 #define DDS_PAL8 0x00000020 // DDPF_PALETTEINDEXED8
63 
64 #ifndef MAKEFOURCC
65  #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
66  ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
67  ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
68 #endif /* defined(MAKEFOURCC) */
69 
70 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT1 =
71  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
72 
73 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT2 =
74  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
75 
76 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT3 =
77  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
78 
79 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT4 =
80  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
81 
82 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT5 =
83  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
84 
85 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_UNORM =
86  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 };
87 
88 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_SNORM =
89  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 };
90 
91 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_UNORM =
92  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 };
93 
94 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_SNORM =
95  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 };
96 
97 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
98  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 };
99 
100 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
101  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 };
102 
103 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_YUY2 =
104  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 };
105 
106 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
107  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
108 
109 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
110  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
111 
112 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
113  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
114 
115 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
116  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 };
117 
118 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G16R16 =
119  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 };
120 
121 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R5G6B5 =
122  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 };
123 
124 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
125  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 };
126 
127 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
128  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00000f00, 0x000000f0, 0x0000000f, 0x0000f000 };
129 
130 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8B8 =
131  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
132 
133 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L8 =
134  { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0x00, 0x00, 0x00 };
135 
136 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L16 =
137  { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0x0000, 0x0000, 0x0000 };
138 
139 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8L8 =
140  { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0x0000, 0x0000, 0xff00 };
141 
142 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8 =
143  { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0x00, 0x00, 0x00, 0xff };
144 
145 // D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
146 
147 // This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
148 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DX10 =
149  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 };
150 
151 #define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
152 #define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
153 #define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
154 #define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
155 #define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
156 
157 #define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
158 #define DDS_WIDTH 0x00000004 // DDSD_WIDTH
159 
160 #define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
161 #define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
162 #define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX
163 
164 #define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
165 #define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
166 #define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
167 #define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
168 #define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
169 #define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
170 
171 #define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
172  DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
173  DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
174 
175 #define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP
176 
177 #define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
178 
179 // Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
181 {
185 };
186 
187 // Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
189 {
191 };
192 
194 {
196 };
197 
199 {
205 };
206 
208 {
209  uint32_t dwSize;
210  uint32_t dwFlags;
211  uint32_t dwHeight;
212  uint32_t dwWidth;
214  uint32_t dwDepth; // only if DDS_HEADER_FLAGS_VOLUME is set in dwFlags
215  uint32_t dwMipMapCount;
216  uint32_t dwReserved1[11];
218  uint32_t dwCaps;
219  uint32_t dwCaps2;
220  uint32_t dwCaps3;
221  uint32_t dwCaps4;
222  uint32_t dwReserved2;
223 };
224 
226 {
227  DXGI_FORMAT dxgiFormat;
229  uint32_t miscFlag; // see DDS_RESOURCE_MISC_FLAG
230  uint32_t arraySize;
231  uint32_t miscFlags2; // see DDS_MISC_FLAGS2
232 };
233 
234 #pragma pack(pop)
235 
236 static_assert( sizeof(DDS_HEADER) == 124, "DDS Header size mismatch" );
237 static_assert( sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch");
238 
239 }; // namespace
uint32_t dwBBitMask
Definition: DDS.h:52
uint32_t dwRBitMask
Definition: DDS.h:50
uint32_t dwGBitMask
Definition: DDS.h:51
uint32_t dwFlags
Definition: DDS.h:47
#define DDS_LUMINANCEA
Definition: DDS.h:60
DDS_RESOURCE_DIMENSION
Definition: DDS.h:180
__declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT1
uint32_t dwRGBBitCount
Definition: DDS.h:49
DXGI_FORMAT dxgiFormat
Definition: DDS.h:227
uint32_t miscFlags2
Definition: DDS.h:231
uint32_t resourceDimension
Definition: DDS.h:228
uint32_t dwCaps4
Definition: DDS.h:221
uint32_t dwABitMask
Definition: DDS.h:53
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: DDS.h:65
#define DDS_RGBA
Definition: DDS.h:58
DDS_ALPHA_MODE
Definition: DDS.h:198
#define DDS_LUMINANCE
Definition: DDS.h:59
uint32_t dwWidth
Definition: DDS.h:212
uint32_t dwMipMapCount
Definition: DDS.h:215
uint32_t dwFlags
Definition: DDS.h:210
#define DDS_ALPHA
Definition: DDS.h:61
uint32_t dwHeight
Definition: DDS.h:211
DDS_RESOURCE_MISC_FLAG
Definition: DDS.h:188
DDS_PIXELFORMAT ddspf
Definition: DDS.h:217
uint32_t dwPitchOrLinearSize
Definition: DDS.h:213
uint32_t dwCaps3
Definition: DDS.h:220
DDS_MISC_FLAGS2
Definition: DDS.h:193
uint32_t dwDepth
Definition: DDS.h:214
uint32_t dwSize
Definition: DDS.h:46
#define DDS_RGB
Definition: DDS.h:57
uint32_t dwCaps2
Definition: DDS.h:219
uint32_t arraySize
Definition: DDS.h:230
uint32_t dwSize
Definition: DDS.h:209
uint32_t dwCaps
Definition: DDS.h:218
const uint32_t DDS_MAGIC
Definition: DDS.h:42
#define DDS_FOURCC
Definition: DDS.h:56
uint32_t dwFourCC
Definition: DDS.h:48
uint32_t dwReserved1[11]
Definition: DDS.h:216
uint32_t dwReserved2
Definition: DDS.h:222