1/**
2 * Simple DDS data parser for compressed 2D textures.
3 *
4 * Copyright (c) 2013-2023 Sasha Szpakowski
5 *
6 * This software is provided 'as-is', without any express or implied
7 * warranty. In no event will the authors be held liable for any damages
8 * arising from the use of this software.
9 *
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
13 *
14 * 1. The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software
16 * in a product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 * 3. This notice may not be removed or altered from any source distribution.
21 *
22 *
23 * Enums and structs copied from Microsoft.
24 * http://msdn.microsoft.com/en-us/library/bb943991.aspx
25 **/
26
27#ifndef DDS_INFO_H
28#define DDS_INFO_H
29
30#include <stdint.h>
31
32namespace dds
33{
34namespace dxinfo
35{
36
37enum DDPF
38{
39 DDPF_ALPHAPIXELS = 0x000001,
40 DDPF_ALPHA = 0x000002,
41 DDPF_FOURCC = 0x000004,
42 DDPF_RGB = 0x000040,
43 DDPF_YUV = 0x000200,
44 DDPF_LUMINANCE = 0x020000,
45 DDPF_BUMPDUDV = 0x080000,
46};
47
48enum D3D10ResourceDimension
49{
50 D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
51 D3D10_RESOURCE_DIMENSION_BUFFER = 1,
52 D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
53 D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
54 D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4
55};
56
57enum DXGIFormat
58{
59 DXGI_FORMAT_UNKNOWN = 0,
60
61 DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
62 DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
63 DXGI_FORMAT_R32G32B32A32_UINT = 3,
64 DXGI_FORMAT_R32G32B32A32_SINT = 4,
65
66 DXGI_FORMAT_R32G32B32_TYPELESS = 5,
67 DXGI_FORMAT_R32G32B32_FLOAT = 6,
68 DXGI_FORMAT_R32G32B32_UINT = 7,
69 DXGI_FORMAT_R32G32B32_SINT = 8,
70
71 DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
72 DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
73 DXGI_FORMAT_R16G16B16A16_UNORM = 11,
74 DXGI_FORMAT_R16G16B16A16_UINT = 12,
75 DXGI_FORMAT_R16G16B16A16_SNORM = 13,
76 DXGI_FORMAT_R16G16B16A16_SINT = 14,
77
78 DXGI_FORMAT_R32G32_TYPELESS = 15,
79 DXGI_FORMAT_R32G32_FLOAT = 16,
80 DXGI_FORMAT_R32G32_UINT = 17,
81 DXGI_FORMAT_R32G32_SINT = 18,
82
83 DXGI_FORMAT_R32G8X24_TYPELESS = 19,
84 DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
85 DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
86 DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
87
88 DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
89 DXGI_FORMAT_R10G10B10A2_UNORM = 24,
90 DXGI_FORMAT_R10G10B10A2_UINT = 25,
91
92 DXGI_FORMAT_R11G11B10_FLOAT = 26,
93
94 DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
95 DXGI_FORMAT_R8G8B8A8_UNORM = 28,
96 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
97 DXGI_FORMAT_R8G8B8A8_UINT = 30,
98 DXGI_FORMAT_R8G8B8A8_SNORM = 31,
99 DXGI_FORMAT_R8G8B8A8_SINT = 32,
100
101 DXGI_FORMAT_R16G16_TYPELESS = 33,
102 DXGI_FORMAT_R16G16_FLOAT = 34,
103 DXGI_FORMAT_R16G16_UNORM = 35,
104 DXGI_FORMAT_R16G16_UINT = 36,
105 DXGI_FORMAT_R16G16_SNORM = 37,
106 DXGI_FORMAT_R16G16_SINT = 38,
107
108 DXGI_FORMAT_R32_TYPELESS = 39,
109 DXGI_FORMAT_D32_FLOAT = 40,
110 DXGI_FORMAT_R32_FLOAT = 41,
111 DXGI_FORMAT_R32_UINT = 42,
112 DXGI_FORMAT_R32_SINT = 43,
113
114 DXGI_FORMAT_R24G8_TYPELESS = 44,
115 DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
116 DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
117 DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
118
119 DXGI_FORMAT_R8G8_TYPELESS = 48,
120 DXGI_FORMAT_R8G8_UNORM = 49,
121 DXGI_FORMAT_R8G8_UINT = 50,
122 DXGI_FORMAT_R8G8_SNORM = 51,
123 DXGI_FORMAT_R8G8_SINT = 52,
124
125 DXGI_FORMAT_R16_TYPELESS = 53,
126 DXGI_FORMAT_R16_FLOAT = 54,
127 DXGI_FORMAT_D16_UNORM = 55,
128 DXGI_FORMAT_R16_UNORM = 56,
129 DXGI_FORMAT_R16_UINT = 57,
130 DXGI_FORMAT_R16_SNORM = 58,
131 DXGI_FORMAT_R16_SINT = 59,
132
133 DXGI_FORMAT_R8_TYPELESS = 60,
134 DXGI_FORMAT_R8_UNORM = 61,
135 DXGI_FORMAT_R8_UINT = 62,
136 DXGI_FORMAT_R8_SNORM = 63,
137 DXGI_FORMAT_R8_SINT = 64,
138 DXGI_FORMAT_A8_UNORM = 65,
139
140 DXGI_FORMAT_R1_UNORM = 66,
141
142 DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
143
144 DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
145 DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
146
147 DXGI_FORMAT_BC1_TYPELESS = 70,
148 DXGI_FORMAT_BC1_UNORM = 71,
149 DXGI_FORMAT_BC1_UNORM_SRGB = 72,
150
151 DXGI_FORMAT_BC2_TYPELESS = 73,
152 DXGI_FORMAT_BC2_UNORM = 74,
153 DXGI_FORMAT_BC2_UNORM_SRGB = 75,
154
155 DXGI_FORMAT_BC3_TYPELESS = 76,
156 DXGI_FORMAT_BC3_UNORM = 77,
157 DXGI_FORMAT_BC3_UNORM_SRGB = 78,
158
159 DXGI_FORMAT_BC4_TYPELESS = 79,
160 DXGI_FORMAT_BC4_UNORM = 80,
161 DXGI_FORMAT_BC4_SNORM = 81,
162
163 DXGI_FORMAT_BC5_TYPELESS = 82,
164 DXGI_FORMAT_BC5_UNORM = 83,
165 DXGI_FORMAT_BC5_SNORM = 84,
166
167 DXGI_FORMAT_B5G6R5_UNORM = 85,
168 DXGI_FORMAT_B5G5R5A1_UNORM = 86,
169 DXGI_FORMAT_B8G8R8A8_UNORM = 87,
170 DXGI_FORMAT_B8G8R8X8_UNORM = 88,
171
172 DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
173 DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
174 DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
175 DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
176 DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
177
178 DXGI_FORMAT_BC6H_TYPELESS = 94,
179 DXGI_FORMAT_BC6H_UF16 = 95,
180 DXGI_FORMAT_BC6H_SF16 = 96,
181
182 DXGI_FORMAT_BC7_TYPELESS = 97,
183 DXGI_FORMAT_BC7_UNORM = 98,
184 DXGI_FORMAT_BC7_UNORM_SRGB = 99,
185
186 DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
187};
188
189struct DDSPixelFormat
190{
191 uint32_t size;
192 uint32_t flags;
193 uint32_t fourCC;
194 uint32_t rgbBitCount;
195 uint32_t rBitMask;
196 uint32_t gBitMask;
197 uint32_t bBitMask;
198 uint32_t aBitMask;
199};
200
201struct DDSHeader
202{
203 uint32_t size;
204 uint32_t flags;
205 uint32_t height;
206 uint32_t width;
207 uint32_t pitchOrLinearSize;
208 uint32_t depth;
209 uint32_t mipMapCount;
210 uint32_t reserved[11];
211
212 DDSPixelFormat format;
213
214 uint32_t caps1;
215 uint32_t caps2;
216 uint32_t caps3;
217 uint32_t caps4;
218 uint32_t reserved2;
219};
220
221struct DDSHeader10
222{
223 DXGIFormat dxgiFormat;
224 D3D10ResourceDimension resourceDimension;
225
226 uint32_t miscFlag;
227 uint32_t arraySize;
228 uint32_t reserved;
229};
230
231} // dxinfo
232} // dds
233
234#endif // DDS_INFO_H
235