Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDS.h
Go to the documentation of this file.
1 // The copyright in this software is being made available under the BSD License, included below.
2 // This software may be subject to other third party and contributor rights, including patent rights,
3 // and no such rights are granted under this license.
4 //
5 // Copyright (c) 2013, Microsoft Open Technologies, Inc.
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without modification,
9 // are permitted provided that the following conditions are met:
10 //
11 // - Redistributions of source code must retain the above copyright notice,
12 // this list of conditions and the following disclaimer.
13 // - Redistributions in binary form must reproduce the above copyright notice,
14 // this list of conditions and the following disclaimer in the documentation
15 // and/or other materials provided with the distribution.
16 // - Neither the name of Microsoft Open Technologies, Inc. nor the names of its contributors
17 // may be used to endorse or promote products derived from this software
18 // without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 //--------------------------------------------------------------------------------------
30 // dds.h
31 //
32 // This header defines constants and structures that are useful when parsing
33 // DDS files. DDS files were originally designed to use several structures
34 // and constants that are native to DirectDraw and are defined in ddraw.h,
35 // such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar
36 // (compatible) constants and structures so that one can use DDS files
37 // without needing to include ddraw.h.
38 //
39 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
40 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
41 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
42 // PARTICULAR PURPOSE.
43 //
44 // Copyright (c) Microsoft Corporation. All rights reserved.
45 //
46 // http://go.microsoft.com/fwlink/?LinkId=248926
47 // http://go.microsoft.com/fwlink/?LinkId=248929
48 //--------------------------------------------------------------------------------------
49 
50 #if defined(_MSC_VER)
51 #pragma once
52 #endif
53 
54 #include <dxgiformat.h>
55 
56 #pragma warning(push)
57 #pragma warning(disable : 4005)
58 #include <stdint.h>
59 #pragma warning(pop)
60 
61 namespace DirectX
62 {
63 
64 #pragma pack(push,1)
65 
66 const uint32_t DDS_MAGIC = 0x20534444; // "DDS "
67 
69 {
70  uint32_t size;
71  uint32_t flags;
72  uint32_t fourCC;
73  uint32_t RGBBitCount;
74  uint32_t RBitMask;
75  uint32_t GBitMask;
76  uint32_t BBitMask;
77  uint32_t ABitMask;
78 };
79 
80 #define DDS_FOURCC 0x00000004 // DDPF_FOURCC
81 #define DDS_RGB 0x00000040 // DDPF_RGB
82 #define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
83 #define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
84 #define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
85 #define DDS_ALPHA 0x00000002 // DDPF_ALPHA
86 #define DDS_PAL8 0x00000020 // DDPF_PALETTEINDEXED8
87 
88 #ifndef MAKEFOURCC
89  #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
90  ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
91  ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
92 #endif /* defined(MAKEFOURCC) */
93 
94 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT1 =
95  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
96 
97 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT2 =
98  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
99 
100 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT3 =
101  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
102 
103 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT4 =
104  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
105 
106 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT5 =
107  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
108 
109 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_UNORM =
110  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 };
111 
112 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_SNORM =
113  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 };
114 
115 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_UNORM =
116  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 };
117 
118 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_SNORM =
119  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 };
120 
121 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
122  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 };
123 
124 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
125  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 };
126 
127 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
128  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
129 
130 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
131  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
132 
133 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
134  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
135 
136 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
137  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 };
138 
139 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G16R16 =
140  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 };
141 
142 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R5G6B5 =
143  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 };
144 
145 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
146  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 };
147 
148 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
149  { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00000f00, 0x000000f0, 0x0000000f, 0x0000f000 };
150 
151 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8B8 =
152  { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
153 
154 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L8 =
155  { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0x00, 0x00, 0x00 };
156 
157 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L16 =
158  { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0x0000, 0x0000, 0x0000 };
159 
160 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8L8 =
161  { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0x0000, 0x0000, 0xff00 };
162 
163 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8 =
164  { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0x00, 0x00, 0x00, 0xff };
165 
166 // D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
167 
168 // This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
169 extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DX10 =
170  { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 };
171 
172 #define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
173 #define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
174 #define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
175 #define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
176 #define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
177 
178 #define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
179 #define DDS_WIDTH 0x00000004 // DDSD_WIDTH
180 
181 #define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
182 #define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
183 #define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX
184 
185 #define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
186 #define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
187 #define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
188 #define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
189 #define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
190 #define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
191 
192 #define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
193  DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
194  DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
195 
196 #define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP
197 
198 #define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
199 
200 // Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
202 {
206 };
207 
208 // Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
210 {
212 };
213 
215 {
216  uint32_t size;
217  uint32_t flags;
218  uint32_t height;
219  uint32_t width;
221  uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags
222  uint32_t mipMapCount;
223  uint32_t reserved1[11];
225  uint32_t caps;
226  uint32_t caps2;
227  uint32_t caps3;
228  uint32_t caps4;
229  uint32_t reserved2;
230 };
231 
233 {
234  DXGI_FORMAT dxgiFormat;
236  uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG
237  uint32_t arraySize;
238  uint32_t reserved;
239 } ;
240 
241 #pragma pack(pop)
242 
243 }; // namespace
uint32_t RBitMask
Definition: DDS.h:74
uint32_t width
Definition: DDS.h:219
#define DDS_LUMINANCEA
Definition: DDS.h:84
DDS_RESOURCE_DIMENSION
Definition: DDS.h:201
__declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT1
DXGI_FORMAT dxgiFormat
Definition: DDS.h:234
uint32_t flags
Definition: DDS.h:217
uint32_t resourceDimension
Definition: DDS.h:235
uint32_t depth
Definition: DDS.h:221
Definition: DDS.h:68
uint32_t miscFlag
Definition: DDS.h:236
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: DDS.h:89
uint32_t size
Definition: DDS.h:70
uint32_t size
Definition: DDS.h:216
#define DDS_RGBA
Definition: DDS.h:82
uint32_t reserved
Definition: DDS.h:238
uint32_t mipMapCount
Definition: DDS.h:222
#define DDS_LUMINANCE
Definition: DDS.h:83
#define DDS_ALPHA
Definition: DDS.h:85
DDS_RESOURCE_MISC_FLAG
Definition: DDS.h:209
uint32_t RGBBitCount
Definition: DDS.h:73
uint32_t flags
Definition: DDS.h:71
DDS_PIXELFORMAT ddspf
Definition: DDS.h:224
uint32_t caps3
Definition: DDS.h:227
uint32_t reserved2
Definition: DDS.h:229
uint32_t pitchOrLinearSize
Definition: DDS.h:220
uint32_t caps2
Definition: DDS.h:226
uint32_t ABitMask
Definition: DDS.h:77
uint32_t height
Definition: DDS.h:218
uint32_t fourCC
Definition: DDS.h:72
uint32_t caps
Definition: DDS.h:225
uint32_t reserved1[11]
Definition: DDS.h:223
Definition: DDS.h:232
#define DDS_RGB
Definition: DDS.h:81
uint32_t BBitMask
Definition: DDS.h:76
uint32_t arraySize
Definition: DDS.h:237
Definition: DDS.h:214
const uint32_t DDS_MAGIC
Definition: DDS.h:66
#define DDS_FOURCC
Definition: DDS.h:80
uint32_t GBitMask
Definition: DDS.h:75
uint32_t caps4
Definition: DDS.h:228