ddsData.h

Engine/source/gfx/bitmap/ddsData.h

More...

Classes:

Namespaces:

namespace

Public Defines

define
DDS_ALPHA() 0x00000002
define
DDS_ALPHAPIXELS() 0x00000001
define
DDS_BUMPDUDV() 0x00080000
define
DDS_CUBEMAP() 0x00000200
define
DDS_CUBEMAP_ALLFACES()                                   (  |  |  |\
                                   |  |\
                                   |  )
define
DDS_CUBEMAP_NEGATIVEX() 0x00000800
define
DDS_CUBEMAP_NEGATIVEY() 0x00002000
define
DDS_CUBEMAP_NEGATIVEZ() 0x00008000
define
DDS_CUBEMAP_POSITIVEX() 0x00000400
define
DDS_CUBEMAP_POSITIVEY() 0x00001000
define
DDS_CUBEMAP_POSITIVEZ() 0x00004000
define
DDS_FLAGS_VOLUME() 0x00200000
define
DDS_FOURCC() 0x00000004
define
define
define
define
define
define
define
DDS_HEIGHT() 0x00000002
define
DDS_LUMINANCE() 0x00020000
define
DDS_LUMINANCEA() 0x00020001
define
DDS_MAGIC() 0x20534444
define
DDS_PAL8() 0x00000020
define
DDS_RGB() 0x00000040
define
DDS_RGBA() 0x00000041
define
define
define
define
DDS_WIDTH() 0x00000004
define
DDS_YUV() 0x00000200

Detailed Description

Public Defines

DDS_ALPHA() 0x00000002
DDS_ALPHAPIXELS() 0x00000001
DDS_BUMPDUDV() 0x00080000
DDS_CUBEMAP() 0x00000200
DDS_CUBEMAP_ALLFACES()                                   (  |  |  |\
                                   |  |\
                                   |  )
DDS_CUBEMAP_NEGATIVEX() 0x00000800
DDS_CUBEMAP_NEGATIVEY() 0x00002000
DDS_CUBEMAP_NEGATIVEZ() 0x00008000
DDS_CUBEMAP_POSITIVEX() 0x00000400
DDS_CUBEMAP_POSITIVEY() 0x00001000
DDS_CUBEMAP_POSITIVEZ() 0x00004000
DDS_FLAGS_VOLUME() 0x00200000
DDS_FOURCC() 0x00000004
DDS_HEADER_DX10_SIZE() 20
DDS_HEADER_FLAGS_LINEARSIZE() 0x00080000
DDS_HEADER_FLAGS_MIPMAP() 0x00020000
DDS_HEADER_FLAGS_PITCH() 0x00000008
DDS_HEADER_FLAGS_TEXTURE() 0x00001007
DDS_HEADER_FLAGS_VOLUME() 0x00800000
DDS_HEADER_SIZE() 124
DDS_HEIGHT() 0x00000002
DDS_LUMINANCE() 0x00020000
DDS_LUMINANCEA() 0x00020001
DDS_MAGIC() 0x20534444
DDS_PAL8() 0x00000020
DDS_RGB() 0x00000040
DDS_RGBA() 0x00000041
DDS_SURFACE_FLAGS_CUBEMAP() 0x00000008
DDS_SURFACE_FLAGS_MIPMAP() 0x00400008
DDS_SURFACE_FLAGS_TEXTURE() 0x00001000
DDS_WIDTH() 0x00000004
DDS_YUV() 0x00000200
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2016 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24////////////////////////////////////////////////////////////////////////////////
 25// Portions Copyright (c) Microsoft Corporation. All rights reserved.
 26// https://github.com/Microsoft/DirectXTex
 27////////////////////////////////////////////////////////////////////////////////
 28
 29#ifndef _DDSDATA_H_
 30#define _DDSDATA_H_
 31
 32#ifndef _TORQUE_TYPES_H_
 33#include "platform/types.h"
 34#endif
 35
 36#include "core/util/fourcc.h"
 37
 38#ifdef TORQUE_OS_WIN
 39#include <dxgiformat.h>
 40#endif
 41
 42namespace dds
 43{
 44   ///////////////////////////////////////////////////////////////////////////////////
 45   //                           DXGI Formats                                        //
 46   ///////////////////////////////////////////////////////////////////////////////////
 47#ifndef TORQUE_OS_WIN
 48   //From directx SDK
 49   typedef enum DXGI_FORMAT
 50   {
 51      DXGI_FORMAT_UNKNOWN = 0,
 52      DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
 53      DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
 54      DXGI_FORMAT_R32G32B32A32_UINT = 3,
 55      DXGI_FORMAT_R32G32B32A32_SINT = 4,
 56      DXGI_FORMAT_R32G32B32_TYPELESS = 5,
 57      DXGI_FORMAT_R32G32B32_FLOAT = 6,
 58      DXGI_FORMAT_R32G32B32_UINT = 7,
 59      DXGI_FORMAT_R32G32B32_SINT = 8,
 60      DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
 61      DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
 62      DXGI_FORMAT_R16G16B16A16_UNORM = 11,
 63      DXGI_FORMAT_R16G16B16A16_UINT = 12,
 64      DXGI_FORMAT_R16G16B16A16_SNORM = 13,
 65      DXGI_FORMAT_R16G16B16A16_SINT = 14,
 66      DXGI_FORMAT_R32G32_TYPELESS = 15,
 67      DXGI_FORMAT_R32G32_FLOAT = 16,
 68      DXGI_FORMAT_R32G32_UINT = 17,
 69      DXGI_FORMAT_R32G32_SINT = 18,
 70      DXGI_FORMAT_R32G8X24_TYPELESS = 19,
 71      DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
 72      DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
 73      DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
 74      DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
 75      DXGI_FORMAT_R10G10B10A2_UNORM = 24,
 76      DXGI_FORMAT_R10G10B10A2_UINT = 25,
 77      DXGI_FORMAT_R11G11B10_FLOAT = 26,
 78      DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
 79      DXGI_FORMAT_R8G8B8A8_UNORM = 28,
 80      DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
 81      DXGI_FORMAT_R8G8B8A8_UINT = 30,
 82      DXGI_FORMAT_R8G8B8A8_SNORM = 31,
 83      DXGI_FORMAT_R8G8B8A8_SINT = 32,
 84      DXGI_FORMAT_R16G16_TYPELESS = 33,
 85      DXGI_FORMAT_R16G16_FLOAT = 34,
 86      DXGI_FORMAT_R16G16_UNORM = 35,
 87      DXGI_FORMAT_R16G16_UINT = 36,
 88      DXGI_FORMAT_R16G16_SNORM = 37,
 89      DXGI_FORMAT_R16G16_SINT = 38,
 90      DXGI_FORMAT_R32_TYPELESS = 39,
 91      DXGI_FORMAT_D32_FLOAT = 40,
 92      DXGI_FORMAT_R32_FLOAT = 41,
 93      DXGI_FORMAT_R32_UINT = 42,
 94      DXGI_FORMAT_R32_SINT = 43,
 95      DXGI_FORMAT_R24G8_TYPELESS = 44,
 96      DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
 97      DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
 98      DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
 99      DXGI_FORMAT_R8G8_TYPELESS = 48,
100      DXGI_FORMAT_R8G8_UNORM = 49,
101      DXGI_FORMAT_R8G8_UINT = 50,
102      DXGI_FORMAT_R8G8_SNORM = 51,
103      DXGI_FORMAT_R8G8_SINT = 52,
104      DXGI_FORMAT_R16_TYPELESS = 53,
105      DXGI_FORMAT_R16_FLOAT = 54,
106      DXGI_FORMAT_D16_UNORM = 55,
107      DXGI_FORMAT_R16_UNORM = 56,
108      DXGI_FORMAT_R16_UINT = 57,
109      DXGI_FORMAT_R16_SNORM = 58,
110      DXGI_FORMAT_R16_SINT = 59,
111      DXGI_FORMAT_R8_TYPELESS = 60,
112      DXGI_FORMAT_R8_UNORM = 61,
113      DXGI_FORMAT_R8_UINT = 62,
114      DXGI_FORMAT_R8_SNORM = 63,
115      DXGI_FORMAT_R8_SINT = 64,
116      DXGI_FORMAT_A8_UNORM = 65,
117      DXGI_FORMAT_R1_UNORM = 66,
118      DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
119      DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
120      DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
121      DXGI_FORMAT_BC1_TYPELESS = 70,
122      DXGI_FORMAT_BC1_UNORM = 71,
123      DXGI_FORMAT_BC1_UNORM_SRGB = 72,
124      DXGI_FORMAT_BC2_TYPELESS = 73,
125      DXGI_FORMAT_BC2_UNORM = 74,
126      DXGI_FORMAT_BC2_UNORM_SRGB = 75,
127      DXGI_FORMAT_BC3_TYPELESS = 76,
128      DXGI_FORMAT_BC3_UNORM = 77,
129      DXGI_FORMAT_BC3_UNORM_SRGB = 78,
130      DXGI_FORMAT_BC4_TYPELESS = 79,
131      DXGI_FORMAT_BC4_UNORM = 80,
132      DXGI_FORMAT_BC4_SNORM = 81,
133      DXGI_FORMAT_BC5_TYPELESS = 82,
134      DXGI_FORMAT_BC5_UNORM = 83,
135      DXGI_FORMAT_BC5_SNORM = 84,
136      DXGI_FORMAT_B5G6R5_UNORM = 85,
137      DXGI_FORMAT_B5G5R5A1_UNORM = 86,
138      DXGI_FORMAT_B8G8R8A8_UNORM = 87,
139      DXGI_FORMAT_B8G8R8X8_UNORM = 88,
140      DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
141      DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
142      DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
143      DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
144      DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
145      DXGI_FORMAT_BC6H_TYPELESS = 94,
146      DXGI_FORMAT_BC6H_UF16 = 95,
147      DXGI_FORMAT_BC6H_SF16 = 96,
148      DXGI_FORMAT_BC7_TYPELESS = 97,
149      DXGI_FORMAT_BC7_UNORM = 98,
150      DXGI_FORMAT_BC7_UNORM_SRGB = 99,
151      DXGI_FORMAT_AYUV = 100,
152      DXGI_FORMAT_Y410 = 101,
153      DXGI_FORMAT_Y416 = 102,
154      DXGI_FORMAT_NV12 = 103,
155      DXGI_FORMAT_P010 = 104,
156      DXGI_FORMAT_P016 = 105,
157      DXGI_FORMAT_420_OPAQUE = 106,
158      DXGI_FORMAT_YUY2 = 107,
159      DXGI_FORMAT_Y210 = 108,
160      DXGI_FORMAT_Y216 = 109,
161      DXGI_FORMAT_NV11 = 110,
162      DXGI_FORMAT_AI44 = 111,
163      DXGI_FORMAT_IA44 = 112,
164      DXGI_FORMAT_P8 = 113,
165      DXGI_FORMAT_A8P8 = 114,
166      DXGI_FORMAT_B4G4R4A4_UNORM = 115,
167      DXGI_FORMAT_FORCE_UINT = 0xffffffff
168   } DXGI_FORMAT;
169#endif
170
171   ///////////////////////////////////////////////////////////////////////////////////
172   //                           D3DFMT Formats                                      //
173   ///////////////////////////////////////////////////////////////////////////////////
174   enum D3DFMT
175   {
176      D3DFMT_UNKNOWN = 0,
177
178      D3DFMT_R8G8B8 = 20,
179      D3DFMT_A8R8G8B8 = 21,
180      D3DFMT_X8R8G8B8 = 22,
181      D3DFMT_R5G6B5 = 23,
182      D3DFMT_X1R5G5B5 = 24,
183      D3DFMT_A1R5G5B5 = 25,
184      D3DFMT_A4R4G4B4 = 26,
185      D3DFMT_R3G3B2 = 27,
186      D3DFMT_A8 = 28,
187      D3DFMT_A8R3G3B2 = 29,
188      D3DFMT_X4R4G4B4 = 30,
189      D3DFMT_A2B10G10R10 = 31,
190      D3DFMT_A8B8G8R8 = 32,
191      D3DFMT_X8B8G8R8 = 33,
192      D3DFMT_G16R16 = 34,
193      D3DFMT_A2R10G10B10 = 35,
194      D3DFMT_A16B16G16R16 = 36,
195
196      D3DFMT_A8P8 = 40,
197      D3DFMT_P8 = 41,
198
199      D3DFMT_L8 = 50,
200      D3DFMT_A8L8 = 51,
201      D3DFMT_A4L4 = 52,
202
203      D3DFMT_V8U8 = 60,
204      D3DFMT_L6V5U5 = 61,
205      D3DFMT_X8L8V8U8 = 62,
206      D3DFMT_Q8W8V8U8 = 63,
207      D3DFMT_V16U16 = 64,
208      D3DFMT_A2W10V10U10 = 67,
209
210      D3DFMT_UYVY = MakeFourCC('U', 'Y', 'V', 'Y'),
211      D3DFMT_R8G8_B8G8 = MakeFourCC('R', 'G', 'B', 'G'),
212      D3DFMT_YUY2 = MakeFourCC('Y', 'U', 'Y', '2'),
213      D3DFMT_G8R8_G8B8 = MakeFourCC('G', 'R', 'G', 'B'),
214      D3DFMT_DXT1 = MakeFourCC('D', 'X', 'T', '1'),
215      D3DFMT_DXT2 = MakeFourCC('D', 'X', 'T', '2'),
216      D3DFMT_DXT3 = MakeFourCC('D', 'X', 'T', '3'),
217      D3DFMT_DXT4 = MakeFourCC('D', 'X', 'T', '4'),
218      D3DFMT_DXT5 = MakeFourCC('D', 'X', 'T', '5'),
219
220      D3DFMT_ATI1 = MakeFourCC('A', 'T', 'I', '1'),
221      D3DFMT_AT1N = MakeFourCC('A', 'T', '1', 'N'),
222      D3DFMT_ATI2 = MakeFourCC('A', 'T', 'I', '2'),
223      D3DFMT_AT2N = MakeFourCC('A', 'T', '2', 'N'),
224
225      D3DFMT_BC4U = MakeFourCC('B', 'C', '4', 'U'),
226      D3DFMT_BC4S = MakeFourCC('B', 'C', '4', 'S'),
227      D3DFMT_BC5U = MakeFourCC('B', 'C', '5', 'U'),
228      D3DFMT_BC5S = MakeFourCC('B', 'C', '5', 'S'),
229
230      D3DFMT_ETC = MakeFourCC('E', 'T', 'C', ' '),
231      D3DFMT_ETC1 = MakeFourCC('E', 'T', 'C', '1'),
232      D3DFMT_ATC = MakeFourCC('A', 'T', 'C', ' '),
233      D3DFMT_ATCA = MakeFourCC('A', 'T', 'C', 'A'),
234      D3DFMT_ATCI = MakeFourCC('A', 'T', 'C', 'I'),
235
236      D3DFMT_POWERVR_2BPP = MakeFourCC('P', 'T', 'C', '2'),
237      D3DFMT_POWERVR_4BPP = MakeFourCC('P', 'T', 'C', '4'),
238
239      D3DFMT_D16_LOCKABLE = 70,
240      D3DFMT_D32 = 71,
241      D3DFMT_D15S1 = 73,
242      D3DFMT_D24S8 = 75,
243      D3DFMT_D24X8 = 77,
244      D3DFMT_D24X4S4 = 79,
245      D3DFMT_D16 = 80,
246
247      D3DFMT_D32F_LOCKABLE = 82,
248      D3DFMT_D24FS8 = 83,
249
250      D3DFMT_L16 = 81,
251
252      D3DFMT_VERTEXDATA = 100,
253      D3DFMT_INDEX16 = 101,
254      D3DFMT_INDEX32 = 102,
255
256      D3DFMT_Q16W16V16U16 = 110,
257
258      D3DFMT_MULTI2_ARGB8 = MakeFourCC('M', 'E', 'T', '1'),
259
260      D3DFMT_R16F = 111,
261      D3DFMT_G16R16F = 112,
262      D3DFMT_A16B16G16R16F = 113,
263
264      D3DFMT_R32F = 114,
265      D3DFMT_G32R32F = 115,
266      D3DFMT_A32B32G32R32F = 116,
267
268      D3DFMT_CxV8U8 = 117,
269
270      D3DFMT_DX10 = MakeFourCC('D', 'X', '1', '0'),
271
272      D3DFMT_FORCE_DWORD = 0x7fffffff
273   };
274
275   ///////////////////////////////////////////////////////////////////////////////////
276   //                               Defines                                         //
277   ///////////////////////////////////////////////////////////////////////////////////
278   #pragma pack(push,1)
279
280   #define DDS_HEADER_SIZE       124
281   #define DDS_HEADER_DX10_SIZE  20
282   #define DDS_MAGIC       0x20534444  // "DDS "
283   #define DDS_FOURCC      0x00000004  // DDPF_FOURCC
284   #define DDS_RGB         0x00000040  // DDPF_RGB
285   #define DDS_RGBA        0x00000041  // DDPF_RGB | DDPF_ALPHAPIXELS
286   #define DDS_LUMINANCE   0x00020000  // DDPF_LUMINANCE
287   #define DDS_LUMINANCEA  0x00020001  // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
288   #define DDS_ALPHAPIXELS 0x00000001  // DDPF_ALPHAPIXELS
289   #define DDS_ALPHA       0x00000002  // DDPF_ALPHA
290   #define DDS_PAL8        0x00000020  // DDPF_PALETTEINDEXED8
291   #define DDS_BUMPDUDV    0x00080000  // DDPF_BUMPDUDV
292   #define DDS_YUV         0x00000200  //DDPF_YUV
293
294   #define DDS_HEADER_FLAGS_TEXTURE        0x00001007  // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT 
295   #define DDS_HEADER_FLAGS_MIPMAP         0x00020000  // DDSD_MIPMAPCOUNT
296   #define DDS_HEADER_FLAGS_VOLUME         0x00800000  // DDSD_DEPTH
297   #define DDS_HEADER_FLAGS_PITCH          0x00000008  // DDSD_PITCH
298   #define DDS_HEADER_FLAGS_LINEARSIZE     0x00080000  // DDSD_LINEARSIZE
299
300   #define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
301   #define DDS_WIDTH  0x00000004 // DDSD_WIDTH
302
303   #define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
304   #define DDS_SURFACE_FLAGS_MIPMAP  0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
305   #define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX
306
307   #define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP
308   #define DDS_CUBEMAP_POSITIVEX 0x00000400 //  DDSCAPS2_CUBEMAP_POSITIVEX
309   #define DDS_CUBEMAP_NEGATIVEX 0x00000800 //  DDSCAPS2_CUBEMAP_NEGATIVEX
310   #define DDS_CUBEMAP_POSITIVEY 0x00001000 //  DDSCAPS2_CUBEMAP_POSITIVEY
311   #define DDS_CUBEMAP_NEGATIVEY 0x00002000 //  DDSCAPS2_CUBEMAP_NEGATIVEY
312   #define DDS_CUBEMAP_POSITIVEZ 0x00004000 //  DDSCAPS2_CUBEMAP_POSITIVEZ
313   #define DDS_CUBEMAP_NEGATIVEZ 0x00008000 //  DDSCAPS2_CUBEMAP_NEGATIVEZ
314
315   #define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP | DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
316                                  DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
317                                  DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
318
319   #define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
320
321   ///////////////////////////////////////////////////////////////////////////////////
322   //                                Enums                                          //
323   ///////////////////////////////////////////////////////////////////////////////////
324   // Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
325   enum DDS_RESOURCE_DIMENSION
326   {
327      DDS_DIMENSION_TEXTURE1D = 2,
328      DDS_DIMENSION_TEXTURE2D = 3,
329      DDS_DIMENSION_TEXTURE3D = 4,
330   };
331
332   // Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
333   enum DDS_RESOURCE_MISC_FLAG
334   {
335      DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L,
336   };
337
338   enum DDS_MISC_FLAGS2
339   {
340      DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L,
341   };
342
343   enum DDS_ALPHA_MODE
344   {
345      DDS_ALPHA_MODE_UNKNOWN = 0,
346      DDS_ALPHA_MODE_STRAIGHT = 1,
347      DDS_ALPHA_MODE_PREMULTIPLIED = 2,
348      DDS_ALPHA_MODE_OPAQUE = 3,
349      DDS_ALPHA_MODE_CUSTOM = 4,
350   };
351
352   enum D3D10_RESOURCE_DIMENSION
353   {
354      D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
355      D3D10_RESOURCE_DIMENSION_BUFFER = 1,
356      D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
357      D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
358      D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4
359   };
360
361   enum D3D10_RESOURCE_MISC_FLAG
362   {
363      D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x1L,
364      D3D10_RESOURCE_MISC_SHARED = 0x2L,
365      D3D10_RESOURCE_MISC_TEXTURECUBE = 0x4L,
366      D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10L,
367      D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20L,
368   };
369
370   ///////////////////////////////////////////////////////////////////////////////////
371   //                                Structs                                        //
372   ///////////////////////////////////////////////////////////////////////////////////
373
374   struct DDS_PIXELFORMAT
375   {
376      U32   size;
377      U32   flags;
378      U32   fourCC;
379      U32   bpp;
380      U32   RBitMask;
381      U32   GBitMask;
382      U32   BBitMask;
383      U32   ABitMask;
384
385      bool operator==(const DDS_PIXELFORMAT& _test) const
386      {
387         return ( size == _test.size &&
388                  flags == _test.flags &&
389                  fourCC == _test.fourCC &&
390                  bpp == _test.bpp &&
391                  RBitMask == _test.RBitMask &&
392                  GBitMask == _test.GBitMask &&
393                  BBitMask == _test.BBitMask &&
394                  ABitMask == _test.ABitMask);
395      }
396   };
397
398   struct DDS_HEADER
399   {
400      U32   size;
401      U32   flags;
402      U32   height;
403      U32   width;
404      U32   pitchOrLinearSize;
405      U32   depth; // only if DDS_HEADER_FLAGS_VOLUME is set in dwFlags
406      U32   mipMapCount;
407      U32   reserved1[11];
408      DDS_PIXELFORMAT ddspf;
409      U32   surfaceFlags;
410      U32   cubemapFlags;
411      U32   reserved2[3];
412   };
413
414   struct DDS_HEADER_DXT10
415   {
416      DXGI_FORMAT dxgiFormat;
417      U32    resourceDimension;
418      U32    miscFlag; // see DDS_RESOURCE_MISC_FLAG
419      U32    arraySize;
420      U32    miscFlags2; // see DDS_MISC_FLAGS2
421   };
422
423   ///////////////////////////////////////////////////////////////////////////////////
424   //                            Pixel Formats                                      //
425   ///////////////////////////////////////////////////////////////////////////////////
426
427   const DDS_PIXELFORMAT DDSPF_DXT1 =
428   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_DXT1, 0, 0, 0, 0, 0 };
429
430   const DDS_PIXELFORMAT DDSPF_DXT2 =
431   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_DXT2, 0, 0, 0, 0, 0 };
432
433   const DDS_PIXELFORMAT DDSPF_DXT3 =
434   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_DXT3, 0, 0, 0, 0, 0 };
435
436   const DDS_PIXELFORMAT DDSPF_DXT4 =
437   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_DXT4, 0, 0, 0, 0, 0 };
438
439   const DDS_PIXELFORMAT DDSPF_DXT5 =
440   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_DXT5, 0, 0, 0, 0, 0 };
441
442   const DDS_PIXELFORMAT DDSPF_BC4_UNORM =
443   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_BC4U, 0, 0, 0, 0, 0 };
444
445   const DDS_PIXELFORMAT DDSPF_BC4_SNORM =
446   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_BC4S, 0, 0, 0, 0, 0 };
447
448   //todo check diff between this and ('B','C','5','U')
449   const DDS_PIXELFORMAT DDSPF_ATI2 =
450   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_ATI2, 0, 0, 0, 0, 0 };
451
452   const DDS_PIXELFORMAT DDSPF_ATI1 =
453   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_ATI1, 0, 0, 0, 0, 0 };
454
455   const DDS_PIXELFORMAT DDSPF_BC5_UNORM =
456   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_BC5U, 0, 0, 0, 0, 0 };
457
458   const DDS_PIXELFORMAT DDSPF_BC5_SNORM =
459   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_BC5S, 0, 0, 0, 0, 0 };
460
461   const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
462   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_R8G8_B8G8, 0, 0, 0, 0, 0 };
463
464   const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
465   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_G8R8_G8B8, 0, 0, 0, 0, 0 };
466
467   const DDS_PIXELFORMAT DDSPF_YUY2 =
468   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_YUY2, 0, 0, 0, 0, 0 };
469
470   const DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
471   { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
472
473   const DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
474   { sizeof(DDS_PIXELFORMAT), DDS_RGB,  0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
475
476   const DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
477   { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
478
479   const DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
480   { sizeof(DDS_PIXELFORMAT), DDS_RGB,  0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 };
481
482   const DDS_PIXELFORMAT DDSPF_G16R16 =
483   { sizeof(DDS_PIXELFORMAT), DDS_RGB,  0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 };
484
485   const DDS_PIXELFORMAT DDSPF_R5G6B5 =
486   { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 };
487
488   const DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
489   { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 };
490
491   const DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
492   { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00000f00, 0x000000f0, 0x0000000f, 0x0000f000 };
493
494   const DDS_PIXELFORMAT DDSPF_R8G8B8 =
495   { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
496
497   const DDS_PIXELFORMAT DDSPF_L8 =
498   { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0,  8, 0xff, 0x00, 0x00, 0x00 };
499
500   const DDS_PIXELFORMAT DDSPF_L16 =
501   { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0x0000, 0x0000, 0x0000 };
502
503   const DDS_PIXELFORMAT DDSPF_A8L8 =
504   { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0x0000, 0x0000, 0xff00 };
505
506   const DDS_PIXELFORMAT DDSPF_A4L4 =
507   { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0000000f, 0x0000, 0x0000, 0x000000f0 };
508
509   const DDS_PIXELFORMAT DDSPF_A8 =
510   { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0x00, 0x00, 0x00, 0xff };
511
512   const DDS_PIXELFORMAT DDSPF_V8U8 =
513   { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0x0000, 0x0000 };
514
515   const DDS_PIXELFORMAT DDSPF_Q8W8V8U8 =
516   { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
517
518   const DDS_PIXELFORMAT DDSPF_V16U16 =
519   { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 };
520
521   // D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
522
523   // This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
524   const DDS_PIXELFORMAT DDSPF_DX10 =
525   { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, D3DFMT_DX10, 0, 0, 0, 0, 0 };
526
527   #pragma pack(pop)
528
529   ///////////////////////////////////////////////////////////////////////////////////
530   //                               Functions                                       //
531   ///////////////////////////////////////////////////////////////////////////////////
532
533   //get DDS_PIXELFORMAT struct from GFXFormat - todo more formats
534   const DDS_PIXELFORMAT getDDSFormat(const GFXFormat format)
535   {
536      switch (format)
537      {
538         case GFXFormatA4L4:     return DDSPF_A4L4;
539         case GFXFormatL8:       return DDSPF_L8;
540         case GFXFormatA8:       return DDSPF_A8;
541         case GFXFormatA8L8:     return DDSPF_A8L8;
542         case GFXFormatL16:      return DDSPF_L16;
543         case GFXFormatR5G6B5:   return DDSPF_R5G6B5;
544         case GFXFormatR5G5B5A1: return DDSPF_A1R5G5B5;
545         case GFXFormatR8G8B8:   return DDSPF_R8G8B8;
546         case GFXFormatR8G8B8A8: return DDSPF_A8R8G8B8;
547         case GFXFormatR8G8B8X8: return DDSPF_X8R8G8B8;
548         case GFXFormatB8G8R8A8: return DDSPF_A8B8G8R8;
549         case GFXFormatR16G16B16A16F:
550         case GFXFormatR32G32B32A32F: return DDSPF_DX10;
551         //compressed
552         case GFXFormatBC1:      return DDSPF_DXT1;
553         case GFXFormatBC2:      return DDSPF_DXT3;
554         case GFXFormatBC3:      return DDSPF_DXT5;
555         case GFXFormatBC4:      return DDSPF_ATI1;
556         case GFXFormatBC5:      return DDSPF_ATI2;
557         default:
558         {
559            Con::errorf("dds::getDDSFormat: unknown format");
560            return DDSPF_A8R8G8B8;
561         }
562      }
563   }
564
565   //get DXGI_FORMAT from GFXFormat - todo more formats
566   const DXGI_FORMAT getDXGIFormat(const GFXFormat format)
567   {
568      switch (format)
569      {
570         //byte
571         case GFXFormatR5G6B5:         return DXGI_FORMAT_B5G6R5_UNORM;
572         case GFXFormatR5G5B5A1:       return DXGI_FORMAT_B5G5R5A1_UNORM;
573         case GFXFormatB8G8R8A8:       return DXGI_FORMAT_R8G8B8A8_UNORM;
574         case GFXFormatR8G8B8A8:       return DXGI_FORMAT_B8G8R8A8_UNORM;
575         case GFXFormatR8G8B8X8:       return DXGI_FORMAT_B8G8R8X8_UNORM;
576         case GFXFormatR10G10B10A2:    return DXGI_FORMAT_R10G10B10A2_UNORM;
577         //uint
578         case GFXFormatR16G16:         return DXGI_FORMAT_R16G16_UINT;
579         case GFXFormatR16G16B16A16:   return DXGI_FORMAT_R16G16B16A16_UINT;
580         //float
581         case GFXFormatR16F:           return DXGI_FORMAT_R16_FLOAT;
582         case GFXFormatR32F:           return DXGI_FORMAT_R32_FLOAT;
583         case GFXFormatR16G16B16A16F:  return DXGI_FORMAT_R16G16B16A16_FLOAT;
584         case GFXFormatR32G32B32A32F:  return DXGI_FORMAT_R32G32B32A32_FLOAT;
585         //compressed
586         case GFXFormatBC1:            return DXGI_FORMAT_BC1_UNORM;
587         case GFXFormatBC2:            return DXGI_FORMAT_BC2_UNORM;
588         case GFXFormatBC3:            return DXGI_FORMAT_BC3_UNORM;
589         case GFXFormatBC4:            return DXGI_FORMAT_BC4_UNORM;
590         case GFXFormatBC5:            return DXGI_FORMAT_BC5_UNORM;
591         default:
592         {
593            Con::errorf("dds::getDXGIFormat: unknown format");
594            return DXGI_FORMAT_UNKNOWN;
595         }
596      }
597   }
598
599   //get GFXFormat from D3DFMT - todo more formats
600   const GFXFormat getGFXFormat(const D3DFMT format)
601   {
602      switch (format)
603      {
604         //byte        
605         case D3DFMT_A4L4:          return GFXFormatA4L4;
606         case D3DFMT_L8:            return GFXFormatL8;
607         case D3DFMT_A8:            return GFXFormatA8;
608         case D3DFMT_A8L8:          return GFXFormatA8L8;
609         case D3DFMT_L16:           return GFXFormatL16;
610         case D3DFMT_R5G6B5:        return GFXFormatR5G6B5;
611         case D3DFMT_A1R5G5B5:      return GFXFormatR5G5B5A1;
612         case D3DFMT_R8G8B8:        return GFXFormatR8G8B8;
613         case D3DFMT_A8R8G8B8:      return GFXFormatR8G8B8A8;
614         case D3DFMT_X8R8G8B8:      return GFXFormatR8G8B8A8;
615         case D3DFMT_A8B8G8R8:      return GFXFormatB8G8R8A8;
616         case D3DFMT_X8B8G8R8:      return GFXFormatB8G8R8A8;
617         //uint
618         case D3DFMT_G16R16:        return GFXFormatR16G16;
619         case D3DFMT_A16B16G16R16:  return GFXFormatR16G16B16A16;
620         //float
621         case D3DFMT_R16F:          return GFXFormatR16F;
622         case D3DFMT_R32F:          return GFXFormatR32F;
623         case D3DFMT_G16R16F:       return GFXFormatR16G16F;
624         case D3DFMT_A16B16G16R16F: return GFXFormatR16G16B16A16F;
625         case D3DFMT_A32B32G32R32F: return GFXFormatR32G32B32A32F;
626         //compressed
627         case D3DFMT_DXT1:          return GFXFormatBC1;
628         case D3DFMT_DXT2:          
629         case D3DFMT_DXT3:          return GFXFormatBC2;
630         case D3DFMT_DXT4:
631         case D3DFMT_DXT5:          return GFXFormatBC3;
632         case D3DFMT_ATI1:          return GFXFormatBC4;
633         case D3DFMT_ATI2:          return GFXFormatBC5;
634         default:
635         {
636            Con::errorf("dds::getGFXFormat: unknown format");
637            return GFXFormat_FIRST;
638         }
639      }
640   }
641
642   //get GFXFormat from DXGI_FORMAT - todo more formats
643   const GFXFormat getGFXFormat(const DXGI_FORMAT format)
644   {
645      switch (format)
646      {
647         //byte
648         case DXGI_FORMAT_B5G6R5_UNORM:         return GFXFormatR5G6B5;
649         case DXGI_FORMAT_B5G5R5A1_UNORM:       return GFXFormatR5G5B5A1;
650         case DXGI_FORMAT_R8G8B8A8_UNORM:       return GFXFormatB8G8R8A8;
651         case DXGI_FORMAT_B8G8R8A8_UNORM:       return GFXFormatR8G8B8A8;
652         case DXGI_FORMAT_B8G8R8X8_UNORM:       return GFXFormatR8G8B8X8;
653         case DXGI_FORMAT_R10G10B10A2_UNORM:    return GFXFormatR10G10B10A2;
654         //uint
655         case DXGI_FORMAT_R16G16_UINT:          return GFXFormatR16G16;
656         case DXGI_FORMAT_R16G16B16A16_UINT:    return GFXFormatR16G16B16A16;
657         //float
658         case DXGI_FORMAT_R16_FLOAT:            return GFXFormatR16F;
659         case DXGI_FORMAT_R32_FLOAT:            return GFXFormatR32F;
660         case DXGI_FORMAT_R16G16_FLOAT:         return GFXFormatR16G16F;
661         case DXGI_FORMAT_R16G16B16A16_FLOAT:   return GFXFormatR16G16B16A16F;
662         case DXGI_FORMAT_R32G32B32A32_FLOAT:   return GFXFormatR32G32B32A32F;
663         //compressed
664         case DXGI_FORMAT_BC1_UNORM:            return GFXFormatBC1;
665         case DXGI_FORMAT_BC2_UNORM:            return GFXFormatBC2;
666         case DXGI_FORMAT_BC3_UNORM:            return GFXFormatBC3;
667         case DXGI_FORMAT_BC4_UNORM:            return GFXFormatBC4;
668         case DXGI_FORMAT_BC5_UNORM:            return GFXFormatBC5;
669         default:
670         {
671            Con::errorf("dds::getGFXFormatDxgi: unknown format");
672            return GFXFormat_FIRST;
673         }
674      }
675   }
676
677   //get GFXFormat from DDS_PIXELFORMAT struct - todo more formats
678   const GFXFormat getGFXFormat(const DDS_PIXELFORMAT &format)
679   {
680      if (format == DDSPF_DXT1)
681         return GFXFormatBC1;
682      else if (format == DDSPF_DXT2)
683         return GFXFormatBC2;
684      else if (format == DDSPF_DXT3)
685         return GFXFormatBC2;
686      else if (format == DDSPF_DXT4)
687         return GFXFormatBC3;
688      else if (format == DDSPF_DXT5)
689         return GFXFormatBC3;
690      else if (format == DDSPF_ATI1)
691         return GFXFormatBC4;
692      else if (format == DDSPF_ATI2)
693         return GFXFormatBC5;
694      else if (format == DDSPF_A8R8G8B8)
695         return GFXFormatR8G8B8A8;
696      else if (format == DDSPF_X8R8G8B8)
697         return GFXFormatR8G8B8A8;
698      else if (format == DDSPF_A8B8G8R8)
699         return GFXFormatB8G8R8A8;
700      else if (format == DDSPF_X8B8G8R8)
701         return GFXFormatB8G8R8A8;
702      else if (format == DDSPF_R8G8B8)
703         return GFXFormatR8G8B8;
704      else if (format == DDSPF_A8L8)
705         return GFXFormatA8L8;
706      else if (format == DDSPF_A4L4)
707         return GFXFormatA4L4;
708      else if (format == DDSPF_A8)
709         return GFXFormatA8;
710      else if (format == DDSPF_L8)
711         return GFXFormatL8;
712      else if (format == DDSPF_R5G6B5)
713         return GFXFormatR5G6B5;
714      else if (format == DDSPF_A1R5G5B5)
715         return GFXFormatR5G5B5A1;
716      else
717      {
718         Con::errorf("dds::getGFXFormat: unknown format");
719         return GFXFormat_FIRST;
720      }
721   }
722
723   //get GFXFormat from fourcc value - todo more formats
724   const GFXFormat getGFXFormat(const U32 fourcc)
725   {
726      switch (fourcc)
727      {
728         case D3DFMT_DXT1: return GFXFormatBC1;
729         case D3DFMT_DXT2:
730         case D3DFMT_DXT3: return GFXFormatBC2;
731         case D3DFMT_DXT4:
732         case D3DFMT_DXT5: return GFXFormatBC3;
733         case D3DFMT_ATI1: return GFXFormatBC4;
734         case D3DFMT_ATI2: return GFXFormatBC5;
735         case D3DFMT_A16B16G16R16F: return GFXFormatR16G16B16A16F;
736         case D3DFMT_A32B32G32R32F: return GFXFormatR32G32B32A32F;
737         case D3DFMT_G16R16F: return GFXFormatR16G16F;
738         default:
739         {
740            Con::errorf("dds::getGFXFormatFourcc: unknown format");
741            return GFXFormat_FIRST;
742         }
743      }
744   }
745
746   const U32 getBitsPerPixel(DXGI_FORMAT fmt)
747   {
748      switch (fmt)
749      {
750      case DXGI_FORMAT_R32G32B32A32_TYPELESS:
751      case DXGI_FORMAT_R32G32B32A32_FLOAT:
752      case DXGI_FORMAT_R32G32B32A32_UINT:
753      case DXGI_FORMAT_R32G32B32A32_SINT:
754         return 128;
755
756      case DXGI_FORMAT_R32G32B32_TYPELESS:
757      case DXGI_FORMAT_R32G32B32_FLOAT:
758      case DXGI_FORMAT_R32G32B32_UINT:
759      case DXGI_FORMAT_R32G32B32_SINT:
760         return 96;
761
762      case DXGI_FORMAT_R16G16B16A16_TYPELESS:
763      case DXGI_FORMAT_R16G16B16A16_FLOAT:
764      case DXGI_FORMAT_R16G16B16A16_UNORM:
765      case DXGI_FORMAT_R16G16B16A16_UINT:
766      case DXGI_FORMAT_R16G16B16A16_SNORM:
767      case DXGI_FORMAT_R16G16B16A16_SINT:
768      case DXGI_FORMAT_R32G32_TYPELESS:
769      case DXGI_FORMAT_R32G32_FLOAT:
770      case DXGI_FORMAT_R32G32_UINT:
771      case DXGI_FORMAT_R32G32_SINT:
772      case DXGI_FORMAT_R32G8X24_TYPELESS:
773      case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
774      case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
775      case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
776         return 64;
777
778      case DXGI_FORMAT_R10G10B10A2_TYPELESS:
779      case DXGI_FORMAT_R10G10B10A2_UNORM:
780      case DXGI_FORMAT_R10G10B10A2_UINT:
781      case DXGI_FORMAT_R11G11B10_FLOAT:
782      case DXGI_FORMAT_R8G8B8A8_TYPELESS:
783      case DXGI_FORMAT_R8G8B8A8_UNORM:
784      case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
785      case DXGI_FORMAT_R8G8B8A8_UINT:
786      case DXGI_FORMAT_R8G8B8A8_SNORM:
787      case DXGI_FORMAT_R8G8B8A8_SINT:
788      case DXGI_FORMAT_R16G16_TYPELESS:
789      case DXGI_FORMAT_R16G16_FLOAT:
790      case DXGI_FORMAT_R16G16_UNORM:
791      case DXGI_FORMAT_R16G16_UINT:
792      case DXGI_FORMAT_R16G16_SNORM:
793      case DXGI_FORMAT_R16G16_SINT:
794      case DXGI_FORMAT_R32_TYPELESS:
795      case DXGI_FORMAT_D32_FLOAT:
796      case DXGI_FORMAT_R32_FLOAT:
797      case DXGI_FORMAT_R32_UINT:
798      case DXGI_FORMAT_R32_SINT:
799      case DXGI_FORMAT_R24G8_TYPELESS:
800      case DXGI_FORMAT_D24_UNORM_S8_UINT:
801      case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
802      case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
803      case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
804      case DXGI_FORMAT_R8G8_B8G8_UNORM:
805      case DXGI_FORMAT_G8R8_G8B8_UNORM:
806      case DXGI_FORMAT_B8G8R8A8_UNORM:
807      case DXGI_FORMAT_B8G8R8X8_UNORM:
808      case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
809      case DXGI_FORMAT_B8G8R8A8_TYPELESS:
810      case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
811      case DXGI_FORMAT_B8G8R8X8_TYPELESS:
812      case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
813         return 32;
814
815      case DXGI_FORMAT_R8G8_TYPELESS:
816      case DXGI_FORMAT_R8G8_UNORM:
817      case DXGI_FORMAT_R8G8_UINT:
818      case DXGI_FORMAT_R8G8_SNORM:
819      case DXGI_FORMAT_R8G8_SINT:
820      case DXGI_FORMAT_R16_TYPELESS:
821      case DXGI_FORMAT_R16_FLOAT:
822      case DXGI_FORMAT_D16_UNORM:
823      case DXGI_FORMAT_R16_UNORM:
824      case DXGI_FORMAT_R16_UINT:
825      case DXGI_FORMAT_R16_SNORM:
826      case DXGI_FORMAT_R16_SINT:
827      case DXGI_FORMAT_B5G6R5_UNORM:
828      case DXGI_FORMAT_B5G5R5A1_UNORM:
829         return 16;
830
831      case DXGI_FORMAT_R8_TYPELESS:
832      case DXGI_FORMAT_R8_UNORM:
833      case DXGI_FORMAT_R8_UINT:
834      case DXGI_FORMAT_R8_SNORM:
835      case DXGI_FORMAT_R8_SINT:
836      case DXGI_FORMAT_A8_UNORM:
837         return 8;
838
839      case DXGI_FORMAT_R1_UNORM:
840         return 1;
841
842      case DXGI_FORMAT_BC1_TYPELESS:
843      case DXGI_FORMAT_BC1_UNORM:
844      case DXGI_FORMAT_BC1_UNORM_SRGB:
845      case DXGI_FORMAT_BC4_TYPELESS:
846      case DXGI_FORMAT_BC4_UNORM:
847      case DXGI_FORMAT_BC4_SNORM:
848         return 4;
849
850      case DXGI_FORMAT_BC2_TYPELESS:
851      case DXGI_FORMAT_BC2_UNORM:
852      case DXGI_FORMAT_BC2_UNORM_SRGB:
853      case DXGI_FORMAT_BC3_TYPELESS:
854      case DXGI_FORMAT_BC3_UNORM:
855      case DXGI_FORMAT_BC3_UNORM_SRGB:
856      case DXGI_FORMAT_BC5_TYPELESS:
857      case DXGI_FORMAT_BC5_UNORM:
858      case DXGI_FORMAT_BC5_SNORM:
859      case DXGI_FORMAT_BC6H_TYPELESS:
860      case DXGI_FORMAT_BC6H_UF16:
861      case DXGI_FORMAT_BC6H_SF16:
862      case DXGI_FORMAT_BC7_TYPELESS:
863      case DXGI_FORMAT_BC7_UNORM:
864      case DXGI_FORMAT_BC7_UNORM_SRGB:
865         return 8;
866
867      default:
868         return 0;
869      }
870   }
871
872   const bool validateHeader(const DDS_HEADER &header)
873   {
874      if (header.size != DDS_HEADER_SIZE)
875      {
876         Con::errorf("DDS_HEADER - incorrect header size. Expected 124 bytes.");
877         return false;
878      }
879
880      if (!(header.flags & DDS_HEADER_FLAGS_TEXTURE))
881      {
882         Con::errorf("DDS_HEADER - incorrect surface description flags.");
883         return false;
884      }
885
886      if ((header.flags & (DDS_HEADER_FLAGS_LINEARSIZE | DDS_HEADER_FLAGS_PITCH)) == (DDS_HEADER_FLAGS_LINEARSIZE | DDS_HEADER_FLAGS_PITCH))
887      {
888         // Both are invalid!
889         Con::errorf("DDS_HEADER - encountered both DDSD_LINEARSIZE and DDSD_PITCH!");
890         return false;
891      }
892
893      return true;
894   }
895
896   const bool validateHeaderDx10(const DDS_HEADER_DXT10 &header)
897   {
898      if (sizeof(DDS_HEADER_DXT10) != DDS_HEADER_DX10_SIZE)
899      {
900         Con::errorf("DDS_HEADER_DXT10 - incorrect header size. Expected 20 bytes.");
901         return false;
902      }
903
904      return true;
905   }
906
907}
908
909#endif
910