1 /*
2  * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22 
23 #ifndef _D3D9TYPES_H_
24 #define _D3D9TYPES_H_
25 
26 #ifdef _WIN32
27 #include <windows.h>
28 #else /* _WIN32 */
29 #include <stdint.h>
30 
31 #ifndef NULL
32 #define NULL 0
33 #endif
34 
35 /********************************************************
36  * Windows types                                        *
37  ********************************************************/
38 /* Function macros */
39 #define FAILED(x)    ((HRESULT)(x) < 0)
40 #define SUCCEEDED(x) ((HRESULT)(x) >= 0)
41 
42 #define MAKE_HRESULT(sev,fac,code) \
43     ( \
44         ((HRESULT)(sev) << 31) | \
45         ((HRESULT)(fac) << 16) | \
46          (HRESULT)(code) \
47     )
48 
49 /* Windows errors */
50 #define E_OUTOFMEMORY MAKE_HRESULT(1, 0x007, 14)
51 #define E_NOINTERFACE MAKE_HRESULT(1, 0x000, 0x4002)
52 #define E_POINTER     MAKE_HRESULT(1, 0x000, 0x4003)
53 #define E_FAIL        MAKE_HRESULT(1, 0x000, 0x4005)
54 
55 #define S_OK          ((HRESULT)0)
56 #define S_FALSE       ((HRESULT)1)
57 
58 /* WORD types */
59 typedef uint8_t BYTE;
60 typedef uint16_t WORD;
61 typedef uint32_t DWORD;
62 
63 /* Renamed types */
64 typedef int BOOL;
65 #ifndef FALSE
66 #define FALSE 0
67 #define TRUE (!FALSE)
68 #endif
69 
70 typedef uint32_t UINT32;
71 typedef uint64_t UINT64;
72 
73 typedef unsigned short USHORT;
74 typedef unsigned int UINT;
75 typedef unsigned int ULONG;
76 typedef unsigned long long ULONGLONG;
77 
78 typedef short SHORT;
79 typedef int INT;
80 typedef int LONG;
81 typedef long long LONGLONG;
82 typedef float FLOAT;
83 
84 /* Windows types */
85 typedef void *HANDLE;
86 typedef int32_t HRESULT;
87 typedef HANDLE HWND;
88 typedef HANDLE HMONITOR;
89 typedef HANDLE HDC;
90 
91 /* Unions */
92 typedef union {
93     struct {
94         DWORD LowPart;
95         LONG HighPart;
96     };
97 
98     struct {
99         DWORD LowPart;
100         LONG HighPart;
101     } u;
102 
103     LONGLONG QuadPart;
104 } LARGE_INTEGER, *LPLARGE_INTEGER;
105 
106 /* Structs */
107 
108 typedef struct _GUID {
109     DWORD Data1;
110     WORD Data2;
111     WORD Data3;
112     BYTE Data4[8];
113 } GUID, IID, *LPGUID, *REFGUID, *REFIID;
114 
115 typedef struct _LUID {
116     DWORD LowPart;
117     LONG HighPart;
118 } LUID, *LPLUID, *PLUID;
119 
120 typedef struct _PALETTEENTRY {
121     BYTE peRed;
122     BYTE peGreen;
123     BYTE peBlue;
124     BYTE peFlags;
125 } PALETTEENTRY, *LPPALETTEENTRY;
126 
127 typedef struct _POINT {
128     LONG x;
129     LONG y;
130 } POINT, *LPPOINT;
131 
132 typedef struct _RECT {
133     LONG left;
134     LONG top;
135     LONG right;
136     LONG bottom;
137 } RECT, *LPRECT;
138 
139 typedef struct _RGNDATAHEADER {
140     DWORD dwSize;
141     DWORD iType;
142     DWORD nCount;
143     DWORD nRgnSize;
144     RECT rcBound;
145 } RGNDATAHEADER, *LPRGNDATAHEADER;
146 
147 typedef struct _RGNDATA {
148     RGNDATAHEADER rdh;
149     char Buffer[1];
150 } RGNDATA, *LPRGNDATA;
151 #endif /* _WIN32 */
152 
153 #ifndef MAKEFOURCC
154 #define MAKEFOURCC(a, b, c, d) \
155     ( \
156          (DWORD)(BYTE)(a) | \
157         ((DWORD)(BYTE)(b) << 8) | \
158         ((DWORD)(BYTE)(c) << 16) | \
159         ((DWORD)(BYTE)(d) << 24) \
160     )
161 #endif /* MAKEFOURCC */
162 
163 
164 #define D3DPRESENTFLAG_LOCKABLE_BACKBUFFER             0x00000001
165 #define D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL            0x00000002
166 #define D3DPRESENTFLAG_DEVICECLIP                      0x00000004
167 #define D3DPRESENTFLAG_VIDEO                           0x00000010
168 #define D3DPRESENTFLAG_NOAUTOROTATE                    0x00000020
169 #define D3DPRESENTFLAG_UNPRUNEDMODE                    0x00000040
170 #define D3DPRESENTFLAG_OVERLAY_LIMITEDRGB              0x00000080
171 #define D3DPRESENTFLAG_OVERLAY_YCbCr_BT709             0x00000100
172 #define D3DPRESENTFLAG_OVERLAY_YCbCr_xvYCC             0x00000200
173 #define D3DPRESENTFLAG_RESTRICTED_CONTENT              0x00000400
174 #define D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER 0x00000800
175 
176 /* Windows calling convention */
177 #ifndef WINAPI
178   #if defined(__x86_64__) && !defined(__ILP32__)
179     #define WINAPI __attribute__((ms_abi))
180   #elif defined(__i386__)
181     #define WINAPI __attribute__((__stdcall__))
182   #else /* neither amd64 nor i386 */
183     #define WINAPI
184   #endif
185 #endif /* WINAPI */
186 
187 /* Implementation caps */
188 #define D3DPRESENT_BACK_BUFFERS_MAX    3
189 #define D3DPRESENT_BACK_BUFFERS_MAX_EX 30
190 
191 /* Functions */
192 #define MAKE_D3DHRESULT(code) MAKE_HRESULT(1, 0x876, code)
193 #define MAKE_D3DSTATUS(code)  MAKE_HRESULT(0, 0x876, code)
194 
195 /* SDK version */
196 #define D3D_SDK_VERSION 32
197 
198 /* Adapter */
199 #define D3DADAPTER_DEFAULT 0
200 
201 /********************************************************
202  * Return codes                                         *
203  ********************************************************/
204 #define D3D_OK                           S_OK
205 #define D3DOK_NOAUTOGEN                  MAKE_D3DSTATUS(2159)
206 #define D3DERR_OUTOFVIDEOMEMORY          MAKE_D3DHRESULT(380)
207 #define D3DERR_WASSTILLDRAWING           MAKE_D3DHRESULT(540)
208 #define D3DERR_WRONGTEXTUREFORMAT        MAKE_D3DHRESULT(2072)
209 #define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073)
210 #define D3DERR_UNSUPPORTEDCOLORARG       MAKE_D3DHRESULT(2074)
211 #define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075)
212 #define D3DERR_UNSUPPORTEDALPHAARG       MAKE_D3DHRESULT(2076)
213 #define D3DERR_TOOMANYOPERATIONS         MAKE_D3DHRESULT(2077)
214 #define D3DERR_CONFLICTINGTEXTUREFILTER  MAKE_D3DHRESULT(2078)
215 #define D3DERR_UNSUPPORTEDFACTORVALUE    MAKE_D3DHRESULT(2079)
216 #define D3DERR_CONFLICTINGRENDERSTATE    MAKE_D3DHRESULT(2081)
217 #define D3DERR_UNSUPPORTEDTEXTUREFILTER  MAKE_D3DHRESULT(2082)
218 #define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086)
219 #define D3DERR_DRIVERINTERNALERROR       MAKE_D3DHRESULT(2087)
220 #define D3DERR_NOTFOUND                  MAKE_D3DHRESULT(2150)
221 #define D3DERR_MOREDATA                  MAKE_D3DHRESULT(2151)
222 #define D3DERR_DEVICELOST                MAKE_D3DHRESULT(2152)
223 #define D3DERR_DEVICENOTRESET            MAKE_D3DHRESULT(2153)
224 #define D3DERR_NOTAVAILABLE              MAKE_D3DHRESULT(2154)
225 #define D3DERR_INVALIDDEVICE             MAKE_D3DHRESULT(2155)
226 #define D3DERR_INVALIDCALL               MAKE_D3DHRESULT(2156)
227 #define D3DERR_DRIVERINVALIDCALL         MAKE_D3DHRESULT(2157)
228 #define D3DERR_DEVICEREMOVED             MAKE_D3DHRESULT(2160)
229 #define D3DERR_DEVICEHUNG                MAKE_D3DHRESULT(2164)
230 #define S_PRESENT_OCCLUDED               MAKE_D3DSTATUS(2168)
231 
232 /********************************************************
233  * Bitmasks                                             *
234  *******************************************************/
235 /* IDirect3DDevice9::Clear */
236 #define D3DCLEAR_TARGET  0x00000001
237 #define D3DCLEAR_ZBUFFER 0x00000002
238 #define D3DCLEAR_STENCIL 0x00000004
239 
240 /* Usage */
241 /* http://msdn.microsoft.com/en-us/library/ee416659(VS.85).aspx */
242 #define D3DUSAGE_RENDERTARGET                    0x00000001
243 #define D3DUSAGE_DEPTHSTENCIL                    0x00000002
244 #define D3DUSAGE_WRITEONLY                       0x00000008
245 #define D3DUSAGE_SOFTWAREPROCESSING              0x00000010
246 #define D3DUSAGE_DONOTCLIP                       0x00000020
247 #define D3DUSAGE_POINTS                          0x00000040
248 #define D3DUSAGE_RTPATCHES                       0x00000080
249 #define D3DUSAGE_NPATCHES                        0x00000100
250 #define D3DUSAGE_DYNAMIC                         0x00000200
251 #define D3DUSAGE_AUTOGENMIPMAP                   0x00000400
252 #ifndef D3D_DISABLE_9EX
253 #define D3DUSAGE_RESTRICTED_CONTENT              0x00000800
254 #define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER 0x00001000
255 #define D3DUSAGE_RESTRICT_SHARED_RESOURCE        0x00002000
256 #endif
257 #define D3DUSAGE_DMAP                            0x00004000
258 #define D3DUSAGE_QUERY_LEGACYBUMPMAP             0x00008000
259 #define D3DUSAGE_QUERY_SRGBREAD                  0x00010000
260 #define D3DUSAGE_QUERY_FILTER                    0x00020000
261 #define D3DUSAGE_QUERY_SRGBWRITE                 0x00040000
262 #define D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING  0x00080000
263 #define D3DUSAGE_QUERY_VERTEXTEXTURE             0x00100000
264 #define D3DUSAGE_QUERY_WRAPANDMIP	             0x00200000
265 #ifndef D3D_DISABLE_9EX
266 #define D3DUSAGE_NONSECURE                       0x00800000
267 #define D3DUSAGE_TEXTAPI                         0x10000000
268 #endif
269 
270 /* Buffer locking */
271 /* http://msdn.microsoft.com/en-us/library/ee416503(VS.85).aspx */
272 #define D3DLOCK_READONLY        0x00000010
273 #define D3DLOCK_NOSYSLOCK       0x00000800
274 #define D3DLOCK_NOOVERWRITE     0x00001000
275 #define D3DLOCK_DISCARD         0x00002000
276 #define D3DLOCK_DONOTWAIT       0x00004000
277 #define D3DLOCK_NO_DIRTY_UPDATE 0x00008000
278 
279 /* FVF */
280 /* http://msdn.microsoft.com/en-us/library/ee416490(VS.85).aspx */
281 /* http://msdn.microsoft.com/en-us/library/ms791638.aspx */
282 #define D3DFVF_XYZ              0x00000002
283 #define D3DFVF_XYZRHW           0x00000004
284 #define D3DFVF_XYZB1            0x00000006
285 #define D3DFVF_XYZB2            0x00000008
286 #define D3DFVF_XYZB3            0x0000000A
287 #define D3DFVF_XYZB4            0x0000000C
288 #define D3DFVF_XYZB5            0x0000000E
289 #define D3DFVF_XYZW             0x00004002
290 #define D3DFVF_POSITION_MASK    0x0000400E
291 
292 #define D3DFVF_NORMAL           0x00000010
293 #define D3DFVF_PSIZE            0x00000020
294 #define D3DFVF_DIFFUSE          0x00000040
295 #define D3DFVF_SPECULAR         0x00000080
296 
297 #define D3DFVF_TEX0             0x00000000
298 #define D3DFVF_TEX1             0x00000100
299 #define D3DFVF_TEX2             0x00000200
300 #define D3DFVF_TEX3             0x00000300
301 #define D3DFVF_TEX4             0x00000400
302 #define D3DFVF_TEX5             0x00000500
303 #define D3DFVF_TEX6             0x00000600
304 #define D3DFVF_TEX7             0x00000700
305 #define D3DFVF_TEX8             0x00000800
306 #define D3DFVF_TEXCOUNT_MASK    0x00000F00
307 #define D3DFVF_TEXCOUNT_SHIFT            8
308 #define D3DFVF_TEXTUREFORMAT1   0x00000003
309 #define D3DFVF_TEXTUREFORMAT2   0x00000000
310 #define D3DFVF_TEXTUREFORMAT3   0x00000001
311 #define D3DFVF_TEXTUREFORMAT4   0x00000002
312 
313 #define D3DFVF_POSITION_MASK  0x0000400E
314 #define D3DFVF_TEXCOUNT_MASK  0x00000F00
315 #define D3DFVF_TEXCOUNT_SHIFT 8
316 
317 #define D3DFVF_LASTBETA_UBYTE4   0x00001000
318 #define D3DFVF_LASTBETA_D3DCOLOR 0x00008000
319 
320 #define D3DFVF_RESERVED0 0x00000001
321 #define D3DFVF_RESERVED2 0x00006000
322 
323 #define D3DTA_SELECTMASK        0x0000000f
324 #define D3DTA_DIFFUSE           0x00000000
325 #define D3DTA_CURRENT           0x00000001
326 #define D3DTA_TEXTURE           0x00000002
327 #define D3DTA_TFACTOR           0x00000003
328 #define D3DTA_SPECULAR          0x00000004
329 #define D3DTA_TEMP              0x00000005
330 #define D3DTA_CONSTANT          0x00000006
331 #define D3DTA_COMPLEMENT        0x00000010
332 #define D3DTA_ALPHAREPLICATE    0x00000020
333 
334 #define D3DSPD_IUNKNOWN 0x00000001
335 
336 #define D3DPRESENT_DONOTWAIT      0x00000001
337 #define D3DPRESENT_LINEAR_CONTENT 0x00000002
338 #define D3DPRESENT_RATE_DEFAULT            0
339 
340 #define D3DCREATE_FPU_PRESERVE              0x00000002
341 #define D3DCREATE_MULTITHREADED             0x00000004
342 #define D3DCREATE_PUREDEVICE                0x00000010
343 #define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020
344 #define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040
345 #define D3DCREATE_MIXED_VERTEXPROCESSING    0x00000080
346 #define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100
347 #define D3DCREATE_ADAPTERGROUP_DEVICE       0x00000200
348 
349 #define D3DSTREAMSOURCE_INDEXEDDATA  (1 << 30)
350 #define D3DSTREAMSOURCE_INSTANCEDATA (2 << 30)
351 
352 /* D3DRS_COLORWRITEENABLE */
353 #define D3DCOLORWRITEENABLE_RED     (1L << 0)
354 #define D3DCOLORWRITEENABLE_GREEN   (1L << 1)
355 #define D3DCOLORWRITEENABLE_BLUE    (1L << 2)
356 #define D3DCOLORWRITEENABLE_ALPHA   (1L << 3)
357 
358 
359 /********************************************************
360  * Function macros                                      *
361  *******************************************************/
362 
363 /* Colors */
364 #define D3DCOLOR_ARGB(a,r,g,b) \
365     ((D3DCOLOR)( \
366         (((a) & 0xFF) << 24) | \
367         (((r) & 0xFF) << 16) | \
368         (((g) & 0xFF) << 8) | \
369          ((b) & 0xFF) \
370     ))
371 
372 #define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b)
373 #define D3DCOLOR_XRGB(r,g,b)   D3DCOLOR_ARGB(0xFF,r,g,b)
374 #define D3DCOLOR_AYUV(a,y,u,v) D3DCOLOR_ARGB(a,y,u,v)
375 #define D3DCOLOR_XYUV(y,u,v)   D3DCOLOR_ARGB(0xFF,y,u,v)
376 
377 #define D3DCOLOR_COLORVALUE(r,g,b,a) \
378     D3DCOLOR_RGBA( \
379         (DWORD)((r) * 255.0f), \
380         (DWORD)((g) * 255.0f), \
381         (DWORD)((b) * 255.0f), \
382         (DWORD)((a) * 255.0f) \
383     )
384 
385 /* Shaders */
386 #define D3DDECL_END() { 0xFF, 0, D3DDECLTYPE_UNUSED, 0, 0, 0 }
387 
388 /*****************************************************************************
389  * Typedefs                                                                  *
390  *****************************************************************************/
391 typedef DWORD D3DCOLOR;
392 
393 /*****************************************************************************
394  * Enums                                                                     *
395  *****************************************************************************/
396 typedef enum D3DDISPLAYROTATION {
397     D3DDISPLAYROTATION_IDENTITY = 1,
398     D3DDISPLAYROTATION_90 = 2,
399     D3DDISPLAYROTATION_180 = 3,
400     D3DDISPLAYROTATION_270 = 4
401 } D3DDISPLAYROTATION;
402 
403 typedef enum D3DSCANLINEORDERING {
404     D3DSCANLINEORDERING_UNKNOWN = 0,
405     D3DSCANLINEORDERING_PROGRESSIVE = 1,
406     D3DSCANLINEORDERING_INTERLACED = 2
407 } D3DSCANLINEORDERING;
408 
409 typedef enum _D3DAUTHENTICATEDCHANNELTYPE {
410     D3DAUTHENTICATEDCHANNEL_D3D9 = 1,
411     D3DAUTHENTICATEDCHANNEL_DRIVER_SOFTWARE = 2,
412     D3DAUTHENTICATEDCHANNEL_DRIVER_HARDWARE = 3
413 } D3DAUTHENTICATEDCHANNELTYPE;
414 
415 typedef enum _D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE {
416     PROCESSIDTYPE_UNKNOWN = 0,
417     PROCESSIDTYPE_DWM = 1,
418     PROCESSIDTYPE_HANDLE = 2
419 } D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE;
420 
421 typedef enum _D3DBACKBUFFER_TYPE {
422     D3DBACKBUFFER_TYPE_MONO = 0,
423     D3DBACKBUFFER_TYPE_LEFT = 1,
424     D3DBACKBUFFER_TYPE_RIGHT = 2
425 } D3DBACKBUFFER_TYPE;
426 
427 typedef enum _D3DBASISTYPE {
428    D3DBASIS_BEZIER = 0,
429    D3DBASIS_BSPLINE = 1,
430    D3DBASIS_CATMULL_ROM = 2
431 } D3DBASISTYPE;
432 
433 typedef enum _D3DBLEND {
434     D3DBLEND_ZERO = 1,
435     D3DBLEND_ONE = 2,
436     D3DBLEND_SRCCOLOR = 3,
437     D3DBLEND_INVSRCCOLOR = 4,
438     D3DBLEND_SRCALPHA = 5,
439     D3DBLEND_INVSRCALPHA = 6,
440     D3DBLEND_DESTALPHA = 7,
441     D3DBLEND_INVDESTALPHA = 8,
442     D3DBLEND_DESTCOLOR = 9,
443     D3DBLEND_INVDESTCOLOR = 10,
444     D3DBLEND_SRCALPHASAT = 11,
445     D3DBLEND_BOTHSRCALPHA = 12,
446     D3DBLEND_BOTHINVSRCALPHA = 13,
447     D3DBLEND_BLENDFACTOR = 14,
448     D3DBLEND_INVBLENDFACTOR = 15,
449     D3DBLEND_SRCCOLOR2 = 16,
450     D3DBLEND_INVSRCCOLOR2 = 17
451 } D3DBLEND;
452 
453 typedef enum _D3DBLENDOP {
454     D3DBLENDOP_ADD = 1,
455     D3DBLENDOP_SUBTRACT = 2,
456     D3DBLENDOP_REVSUBTRACT = 3,
457     D3DBLENDOP_MIN = 4,
458     D3DBLENDOP_MAX = 5
459 } D3DBLENDOP;
460 
461 typedef enum _D3DBUSTYPE {
462     D3DBUSTYPE_OTHER = 0x00000000,
463     D3DBUSTYPE_PCI = 0x00000001,
464     D3DBUSTYPE_PCIX = 0x00000002,
465     D3DBUSTYPE_PCIEXPRESS = 0x00000003,
466     D3DBUSTYPE_AGP = 0x00000004,
467     D3DBUSIMPL_MODIFIER_INSIDE_OF_CHIPSET = 0x00010000,
468     D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x00020000,
469     D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000,
470     D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x00040000,
471     D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000,
472     D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000
473 } D3DBUSTYPE;
474 
475 typedef enum _D3DCMPFUNC {
476     D3DCMP_NEVER_ZERO = 0, //Needed to avoid warnings
477     D3DCMP_NEVER = 1,
478     D3DCMP_LESS = 2,
479     D3DCMP_EQUAL = 3,
480     D3DCMP_LESSEQUAL = 4,
481     D3DCMP_GREATER = 5,
482     D3DCMP_NOTEQUAL = 6,
483     D3DCMP_GREATEREQUAL = 7,
484     D3DCMP_ALWAYS = 8
485 } D3DCMPFUNC;
486 
487 typedef enum _D3DCOMPOSERECTSOP{
488     D3DCOMPOSERECTS_COPY = 1,
489     D3DCOMPOSERECTS_OR = 2,
490     D3DCOMPOSERECTS_AND = 3,
491     D3DCOMPOSERECTS_NEG = 4
492 } D3DCOMPOSERECTSOP;
493 
494 typedef enum _D3DCUBEMAP_FACES {
495     D3DCUBEMAP_FACE_POSITIVE_X = 0,
496     D3DCUBEMAP_FACE_NEGATIVE_X = 1,
497     D3DCUBEMAP_FACE_POSITIVE_Y = 2,
498     D3DCUBEMAP_FACE_NEGATIVE_Y = 3,
499     D3DCUBEMAP_FACE_POSITIVE_Z = 4,
500     D3DCUBEMAP_FACE_NEGATIVE_Z = 5
501 } D3DCUBEMAP_FACES;
502 
503 typedef enum _D3DCULL {
504     D3DCULL_NONE = 1,
505     D3DCULL_CW = 2,
506     D3DCULL_CCW = 3
507 } D3DCULL;
508 
509 typedef enum _D3DDEBUGMONITORTOKENS {
510     D3DDMT_ENABLE = 0,
511     D3DDMT_DISABLE = 1
512 } D3DDEBUGMONITORTOKENS;
513 
514 typedef enum _D3DDECLMETHOD {
515     D3DDECLMETHOD_DEFAULT = 0,
516     D3DDECLMETHOD_PARTIALU = 1,
517     D3DDECLMETHOD_PARTIALV = 2,
518     D3DDECLMETHOD_CROSSUV = 3,
519     D3DDECLMETHOD_UV = 4,
520     D3DDECLMETHOD_LOOKUP = 5,
521     D3DDECLMETHOD_LOOKUPPRESAMPLED = 6
522 } D3DDECLMETHOD;
523 
524 typedef enum _D3DDECLTYPE {
525     D3DDECLTYPE_FLOAT1 = 0,
526     D3DDECLTYPE_FLOAT2 = 1,
527     D3DDECLTYPE_FLOAT3 = 2,
528     D3DDECLTYPE_FLOAT4 = 3,
529     D3DDECLTYPE_D3DCOLOR = 4,
530     D3DDECLTYPE_UBYTE4 = 5,
531     D3DDECLTYPE_SHORT2 = 6,
532     D3DDECLTYPE_SHORT4 = 7,
533     D3DDECLTYPE_UBYTE4N = 8,
534     D3DDECLTYPE_SHORT2N = 9,
535     D3DDECLTYPE_SHORT4N = 10,
536     D3DDECLTYPE_USHORT2N = 11,
537     D3DDECLTYPE_USHORT4N = 12,
538     D3DDECLTYPE_UDEC3 = 13,
539     D3DDECLTYPE_DEC3N = 14,
540     D3DDECLTYPE_FLOAT16_2 = 15,
541     D3DDECLTYPE_FLOAT16_4 = 16,
542     D3DDECLTYPE_UNUSED = 17
543 } D3DDECLTYPE;
544 
545 typedef enum _D3DDECLUSAGE {
546     D3DDECLUSAGE_POSITION = 0,
547     D3DDECLUSAGE_BLENDWEIGHT = 1,
548     D3DDECLUSAGE_BLENDINDICES = 2,
549     D3DDECLUSAGE_NORMAL = 3,
550     D3DDECLUSAGE_PSIZE = 4,
551     D3DDECLUSAGE_TEXCOORD = 5,
552     D3DDECLUSAGE_TANGENT = 6,
553     D3DDECLUSAGE_BINORMAL = 7,
554     D3DDECLUSAGE_TESSFACTOR = 8,
555     D3DDECLUSAGE_POSITIONT = 9,
556     D3DDECLUSAGE_COLOR = 10,
557     D3DDECLUSAGE_FOG = 11,
558     D3DDECLUSAGE_DEPTH = 12,
559     D3DDECLUSAGE_SAMPLE = 13
560 } D3DDECLUSAGE;
561 
562 typedef enum _D3DDEGREETYPE {
563    D3DDEGREE_LINEAR = 1,
564    D3DDEGREE_QUADRATIC = 2,
565    D3DDEGREE_CUBIC = 3,
566    D3DDEGREE_QUINTIC = 5
567 } D3DDEGREETYPE;
568 
569 typedef enum _D3DDEVTYPE {
570     D3DDEVTYPE_HAL = 1,
571     D3DDEVTYPE_REF = 2,
572     D3DDEVTYPE_SW = 3,
573     D3DDEVTYPE_NULLREF = 4
574 } D3DDEVTYPE;
575 
576 typedef enum _D3DFILLMODE {
577     D3DFILL_SOLID_ZERO = 0,
578     D3DFILL_POINT = 1,
579     D3DFILL_WIREFRAME = 2,
580     D3DFILL_SOLID = 3
581 } D3DFILLMODE;
582 
583 typedef enum _D3DFOGMODE {
584     D3DFOG_NONE = 0,
585     D3DFOG_EXP = 1,
586     D3DFOG_EXP2 = 2,
587     D3DFOG_LINEAR = 3
588 } D3DFOGMODE;
589 
590 typedef enum _D3DFORMAT {
591     D3DFMT_UNKNOWN = 0,
592     D3DFMT_R8G8B8 = 20,
593     D3DFMT_A8R8G8B8 = 21,
594     D3DFMT_X8R8G8B8 = 22,
595     D3DFMT_R5G6B5 = 23,
596     D3DFMT_X1R5G5B5 = 24,
597     D3DFMT_A1R5G5B5 = 25,
598     D3DFMT_A4R4G4B4 = 26,
599     D3DFMT_R3G3B2 = 27,
600     D3DFMT_A8 = 28,
601     D3DFMT_A8R3G3B2 = 29,
602     D3DFMT_X4R4G4B4 = 30,
603     D3DFMT_A2B10G10R10 = 31,
604     D3DFMT_A8B8G8R8 = 32,
605     D3DFMT_X8B8G8R8 = 33,
606     D3DFMT_G16R16 = 34,
607     D3DFMT_A2R10G10B10 = 35,
608     D3DFMT_A16B16G16R16 = 36,
609     D3DFMT_A8P8 = 40,
610     D3DFMT_P8 = 41,
611     D3DFMT_L8 = 50,
612     D3DFMT_A8L8 = 51,
613     D3DFMT_A4L4 = 52,
614     D3DFMT_V8U8 = 60,
615     D3DFMT_L6V5U5 = 61,
616     D3DFMT_X8L8V8U8 = 62,
617     D3DFMT_Q8W8V8U8 = 63,
618     D3DFMT_V16U16 = 64,
619     D3DFMT_A2W10V10U10 = 67,
620     D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
621     D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'),
622     D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
623     D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'),
624     D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
625     D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
626     D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
627     D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
628     D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
629     D3DFMT_D16_LOCKABLE = 70,
630     D3DFMT_D32 = 71,
631     D3DFMT_D15S1 = 73,
632     D3DFMT_D24S8 = 75,
633     D3DFMT_D24X8 = 77,
634     D3DFMT_D24X4S4 = 79,
635     D3DFMT_D16 = 80,
636     D3DFMT_D32F_LOCKABLE = 82,
637     D3DFMT_D24FS8 = 83,
638     D3DFMT_D32_LOCKABLE = 84,
639     D3DFMT_S8_LOCKABLE = 85,
640     D3DFMT_L16 = 81,
641     D3DFMT_VERTEXDATA = 100,
642     D3DFMT_INDEX16 = 101,
643     D3DFMT_INDEX32 = 102,
644     D3DFMT_Q16W16V16U16 = 110,
645     D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M','E','T','1'),
646     D3DFMT_R16F = 111,
647     D3DFMT_G16R16F = 112,
648     D3DFMT_A16B16G16R16F = 113,
649     D3DFMT_R32F = 114,
650     D3DFMT_G32R32F = 115,
651     D3DFMT_A32B32G32R32F = 116,
652     D3DFMT_CxV8U8 = 117,
653     D3DFMT_A1 = 118,
654     D3DFMT_A2B10G10R10_XR_BIAS = 119,
655     D3DFMT_BINARYBUFFER = 199,
656     D3DFMT_ATI1 = MAKEFOURCC('A', 'T', 'I', '1'),
657     D3DFMT_ATI2 = MAKEFOURCC('A', 'T', 'I', '2'),
658     D3DFMT_ATOC = MAKEFOURCC('A', 'T', 'O', 'C'),
659     D3DFMT_DF16 = MAKEFOURCC('D', 'F', '1', '6'),
660     D3DFMT_DF24 = MAKEFOURCC('D', 'F', '2', '4'),
661     D3DFMT_INTZ = MAKEFOURCC('I', 'N', 'T', 'Z'),
662     D3DFMT_NULL = MAKEFOURCC('N', 'U', 'L', 'L'),
663     D3DFMT_NVDB = MAKEFOURCC('N', 'V', 'D', 'B'),
664     D3DFMT_NV11 = MAKEFOURCC('N', 'V', '1', '1'),
665     D3DFMT_NV12 = MAKEFOURCC('N', 'V', '1', '2'),
666     D3DFMT_RESZ = MAKEFOURCC('R', 'E', 'S', 'Z'),
667     D3DFMT_Y210 = MAKEFOURCC('Y', '2', '1', '0'),
668     D3DFMT_Y216 = MAKEFOURCC('Y', '2', '1', '6'),
669     D3DFMT_Y410 = MAKEFOURCC('Y', '4', '1', '0')
670 } D3DFORMAT;
671 
672 typedef enum _D3DLIGHTTYPE {
673     D3DLIGHT_POINT = 1,
674     D3DLIGHT_SPOT = 2,
675     D3DLIGHT_DIRECTIONAL = 3
676 } D3DLIGHTTYPE;
677 
678 typedef enum _D3DMATERIALCOLORSOURCE {
679     D3DMCS_MATERIAL = 0,
680     D3DMCS_COLOR1 = 1,
681     D3DMCS_COLOR2 = 2
682 } D3DMATERIALCOLORSOURCE;
683 
684 typedef enum _D3DMULTISAMPLE_TYPE {
685     D3DMULTISAMPLE_NONE = 0,
686     D3DMULTISAMPLE_NONMASKABLE = 1,
687     D3DMULTISAMPLE_2_SAMPLES = 2,
688     D3DMULTISAMPLE_3_SAMPLES = 3,
689     D3DMULTISAMPLE_4_SAMPLES = 4,
690     D3DMULTISAMPLE_5_SAMPLES = 5,
691     D3DMULTISAMPLE_6_SAMPLES = 6,
692     D3DMULTISAMPLE_7_SAMPLES = 7,
693     D3DMULTISAMPLE_8_SAMPLES = 8,
694     D3DMULTISAMPLE_9_SAMPLES = 9,
695     D3DMULTISAMPLE_10_SAMPLES = 10,
696     D3DMULTISAMPLE_11_SAMPLES = 11,
697     D3DMULTISAMPLE_12_SAMPLES = 12,
698     D3DMULTISAMPLE_13_SAMPLES = 13,
699     D3DMULTISAMPLE_14_SAMPLES = 14,
700     D3DMULTISAMPLE_15_SAMPLES = 15,
701     D3DMULTISAMPLE_16_SAMPLES = 16
702 } D3DMULTISAMPLE_TYPE;
703 
704 typedef enum _D3DPATCHEDGESTYLE {
705    D3DPATCHEDGE_DISCRETE = 0,
706    D3DPATCHEDGE_CONTINUOUS = 1
707 } D3DPATCHEDGESTYLE;
708 
709 typedef enum _D3DPOOL {
710     D3DPOOL_DEFAULT = 0,
711     D3DPOOL_MANAGED = 1,
712     D3DPOOL_SYSTEMMEM = 2,
713     D3DPOOL_SCRATCH = 3
714 } D3DPOOL;
715 
716 typedef enum _D3DPRIMITIVETYPE {
717     D3DPT_POINTLIST = 1,
718     D3DPT_LINELIST = 2,
719     D3DPT_LINESTRIP = 3,
720     D3DPT_TRIANGLELIST = 4,
721     D3DPT_TRIANGLESTRIP = 5,
722     D3DPT_TRIANGLEFAN = 6
723 } D3DPRIMITIVETYPE;
724 
725 typedef enum _D3DQUERYTYPE {
726     D3DQUERYTYPE_VCACHE = 4,
727     D3DQUERYTYPE_RESOURCEMANAGER = 5,
728     D3DQUERYTYPE_VERTEXSTATS = 6,
729     D3DQUERYTYPE_EVENT = 8,
730     D3DQUERYTYPE_OCCLUSION = 9,
731     D3DQUERYTYPE_TIMESTAMP = 10,
732     D3DQUERYTYPE_TIMESTAMPDISJOINT = 11,
733     D3DQUERYTYPE_TIMESTAMPFREQ = 12,
734     D3DQUERYTYPE_PIPELINETIMINGS = 13,
735     D3DQUERYTYPE_INTERFACETIMINGS = 14,
736     D3DQUERYTYPE_VERTEXTIMINGS = 15,
737     D3DQUERYTYPE_PIXELTIMINGS = 16,
738     D3DQUERYTYPE_BANDWIDTHTIMINGS = 17,
739     D3DQUERYTYPE_CACHEUTILIZATION = 18,
740     D3DQUERYTYPE_MEMORYPRESSURE = 19
741 } D3DQUERYTYPE;
742 
743 #define D3DISSUE_BEGIN   (1 << 1)
744 #define D3DISSUE_END     (1 << 0)
745 #define D3DGETDATA_FLUSH (1 << 0)
746 
747 
748 typedef enum _D3DRENDERSTATETYPE {
749     D3DRS_ZENABLE = 7,
750     D3DRS_FILLMODE = 8,
751     D3DRS_SHADEMODE = 9,
752     D3DRS_ZWRITEENABLE = 14,
753     D3DRS_ALPHATESTENABLE = 15,
754     D3DRS_LASTPIXEL = 16,
755     D3DRS_SRCBLEND = 19,
756     D3DRS_DESTBLEND = 20,
757     D3DRS_CULLMODE = 22,
758     D3DRS_ZFUNC = 23,
759     D3DRS_ALPHAREF = 24,
760     D3DRS_ALPHAFUNC = 25,
761     D3DRS_DITHERENABLE = 26,
762     D3DRS_ALPHABLENDENABLE = 27,
763     D3DRS_FOGENABLE = 28,
764     D3DRS_SPECULARENABLE = 29,
765     D3DRS_FOGCOLOR = 34,
766     D3DRS_FOGTABLEMODE = 35,
767     D3DRS_FOGSTART = 36,
768     D3DRS_FOGEND = 37,
769     D3DRS_FOGDENSITY = 38,
770     D3DRS_RANGEFOGENABLE = 48,
771     D3DRS_STENCILENABLE = 52,
772     D3DRS_STENCILFAIL = 53,
773     D3DRS_STENCILZFAIL = 54,
774     D3DRS_STENCILPASS = 55,
775     D3DRS_STENCILFUNC = 56,
776     D3DRS_STENCILREF = 57,
777     D3DRS_STENCILMASK = 58,
778     D3DRS_STENCILWRITEMASK = 59,
779     D3DRS_TEXTUREFACTOR = 60,
780     D3DRS_WRAP0 = 128,
781     D3DRS_WRAP1 = 129,
782     D3DRS_WRAP2 = 130,
783     D3DRS_WRAP3 = 131,
784     D3DRS_WRAP4 = 132,
785     D3DRS_WRAP5 = 133,
786     D3DRS_WRAP6 = 134,
787     D3DRS_WRAP7 = 135,
788     D3DRS_CLIPPING = 136,
789     D3DRS_LIGHTING = 137,
790     D3DRS_AMBIENT = 139,
791     D3DRS_FOGVERTEXMODE = 140,
792     D3DRS_COLORVERTEX = 141,
793     D3DRS_LOCALVIEWER = 142,
794     D3DRS_NORMALIZENORMALS = 143,
795     D3DRS_DIFFUSEMATERIALSOURCE = 145,
796     D3DRS_SPECULARMATERIALSOURCE = 146,
797     D3DRS_AMBIENTMATERIALSOURCE = 147,
798     D3DRS_EMISSIVEMATERIALSOURCE = 148,
799     D3DRS_VERTEXBLEND = 151,
800     D3DRS_CLIPPLANEENABLE = 152,
801     D3DRS_POINTSIZE = 154,
802     D3DRS_POINTSIZE_MIN = 155,
803     D3DRS_POINTSPRITEENABLE = 156,
804     D3DRS_POINTSCALEENABLE = 157,
805     D3DRS_POINTSCALE_A = 158,
806     D3DRS_POINTSCALE_B = 159,
807     D3DRS_POINTSCALE_C = 160,
808     D3DRS_MULTISAMPLEANTIALIAS = 161,
809     D3DRS_MULTISAMPLEMASK = 162,
810     D3DRS_PATCHEDGESTYLE = 163,
811     D3DRS_DEBUGMONITORTOKEN = 165,
812     D3DRS_POINTSIZE_MAX = 166,
813     D3DRS_INDEXEDVERTEXBLENDENABLE = 167,
814     D3DRS_COLORWRITEENABLE = 168,
815     D3DRS_TWEENFACTOR = 170,
816     D3DRS_BLENDOP = 171,
817     D3DRS_POSITIONDEGREE = 172,
818     D3DRS_NORMALDEGREE = 173,
819     D3DRS_SCISSORTESTENABLE = 174,
820     D3DRS_SLOPESCALEDEPTHBIAS = 175,
821     D3DRS_ANTIALIASEDLINEENABLE = 176,
822     D3DRS_MINTESSELLATIONLEVEL = 178,
823     D3DRS_MAXTESSELLATIONLEVEL = 179,
824     D3DRS_ADAPTIVETESS_X = 180,
825     D3DRS_ADAPTIVETESS_Y = 181,
826     D3DRS_ADAPTIVETESS_Z = 182,
827     D3DRS_ADAPTIVETESS_W = 183,
828     D3DRS_ENABLEADAPTIVETESSELLATION = 184,
829     D3DRS_TWOSIDEDSTENCILMODE = 185,
830     D3DRS_CCW_STENCILFAIL = 186,
831     D3DRS_CCW_STENCILZFAIL = 187,
832     D3DRS_CCW_STENCILPASS = 188,
833     D3DRS_CCW_STENCILFUNC = 189,
834     D3DRS_COLORWRITEENABLE1 = 190,
835     D3DRS_COLORWRITEENABLE2 = 191,
836     D3DRS_COLORWRITEENABLE3 = 192,
837     D3DRS_BLENDFACTOR = 193,
838     D3DRS_SRGBWRITEENABLE = 194,
839     D3DRS_DEPTHBIAS = 195,
840     D3DRS_WRAP8 = 198,
841     D3DRS_WRAP9 = 199,
842     D3DRS_WRAP10 = 200,
843     D3DRS_WRAP11 = 201,
844     D3DRS_WRAP12 = 202,
845     D3DRS_WRAP13 = 203,
846     D3DRS_WRAP14 = 204,
847     D3DRS_WRAP15 = 205,
848     D3DRS_SEPARATEALPHABLENDENABLE = 206,
849     D3DRS_SRCBLENDALPHA = 207,
850     D3DRS_DESTBLENDALPHA = 208,
851     D3DRS_BLENDOPALPHA = 209
852 } D3DRENDERSTATETYPE;
853 
854 typedef enum _D3DRESOURCETYPE {
855     D3DRTYPE_SURFACE = 1,
856     D3DRTYPE_VOLUME = 2,
857     D3DRTYPE_TEXTURE = 3,
858     D3DRTYPE_VOLUMETEXTURE = 4,
859     D3DRTYPE_CUBETEXTURE = 5,
860     D3DRTYPE_VERTEXBUFFER = 6,
861     D3DRTYPE_INDEXBUFFER = 7
862 } D3DRESOURCETYPE;
863 #define D3DRTYPECOUNT (D3DRTYPE_INDEXBUFFER+1)
864 
865 typedef enum _D3DSAMPLERSTATETYPE {
866     D3DSAMP_ADDRESSU = 1,
867     D3DSAMP_ADDRESSV = 2,
868     D3DSAMP_ADDRESSW = 3,
869     D3DSAMP_BORDERCOLOR = 4,
870     D3DSAMP_MAGFILTER = 5,
871     D3DSAMP_MINFILTER = 6,
872     D3DSAMP_MIPFILTER = 7,
873     D3DSAMP_MIPMAPLODBIAS = 8,
874     D3DSAMP_MAXMIPLEVEL = 9,
875     D3DSAMP_MAXANISOTROPY = 10,
876     D3DSAMP_SRGBTEXTURE = 11,
877     D3DSAMP_ELEMENTINDEX = 12,
878     D3DSAMP_DMAPOFFSET = 13
879 } D3DSAMPLERSTATETYPE;
880 
881 typedef enum _D3DSAMPLER_TEXTURE_TYPE {
882     D3DSTT_UNKNOWN = 0<<27,
883     D3DSTT_1D = 1<<27,
884     D3DSTT_2D = 2<<27,
885     D3DSTT_CUBE = 3<<27,
886     D3DSTT_VOLUME = 4<<27
887 } D3DSAMPLER_TEXTURE_TYPE;
888 
889 typedef enum _D3DSHADEMODE {
890     D3DSHADE_FLAT = 1,
891     D3DSHADE_GOURAUD = 2,
892     D3DSHADE_PHONG = 3
893 } D3DSHADEMODE;
894 
895 typedef enum _D3DSHADER_ADDRESSMODE_TYPE {
896     D3DSHADER_ADDRMODE_ABSOLUTE = 0<<13,
897     D3DSHADER_ADDRMODE_RELATIVE = 1<<13
898 } D3DSHADER_ADDRESSMODE_TYPE;
899 
900 typedef enum _D3DSHADER_COMPARISON {
901     D3DSPC_RESERVED0 = 0,
902     D3DSPC_GT = 1,
903     D3DSPC_EQ = 2,
904     D3DSPC_GE = 3,
905     D3DSPC_LT = 4,
906     D3DSPC_NE = 5,
907     D3DSPC_LE = 6,
908     D3DSPC_RESERVED1 = 7
909 } D3DSHADER_COMPARISON;
910 
911 #define D3DDP_MAXTEXCOORD   8
912 
913 #define D3DSI_OPCODE_MASK       0x0000FFFF
914 #define D3DSI_INSTLENGTH_MASK   0x0F000000
915 #define D3DSI_INSTLENGTH_SHIFT  24
916 
917 typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE {
918     D3DSIO_NOP = 0,
919     D3DSIO_MOV = 1,
920     D3DSIO_ADD = 2,
921     D3DSIO_SUB = 3,
922     D3DSIO_MAD = 4,
923     D3DSIO_MUL = 5,
924     D3DSIO_RCP = 6,
925     D3DSIO_RSQ = 7,
926     D3DSIO_DP3 = 8,
927     D3DSIO_DP4 = 9,
928     D3DSIO_MIN = 10,
929     D3DSIO_MAX = 11,
930     D3DSIO_SLT = 12,
931     D3DSIO_SGE = 13,
932     D3DSIO_EXP = 14,
933     D3DSIO_LOG = 15,
934     D3DSIO_LIT = 16,
935     D3DSIO_DST = 17,
936     D3DSIO_LRP = 18,
937     D3DSIO_FRC = 19,
938     D3DSIO_M4x4 = 20,
939     D3DSIO_M4x3 = 21,
940     D3DSIO_M3x4 = 22,
941     D3DSIO_M3x3 = 23,
942     D3DSIO_M3x2 = 24,
943     D3DSIO_CALL = 25,
944     D3DSIO_CALLNZ = 26,
945     D3DSIO_LOOP = 27,
946     D3DSIO_RET = 28,
947     D3DSIO_ENDLOOP = 29,
948     D3DSIO_LABEL = 30,
949     D3DSIO_DCL = 31,
950     D3DSIO_POW = 32,
951     D3DSIO_CRS = 33,
952     D3DSIO_SGN = 34,
953     D3DSIO_ABS = 35,
954     D3DSIO_NRM = 36,
955     D3DSIO_SINCOS = 37,
956     D3DSIO_REP = 38,
957     D3DSIO_ENDREP = 39,
958     D3DSIO_IF = 40,
959     D3DSIO_IFC = 41,
960     D3DSIO_ELSE = 42,
961     D3DSIO_ENDIF = 43,
962     D3DSIO_BREAK = 44,
963     D3DSIO_BREAKC = 45,
964     D3DSIO_MOVA = 46,
965     D3DSIO_DEFB = 47,
966     D3DSIO_DEFI = 48,
967     D3DSIO_TEXCOORD = 64,
968     D3DSIO_TEXKILL = 65,
969     D3DSIO_TEX = 66,
970     D3DSIO_TEXBEM = 67,
971     D3DSIO_TEXBEML = 68,
972     D3DSIO_TEXREG2AR = 69,
973     D3DSIO_TEXREG2GB = 70,
974     D3DSIO_TEXM3x2PAD = 71,
975     D3DSIO_TEXM3x2TEX = 72,
976     D3DSIO_TEXM3x3PAD = 73,
977     D3DSIO_TEXM3x3TEX = 74,
978     D3DSIO_RESERVED0 = 75,
979     D3DSIO_TEXM3x3SPEC = 76,
980     D3DSIO_TEXM3x3VSPEC = 77,
981     D3DSIO_EXPP = 78,
982     D3DSIO_LOGP = 79,
983     D3DSIO_CND = 80,
984     D3DSIO_DEF = 81,
985     D3DSIO_TEXREG2RGB = 82,
986     D3DSIO_TEXDP3TEX = 83,
987     D3DSIO_TEXM3x2DEPTH = 84,
988     D3DSIO_TEXDP3 = 85,
989     D3DSIO_TEXM3x3 = 86,
990     D3DSIO_TEXDEPTH = 87,
991     D3DSIO_CMP = 88,
992     D3DSIO_BEM = 89,
993     D3DSIO_DP2ADD = 90,
994     D3DSIO_DSX = 91,
995     D3DSIO_DSY = 92,
996     D3DSIO_TEXLDD = 93,
997     D3DSIO_SETP = 94,
998     D3DSIO_TEXLDL = 95,
999     D3DSIO_BREAKP = 96,
1000     D3DSIO_PHASE = 0xFFFD,
1001     D3DSIO_COMMENT = 0xFFFE,
1002     D3DSIO_END = 0xFFFF
1003 } D3DSHADER_INSTRUCTION_OPCODE_TYPE;
1004 
1005 #define D3DSI_COISSUE 0x40000000
1006 
1007 #define D3DSP_DCL_USAGE_SHIFT 0
1008 #define D3DSP_DCL_USAGE_MASK  0x0000000f
1009 
1010 #define D3DSP_DCL_USAGEINDEX_SHIFT 16
1011 #define D3DSP_DCL_USAGEINDEX_MASK  0x000f0000
1012 
1013 #define D3DSP_TEXTURETYPE_SHIFT 27
1014 #define D3DSP_TEXTURETYPE_MASK  0x78000000
1015 
1016 #define D3DSP_REGNUM_MASK       0x000007FF
1017 
1018 #define D3DSP_WRITEMASK_0       0x00010000
1019 #define D3DSP_WRITEMASK_1       0x00020000
1020 #define D3DSP_WRITEMASK_2       0x00040000
1021 #define D3DSP_WRITEMASK_3       0x00080000
1022 #define D3DSP_WRITEMASK_ALL     0x000F0000
1023 
1024 #define D3DSP_DSTMOD_SHIFT      20
1025 #define D3DSP_DSTMOD_MASK       (0xF << D3DSP_DSTMOD_SHIFT)
1026 
1027 typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE {
1028     D3DSPDM_NONE             = 0 << D3DSP_DSTMOD_SHIFT,
1029     D3DSPDM_SATURATE         = 1 << D3DSP_DSTMOD_SHIFT,
1030     D3DSPDM_PARTIALPRECISION = 2 << D3DSP_DSTMOD_SHIFT,
1031     D3DSPDM_MSAMPCENTROID    = 4 << D3DSP_DSTMOD_SHIFT,
1032     D3DSPDM_FORCE_DWORD  = 0x7FFFFFFF
1033 } D3DSHADER_PARAM_DSTMOD_TYPE;
1034 
1035 #define D3DSP_DSTSHIFT_SHIFT     24
1036 #define D3DSP_DSTSHIFT_MASK      (0xF << D3DSP_DSTSHIFT_SHIFT)
1037 
1038 #define D3DSP_REGTYPE_SHIFT      28
1039 #define D3DSP_REGTYPE_SHIFT2     8
1040 #define D3DSP_REGTYPE_MASK       (0x7 << D3DSP_REGTYPE_SHIFT)
1041 #define D3DSP_REGTYPE_MASK2      0x00001800
1042 
1043 typedef enum _D3DSHADER_MISCTYPE_OFFSETS {
1044     D3DSMO_POSITION = 0,
1045     D3DSMO_FACE = 1
1046 } D3DSHADER_MISCTYPE_OFFSETS;
1047 
1048 typedef enum _D3DSHADER_PARAM_REGISTER_TYPE {
1049     D3DSPR_TEMP = 0,
1050     D3DSPR_INPUT = 1,
1051     D3DSPR_CONST = 2,
1052     D3DSPR_ADDR = 3,
1053     D3DSPR_TEXTURE = 3,
1054     D3DSPR_RASTOUT = 4,
1055     D3DSPR_ATTROUT = 5,
1056     D3DSPR_TEXCRDOUT = 6,
1057     D3DSPR_OUTPUT = 6,
1058     D3DSPR_CONSTINT = 7,
1059     D3DSPR_COLOROUT = 8,
1060     D3DSPR_DEPTHOUT = 9,
1061     D3DSPR_SAMPLER = 10,
1062     D3DSPR_CONST2 = 11,
1063     D3DSPR_CONST3 = 12,
1064     D3DSPR_CONST4 = 13,
1065     D3DSPR_CONSTBOOL = 14,
1066     D3DSPR_LOOP = 15,
1067     D3DSPR_TEMPFLOAT16 = 16,
1068     D3DSPR_MISCTYPE = 17,
1069     D3DSPR_LABEL = 18,
1070     D3DSPR_PREDICATE = 19
1071 } D3DSHADER_PARAM_REGISTER_TYPE;
1072 
1073 #define D3DSP_SWIZZLE_SHIFT      16
1074 #define D3DSP_SWIZZLE_MASK       (0xFF << D3DSP_SWIZZLE_SHIFT)
1075 
1076 #define D3DSP_NOSWIZZLE \
1077     ((0 << (D3DSP_SWIZZLE_SHIFT + 0)) | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | (3 << (D3DSP_SWIZZLE_SHIFT + 6)))
1078 
1079 #define D3DSP_SRCMOD_SHIFT      24
1080 #define D3DSP_SRCMOD_MASK       (0xF << D3DSP_SRCMOD_SHIFT)
1081 
1082 typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE {
1083     D3DSPSM_NONE = 0<<24,
1084     D3DSPSM_NEG = 1<<24,
1085     D3DSPSM_BIAS = 2<<24,
1086     D3DSPSM_BIASNEG = 3<<24,
1087     D3DSPSM_SIGN = 4<<24,
1088     D3DSPSM_SIGNNEG = 5<<24,
1089     D3DSPSM_COMP = 6<<24,
1090     D3DSPSM_X2 = 7<<24,
1091     D3DSPSM_X2NEG = 8<<24,
1092     D3DSPSM_DZ = 9<<24,
1093     D3DSPSM_DW = 10<<24,
1094     D3DSPSM_ABS = 11<<24,
1095     D3DSPSM_ABSNEG = 12<<24,
1096     D3DSPSM_NOT = 13<<24
1097 } D3DSHADER_PARAM_SRCMOD_TYPE;
1098 
1099 #define D3DPS_VERSION(major, minor) (0xFFFF0000 | ((major) << 8) | (minor))
1100 #define D3DVS_VERSION(major, minor) (0xFFFE0000 | ((major) << 8) | (minor))
1101 #define D3DSHADER_VERSION_MAJOR(version) (((version) >> 8) & 0xFF)
1102 #define D3DSHADER_VERSION_MINOR(version) (((version) >> 0) & 0xFF)
1103 
1104 #define D3DSI_COMMENTSIZE_SHIFT 16
1105 #define D3DSI_COMMENTSIZE_MASK (0x7FFF << D3DSI_COMMENTSIZE_SHIFT)
1106 
1107 typedef enum _D3DSTATEBLOCKTYPE {
1108     D3DSBT_ALL = 1,
1109     D3DSBT_PIXELSTATE = 2,
1110     D3DSBT_VERTEXSTATE = 3
1111 } D3DSTATEBLOCKTYPE;
1112 
1113 typedef enum _D3DSTENCILOP {
1114     D3DSTENCILOP_KEEP = 1,
1115     D3DSTENCILOP_ZERO = 2,
1116     D3DSTENCILOP_REPLACE = 3,
1117     D3DSTENCILOP_INCRSAT = 4,
1118     D3DSTENCILOP_DECRSAT = 5,
1119     D3DSTENCILOP_INVERT = 6,
1120     D3DSTENCILOP_INCR = 7,
1121     D3DSTENCILOP_DECR = 8
1122 } D3DSTENCILOP;
1123 
1124 typedef enum _D3DSWAPEFFECT {
1125     D3DSWAPEFFECT_DISCARD = 1,
1126     D3DSWAPEFFECT_FLIP = 2,
1127     D3DSWAPEFFECT_COPY = 3,
1128     D3DSWAPEFFECT_OVERLAY = 4,
1129     D3DSWAPEFFECT_FLIPEX = 5
1130 } D3DSWAPEFFECT;
1131 
1132 typedef enum _D3DTEXTUREADDRESS {
1133     D3DTADDRESS_WRAP = 1,
1134     D3DTADDRESS_MIRROR = 2,
1135     D3DTADDRESS_CLAMP = 3,
1136     D3DTADDRESS_BORDER = 4,
1137     D3DTADDRESS_MIRRORONCE = 5
1138 } D3DTEXTUREADDRESS;
1139 
1140 typedef enum _D3DTEXTUREFILTERTYPE {
1141     D3DTEXF_NONE = 0,
1142     D3DTEXF_POINT = 1,
1143     D3DTEXF_LINEAR = 2,
1144     D3DTEXF_ANISOTROPIC = 3,
1145     D3DTEXF_PYRAMIDALQUAD = 6,
1146     D3DTEXF_GAUSSIANQUAD = 7,
1147     D3DTEXF_CONVOLUTIONMONO = 8
1148 } D3DTEXTUREFILTERTYPE;
1149 
1150 typedef enum _D3DTEXTUREOP {
1151     D3DTOP_DISABLE = 1,
1152     D3DTOP_SELECTARG1 = 2,
1153     D3DTOP_SELECTARG2 = 3,
1154     D3DTOP_MODULATE = 4,
1155     D3DTOP_MODULATE2X = 5,
1156     D3DTOP_MODULATE4X = 6,
1157     D3DTOP_ADD = 7,
1158     D3DTOP_ADDSIGNED = 8,
1159     D3DTOP_ADDSIGNED2X = 9,
1160     D3DTOP_SUBTRACT = 10,
1161     D3DTOP_ADDSMOOTH = 11,
1162     D3DTOP_BLENDDIFFUSEALPHA = 12,
1163     D3DTOP_BLENDTEXTUREALPHA = 13,
1164     D3DTOP_BLENDFACTORALPHA = 14,
1165     D3DTOP_BLENDTEXTUREALPHAPM = 15,
1166     D3DTOP_BLENDCURRENTALPHA = 16,
1167     D3DTOP_PREMODULATE = 17,
1168     D3DTOP_MODULATEALPHA_ADDCOLOR = 18,
1169     D3DTOP_MODULATECOLOR_ADDALPHA = 19,
1170     D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,
1171     D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,
1172     D3DTOP_BUMPENVMAP = 22,
1173     D3DTOP_BUMPENVMAPLUMINANCE = 23,
1174     D3DTOP_DOTPRODUCT3 = 24,
1175     D3DTOP_MULTIPLYADD = 25,
1176     D3DTOP_LERP = 26
1177 } D3DTEXTUREOP;
1178 
1179 typedef enum _D3DTEXTURESTAGESTATETYPE {
1180     D3DTSS_COLOROP = 1,
1181     D3DTSS_COLORARG1 = 2,
1182     D3DTSS_COLORARG2 = 3,
1183     D3DTSS_ALPHAOP = 4,
1184     D3DTSS_ALPHAARG1 = 5,
1185     D3DTSS_ALPHAARG2 = 6,
1186     D3DTSS_BUMPENVMAT00 = 7,
1187     D3DTSS_BUMPENVMAT01 = 8,
1188     D3DTSS_BUMPENVMAT10 = 9,
1189     D3DTSS_BUMPENVMAT11 = 10,
1190     D3DTSS_TEXCOORDINDEX = 11,
1191     D3DTSS_BUMPENVLSCALE = 22,
1192     D3DTSS_BUMPENVLOFFSET = 23,
1193     D3DTSS_TEXTURETRANSFORMFLAGS = 24,
1194     D3DTSS_COLORARG0 = 26,
1195     D3DTSS_ALPHAARG0 = 27,
1196     D3DTSS_RESULTARG = 28,
1197     D3DTSS_CONSTANT = 32
1198 } D3DTEXTURESTAGESTATETYPE;
1199 
1200 /* MSDN has this in d3d9caps.h, but it should be here */
1201 #define D3DTSS_TCI_PASSTHRU                       0x00000
1202 #define D3DTSS_TCI_CAMERASPACENORMAL              0x10000
1203 #define D3DTSS_TCI_CAMERASPACEPOSITION            0x20000
1204 #define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR    0x30000
1205 #define D3DTSS_TCI_SPHEREMAP                      0x40000
1206 
1207 typedef enum _D3DTEXTURETRANSFORMFLAGS {
1208     D3DTTFF_DISABLE = 0,
1209     D3DTTFF_COUNT1 = 1,
1210     D3DTTFF_COUNT2 = 2,
1211     D3DTTFF_COUNT3 = 3,
1212     D3DTTFF_COUNT4 = 4,
1213     D3DTTFF_PROJECTED = 256
1214 } D3DTEXTURETRANSFORMFLAGS;
1215 
1216 typedef enum _D3DTRANSFORMSTATETYPE {
1217     D3DTS_VIEW = 2,
1218     D3DTS_PROJECTION = 3,
1219     D3DTS_TEXTURE0 = 16,
1220     D3DTS_TEXTURE1 = 17,
1221     D3DTS_TEXTURE2 = 18,
1222     D3DTS_TEXTURE3 = 19,
1223     D3DTS_TEXTURE4 = 20,
1224     D3DTS_TEXTURE5 = 21,
1225     D3DTS_TEXTURE6 = 22,
1226     D3DTS_TEXTURE7 = 23
1227 } D3DTRANSFORMSTATETYPE;
1228 
1229 #define D3DDMAPSAMPLER 256
1230 #define D3DVERTEXTEXTURESAMPLER0 (D3DDMAPSAMPLER+1)
1231 #define D3DVERTEXTEXTURESAMPLER1 (D3DDMAPSAMPLER+2)
1232 #define D3DVERTEXTEXTURESAMPLER2 (D3DDMAPSAMPLER+3)
1233 #define D3DVERTEXTEXTURESAMPLER3 (D3DDMAPSAMPLER+4)
1234 
1235 #define D3DTS_WORLD  D3DTS_WORLDMATRIX(0)
1236 #define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1)
1237 #define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2)
1238 #define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3)
1239 #define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
1240 
1241 typedef enum _D3DVERTEXBLENDFLAGS {
1242     D3DVBF_DISABLE = 0,
1243     D3DVBF_1WEIGHTS = 1,
1244     D3DVBF_2WEIGHTS = 2,
1245     D3DVBF_3WEIGHTS = 3,
1246     D3DVBF_TWEENING = 255,
1247     D3DVBF_0WEIGHTS = 256
1248 } D3DVERTEXBLENDFLAGS;
1249 
1250 typedef enum _D3DVS_ADDRESSMODE_TYPE {
1251     D3DVS_ADDRMODE_ABSOLUTE = 0<<13,
1252     D3DVS_ADDRMODE_RELATIVE = 1<<13
1253 } D3DVS_ADDRESSMODE_TYPE;
1254 
1255 typedef enum _D3DVS_RASTOUT_OFFSETS {
1256     D3DSRO_POSITION = 0,
1257     D3DSRO_FOG = 1,
1258     D3DSRO_POINT_SIZE = 2
1259 } D3DVS_RASTOUT_OFFSETS;
1260 
1261 typedef enum _D3DZBUFFERTYPE {
1262     D3DZB_FALSE = 0,
1263     D3DZB_TRUE = 1,
1264     D3DZB_USEW = 2
1265 } D3DZBUFFERTYPE;
1266 
1267 /*****************************************************************************
1268  * Structs                                                                   *
1269  *****************************************************************************/
1270 typedef struct D3DDISPLAYMODEEX {
1271     UINT Size;
1272     UINT Width;
1273     UINT Height;
1274     UINT RefreshRate;
1275     D3DFORMAT Format;
1276     D3DSCANLINEORDERING ScanLineOrdering;
1277 } D3DDISPLAYMODEEX, *PD3DDISPLAYMODEEX, *LPD3DDISPLAYMODEEX;
1278 
1279 typedef struct D3DDISPLAYMODEFILTER {
1280     UINT Size;
1281     D3DFORMAT Format;
1282     D3DSCANLINEORDERING ScanLineOrdering;
1283 } D3DDISPLAYMODEFILTER, *PD3DDISPLAYMODEFILTER, *LPD3DDISPLAYMODEFILTER;
1284 
1285 typedef struct _D3D_OMAC {
1286     BYTE Omac[16];
1287 } D3D_OMAC, *PD3D_OMAC, *LPD3D_OMAC;
1288 
1289 typedef struct _D3DADAPTER_IDENTIFIER9 {
1290     char Driver[512];
1291     char Description[512];
1292     char DeviceName[32];
1293     DWORD DriverVersionLowPart;
1294     DWORD DriverVersionHighPart;
1295     DWORD VendorId;
1296     DWORD DeviceId;
1297     DWORD SubSysId;
1298     DWORD Revision;
1299     GUID DeviceIdentifier;
1300     DWORD WHQLLevel;
1301 } D3DADAPTER_IDENTIFIER9, *PD3DADAPTER_IDENTIFIER9, *LPD3DADAPTER_IDENTIFIER9;
1302 
1303 typedef struct _D3DAES_CTR_IV {
1304     UINT64 IV;
1305     UINT64 Count;
1306 } D3DAES_CTR_IV, *PD3DAES_CTR_IV, *LPD3DAES_CTR_IV;
1307 
1308 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT {
1309     D3D_OMAC omac;
1310     GUID ConfigureType;
1311     HANDLE hChannel;
1312     UINT SequenceNumber;
1313 } D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, *PD3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT;
1314 
1315 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION {
1316     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
1317     HANDLE DXVA2DecodeHandle;
1318     HANDLE CryptoSessionHandle;
1319     HANDLE DeviceHandle;
1320 } D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION, *PD3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION;
1321 
1322 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE {
1323     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
1324     UINT StartSequenceQuery;
1325     UINT StartSequenceConfigure;
1326 } D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE, *PD3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE, *LPD3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE;
1327 
1328 typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS {
1329     union {
1330         struct {
1331             UINT ProtectionEnabled : 1;
1332             UINT OverlayOrFullscreenRequired : 1;
1333             UINT Reserved : 30;
1334         };
1335         UINT Value;
1336     };
1337 } D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, *PD3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, *LPD3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS;
1338 
1339 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION {
1340     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
1341     D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS Protections;
1342 } D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION, *PD3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION, *LPD3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION;
1343 
1344 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE {
1345     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
1346     D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE ProcessIdentiferType;
1347     HANDLE ProcessHandle;
1348     BOOL AllowAccess;
1349 } D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE, *PD3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE;
1350 
1351 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION {
1352     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT Parameters;
1353     GUID EncryptionGuid;
1354 } D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION, *PD3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION, *LPD3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION;
1355 
1356 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT {
1357     D3D_OMAC omac;
1358     GUID ConfigureType;
1359     HANDLE hChannel;
1360     UINT SequenceNumber;
1361     HRESULT ReturnCode;
1362 } D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT;
1363 
1364 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_INPUT {
1365     GUID QueryType;
1366     HANDLE hChannel;
1367     UINT SequenceNumber;
1368 } D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERY_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERY_INPUT;
1369 
1370 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT {
1371     D3D_OMAC omac;
1372     GUID QueryType;
1373     HANDLE hChannel;
1374     UINT SequenceNumber;
1375     HRESULT ReturnCode;
1376 } D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT;
1377 
1378 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT {
1379     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1380     D3DAUTHENTICATEDCHANNELTYPE ChannelType;
1381 } D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT;
1382 
1383 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT {
1384     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
1385     HANDLE DXVA2DecodeHandle;
1386 } D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT;
1387 
1388 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT {
1389     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1390     HANDLE DXVA2DecodeHandle;
1391     HANDLE CryptoSessionHandle;
1392     HANDLE DeviceHandle;
1393 } D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT;
1394 
1395 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT {
1396     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1397     HANDLE DeviceHandle;
1398 } D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT;
1399 
1400 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT {
1401     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1402     UINT NumEncryptionGuids;
1403 } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT;
1404 
1405 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT {
1406     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
1407     UINT EncryptionGuidIndex;
1408 } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT;
1409 
1410 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT {
1411     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1412     UINT EncryptionGuidIndex;
1413     GUID EncryptionGuid;
1414 } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT;
1415 
1416 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT {
1417     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1418     D3DBUSTYPE BusType;
1419     BOOL bAccessibleInContiguousBlocks;
1420     BOOL bAccessibleInNonContiguousBlocks;
1421 } D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT;
1422 
1423 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT {
1424     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
1425     HANDLE DeviceHandle;
1426     HANDLE CryptoSessionHandle;
1427 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT;
1428 
1429 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT {
1430     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1431     HANDLE DeviceHandle;
1432     HANDLE CryptoSessionHandle;
1433     UINT NumOutputIDs;
1434 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT;
1435 
1436 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT {
1437     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
1438     HANDLE DeviceHandle;
1439     HANDLE CryptoSessionHandle;
1440     UINT OutputIDIndex;
1441 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT;
1442 
1443 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT {
1444     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1445     HANDLE DeviceHandle;
1446     HANDLE CryptoSessionHandle;
1447     UINT OutputIDIndex;
1448     UINT64 OutputID;
1449 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT;
1450 
1451 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT {
1452     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1453     D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS ProtectionFlags;
1454 } D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT;
1455 
1456 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT {
1457     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1458     UINT NumRestrictedSharedResourceProcesses;
1459 } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT;
1460 
1461 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT {
1462     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
1463     UINT ProcessIndex;
1464 } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT;
1465 
1466 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT {
1467     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1468     UINT ProcessIndex;
1469     D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE ProcessIdentifer;
1470     HANDLE ProcessHandle;
1471 } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT;
1472 
1473 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT {
1474     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1475     GUID EncryptionGuid;
1476 } D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT;
1477 
1478 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT {
1479     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
1480     UINT NumUnrestrictedProtectedSharedResources;
1481 } D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT, *PD3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT, *LPD3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT;
1482 
1483 typedef struct _D3DBOX {
1484     UINT Left;
1485     UINT Top;
1486     UINT Right;
1487     UINT Bottom;
1488     UINT Front;
1489     UINT Back;
1490 } D3DBOX, *PD3DBOX, *LPD3DBOX;
1491 
1492 typedef struct _D3DCLIPSTATUS9 {
1493     DWORD ClipUnion;
1494     DWORD ClipIntersection;
1495 } D3DCLIPSTATUS9, *PD3DCLIPSTATUS9, *LPD3DCLIPSTATUS9;
1496 
1497 typedef struct _D3DCOLORVALUE {
1498     float r;
1499     float g;
1500     float b;
1501     float a;
1502 } D3DCOLORVALUE, *PD3DCOLORVALUE, *LPD3DCOLORVALUE;
1503 
1504 typedef struct _D3DCOMPOSERECTDESC {
1505     USHORT X, Y;
1506     USHORT Width, Height;
1507 } D3DCOMPOSERECTDESC, *PD3DCOMPOSERECTDESC, *LPD3DCOMPOSERECTDESC;
1508 
1509 typedef struct _D3DCOMPOSERECTDESTINATION {
1510     USHORT SrcRectIndex;
1511     USHORT Reserved;
1512     SHORT X, Y;
1513 } D3DCOMPOSERECTDESTINATION, *PD3DCOMPOSERECTDESTINATION, *LPD3DCOMPOSERECTDESTINATION;
1514 
1515 typedef struct _D3DDEVICE_CREATION_PARAMETERS {
1516     UINT AdapterOrdinal;
1517     D3DDEVTYPE DeviceType;
1518     HWND hFocusWindow;
1519     DWORD BehaviorFlags;
1520 } D3DDEVICE_CREATION_PARAMETERS, *PD3DDEVICE_CREATION_PARAMETERS, *LPD3DDEVICE_CREATION_PARAMETERS;
1521 
1522 typedef struct _D3DDEVINFO_D3D9BANDWIDTHTIMINGS {
1523     FLOAT MaxBandwidthUtilized;
1524     FLOAT FrontEndUploadMemoryUtilizedPercent;
1525     FLOAT VertexRateUtilizedPercent;
1526     FLOAT TriangleSetupRateUtilizedPercent;
1527     FLOAT FillRateUtilizedPercent;
1528 } D3DDEVINFO_D3D9BANDWIDTHTIMINGS, *PD3DDEVINFO_D3D9BANDWIDTHTIMINGS, *LPD3DDEVINFO_D3D9BANDWIDTHTIMINGS;
1529 
1530 typedef struct _D3DDEVINFO_D3D9CACHEUTILIZATION {
1531     FLOAT TextureCacheHitRate;
1532     FLOAT PostTransformVertexCacheHitRate;
1533 } D3DDEVINFO_D3D9CACHEUTILIZATION, *PD3DDEVINFO_D3D9CACHEUTILIZATION, *LPD3DDEVINFO_D3D9CACHEUTILIZATION;
1534 
1535 typedef struct _D3DDEVINFO_D3D9INTERFACETIMINGS {
1536     FLOAT WaitingForGPUToUseApplicationResourceTimePercent;
1537     FLOAT WaitingForGPUToAcceptMoreCommandsTimePercent;
1538     FLOAT WaitingForGPUToStayWithinLatencyTimePercent;
1539     FLOAT WaitingForGPUExclusiveResourceTimePercent;
1540     FLOAT WaitingForGPUOtherTimePercent;
1541 } D3DDEVINFO_D3D9INTERFACETIMINGS, *PD3DDEVINFO_D3D9INTERFACETIMINGS, *LPD3DDEVINFO_D3D9INTERFACETIMINGS;
1542 
1543 typedef struct _D3DDEVINFO_D3D9PIPELINETIMINGS {
1544     FLOAT VertexProcessingTimePercent;
1545     FLOAT PixelProcessingTimePercent;
1546     FLOAT OtherGPUProcessingTimePercent;
1547     FLOAT GPUIdleTimePercent;
1548 } D3DDEVINFO_D3D9PIPELINETIMINGS, *PD3DDEVINFO_D3D9PIPELINETIMINGS, *LPD3DDEVINFO_D3D9PIPELINETIMINGS;
1549 
1550 typedef struct _D3DDEVINFO_D3D9STAGETIMINGS {
1551     FLOAT MemoryProcessingPercent;
1552     FLOAT ComputationProcessingPercent;
1553 } D3DDEVINFO_D3D9STAGETIMINGS, *PD3DDEVINFO_D3D9STAGETIMINGS, *LPD3DDEVINFO_D3D9STAGETIMINGS;
1554 
1555 typedef struct _D3DDEVINFO_D3DVERTEXSTATS {
1556     DWORD NumRenderedTriangles;
1557     DWORD NumExtraClippingTriangles;
1558 } D3DDEVINFO_D3DVERTEXSTATS, *LPD3DDEVINFO_D3DVERTEXSTATS;
1559 
1560 typedef struct _D3DRESOURCESTATS {
1561     BOOL bThrashing;
1562     DWORD ApproxBytesDownloaded;
1563     DWORD NumEvicts;
1564     DWORD NumVidCreates;
1565     DWORD LastPri;
1566     DWORD NumUsed;
1567     DWORD NumUsedInVidMem;
1568     DWORD WorkingSet;
1569     DWORD WorkingSetBytes;
1570     DWORD TotalManaged;
1571     DWORD TotalBytes;
1572 } D3DRESOURCESTATS, *PD3DRESOURCESTATS, *LPD3DRESOURCESTATS;
1573 
1574 typedef struct _D3DDEVINFO_RESOURCEMANAGER {
1575     D3DRESOURCESTATS stats[(D3DRTYPE_INDEXBUFFER+1)];
1576 } D3DDEVINFO_RESOURCEMANAGER, *LPD3DDEVINFO_RESOURCEMANAGER;
1577 
1578 typedef struct _D3DDEVINFO_VCACHE {
1579     DWORD Pattern;
1580     DWORD OptMethod;
1581     DWORD CacheSize;
1582     DWORD MagicNumber;
1583 } D3DDEVINFO_VCACHE, *LPD3DDEVINFO_VCACHE;
1584 
1585 typedef struct _D3DDISPLAYMODE {
1586     UINT Width;
1587     UINT Height;
1588     UINT RefreshRate;
1589     D3DFORMAT Format;
1590 } D3DDISPLAYMODE, *PD3DDISPLAYMODE, *LPD3DDISPLAYMODE;
1591 
1592 typedef struct _D3DENCRYPTED_BLOCK_INFO {
1593     UINT NumEncryptedBytesAtBeginning;
1594     UINT NumBytesInSkipPattern;
1595     UINT NumBytesInEncryptPattern;
1596 } D3DENCRYPTED_BLOCK_INFO, *PD3DENCRYPTED_BLOCK_INFO, *LPD3DENCRYPTED_BLOCK_INFO;
1597 
1598 typedef struct _D3DGAMMARAMP {
1599     WORD red [256];
1600     WORD green[256];
1601     WORD blue [256];
1602 } D3DGAMMARAMP, *PD3DGAMMARAMP, *LPD3DGAMMARAMP;
1603 
1604 typedef struct _D3DINDEXBUFFER_DESC {
1605     D3DFORMAT Format;
1606     D3DRESOURCETYPE Type;
1607     DWORD Usage;
1608     D3DPOOL Pool;
1609     UINT Size;
1610 } D3DINDEXBUFFER_DESC, *PD3DINDEXBUFFER_DESC, *LPD3DINDEXBUFFER_DESC;
1611 
1612 typedef struct _D3DVECTOR {
1613     float x;
1614     float y;
1615     float z;
1616 } D3DVECTOR, *PD3DVECTOR, *LPD3DVECTOR;
1617 
1618 typedef struct _D3DLIGHT9 {
1619     D3DLIGHTTYPE Type;
1620     D3DCOLORVALUE Diffuse;
1621     D3DCOLORVALUE Specular;
1622     D3DCOLORVALUE Ambient;
1623     D3DVECTOR Position;
1624     D3DVECTOR Direction;
1625     float Range;
1626     float Falloff;
1627     float Attenuation0;
1628     float Attenuation1;
1629     float Attenuation2;
1630     float Theta;
1631     float Phi;
1632 } D3DLIGHT9, *PD3DLIGHT9, *LPD3DLIGHT9;
1633 
1634 typedef struct _D3DLOCKED_BOX {
1635     INT RowPitch;
1636     INT SlicePitch;
1637     void* pBits;
1638 } D3DLOCKED_BOX, *PD3DLOCKED_BOX, *LPD3DLOCKED_BOX;
1639 
1640 typedef struct _D3DLOCKED_RECT {
1641     INT Pitch;
1642     void* pBits;
1643 } D3DLOCKED_RECT, *PD3DLOCKED_RECT, *LPD3DLOCKED_RECT;
1644 
1645 typedef struct _D3DMATERIAL9 {
1646     D3DCOLORVALUE Diffuse;
1647     D3DCOLORVALUE Ambient;
1648     D3DCOLORVALUE Specular;
1649     D3DCOLORVALUE Emissive;
1650     float Power;
1651 } D3DMATERIAL9, *PD3DMATERIAL9, *LPD3DMATERIAL9;
1652 
1653 typedef struct _D3DMATRIX {
1654     union {
1655         struct {
1656             float _11, _12, _13, _14;
1657             float _21, _22, _23, _24;
1658             float _31, _32, _33, _34;
1659             float _41, _42, _43, _44;
1660         };
1661         float m[4][4];
1662     };
1663 } D3DMATRIX, *PD3DMATRIX, *LPD3DMATRIX;
1664 
1665 typedef struct _D3DMEMORYPRESSURE {
1666     UINT64 BytesEvictedFromProcess;
1667     UINT64 SizeOfInefficientAllocation;
1668     DWORD LevelOfEfficiency;
1669 } D3DMEMORYPRESSURE, *PD3DMEMORYPRESSURE, *LPD3DMEMORYPRESSURE;
1670 
1671 typedef struct _D3DPRESENTSTATS {
1672     UINT PresentCount;
1673     UINT PresentRefreshCount;
1674     UINT SyncRefreshCount;
1675     LARGE_INTEGER SyncQPCTime;
1676     LARGE_INTEGER SyncGPUTime;
1677 } D3DPRESENTSTATS, *PD3DPRESENTSTATS, *LPD3DPRESENTSTATS;
1678 
1679 typedef struct _D3DPRESENT_PARAMETERS_ {
1680     UINT BackBufferWidth;
1681     UINT BackBufferHeight;
1682     D3DFORMAT BackBufferFormat;
1683     UINT BackBufferCount;
1684     D3DMULTISAMPLE_TYPE MultiSampleType;
1685     DWORD MultiSampleQuality;
1686     D3DSWAPEFFECT SwapEffect;
1687     HWND hDeviceWindow;
1688     BOOL Windowed;
1689     BOOL EnableAutoDepthStencil;
1690     D3DFORMAT AutoDepthStencilFormat;
1691     DWORD Flags;
1692     UINT FullScreen_RefreshRateInHz;
1693     UINT PresentationInterval;
1694 } D3DPRESENT_PARAMETERS, *PD3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS;
1695 
1696 typedef struct _D3DRANGE {
1697     UINT Offset;
1698     UINT Size;
1699 } D3DRANGE, *PD3DRANGE, *LPD3DRANGE;
1700 
1701 typedef struct _D3DRASTER_STATUS {
1702     BOOL InVBlank;
1703     UINT ScanLine;
1704 } D3DRASTER_STATUS, *PD3DRASTER_STATUS, *LPD3DRASTER_STATUS;
1705 
1706 typedef struct _D3DRECT {
1707     LONG x1;
1708     LONG y1;
1709     LONG x2;
1710     LONG y2;
1711 } D3DRECT, *PD3DRECT, *LPD3DRECT;
1712 
1713 typedef struct _D3DRECTPATCH_INFO {
1714     UINT StartVertexOffsetWidth;
1715     UINT StartVertexOffsetHeight;
1716     UINT Width;
1717     UINT Height;
1718     UINT Stride;
1719     D3DBASISTYPE Basis;
1720     D3DDEGREETYPE Degree;
1721 } D3DRECTPATCH_INFO, *PD3DRECTPATCH_INFO, *LPD3DRECTPATCH_INFO;
1722 
1723 typedef struct _D3DSURFACE_DESC {
1724     D3DFORMAT Format;
1725     D3DRESOURCETYPE Type;
1726     DWORD Usage;
1727     D3DPOOL Pool;
1728     D3DMULTISAMPLE_TYPE MultiSampleType;
1729     DWORD MultiSampleQuality;
1730     UINT Width;
1731     UINT Height;
1732 } D3DSURFACE_DESC, *PD3DSURFACE_DESC, *LPD3DSURFACE_DESC;
1733 
1734 typedef struct _D3DTRIPATCH_INFO {
1735     UINT StartVertexOffset;
1736     UINT NumVertices;
1737     D3DBASISTYPE Basis;
1738     D3DDEGREETYPE Degree;
1739 } D3DTRIPATCH_INFO, *PD3DTRIPATCH_INFO, *LPD3DTRIPATCH_INFO;
1740 
1741 typedef struct _D3DVERTEXBUFFER_DESC {
1742     D3DFORMAT Format;
1743     D3DRESOURCETYPE Type;
1744     DWORD Usage;
1745     D3DPOOL Pool;
1746     UINT Size;
1747     DWORD FVF;
1748 } D3DVERTEXBUFFER_DESC, *PD3DVERTEXBUFFER_DESC, *LPD3DVERTEXBUFFER_DESC;
1749 
1750 typedef struct _D3DVERTEXELEMENT9 {
1751     WORD Stream;
1752     WORD Offset;
1753     BYTE Type;
1754     BYTE Method;
1755     BYTE Usage;
1756     BYTE UsageIndex;
1757 } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9;
1758 
1759 typedef struct _D3DVIEWPORT9 {
1760     DWORD X;
1761     DWORD Y;
1762     DWORD Width;
1763     DWORD Height;
1764     float MinZ;
1765     float MaxZ;
1766 } D3DVIEWPORT9, *PD3DVIEWPORT9, *LPD3DVIEWPORT9;
1767 
1768 typedef struct _D3DVOLUME_DESC {
1769     D3DFORMAT Format;
1770     D3DRESOURCETYPE Type;
1771     DWORD Usage;
1772     D3DPOOL Pool;
1773     UINT Width;
1774     UINT Height;
1775     UINT Depth;
1776 } D3DVOLUME_DESC, *PD3DVOLUME_DESC, *LPD3DVOLUME_DESC;
1777 
1778 #ifndef _WIN32
1779 /* If _WIN32 isn't declared it means only internal header files are used. To
1780  * avoid a conflict, IUnknown is declared here rather than in d3d9.h */
1781 
1782 typedef struct IUnknown IUnknown, *PUNKNOWN, *LPUNKNOWN;
1783 
1784 #ifdef __cplusplus
1785 extern "C" const GUID IID_IUnknown;
1786 
1787 struct IUnknown
1788 {
1789 	virtual HRESULT WINAPI QueryInterface(REFIID riid, void **ppvObject) = 0;
1790 	virtual ULONG WINAPI AddRef() = 0;
1791 	virtual ULONG WINAPI Release() = 0;
1792 };
1793 #else /* __cplusplus */
1794 extern const GUID IID_IUnknown;
1795 
1796 typedef struct IUnknownVtbl
1797 {
1798 	/* IUnknown */
1799 	HRESULT (WINAPI *QueryInterface)(IUnknown *This, REFIID riid, void **ppvObject);
1800 	ULONG (WINAPI *AddRef)(IUnknown *This);
1801 	ULONG (WINAPI *Release)(IUnknown *This);
1802 } IUnknownVtbl;
1803 
1804 struct IUnknown
1805 {
1806 	IUnknownVtbl *lpVtbl;
1807 };
1808 
1809 /* IUnknown macros */
1810 #define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
1811 #define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p)
1812 #define IUnknown_Release(p) (p)->lpVtbl->Release(p)
1813 #endif /* __cplusplus */
1814 #endif /* _WIN32 */
1815 
1816 #endif /* _D3D9TYPES_H_ */
1817