1 /*==========================================================================;
2  *
3  *  Copyright (C) Microsoft Corporation.  All Rights Reserved.
4  *
5  *  File:       d3d9types.h
6  *  Content:    Direct3D capabilities include file
7  *
8  ***************************************************************************/
9 
10 #ifndef _d3d9TYPES_H_
11 #define _d3d9TYPES_H_
12 
13 #ifndef DIRECT3D_VERSION
14 #define DIRECT3D_VERSION         0x0900
15 #endif
16 
17 /* include this file content only if compiling for DX9 interfaces */
18 #if(DIRECT3D_VERSION >= 0x0900)
19 
20 #include <float.h>
21 
22 #if _MSC_VER >= 1200
23 #pragma warning(push)
24 #endif
25 
26 #if defined(_X86_) || defined(_IA64_)
27 #pragma pack(4)
28 #endif
29 
30 /* D3DCOLOR is equivalent to D3DFMT_A8R8G8B8 */
31 #ifndef D3DCOLOR_DEFINED
32 typedef DWORD D3DCOLOR;
33 #define D3DCOLOR_DEFINED
34 #endif
35 
36 /* maps unsigned 8 bits/channel to D3DCOLOR */
37 #define D3DCOLOR_ARGB(a,r,g,b) \
38     ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
39 #define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b)
40 #define D3DCOLOR_XRGB(r,g,b)   D3DCOLOR_ARGB(0xff,r,g,b)
41 
42 #define D3DCOLOR_XYUV(y,u,v)   D3DCOLOR_ARGB(0xff,y,u,v)
43 #define D3DCOLOR_AYUV(a,y,u,v) D3DCOLOR_ARGB(a,y,u,v)
44 
45 /* maps floating point channels (0.f to 1.f range) to D3DCOLOR */
46 #define D3DCOLOR_COLORVALUE(r,g,b,a) \
47     D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f))
48 
49 #ifndef D3DVECTOR_DEFINED
50 typedef struct _D3DVECTOR {
51     float x;
52     float y;
53     float z;
54 } D3DVECTOR;
55 #define D3DVECTOR_DEFINED
56 #endif
57 
58 #ifndef D3DCOLORVALUE_DEFINED
59 typedef struct _D3DCOLORVALUE {
60     float r;
61     float g;
62     float b;
63     float a;
64 } D3DCOLORVALUE;
65 #define D3DCOLORVALUE_DEFINED
66 #endif
67 
68 #ifndef D3DRECT_DEFINED
69 typedef struct _D3DRECT {
70     LONG x1;
71     LONG y1;
72     LONG x2;
73     LONG y2;
74 } D3DRECT;
75 #define D3DRECT_DEFINED
76 #endif
77 
78 #ifndef D3DMATRIX_DEFINED
79 typedef struct _D3DMATRIX {
80     union {
81         struct {
82             float        _11, _12, _13, _14;
83             float        _21, _22, _23, _24;
84             float        _31, _32, _33, _34;
85             float        _41, _42, _43, _44;
86 
87         };
88         float m[4][4];
89     };
90 } D3DMATRIX;
91 #define D3DMATRIX_DEFINED
92 #endif
93 
94 typedef struct _D3DVIEWPORT9 {
95     DWORD       X;
96     DWORD       Y;            /* Viewport Top left */
97     DWORD       Width;
98     DWORD       Height;       /* Viewport Dimensions */
99     float       MinZ;         /* Min/max of clip Volume */
100     float       MaxZ;
101 } D3DVIEWPORT9;
102 
103 /*
104  * Values for clip fields.
105  */
106 
107 /* Max number of user clipping planes, supported in D3D. */
108 #define D3DMAXUSERCLIPPLANES 32
109 
110 /* These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE */
111 #define D3DCLIPPLANE0 (1 << 0)
112 #define D3DCLIPPLANE1 (1 << 1)
113 #define D3DCLIPPLANE2 (1 << 2)
114 #define D3DCLIPPLANE3 (1 << 3)
115 #define D3DCLIPPLANE4 (1 << 4)
116 #define D3DCLIPPLANE5 (1 << 5)
117 
118 /* The following bits are used in the ClipUnion and ClipIntersection
119  * members of the D3DCLIPSTATUS9
120  */
121 
122 #define D3DCS_LEFT        0x00000001L
123 #define D3DCS_RIGHT       0x00000002L
124 #define D3DCS_TOP         0x00000004L
125 #define D3DCS_BOTTOM      0x00000008L
126 #define D3DCS_FRONT       0x00000010L
127 #define D3DCS_BACK        0x00000020L
128 #define D3DCS_PLANE0      0x00000040L
129 #define D3DCS_PLANE1      0x00000080L
130 #define D3DCS_PLANE2      0x00000100L
131 #define D3DCS_PLANE3      0x00000200L
132 #define D3DCS_PLANE4      0x00000400L
133 #define D3DCS_PLANE5      0x00000800L
134 
135 #define D3DCS_ALL (D3DCS_LEFT   | \
136                    D3DCS_RIGHT  | \
137                    D3DCS_TOP    | \
138                    D3DCS_BOTTOM | \
139                    D3DCS_FRONT  | \
140                    D3DCS_BACK   | \
141                    D3DCS_PLANE0 | \
142                    D3DCS_PLANE1 | \
143                    D3DCS_PLANE2 | \
144                    D3DCS_PLANE3 | \
145                    D3DCS_PLANE4 | \
146                    D3DCS_PLANE5)
147 
148 typedef struct _D3DCLIPSTATUS9 {
149     DWORD ClipUnion;
150     DWORD ClipIntersection;
151 } D3DCLIPSTATUS9;
152 
153 typedef struct _D3DMATERIAL9 {
154     D3DCOLORVALUE   Diffuse;        /* Diffuse color RGBA */
155     D3DCOLORVALUE   Ambient;        /* Ambient color RGB */
156     D3DCOLORVALUE   Specular;       /* Specular 'shininess' */
157     D3DCOLORVALUE   Emissive;       /* Emissive color RGB */
158     float           Power;          /* Sharpness if specular highlight */
159 } D3DMATERIAL9;
160 
161 typedef enum _D3DLIGHTTYPE {
162     D3DLIGHT_POINT          = 1,
163     D3DLIGHT_SPOT           = 2,
164     D3DLIGHT_DIRECTIONAL    = 3,
165     D3DLIGHT_FORCE_DWORD    = 0x7fffffff /* force 32-bit size enum */
166 } D3DLIGHTTYPE;
167 
168 typedef struct _D3DLIGHT9 {
169     D3DLIGHTTYPE    Type;            /* Type of light source */
170     D3DCOLORVALUE   Diffuse;         /* Diffuse color of light */
171     D3DCOLORVALUE   Specular;        /* Specular color of light */
172     D3DCOLORVALUE   Ambient;         /* Ambient color of light */
173     D3DVECTOR       Position;         /* Position in world space */
174     D3DVECTOR       Direction;        /* Direction in world space */
175     float           Range;            /* Cutoff range */
176     float           Falloff;          /* Falloff */
177     float           Attenuation0;     /* Constant attenuation */
178     float           Attenuation1;     /* Linear attenuation */
179     float           Attenuation2;     /* Quadratic attenuation */
180     float           Theta;            /* Inner angle of spotlight cone */
181     float           Phi;              /* Outer angle of spotlight cone */
182 } D3DLIGHT9;
183 
184 /*
185  * Options for clearing
186  */
187 #define D3DCLEAR_TARGET            0x00000001l  /* Clear target surface */
188 #define D3DCLEAR_ZBUFFER           0x00000002l  /* Clear target z buffer */
189 #define D3DCLEAR_STENCIL           0x00000004l  /* Clear stencil planes */
190 
191 /*
192  * The following defines the rendering states
193  */
194 
195 typedef enum _D3DSHADEMODE {
196     D3DSHADE_FLAT               = 1,
197     D3DSHADE_GOURAUD            = 2,
198     D3DSHADE_PHONG              = 3,
199     D3DSHADE_FORCE_DWORD        = 0x7fffffff /* force 32-bit size enum */
200 } D3DSHADEMODE;
201 
202 typedef enum _D3DFILLMODE {
203     D3DFILL_POINT               = 1,
204     D3DFILL_WIREFRAME           = 2,
205     D3DFILL_SOLID               = 3,
206     D3DFILL_FORCE_DWORD         = 0x7fffffff /* force 32-bit size enum */
207 } D3DFILLMODE;
208 
209 typedef enum _D3DBLEND {
210     D3DBLEND_ZERO               = 1,
211     D3DBLEND_ONE                = 2,
212     D3DBLEND_SRCCOLOR           = 3,
213     D3DBLEND_INVSRCCOLOR        = 4,
214     D3DBLEND_SRCALPHA           = 5,
215     D3DBLEND_INVSRCALPHA        = 6,
216     D3DBLEND_DESTALPHA          = 7,
217     D3DBLEND_INVDESTALPHA       = 8,
218     D3DBLEND_DESTCOLOR          = 9,
219     D3DBLEND_INVDESTCOLOR       = 10,
220     D3DBLEND_SRCALPHASAT        = 11,
221     D3DBLEND_BOTHSRCALPHA       = 12,
222     D3DBLEND_BOTHINVSRCALPHA    = 13,
223     D3DBLEND_BLENDFACTOR        = 14, /* Only supported if D3DPBLENDCAPS_BLENDFACTOR is on */
224     D3DBLEND_INVBLENDFACTOR     = 15, /* Only supported if D3DPBLENDCAPS_BLENDFACTOR is on */
225 /* D3D9Ex only -- */
226 #if !defined(D3D_DISABLE_9EX)
227 
228     D3DBLEND_SRCCOLOR2          = 16,
229     D3DBLEND_INVSRCCOLOR2       = 17,
230 
231 #endif /* !D3D_DISABLE_9EX */
232 /* -- D3D9Ex only */
233     D3DBLEND_FORCE_DWORD        = 0x7fffffff /* force 32-bit size enum */
234 } D3DBLEND;
235 
236 typedef enum _D3DBLENDOP {
237     D3DBLENDOP_ADD              = 1,
238     D3DBLENDOP_SUBTRACT         = 2,
239     D3DBLENDOP_REVSUBTRACT      = 3,
240     D3DBLENDOP_MIN              = 4,
241     D3DBLENDOP_MAX              = 5,
242     D3DBLENDOP_FORCE_DWORD      = 0x7fffffff /* force 32-bit size enum */
243 } D3DBLENDOP;
244 
245 typedef enum _D3DTEXTUREADDRESS {
246     D3DTADDRESS_WRAP            = 1,
247     D3DTADDRESS_MIRROR          = 2,
248     D3DTADDRESS_CLAMP           = 3,
249     D3DTADDRESS_BORDER          = 4,
250     D3DTADDRESS_MIRRORONCE      = 5,
251     D3DTADDRESS_FORCE_DWORD     = 0x7fffffff /* force 32-bit size enum */
252 } D3DTEXTUREADDRESS;
253 
254 typedef enum _D3DCULL {
255     D3DCULL_NONE                = 1,
256     D3DCULL_CW                  = 2,
257     D3DCULL_CCW                 = 3,
258     D3DCULL_FORCE_DWORD         = 0x7fffffff /* force 32-bit size enum */
259 } D3DCULL;
260 
261 typedef enum _D3DCMPFUNC {
262     D3DCMP_NEVER                = 1,
263     D3DCMP_LESS                 = 2,
264     D3DCMP_EQUAL                = 3,
265     D3DCMP_LESSEQUAL            = 4,
266     D3DCMP_GREATER              = 5,
267     D3DCMP_NOTEQUAL             = 6,
268     D3DCMP_GREATEREQUAL         = 7,
269     D3DCMP_ALWAYS               = 8,
270     D3DCMP_FORCE_DWORD          = 0x7fffffff /* force 32-bit size enum */
271 } D3DCMPFUNC;
272 
273 typedef enum _D3DSTENCILOP {
274     D3DSTENCILOP_KEEP           = 1,
275     D3DSTENCILOP_ZERO           = 2,
276     D3DSTENCILOP_REPLACE        = 3,
277     D3DSTENCILOP_INCRSAT        = 4,
278     D3DSTENCILOP_DECRSAT        = 5,
279     D3DSTENCILOP_INVERT         = 6,
280     D3DSTENCILOP_INCR           = 7,
281     D3DSTENCILOP_DECR           = 8,
282     D3DSTENCILOP_FORCE_DWORD    = 0x7fffffff /* force 32-bit size enum */
283 } D3DSTENCILOP;
284 
285 typedef enum _D3DFOGMODE {
286     D3DFOG_NONE                 = 0,
287     D3DFOG_EXP                  = 1,
288     D3DFOG_EXP2                 = 2,
289     D3DFOG_LINEAR               = 3,
290     D3DFOG_FORCE_DWORD          = 0x7fffffff /* force 32-bit size enum */
291 } D3DFOGMODE;
292 
293 typedef enum _D3DZBUFFERTYPE {
294     D3DZB_FALSE                 = 0,
295     D3DZB_TRUE                  = 1, /* Z buffering */
296     D3DZB_USEW                  = 2, /* W buffering */
297     D3DZB_FORCE_DWORD           = 0x7fffffff /* force 32-bit size enum */
298 } D3DZBUFFERTYPE;
299 
300 /* Primitives supported by draw-primitive API */
301 typedef enum _D3DPRIMITIVETYPE {
302     D3DPT_POINTLIST             = 1,
303     D3DPT_LINELIST              = 2,
304     D3DPT_LINESTRIP             = 3,
305     D3DPT_TRIANGLELIST          = 4,
306     D3DPT_TRIANGLESTRIP         = 5,
307     D3DPT_TRIANGLEFAN           = 6,
308     D3DPT_FORCE_DWORD           = 0x7fffffff /* force 32-bit size enum */
309 } D3DPRIMITIVETYPE;
310 
311 typedef enum _D3DTRANSFORMSTATETYPE {
312     D3DTS_VIEW          = 2,
313     D3DTS_PROJECTION    = 3,
314     D3DTS_TEXTURE0      = 16,
315     D3DTS_TEXTURE1      = 17,
316     D3DTS_TEXTURE2      = 18,
317     D3DTS_TEXTURE3      = 19,
318     D3DTS_TEXTURE4      = 20,
319     D3DTS_TEXTURE5      = 21,
320     D3DTS_TEXTURE6      = 22,
321     D3DTS_TEXTURE7      = 23,
322     D3DTS_FORCE_DWORD     = 0x7fffffff /* force 32-bit size enum */
323 } D3DTRANSFORMSTATETYPE;
324 
325 #define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
326 #define D3DTS_WORLD  D3DTS_WORLDMATRIX(0)
327 #define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1)
328 #define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2)
329 #define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3)
330 
331 typedef enum _D3DRENDERSTATETYPE {
332     D3DRS_ZENABLE                   = 7,    /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
333     D3DRS_FILLMODE                  = 8,    /* D3DFILLMODE */
334     D3DRS_SHADEMODE                 = 9,    /* D3DSHADEMODE */
335     D3DRS_ZWRITEENABLE              = 14,   /* TRUE to enable z writes */
336     D3DRS_ALPHATESTENABLE           = 15,   /* TRUE to enable alpha tests */
337     D3DRS_LASTPIXEL                 = 16,   /* TRUE for last-pixel on lines */
338     D3DRS_SRCBLEND                  = 19,   /* D3DBLEND */
339     D3DRS_DESTBLEND                 = 20,   /* D3DBLEND */
340     D3DRS_CULLMODE                  = 22,   /* D3DCULL */
341     D3DRS_ZFUNC                     = 23,   /* D3DCMPFUNC */
342     D3DRS_ALPHAREF                  = 24,   /* D3DFIXED */
343     D3DRS_ALPHAFUNC                 = 25,   /* D3DCMPFUNC */
344     D3DRS_DITHERENABLE              = 26,   /* TRUE to enable dithering */
345     D3DRS_ALPHABLENDENABLE          = 27,   /* TRUE to enable alpha blending */
346     D3DRS_FOGENABLE                 = 28,   /* TRUE to enable fog blending */
347     D3DRS_SPECULARENABLE            = 29,   /* TRUE to enable specular */
348     D3DRS_FOGCOLOR                  = 34,   /* D3DCOLOR */
349     D3DRS_FOGTABLEMODE              = 35,   /* D3DFOGMODE */
350     D3DRS_FOGSTART                  = 36,   /* Fog start (for both vertex and pixel fog) */
351     D3DRS_FOGEND                    = 37,   /* Fog end      */
352     D3DRS_FOGDENSITY                = 38,   /* Fog density  */
353     D3DRS_RANGEFOGENABLE            = 48,   /* Enables range-based fog */
354     D3DRS_STENCILENABLE             = 52,   /* BOOL enable/disable stenciling */
355     D3DRS_STENCILFAIL               = 53,   /* D3DSTENCILOP to do if stencil test fails */
356     D3DRS_STENCILZFAIL              = 54,   /* D3DSTENCILOP to do if stencil test passes and Z test fails */
357     D3DRS_STENCILPASS               = 55,   /* D3DSTENCILOP to do if both stencil and Z tests pass */
358     D3DRS_STENCILFUNC               = 56,   /* D3DCMPFUNC fn.  Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
359     D3DRS_STENCILREF                = 57,   /* Reference value used in stencil test */
360     D3DRS_STENCILMASK               = 58,   /* Mask value used in stencil test */
361     D3DRS_STENCILWRITEMASK          = 59,   /* Write mask applied to values written to stencil buffer */
362     D3DRS_TEXTUREFACTOR             = 60,   /* D3DCOLOR used for multi-texture blend */
363     D3DRS_WRAP0                     = 128,  /* wrap for 1st texture coord. set */
364     D3DRS_WRAP1                     = 129,  /* wrap for 2nd texture coord. set */
365     D3DRS_WRAP2                     = 130,  /* wrap for 3rd texture coord. set */
366     D3DRS_WRAP3                     = 131,  /* wrap for 4th texture coord. set */
367     D3DRS_WRAP4                     = 132,  /* wrap for 5th texture coord. set */
368     D3DRS_WRAP5                     = 133,  /* wrap for 6th texture coord. set */
369     D3DRS_WRAP6                     = 134,  /* wrap for 7th texture coord. set */
370     D3DRS_WRAP7                     = 135,  /* wrap for 8th texture coord. set */
371     D3DRS_CLIPPING                  = 136,
372     D3DRS_LIGHTING                  = 137,
373     D3DRS_AMBIENT                   = 139,
374     D3DRS_FOGVERTEXMODE             = 140,
375     D3DRS_COLORVERTEX               = 141,
376     D3DRS_LOCALVIEWER               = 142,
377     D3DRS_NORMALIZENORMALS          = 143,
378     D3DRS_DIFFUSEMATERIALSOURCE     = 145,
379     D3DRS_SPECULARMATERIALSOURCE    = 146,
380     D3DRS_AMBIENTMATERIALSOURCE     = 147,
381     D3DRS_EMISSIVEMATERIALSOURCE    = 148,
382     D3DRS_VERTEXBLEND               = 151,
383     D3DRS_CLIPPLANEENABLE           = 152,
384     D3DRS_POINTSIZE                 = 154,   /* float point size */
385     D3DRS_POINTSIZE_MIN             = 155,   /* float point size min threshold */
386     D3DRS_POINTSPRITEENABLE         = 156,   /* BOOL point texture coord control */
387     D3DRS_POINTSCALEENABLE          = 157,   /* BOOL point size scale enable */
388     D3DRS_POINTSCALE_A              = 158,   /* float point attenuation A value */
389     D3DRS_POINTSCALE_B              = 159,   /* float point attenuation B value */
390     D3DRS_POINTSCALE_C              = 160,   /* float point attenuation C value */
391     D3DRS_MULTISAMPLEANTIALIAS      = 161,   /* BOOL - set to do FSAA with multisample buffer */
392     D3DRS_MULTISAMPLEMASK           = 162,   /* DWORD - per-sample enable/disable */
393     D3DRS_PATCHEDGESTYLE            = 163,   /* Sets whether patch edges will use float style tessellation */
394     D3DRS_DEBUGMONITORTOKEN         = 165,   /* DEBUG ONLY - token to debug monitor */
395     D3DRS_POINTSIZE_MAX             = 166,   /* float point size max threshold */
396     D3DRS_INDEXEDVERTEXBLENDENABLE  = 167,
397     D3DRS_COLORWRITEENABLE          = 168,   /* per-channel write enable */
398     D3DRS_TWEENFACTOR               = 170,   /* float tween factor */
399     D3DRS_BLENDOP                   = 171,   /* D3DBLENDOP setting */
400     D3DRS_POSITIONDEGREE            = 172,   /* NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) */
401     D3DRS_NORMALDEGREE              = 173,   /* NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC */
402     D3DRS_SCISSORTESTENABLE         = 174,
403     D3DRS_SLOPESCALEDEPTHBIAS       = 175,
404     D3DRS_ANTIALIASEDLINEENABLE     = 176,
405     D3DRS_MINTESSELLATIONLEVEL      = 178,
406     D3DRS_MAXTESSELLATIONLEVEL      = 179,
407     D3DRS_ADAPTIVETESS_X            = 180,
408     D3DRS_ADAPTIVETESS_Y            = 181,
409     D3DRS_ADAPTIVETESS_Z            = 182,
410     D3DRS_ADAPTIVETESS_W            = 183,
411     D3DRS_ENABLEADAPTIVETESSELLATION = 184,
412     D3DRS_TWOSIDEDSTENCILMODE       = 185,   /* BOOL enable/disable 2 sided stenciling */
413     D3DRS_CCW_STENCILFAIL           = 186,   /* D3DSTENCILOP to do if ccw stencil test fails */
414     D3DRS_CCW_STENCILZFAIL          = 187,   /* D3DSTENCILOP to do if ccw stencil test passes and Z test fails */
415     D3DRS_CCW_STENCILPASS           = 188,   /* D3DSTENCILOP to do if both ccw stencil and Z tests pass */
416     D3DRS_CCW_STENCILFUNC           = 189,   /* D3DCMPFUNC fn.  ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
417     D3DRS_COLORWRITEENABLE1         = 190,   /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
418     D3DRS_COLORWRITEENABLE2         = 191,   /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
419     D3DRS_COLORWRITEENABLE3         = 192,   /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */
420     D3DRS_BLENDFACTOR               = 193,   /* D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */
421     D3DRS_SRGBWRITEENABLE           = 194,   /* Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) */
422     D3DRS_DEPTHBIAS                 = 195,
423     D3DRS_WRAP8                     = 198,   /* Additional wrap states for vs_3_0+ attributes with D3DDECLUSAGE_TEXCOORD */
424     D3DRS_WRAP9                     = 199,
425     D3DRS_WRAP10                    = 200,
426     D3DRS_WRAP11                    = 201,
427     D3DRS_WRAP12                    = 202,
428     D3DRS_WRAP13                    = 203,
429     D3DRS_WRAP14                    = 204,
430     D3DRS_WRAP15                    = 205,
431     D3DRS_SEPARATEALPHABLENDENABLE  = 206,  /* TRUE to enable a separate blending function for the alpha channel */
432     D3DRS_SRCBLENDALPHA             = 207,  /* SRC blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
433     D3DRS_DESTBLENDALPHA            = 208,  /* DST blend factor for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
434     D3DRS_BLENDOPALPHA              = 209,  /* Blending operation for the alpha channel when D3DRS_SEPARATEDESTALPHAENABLE is TRUE */
435 
436     D3DRS_FORCE_DWORD               = 0x7fffffff /* force 32-bit size enum */
437 } D3DRENDERSTATETYPE;
438 
439 /* Maximum number of simultaneous render targets D3D supports */
440 #define D3D_MAX_SIMULTANEOUS_RENDERTARGETS 4
441 
442 /* Values for material source */
443 typedef enum _D3DMATERIALCOLORSOURCE
444 {
445     D3DMCS_MATERIAL         = 0,            /* Color from material is used */
446     D3DMCS_COLOR1           = 1,            /* Diffuse vertex color is used */
447     D3DMCS_COLOR2           = 2,            /* Specular vertex color is used */
448     D3DMCS_FORCE_DWORD      = 0x7fffffff    /* force 32-bit size enum */
449 } D3DMATERIALCOLORSOURCE;
450 
451 /* Bias to apply to the texture coordinate set to apply a wrap to. */
452 #define D3DRENDERSTATE_WRAPBIAS                 128UL
453 
454 /* Flags to construct the WRAP render states */
455 #define D3DWRAP_U   0x00000001L
456 #define D3DWRAP_V   0x00000002L
457 #define D3DWRAP_W   0x00000004L
458 
459 /* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */
460 #define D3DWRAPCOORD_0   0x00000001L    /* same as D3DWRAP_U */
461 #define D3DWRAPCOORD_1   0x00000002L    /* same as D3DWRAP_V */
462 #define D3DWRAPCOORD_2   0x00000004L    /* same as D3DWRAP_W */
463 #define D3DWRAPCOORD_3   0x00000008L
464 
465 /* Flags to construct D3DRS_COLORWRITEENABLE */
466 #define D3DCOLORWRITEENABLE_RED     (1L<<0)
467 #define D3DCOLORWRITEENABLE_GREEN   (1L<<1)
468 #define D3DCOLORWRITEENABLE_BLUE    (1L<<2)
469 #define D3DCOLORWRITEENABLE_ALPHA   (1L<<3)
470 
471 /*
472  * State enumerants for per-stage processing of fixed function pixel processing
473  * Two of these affect fixed function vertex processing as well: TEXTURETRANSFORMFLAGS and TEXCOORDINDEX.
474  */
475 typedef enum _D3DTEXTURESTAGESTATETYPE
476 {
477     D3DTSS_COLOROP        =  1, /* D3DTEXTUREOP - per-stage blending controls for color channels */
478     D3DTSS_COLORARG1      =  2, /* D3DTA_* (texture arg) */
479     D3DTSS_COLORARG2      =  3, /* D3DTA_* (texture arg) */
480     D3DTSS_ALPHAOP        =  4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */
481     D3DTSS_ALPHAARG1      =  5, /* D3DTA_* (texture arg) */
482     D3DTSS_ALPHAARG2      =  6, /* D3DTA_* (texture arg) */
483     D3DTSS_BUMPENVMAT00   =  7, /* float (bump mapping matrix) */
484     D3DTSS_BUMPENVMAT01   =  8, /* float (bump mapping matrix) */
485     D3DTSS_BUMPENVMAT10   =  9, /* float (bump mapping matrix) */
486     D3DTSS_BUMPENVMAT11   = 10, /* float (bump mapping matrix) */
487     D3DTSS_TEXCOORDINDEX  = 11, /* identifies which set of texture coordinates index this texture */
488     D3DTSS_BUMPENVLSCALE  = 22, /* float scale for bump map luminance */
489     D3DTSS_BUMPENVLOFFSET = 23, /* float offset for bump map luminance */
490     D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */
491     D3DTSS_COLORARG0      = 26, /* D3DTA_* third arg for triadic ops */
492     D3DTSS_ALPHAARG0      = 27, /* D3DTA_* third arg for triadic ops */
493     D3DTSS_RESULTARG      = 28, /* D3DTA_* arg for result (CURRENT or TEMP) */
494     D3DTSS_CONSTANT       = 32, /* Per-stage constant D3DTA_CONSTANT */
495 
496     D3DTSS_FORCE_DWORD   = 0x7fffffff /* force 32-bit size enum */
497 } D3DTEXTURESTAGESTATETYPE;
498 
499 /*
500  * State enumerants for per-sampler texture processing.
501  */
502 typedef enum _D3DSAMPLERSTATETYPE
503 {
504     D3DSAMP_ADDRESSU       = 1,  /* D3DTEXTUREADDRESS for U coordinate */
505     D3DSAMP_ADDRESSV       = 2,  /* D3DTEXTUREADDRESS for V coordinate */
506     D3DSAMP_ADDRESSW       = 3,  /* D3DTEXTUREADDRESS for W coordinate */
507     D3DSAMP_BORDERCOLOR    = 4,  /* D3DCOLOR */
508     D3DSAMP_MAGFILTER      = 5,  /* D3DTEXTUREFILTER filter to use for magnification */
509     D3DSAMP_MINFILTER      = 6,  /* D3DTEXTUREFILTER filter to use for minification */
510     D3DSAMP_MIPFILTER      = 7,  /* D3DTEXTUREFILTER filter to use between mipmaps during minification */
511     D3DSAMP_MIPMAPLODBIAS  = 8,  /* float Mipmap LOD bias */
512     D3DSAMP_MAXMIPLEVEL    = 9,  /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */
513     D3DSAMP_MAXANISOTROPY  = 10, /* DWORD maximum anisotropy */
514     D3DSAMP_SRGBTEXTURE    = 11, /* Default = 0 (which means Gamma 1.0,
515                                    no correction required.) else correct for
516                                    Gamma = 2.2 */
517     D3DSAMP_ELEMENTINDEX   = 12, /* When multi-element texture is assigned to sampler, this
518                                     indicates which element index to use.  Default = 0.  */
519     D3DSAMP_DMAPOFFSET     = 13, /* Offset in vertices in the pre-sampled displacement map.
520                                     Only valid for D3DDMAPSAMPLER sampler  */
521     D3DSAMP_FORCE_DWORD   = 0x7fffffff /* force 32-bit size enum */
522 } D3DSAMPLERSTATETYPE;
523 
524 /* Special sampler which is used in the tesselator */
525 #define D3DDMAPSAMPLER 256
526 
527 /* Samplers used in vertex shaders */
528 #define D3DVERTEXTEXTURESAMPLER0 (D3DDMAPSAMPLER+1)
529 #define D3DVERTEXTEXTURESAMPLER1 (D3DDMAPSAMPLER+2)
530 #define D3DVERTEXTEXTURESAMPLER2 (D3DDMAPSAMPLER+3)
531 #define D3DVERTEXTEXTURESAMPLER3 (D3DDMAPSAMPLER+4)
532 
533 /* Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position
534  * and normal in the camera space) should be taken as texture coordinates
535  * Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from
536 */
537 #define D3DTSS_TCI_PASSTHRU                             0x00000000
538 #define D3DTSS_TCI_CAMERASPACENORMAL                    0x00010000
539 #define D3DTSS_TCI_CAMERASPACEPOSITION                  0x00020000
540 #define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR          0x00030000
541 #define D3DTSS_TCI_SPHEREMAP                            0x00040000
542 
543 /*
544  * Enumerations for COLOROP and ALPHAOP texture blending operations set in
545  * texture processing stage controls in D3DTSS.
546  */
547 typedef enum _D3DTEXTUREOP
548 {
549     /* Control */
550     D3DTOP_DISABLE              = 1,      /* disables stage */
551     D3DTOP_SELECTARG1           = 2,      /* the default */
552     D3DTOP_SELECTARG2           = 3,
553 
554     /* Modulate */
555     D3DTOP_MODULATE             = 4,      /* multiply args together */
556     D3DTOP_MODULATE2X           = 5,      /* multiply and  1 bit */
557     D3DTOP_MODULATE4X           = 6,      /* multiply and  2 bits */
558 
559     /* Add */
560     D3DTOP_ADD                  =  7,   /* add arguments together */
561     D3DTOP_ADDSIGNED            =  8,   /* add with -0.5 bias */
562     D3DTOP_ADDSIGNED2X          =  9,   /* as above but left  1 bit */
563     D3DTOP_SUBTRACT             = 10,   /* Arg1 - Arg2, with no saturation */
564     D3DTOP_ADDSMOOTH            = 11,   /* add 2 args, subtract product */
565                                         /* Arg1 + Arg2 - Arg1*Arg2 */
566                                         /* = Arg1 + (1-Arg1)*Arg2 */
567 
568     /* Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) */
569     D3DTOP_BLENDDIFFUSEALPHA    = 12, /* iterated alpha */
570     D3DTOP_BLENDTEXTUREALPHA    = 13, /* texture alpha */
571     D3DTOP_BLENDFACTORALPHA     = 14, /* alpha from D3DRS_TEXTUREFACTOR */
572 
573     /* Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) */
574     D3DTOP_BLENDTEXTUREALPHAPM  = 15, /* texture alpha */
575     D3DTOP_BLENDCURRENTALPHA    = 16, /* by alpha of current color */
576 
577     /* Specular mapping */
578     D3DTOP_PREMODULATE            = 17,     /* modulate with next texture before use */
579     D3DTOP_MODULATEALPHA_ADDCOLOR = 18,     /* Arg1.RGB + Arg1.A*Arg2.RGB
580                                              * COLOROP only */
581     D3DTOP_MODULATECOLOR_ADDALPHA = 19,     /* Arg1.RGB*Arg2.RGB + Arg1.A
582                                              * COLOROP only */
583     D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,  /* (1-Arg1.A)*Arg2.RGB + Arg1.RGB
584                                              * COLOROP only */
585     D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,  /* (1-Arg1.RGB)*Arg2.RGB + Arg1.A
586                                              * COLOROP only */
587 
588     /* Bump mapping */
589     D3DTOP_BUMPENVMAP           = 22, /* per pixel env map perturbation */
590     D3DTOP_BUMPENVMAPLUMINANCE  = 23, /* with luminance channel */
591 
592     /* This can do either diffuse or specular bump mapping with correct input.
593      * Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
594      * where each component has been scaled and offset to make it signed.
595      * The result is replicated into all four (including alpha) channels.
596      * This is a valid COLOROP only.
597      */
598     D3DTOP_DOTPRODUCT3          = 24,
599 
600     /* Triadic ops */
601     D3DTOP_MULTIPLYADD          = 25, /* Arg0 + Arg1*Arg2 */
602     D3DTOP_LERP                 = 26, /* (Arg0)*Arg1 + (1-Arg0)*Arg2 */
603 
604     D3DTOP_FORCE_DWORD = 0x7fffffff
605 } D3DTEXTUREOP;
606 
607 /*
608  * Values for COLORARG0,1,2, ALPHAARG0,1,2, and RESULTARG texture blending
609  * operations set in texture processing stage controls in D3DRENDERSTATE.
610  */
611 #define D3DTA_SELECTMASK        0x0000000f  /* mask for arg selector */
612 #define D3DTA_DIFFUSE           0x00000000  /* select diffuse color (read only) */
613 #define D3DTA_CURRENT           0x00000001  /* select stage destination register (read/write) */
614 #define D3DTA_TEXTURE           0x00000002  /* select texture color (read only) */
615 #define D3DTA_TFACTOR           0x00000003  /* select D3DRS_TEXTUREFACTOR (read only) */
616 #define D3DTA_SPECULAR          0x00000004  /* select specular color (read only) */
617 #define D3DTA_TEMP              0x00000005  /* select temporary register color (read/write) */
618 #define D3DTA_CONSTANT          0x00000006  /* select texture stage constant */
619 #define D3DTA_COMPLEMENT        0x00000010  /* take 1.0 - x (read modifier) */
620 #define D3DTA_ALPHAREPLICATE    0x00000020  /* replicate alpha to color components (read modifier) */
621 
622 /* Values for D3DSAMP_***FILTER texture stage states */
623 typedef enum _D3DTEXTUREFILTERTYPE
624 {
625     D3DTEXF_NONE            = 0,    /* filtering disabled (valid for mip filter only) */
626     D3DTEXF_POINT           = 1,    /* nearest */
627     D3DTEXF_LINEAR          = 2,    /* linear interpolation */
628     D3DTEXF_ANISOTROPIC     = 3,    /* anisotropic */
629     D3DTEXF_PYRAMIDALQUAD   = 6,    /* 4-sample tent */
630     D3DTEXF_GAUSSIANQUAD    = 7,    /* 4-sample gaussian */
631 
632        /* D3D9Ex only -- */
633 #if !defined(D3D_DISABLE_9EX)
634 
635     D3DTEXF_CONVOLUTIONMONO = 8,    /* Convolution filter for monochrome textures */
636 
637 #endif /* !D3D_DISABLE_9EX */
638 /* -- D3D9Ex only */
639     D3DTEXF_FORCE_DWORD     = 0x7fffffff   /* force 32-bit size enum */
640 } D3DTEXTUREFILTERTYPE;
641 
642 /* Bits for Flags in ProcessVertices call */
643 
644 #define D3DPV_DONOTCOPYDATA     (1 << 0)
645 
646 /*------------------------------------------------------------------- */
647 
648 /* Flexible vertex format bits */
649 #define D3DFVF_RESERVED0        0x001
650 #define D3DFVF_POSITION_MASK    0x400E
651 #define D3DFVF_XYZ              0x002
652 #define D3DFVF_XYZRHW           0x004
653 #define D3DFVF_XYZB1            0x006
654 #define D3DFVF_XYZB2            0x008
655 #define D3DFVF_XYZB3            0x00a
656 #define D3DFVF_XYZB4            0x00c
657 #define D3DFVF_XYZB5            0x00e
658 #define D3DFVF_XYZW             0x4002
659 
660 #define D3DFVF_NORMAL           0x010
661 #define D3DFVF_PSIZE            0x020
662 #define D3DFVF_DIFFUSE          0x040
663 #define D3DFVF_SPECULAR         0x080
664 
665 #define D3DFVF_TEXCOUNT_MASK    0xf00
666 #define D3DFVF_TEXCOUNT_SHIFT   8
667 #define D3DFVF_TEX0             0x000
668 #define D3DFVF_TEX1             0x100
669 #define D3DFVF_TEX2             0x200
670 #define D3DFVF_TEX3             0x300
671 #define D3DFVF_TEX4             0x400
672 #define D3DFVF_TEX5             0x500
673 #define D3DFVF_TEX6             0x600
674 #define D3DFVF_TEX7             0x700
675 #define D3DFVF_TEX8             0x800
676 
677 #define D3DFVF_LASTBETA_UBYTE4   0x1000
678 #define D3DFVF_LASTBETA_D3DCOLOR 0x8000
679 
680 #define D3DFVF_RESERVED2         0x6000  /* 2 reserved bits */
681 
682 /*---------------------------------------------------------------------
683  * Vertex Shaders
684 */
685 
686 /* Vertex shader declaration */
687 
688 /* Vertex element semantics */
689 typedef enum _D3DDECLUSAGE
690 {
691     D3DDECLUSAGE_POSITION = 0,
692     D3DDECLUSAGE_BLENDWEIGHT,   /* 1 */
693     D3DDECLUSAGE_BLENDINDICES,  /* 2 */
694     D3DDECLUSAGE_NORMAL,        /* 3 */
695     D3DDECLUSAGE_PSIZE,         /* 4 */
696     D3DDECLUSAGE_TEXCOORD,      /* 5 */
697     D3DDECLUSAGE_TANGENT,       /* 6 */
698     D3DDECLUSAGE_BINORMAL,      /* 7 */
699     D3DDECLUSAGE_TESSFACTOR,    /* 8 */
700     D3DDECLUSAGE_POSITIONT,     /* 9 */
701     D3DDECLUSAGE_COLOR,         /* 10 */
702     D3DDECLUSAGE_FOG,           /* 11 */
703     D3DDECLUSAGE_DEPTH,         /* 12 */
704     D3DDECLUSAGE_SAMPLE         /* 13 */
705 } D3DDECLUSAGE;
706 
707 #define MAXD3DDECLUSAGE         D3DDECLUSAGE_SAMPLE
708 #define MAXD3DDECLUSAGEINDEX    15
709 #define MAXD3DDECLLENGTH        64 /* does not include "end" marker vertex element */
710 
711 typedef enum _D3DDECLMETHOD
712 {
713     D3DDECLMETHOD_DEFAULT = 0,
714     D3DDECLMETHOD_PARTIALU,
715     D3DDECLMETHOD_PARTIALV,
716     D3DDECLMETHOD_CROSSUV,    /* Normal */
717     D3DDECLMETHOD_UV,
718     D3DDECLMETHOD_LOOKUP,               /* Lookup a displacement map */
719     D3DDECLMETHOD_LOOKUPPRESAMPLED      /* Lookup a pre-sampled displacement map */
720 } D3DDECLMETHOD;
721 
722 #define MAXD3DDECLMETHOD D3DDECLMETHOD_LOOKUPPRESAMPLED
723 
724 /* Declarations for _Type fields */
725 typedef enum _D3DDECLTYPE
726 {
727     D3DDECLTYPE_FLOAT1    =  0,  /* 1D float expanded to (value, 0., 0., 1.) */
728     D3DDECLTYPE_FLOAT2    =  1,  /* 2D float expanded to (value, value, 0., 1.) */
729     D3DDECLTYPE_FLOAT3    =  2,  /* 3D float expanded to (value, value, value, 1.) */
730     D3DDECLTYPE_FLOAT4    =  3,  /* 4D float */
731     D3DDECLTYPE_D3DCOLOR  =  4,  /* 4D packed unsigned bytes mapped to 0. to 1. range */
732                                  /* Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A) */
733     D3DDECLTYPE_UBYTE4    =  5,  /* 4D unsigned byte */
734     D3DDECLTYPE_SHORT2    =  6,  /* 2D signed short expanded to (value, value, 0., 1.) */
735     D3DDECLTYPE_SHORT4    =  7,  /* 4D signed short */
736 
737     /* The following types are valid only with vertex shaders >= 2.0 */
738 
739     D3DDECLTYPE_UBYTE4N   =  8,  /* Each of 4 bytes is normalized by dividing to 255.0 */
740     D3DDECLTYPE_SHORT2N   =  9,  /* 2D signed short normalized (v[0]/32767.0,v[1]/32767.0,0,1) */
741     D3DDECLTYPE_SHORT4N   = 10,  /* 4D signed short normalized (v[0]/32767.0,v[1]/32767.0,v[2]/32767.0,v[3]/32767.0) */
742     D3DDECLTYPE_USHORT2N  = 11,  /* 2D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,0,1) */
743     D3DDECLTYPE_USHORT4N  = 12,  /* 4D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,v[2]/65535.0,v[3]/65535.0) */
744     D3DDECLTYPE_UDEC3     = 13,  /* 3D unsigned 10 10 10 format expanded to (value, value, value, 1) */
745     D3DDECLTYPE_DEC3N     = 14,  /* 3D signed 10 10 10 format normalized and expanded to (v[0]/511.0, v[1]/511.0, v[2]/511.0, 1) */
746     D3DDECLTYPE_FLOAT16_2 = 15,  /* Two 16-bit floating point values, expanded to (value, value, 0, 1) */
747     D3DDECLTYPE_FLOAT16_4 = 16,  /* Four 16-bit floating point values */
748     D3DDECLTYPE_UNUSED    = 17   /* When the type field in a decl is unused. */
749 } D3DDECLTYPE;
750 
751 #define MAXD3DDECLTYPE      D3DDECLTYPE_UNUSED
752 
753 typedef struct _D3DVERTEXELEMENT9
754 {
755     WORD    Stream;     /* Stream index */
756     WORD    Offset;     /* Offset in the stream in bytes */
757     BYTE    Type;       /* Data type */
758     BYTE    Method;     /* Processing method */
759     BYTE    Usage;      /* Semantics */
760     BYTE    UsageIndex; /* Semantic index */
761 } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9;
762 
763 /* This is used to initialize the last vertex element in a vertex declaration
764  * array */
765 #define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0}
766 
767 /* Maximum supported number of texture coordinate sets */
768 #define D3DDP_MAXTEXCOORD   8
769 
770 /*---------------------------------------------------------------------
771  * Values for IDirect3DDevice9::SetStreamSourceFreq's Setting parameter
772  *---------------------------------------------------------------------
773  */
774 #define D3DSTREAMSOURCE_INDEXEDDATA  (1<<30)
775 #define D3DSTREAMSOURCE_INSTANCEDATA (2<<30)
776 
777 /*---------------------------------------------------------------------
778  *
779  * The internal format of Pixel Shader (PS) & Vertex Shader (VS)
780  * Instruction Tokens is defined in the Direct3D Device Driver Kit
781  *
782  *---------------------------------------------------------------------
783  */
784 
785 /* Instruction Token Bit Definitions */
786 #define D3DSI_OPCODE_MASK       0x0000FFFF
787 
788 #define D3DSI_INSTLENGTH_MASK   0x0F000000
789 #define D3DSI_INSTLENGTH_SHIFT  24
790 
791 typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE
792 {
793     D3DSIO_NOP          = 0,
794     D3DSIO_MOV          ,
795     D3DSIO_ADD          ,
796     D3DSIO_SUB          ,
797     D3DSIO_MAD          ,
798     D3DSIO_MUL          ,
799     D3DSIO_RCP          ,
800     D3DSIO_RSQ          ,
801     D3DSIO_DP3          ,
802     D3DSIO_DP4          ,
803     D3DSIO_MIN          ,
804     D3DSIO_MAX          ,
805     D3DSIO_SLT          ,
806     D3DSIO_SGE          ,
807     D3DSIO_EXP          ,
808     D3DSIO_LOG          ,
809     D3DSIO_LIT          ,
810     D3DSIO_DST          ,
811     D3DSIO_LRP          ,
812     D3DSIO_FRC          ,
813     D3DSIO_M4x4         ,
814     D3DSIO_M4x3         ,
815     D3DSIO_M3x4         ,
816     D3DSIO_M3x3         ,
817     D3DSIO_M3x2         ,
818     D3DSIO_CALL         ,
819     D3DSIO_CALLNZ       ,
820     D3DSIO_LOOP         ,
821     D3DSIO_RET          ,
822     D3DSIO_ENDLOOP      ,
823     D3DSIO_LABEL        ,
824     D3DSIO_DCL          ,
825     D3DSIO_POW          ,
826     D3DSIO_CRS          ,
827     D3DSIO_SGN          ,
828     D3DSIO_ABS          ,
829     D3DSIO_NRM          ,
830     D3DSIO_SINCOS       ,
831     D3DSIO_REP          ,
832     D3DSIO_ENDREP       ,
833     D3DSIO_IF           ,
834     D3DSIO_IFC          ,
835     D3DSIO_ELSE         ,
836     D3DSIO_ENDIF        ,
837     D3DSIO_BREAK        ,
838     D3DSIO_BREAKC       ,
839     D3DSIO_MOVA         ,
840     D3DSIO_DEFB         ,
841     D3DSIO_DEFI         ,
842 
843     D3DSIO_TEXCOORD     = 64,
844     D3DSIO_TEXKILL      ,
845     D3DSIO_TEX          ,
846     D3DSIO_TEXBEM       ,
847     D3DSIO_TEXBEML      ,
848     D3DSIO_TEXREG2AR    ,
849     D3DSIO_TEXREG2GB    ,
850     D3DSIO_TEXM3x2PAD   ,
851     D3DSIO_TEXM3x2TEX   ,
852     D3DSIO_TEXM3x3PAD   ,
853     D3DSIO_TEXM3x3TEX   ,
854     D3DSIO_RESERVED0    ,
855     D3DSIO_TEXM3x3SPEC  ,
856     D3DSIO_TEXM3x3VSPEC ,
857     D3DSIO_EXPP         ,
858     D3DSIO_LOGP         ,
859     D3DSIO_CND          ,
860     D3DSIO_DEF          ,
861     D3DSIO_TEXREG2RGB   ,
862     D3DSIO_TEXDP3TEX    ,
863     D3DSIO_TEXM3x2DEPTH ,
864     D3DSIO_TEXDP3       ,
865     D3DSIO_TEXM3x3      ,
866     D3DSIO_TEXDEPTH     ,
867     D3DSIO_CMP          ,
868     D3DSIO_BEM          ,
869     D3DSIO_DP2ADD       ,
870     D3DSIO_DSX          ,
871     D3DSIO_DSY          ,
872     D3DSIO_TEXLDD       ,
873     D3DSIO_SETP         ,
874     D3DSIO_TEXLDL       ,
875     D3DSIO_BREAKP       ,
876 
877     D3DSIO_PHASE        = 0xFFFD,
878     D3DSIO_COMMENT      = 0xFFFE,
879     D3DSIO_END          = 0xFFFF,
880 
881     D3DSIO_FORCE_DWORD  = 0x7fffffff   /* force 32-bit size enum */
882 } D3DSHADER_INSTRUCTION_OPCODE_TYPE;
883 
884 /*---------------------------------------------------------------------
885  * Use these constants with D3DSIO_SINCOS macro as SRC2, SRC3
886  */
887 #define D3DSINCOSCONST1 -1.5500992e-006f, -2.1701389e-005f,  0.0026041667f, 0.00026041668f
888 #define D3DSINCOSCONST2 -0.020833334f, -0.12500000f, 1.0f, 0.50000000f
889 
890 /*---------------------------------------------------------------------
891  * Co-Issue Instruction Modifier - if set then this instruction is to be
892  * issued in parallel with the previous instruction(s) for which this bit
893  * is not set.
894  */
895 #define D3DSI_COISSUE           0x40000000
896 
897 /*---------------------------------------------------------------------
898  * Opcode specific controls
899  */
900 
901 #define D3DSP_OPCODESPECIFICCONTROL_MASK  0x00ff0000
902 #define D3DSP_OPCODESPECIFICCONTROL_SHIFT 16
903 
904 /* ps_2_0 texld controls */
905 #define D3DSI_TEXLD_PROJECT (0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT)
906 #define D3DSI_TEXLD_BIAS    (0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT)
907 
908 /* Comparison for dynamic conditional instruction opcodes (i.e. if, breakc) */
909 typedef enum _D3DSHADER_COMPARISON
910 {
911                          /* < = > */
912     D3DSPC_RESERVED0= 0, /* 0 0 0 */
913     D3DSPC_GT       = 1, /* 0 0 1 */
914     D3DSPC_EQ       = 2, /* 0 1 0 */
915     D3DSPC_GE       = 3, /* 0 1 1 */
916     D3DSPC_LT       = 4, /* 1 0 0 */
917     D3DSPC_NE       = 5, /* 1 0 1 */
918     D3DSPC_LE       = 6, /* 1 1 0 */
919     D3DSPC_RESERVED1= 7  /* 1 1 1 */
920 } D3DSHADER_COMPARISON;
921 
922 /* Comparison is part of instruction opcode token: */
923 #define D3DSHADER_COMPARISON_SHIFT D3DSP_OPCODESPECIFICCONTROL_SHIFT
924 #define D3DSHADER_COMPARISON_MASK  (0x7<<D3DSHADER_COMPARISON_SHIFT)
925 
926 /*---------------------------------------------------------------------
927  * Predication flags on instruction token */
928 #define D3DSHADER_INSTRUCTION_PREDICATED    (0x1 << 28)
929 
930 /*---------------------------------------------------------------------
931  * DCL Info Token Controls */
932 
933 /* For dcl info tokens requiring a semantic (usage + index) */
934 #define D3DSP_DCL_USAGE_SHIFT 0
935 #define D3DSP_DCL_USAGE_MASK  0x0000000f
936 
937 #define D3DSP_DCL_USAGEINDEX_SHIFT 16
938 #define D3DSP_DCL_USAGEINDEX_MASK  0x000f0000
939 
940 /* DCL pixel shader sampler info token. */
941 #define D3DSP_TEXTURETYPE_SHIFT 27
942 #define D3DSP_TEXTURETYPE_MASK  0x78000000
943 
944 typedef enum _D3DSAMPLER_TEXTURE_TYPE
945 {
946     D3DSTT_UNKNOWN = 0<<D3DSP_TEXTURETYPE_SHIFT, /* uninitialized value */
947     D3DSTT_2D      = 2<<D3DSP_TEXTURETYPE_SHIFT, /* dcl_2d s# (for declaring a 2-D texture) */
948     D3DSTT_CUBE    = 3<<D3DSP_TEXTURETYPE_SHIFT, /* dcl_cube s# (for declaring a cube texture) */
949     D3DSTT_VOLUME  = 4<<D3DSP_TEXTURETYPE_SHIFT, /* dcl_volume s# (for declaring a volume texture) */
950     D3DSTT_FORCE_DWORD  = 0x7fffffff             /* force 32-bit size enum */
951 } D3DSAMPLER_TEXTURE_TYPE;
952 
953 /*---------------------------------------------------------------------
954  * Parameter Token Bit Definitions
955  */
956 #define D3DSP_REGNUM_MASK       0x000007FF
957 
958 /* destination parameter write mask */
959 #define D3DSP_WRITEMASK_0       0x00010000  /* Component 0 (X;Red) */
960 #define D3DSP_WRITEMASK_1       0x00020000  /* Component 1 (Y;Green) */
961 #define D3DSP_WRITEMASK_2       0x00040000  /* Component 2 (Z;Blue) */
962 #define D3DSP_WRITEMASK_3       0x00080000  /* Component 3 (W;Alpha) */
963 #define D3DSP_WRITEMASK_ALL     0x000F0000  /* All Components */
964 
965 /* destination parameter modifiers */
966 #define D3DSP_DSTMOD_SHIFT      20
967 #define D3DSP_DSTMOD_MASK       0x00F00000
968 
969 /* Bit masks for destination parameter modifiers */
970 #define    D3DSPDM_NONE                 (0<<D3DSP_DSTMOD_SHIFT) /* nop */
971 #define    D3DSPDM_SATURATE             (1<<D3DSP_DSTMOD_SHIFT) /* clamp to 0. to 1. range */
972 #define    D3DSPDM_PARTIALPRECISION     (2<<D3DSP_DSTMOD_SHIFT) /* Partial precision hint */
973 #define    D3DSPDM_MSAMPCENTROID        (4<<D3DSP_DSTMOD_SHIFT) /* Relevant to multisampling only: */
974                                                                 /*      When the pixel center is not covered, sample */
975                                                                 /*      attribute or compute gradients/LOD */
976                                                                 /*      using multisample "centroid" location. */
977                                                                 /*      "Centroid" is some location within the covered */
978                                                                 /*      region of the pixel. */
979 
980 /* destination parameter  */
981 #define D3DSP_DSTSHIFT_SHIFT    24
982 #define D3DSP_DSTSHIFT_MASK     0x0F000000
983 
984 /* destination/source parameter register type */
985 #define D3DSP_REGTYPE_SHIFT     28
986 #define D3DSP_REGTYPE_SHIFT2    8
987 #define D3DSP_REGTYPE_MASK      0x70000000
988 #define D3DSP_REGTYPE_MASK2     0x00001800
989 
990 typedef enum _D3DSHADER_PARAM_REGISTER_TYPE
991 {
992     D3DSPR_TEMP           =  0, /* Temporary Register File */
993     D3DSPR_INPUT          =  1, /* Input Register File */
994     D3DSPR_CONST          =  2, /* Constant Register File */
995     D3DSPR_ADDR           =  3, /* Address Register (VS) */
996     D3DSPR_TEXTURE        =  3, /* Texture Register File (PS) */
997     D3DSPR_RASTOUT        =  4, /* Rasterizer Register File */
998     D3DSPR_ATTROUT        =  5, /* Attribute Output Register File */
999     D3DSPR_TEXCRDOUT      =  6, /* Texture Coordinate Output Register File */
1000     D3DSPR_OUTPUT         =  6, /* Output register file for VS3.0+ */
1001     D3DSPR_CONSTINT       =  7, /* Constant Integer Vector Register File */
1002     D3DSPR_COLOROUT       =  8, /* Color Output Register File */
1003     D3DSPR_DEPTHOUT       =  9, /* Depth Output Register File */
1004     D3DSPR_SAMPLER        = 10, /* Sampler State Register File */
1005     D3DSPR_CONST2         = 11, /* Constant Register File  2048 - 4095 */
1006     D3DSPR_CONST3         = 12, /* Constant Register File  4096 - 6143 */
1007     D3DSPR_CONST4         = 13, /* Constant Register File  6144 - 8191 */
1008     D3DSPR_CONSTBOOL      = 14, /* Constant Boolean register file */
1009     D3DSPR_LOOP           = 15, /* Loop counter register file */
1010     D3DSPR_TEMPFLOAT16    = 16, /* 16-bit float temp register file */
1011     D3DSPR_MISCTYPE       = 17, /* Miscellaneous (single) registers. */
1012     D3DSPR_LABEL          = 18, /* Label */
1013     D3DSPR_PREDICATE      = 19, /* Predicate register */
1014     D3DSPR_FORCE_DWORD  = 0x7fffffff          /* force 32-bit size enum */
1015 } D3DSHADER_PARAM_REGISTER_TYPE;
1016 
1017 /* The miscellaneous register file (D3DSPR_MISCTYPES)
1018  * contains register types for which there is only ever one
1019  * register (i.e. the register # is not needed).
1020  * Rather than use up additional register types for such
1021  * registers, they are defined
1022  * as particular offsets into the misc. register file:
1023  */
1024 
1025 typedef enum _D3DSHADER_MISCTYPE_OFFSETS
1026 {
1027     D3DSMO_POSITION   = 0, /* Input position x,y,z,rhw (PS) */
1028     D3DSMO_FACE       = 1  /* Floating point primitive area (PS) */
1029 } D3DSHADER_MISCTYPE_OFFSETS;
1030 
1031 /* Register offsets in the Rasterizer Register File */
1032 typedef enum _D3DVS_RASTOUT_OFFSETS
1033 {
1034     D3DSRO_POSITION = 0,
1035     D3DSRO_FOG,
1036     D3DSRO_POINT_SIZE,
1037     D3DSRO_FORCE_DWORD  = 0x7fffffff         /* force 32-bit size enum */
1038 } D3DVS_RASTOUT_OFFSETS;
1039 
1040 /* Source operand addressing modes */
1041 
1042 #define D3DVS_ADDRESSMODE_SHIFT 13
1043 #define D3DVS_ADDRESSMODE_MASK  (1 << D3DVS_ADDRESSMODE_SHIFT)
1044 
1045 typedef enum _D3DVS_ADDRESSMODE_TYPE
1046 {
1047     D3DVS_ADDRMODE_ABSOLUTE  = (0 << D3DVS_ADDRESSMODE_SHIFT),
1048     D3DVS_ADDRMODE_RELATIVE  = (1 << D3DVS_ADDRESSMODE_SHIFT),
1049     D3DVS_ADDRMODE_FORCE_DWORD = 0x7fffffff  /* force 32-bit size enum */
1050 } D3DVS_ADDRESSMODE_TYPE;
1051 
1052 #define D3DSHADER_ADDRESSMODE_SHIFT 13
1053 #define D3DSHADER_ADDRESSMODE_MASK  (1 << D3DSHADER_ADDRESSMODE_SHIFT)
1054 
1055 typedef enum _D3DSHADER_ADDRESSMODE_TYPE
1056 {
1057     D3DSHADER_ADDRMODE_ABSOLUTE  = (0 << D3DSHADER_ADDRESSMODE_SHIFT),
1058     D3DSHADER_ADDRMODE_RELATIVE  = (1 << D3DSHADER_ADDRESSMODE_SHIFT),
1059     D3DSHADER_ADDRMODE_FORCE_DWORD = 0x7fffffff  /* force 32-bit size enum */
1060 } D3DSHADER_ADDRESSMODE_TYPE;
1061 
1062 /* Source operand swizzle definitions */
1063 #define D3DVS_SWIZZLE_SHIFT     16
1064 #define D3DVS_SWIZZLE_MASK      0x00FF0000
1065 
1066 /* The following bits define where to take component X from: */
1067 
1068 #define D3DVS_X_X       (0 << D3DVS_SWIZZLE_SHIFT)
1069 #define D3DVS_X_Y       (1 << D3DVS_SWIZZLE_SHIFT)
1070 #define D3DVS_X_Z       (2 << D3DVS_SWIZZLE_SHIFT)
1071 #define D3DVS_X_W       (3 << D3DVS_SWIZZLE_SHIFT)
1072 
1073 /* The following bits define where to take component Y from: */
1074 
1075 #define D3DVS_Y_X       (0 << (D3DVS_SWIZZLE_SHIFT + 2))
1076 #define D3DVS_Y_Y       (1 << (D3DVS_SWIZZLE_SHIFT + 2))
1077 #define D3DVS_Y_Z       (2 << (D3DVS_SWIZZLE_SHIFT + 2))
1078 #define D3DVS_Y_W       (3 << (D3DVS_SWIZZLE_SHIFT + 2))
1079 
1080 /* The following bits define where to take component Z from: */
1081 
1082 #define D3DVS_Z_X       (0 << (D3DVS_SWIZZLE_SHIFT + 4))
1083 #define D3DVS_Z_Y       (1 << (D3DVS_SWIZZLE_SHIFT + 4))
1084 #define D3DVS_Z_Z       (2 << (D3DVS_SWIZZLE_SHIFT + 4))
1085 #define D3DVS_Z_W       (3 << (D3DVS_SWIZZLE_SHIFT + 4))
1086 
1087 /* The following bits define where to take component W from: */
1088 
1089 #define D3DVS_W_X       (0 << (D3DVS_SWIZZLE_SHIFT + 6))
1090 #define D3DVS_W_Y       (1 << (D3DVS_SWIZZLE_SHIFT + 6))
1091 #define D3DVS_W_Z       (2 << (D3DVS_SWIZZLE_SHIFT + 6))
1092 #define D3DVS_W_W       (3 << (D3DVS_SWIZZLE_SHIFT + 6))
1093 
1094 /* Value when there is no swizzle (X is taken from X, Y is taken from Y,
1095  * Z is taken from Z, W is taken from W
1096  */
1097 #define D3DVS_NOSWIZZLE (D3DVS_X_X | D3DVS_Y_Y | D3DVS_Z_Z | D3DVS_W_W)
1098 
1099 /* source parameter swizzle */
1100 #define D3DSP_SWIZZLE_SHIFT     16
1101 #define D3DSP_SWIZZLE_MASK      0x00FF0000
1102 
1103 #define D3DSP_NOSWIZZLE \
1104     ( (0 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
1105       (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
1106       (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
1107       (3 << (D3DSP_SWIZZLE_SHIFT + 6)) )
1108 
1109 /* pixel-shader swizzle ops */
1110 #define D3DSP_REPLICATERED \
1111     ( (0 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
1112       (0 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
1113       (0 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
1114       (0 << (D3DSP_SWIZZLE_SHIFT + 6)) )
1115 
1116 #define D3DSP_REPLICATEGREEN \
1117     ( (1 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
1118       (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
1119       (1 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
1120       (1 << (D3DSP_SWIZZLE_SHIFT + 6)) )
1121 
1122 #define D3DSP_REPLICATEBLUE \
1123     ( (2 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
1124       (2 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
1125       (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
1126       (2 << (D3DSP_SWIZZLE_SHIFT + 6)) )
1127 
1128 #define D3DSP_REPLICATEALPHA \
1129     ( (3 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
1130       (3 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
1131       (3 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
1132       (3 << (D3DSP_SWIZZLE_SHIFT + 6)) )
1133 
1134 /* source parameter modifiers */
1135 #define D3DSP_SRCMOD_SHIFT      24
1136 #define D3DSP_SRCMOD_MASK       0x0F000000
1137 
1138 typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE
1139 {
1140     D3DSPSM_NONE    = 0<<D3DSP_SRCMOD_SHIFT,  /* NOP */
1141     D3DSPSM_NEG     = 1<<D3DSP_SRCMOD_SHIFT,  /* negate */
1142     D3DSPSM_BIAS    = 2<<D3DSP_SRCMOD_SHIFT,  /* bias */
1143     D3DSPSM_BIASNEG = 3<<D3DSP_SRCMOD_SHIFT,  /* bias and negate */
1144     D3DSPSM_SIGN    = 4<<D3DSP_SRCMOD_SHIFT,  /* sign */
1145     D3DSPSM_SIGNNEG = 5<<D3DSP_SRCMOD_SHIFT,  /* sign and negate */
1146     D3DSPSM_COMP    = 6<<D3DSP_SRCMOD_SHIFT,  /* complement */
1147     D3DSPSM_X2      = 7<<D3DSP_SRCMOD_SHIFT,  /* *2 */
1148     D3DSPSM_X2NEG   = 8<<D3DSP_SRCMOD_SHIFT,  /* *2 and negate */
1149     D3DSPSM_DZ      = 9<<D3DSP_SRCMOD_SHIFT,  /* divide through by z component */
1150     D3DSPSM_DW      = 10<<D3DSP_SRCMOD_SHIFT, /* divide through by w component */
1151     D3DSPSM_ABS     = 11<<D3DSP_SRCMOD_SHIFT, /* abs() */
1152     D3DSPSM_ABSNEG  = 12<<D3DSP_SRCMOD_SHIFT, /* -abs() */
1153     D3DSPSM_NOT     = 13<<D3DSP_SRCMOD_SHIFT, /* for predicate register: "!p0" */
1154     D3DSPSM_FORCE_DWORD = 0x7fffffff          /* force 32-bit size enum */
1155 } D3DSHADER_PARAM_SRCMOD_TYPE;
1156 
1157 /* Source or dest token bits [15:14]:
1158  * destination parameter modifiers
1159  */
1160 #define D3DSP_MIN_PRECISION_SHIFT      14
1161 #define D3DSP_MIN_PRECISION_MASK       0x0000C000
1162 
1163 typedef enum _D3DSHADER_MIN_PRECISION
1164 {
1165     D3DMP_DEFAULT   = 0, /* Default precision for the shader model */
1166     D3DMP_16        = 1, /* 16 bit per component */
1167     D3DMP_2_8       = 2  /* 10 bits (2.8) per component */
1168 } D3DSHADER_MIN_PRECISION;
1169 
1170 /* If the older D3DSPDM_PARTIALPRECISION is set,
1171  * that is equivalent to the whole operation specifying
1172  * D3DMP_16 (on all operands).  The two encodings are not
1173  * used together however.
1174  */
1175 
1176 /* pixel shader version token */
1177 #define D3DPS_VERSION(_Major,_Minor) (0xFFFF0000|((_Major)<<8)|(_Minor))
1178 
1179 /* vertex shader version token */
1180 #define D3DVS_VERSION(_Major,_Minor) (0xFFFE0000|((_Major)<<8)|(_Minor))
1181 
1182 /* extract major/minor from version cap */
1183 #define D3DSHADER_VERSION_MAJOR(_Version) (((_Version)>>8)&0xFF)
1184 #define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF)
1185 
1186 /* destination/source parameter register type */
1187 #define D3DSI_COMMENTSIZE_SHIFT     16
1188 #define D3DSI_COMMENTSIZE_MASK      0x7FFF0000
1189 #define D3DSHADER_COMMENT(_DWordSize) \
1190     ((((_DWordSize)<<D3DSI_COMMENTSIZE_SHIFT)&D3DSI_COMMENTSIZE_MASK)|D3DSIO_COMMENT)
1191 
1192 /* pixel/vertex shader end token */
1193 #define D3DPS_END()  0x0000FFFF
1194 #define D3DVS_END()  0x0000FFFF
1195 
1196 /*--------------------------------------------------------------------- */
1197 
1198 /* High order surfaces */
1199 typedef enum _D3DBASISTYPE
1200 {
1201    D3DBASIS_BEZIER      = 0,
1202    D3DBASIS_BSPLINE     = 1,
1203    D3DBASIS_CATMULL_ROM = 2, /* In D3D8 this used to be D3DBASIS_INTERPOLATE */
1204    D3DBASIS_FORCE_DWORD = 0x7fffffff
1205 } D3DBASISTYPE;
1206 
1207 typedef enum _D3DDEGREETYPE
1208 {
1209    D3DDEGREE_LINEAR      = 1,
1210    D3DDEGREE_QUADRATIC   = 2,
1211    D3DDEGREE_CUBIC       = 3,
1212    D3DDEGREE_QUINTIC     = 5,
1213    D3DDEGREE_FORCE_DWORD = 0x7fffffff
1214 } D3DDEGREETYPE;
1215 
1216 typedef enum _D3DPATCHEDGESTYLE
1217 {
1218    D3DPATCHEDGE_DISCRETE    = 0,
1219    D3DPATCHEDGE_CONTINUOUS  = 1,
1220    D3DPATCHEDGE_FORCE_DWORD = 0x7fffffff
1221 } D3DPATCHEDGESTYLE;
1222 
1223 typedef enum _D3DSTATEBLOCKTYPE
1224 {
1225     D3DSBT_ALL           = 1, /* capture all state */
1226     D3DSBT_PIXELSTATE    = 2, /* capture pixel state */
1227     D3DSBT_VERTEXSTATE   = 3, /* capture vertex state */
1228     D3DSBT_FORCE_DWORD   = 0x7fffffff
1229 } D3DSTATEBLOCKTYPE;
1230 
1231 /* The D3DVERTEXBLENDFLAGS type is used with D3DRS_VERTEXBLEND state. */
1232 typedef enum _D3DVERTEXBLENDFLAGS
1233 {
1234     D3DVBF_DISABLE  = 0,     /* Disable vertex blending */
1235     D3DVBF_1WEIGHTS = 1,     /* 2 matrix blending */
1236     D3DVBF_2WEIGHTS = 2,     /* 3 matrix blending */
1237     D3DVBF_3WEIGHTS = 3,     /* 4 matrix blending */
1238     D3DVBF_TWEENING = 255,   /* blending using D3DRS_TWEENFACTOR */
1239     D3DVBF_0WEIGHTS = 256,   /* one matrix is used with weight 1.0 */
1240     D3DVBF_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */
1241 } D3DVERTEXBLENDFLAGS;
1242 
1243 typedef enum _D3DTEXTURETRANSFORMFLAGS {
1244     D3DTTFF_DISABLE         = 0,    /* texture coordinates are passed directly */
1245     D3DTTFF_COUNT1          = 1,    /* rasterizer should expect 1-D texture coords */
1246     D3DTTFF_COUNT2          = 2,    /* rasterizer should expect 2-D texture coords */
1247     D3DTTFF_COUNT3          = 3,    /* rasterizer should expect 3-D texture coords */
1248     D3DTTFF_COUNT4          = 4,    /* rasterizer should expect 4-D texture coords */
1249     D3DTTFF_PROJECTED       = 256,  /* texcoords to be divided by COUNTth element */
1250     D3DTTFF_FORCE_DWORD     = 0x7fffffff
1251 } D3DTEXTURETRANSFORMFLAGS;
1252 
1253 /* Macros to set texture coordinate format bits in the FVF id */
1254 
1255 #define D3DFVF_TEXTUREFORMAT2 0         /* Two floating point values */
1256 #define D3DFVF_TEXTUREFORMAT1 3         /* One floating point value */
1257 #define D3DFVF_TEXTUREFORMAT3 1         /* Three floating point values */
1258 #define D3DFVF_TEXTUREFORMAT4 2         /* Four floating point values */
1259 
1260 #define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
1261 #define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
1262 #define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
1263 #define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
1264 
1265 /*--------------------------------------------------------------------- */
1266 
1267 /* Direct3D9 Device types */
1268 typedef enum _D3DDEVTYPE
1269 {
1270     D3DDEVTYPE_HAL         = 1,
1271     D3DDEVTYPE_REF         = 2,
1272     D3DDEVTYPE_SW          = 3,
1273 
1274     D3DDEVTYPE_NULLREF     = 4,
1275 
1276     D3DDEVTYPE_FORCE_DWORD  = 0x7fffffff
1277 } D3DDEVTYPE;
1278 
1279 /* Multi-Sample buffer types */
1280 typedef enum _D3DMULTISAMPLE_TYPE
1281 {
1282     D3DMULTISAMPLE_NONE            =  0,
1283     D3DMULTISAMPLE_NONMASKABLE     =  1,
1284     D3DMULTISAMPLE_2_SAMPLES       =  2,
1285     D3DMULTISAMPLE_3_SAMPLES       =  3,
1286     D3DMULTISAMPLE_4_SAMPLES       =  4,
1287     D3DMULTISAMPLE_5_SAMPLES       =  5,
1288     D3DMULTISAMPLE_6_SAMPLES       =  6,
1289     D3DMULTISAMPLE_7_SAMPLES       =  7,
1290     D3DMULTISAMPLE_8_SAMPLES       =  8,
1291     D3DMULTISAMPLE_9_SAMPLES       =  9,
1292     D3DMULTISAMPLE_10_SAMPLES      = 10,
1293     D3DMULTISAMPLE_11_SAMPLES      = 11,
1294     D3DMULTISAMPLE_12_SAMPLES      = 12,
1295     D3DMULTISAMPLE_13_SAMPLES      = 13,
1296     D3DMULTISAMPLE_14_SAMPLES      = 14,
1297     D3DMULTISAMPLE_15_SAMPLES      = 15,
1298     D3DMULTISAMPLE_16_SAMPLES      = 16,
1299 
1300     D3DMULTISAMPLE_FORCE_DWORD     = 0x7fffffff
1301 } D3DMULTISAMPLE_TYPE;
1302 
1303 /* Formats
1304  * Most of these names have the following convention:
1305  *      A = Alpha
1306  *      R = Red
1307  *      G = Green
1308  *      B = Blue
1309  *      X = Unused Bits
1310  *      P = Palette
1311  *      L = Luminance
1312  *      U = dU coordinate for BumpMap
1313  *      V = dV coordinate for BumpMap
1314  *      S = Stencil
1315  *      D = Depth (e.g. Z or W buffer)
1316  *      C = Computed from other channels (typically on certain read operations)
1317  *
1318  *      Further, the order of the pieces are from MSB first; hence
1319  *      D3DFMT_A8L8 indicates that the high byte of this two byte
1320  *      format is alpha.
1321  *
1322  *      D3DFMT_D16_LOCKABLE indicates:
1323  *           - An integer 16-bit value.
1324  *           - An app-lockable surface.
1325  *
1326  *      D3DFMT_D32F_LOCKABLE indicates:
1327  *           - An IEEE 754 floating-point value.
1328  *           - An app-lockable surface.
1329  *
1330  *      All Depth/Stencil formats except D3DFMT_D16_LOCKABLE and D3DFMT_D32F_LOCKABLE indicate:
1331  *          - no particular bit ordering per pixel, and
1332  *          - are not app lockable, and
1333  *          - the driver is allowed to consume more than the indicated
1334  *            number of bits per Depth channel (but not Stencil channel).
1335  */
1336 #ifndef MAKEFOURCC
1337     #define MAKEFOURCC(ch0, ch1, ch2, ch3)                              \
1338                 ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) |       \
1339                 ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
1340 #endif /* defined(MAKEFOURCC) */
1341 
1342 typedef enum _D3DFORMAT
1343 {
1344     D3DFMT_UNKNOWN              =  0,
1345 
1346     D3DFMT_R8G8B8               = 20,
1347     D3DFMT_A8R8G8B8             = 21,
1348     D3DFMT_X8R8G8B8             = 22,
1349     D3DFMT_R5G6B5               = 23,
1350     D3DFMT_X1R5G5B5             = 24,
1351     D3DFMT_A1R5G5B5             = 25,
1352     D3DFMT_A4R4G4B4             = 26,
1353     D3DFMT_R3G3B2               = 27,
1354     D3DFMT_A8                   = 28,
1355     D3DFMT_A8R3G3B2             = 29,
1356     D3DFMT_X4R4G4B4             = 30,
1357     D3DFMT_A2B10G10R10          = 31,
1358     D3DFMT_A8B8G8R8             = 32,
1359     D3DFMT_X8B8G8R8             = 33,
1360     D3DFMT_G16R16               = 34,
1361     D3DFMT_A2R10G10B10          = 35,
1362     D3DFMT_A16B16G16R16         = 36,
1363 
1364     D3DFMT_A8P8                 = 40,
1365     D3DFMT_P8                   = 41,
1366 
1367     D3DFMT_L8                   = 50,
1368     D3DFMT_A8L8                 = 51,
1369     D3DFMT_A4L4                 = 52,
1370 
1371     D3DFMT_V8U8                 = 60,
1372     D3DFMT_L6V5U5               = 61,
1373     D3DFMT_X8L8V8U8             = 62,
1374     D3DFMT_Q8W8V8U8             = 63,
1375     D3DFMT_V16U16               = 64,
1376     D3DFMT_A2W10V10U10          = 67,
1377 
1378     D3DFMT_UYVY                 = MAKEFOURCC('U', 'Y', 'V', 'Y'),
1379     D3DFMT_R8G8_B8G8            = MAKEFOURCC('R', 'G', 'B', 'G'),
1380     D3DFMT_YUY2                 = MAKEFOURCC('Y', 'U', 'Y', '2'),
1381     D3DFMT_G8R8_G8B8            = MAKEFOURCC('G', 'R', 'G', 'B'),
1382     D3DFMT_DXT1                 = MAKEFOURCC('D', 'X', 'T', '1'),
1383     D3DFMT_DXT2                 = MAKEFOURCC('D', 'X', 'T', '2'),
1384     D3DFMT_DXT3                 = MAKEFOURCC('D', 'X', 'T', '3'),
1385     D3DFMT_DXT4                 = MAKEFOURCC('D', 'X', 'T', '4'),
1386     D3DFMT_DXT5                 = MAKEFOURCC('D', 'X', 'T', '5'),
1387 
1388     D3DFMT_D16_LOCKABLE         = 70,
1389     D3DFMT_D32                  = 71,
1390     D3DFMT_D15S1                = 73,
1391     D3DFMT_D24S8                = 75,
1392     D3DFMT_D24X8                = 77,
1393     D3DFMT_D24X4S4              = 79,
1394     D3DFMT_D16                  = 80,
1395 
1396     D3DFMT_D32F_LOCKABLE        = 82,
1397     D3DFMT_D24FS8               = 83,
1398 
1399 /* D3D9Ex only -- */
1400 #if !defined(D3D_DISABLE_9EX)
1401 
1402     /* Z-Stencil formats valid for CPU access */
1403     D3DFMT_D32_LOCKABLE         = 84,
1404     D3DFMT_S8_LOCKABLE          = 85,
1405 
1406 #endif /* !D3D_DISABLE_9EX */
1407 /* -- D3D9Ex only */
1408 
1409     D3DFMT_L16                  = 81,
1410 
1411     D3DFMT_VERTEXDATA           =100,
1412     D3DFMT_INDEX16              =101,
1413     D3DFMT_INDEX32              =102,
1414 
1415     D3DFMT_Q16W16V16U16         =110,
1416 
1417     D3DFMT_MULTI2_ARGB8         = MAKEFOURCC('M','E','T','1'),
1418 
1419     /* Floating point surface formats */
1420 
1421     /* s10e5 formats (16-bits per channel) */
1422     D3DFMT_R16F                 = 111,
1423     D3DFMT_G16R16F              = 112,
1424     D3DFMT_A16B16G16R16F        = 113,
1425 
1426     /* IEEE s23e8 formats (32-bits per channel) */
1427     D3DFMT_R32F                 = 114,
1428     D3DFMT_G32R32F              = 115,
1429     D3DFMT_A32B32G32R32F        = 116,
1430 
1431     D3DFMT_CxV8U8               = 117,
1432 
1433 /* D3D9Ex only -- */
1434 #if !defined(D3D_DISABLE_9EX)
1435 
1436     /* Monochrome 1 bit per pixel format */
1437     D3DFMT_A1                   = 118,
1438 
1439     /* 2.8 biased fixed point */
1440     D3DFMT_A2B10G10R10_XR_BIAS  = 119,
1441 
1442     /* Binary format indicating that the data has no inherent type */
1443     D3DFMT_BINARYBUFFER         = 199,
1444 
1445 #endif /* !D3D_DISABLE_9EX */
1446 /* -- D3D9Ex only */
1447 
1448     D3DFMT_FORCE_DWORD          =0x7fffffff
1449 } D3DFORMAT;
1450 
1451 /* Display Modes */
1452 typedef struct _D3DDISPLAYMODE
1453 {
1454     UINT            Width;
1455     UINT            Height;
1456     UINT            RefreshRate;
1457     D3DFORMAT       Format;
1458 } D3DDISPLAYMODE;
1459 
1460 /* Creation Parameters */
1461 typedef struct _D3DDEVICE_CREATION_PARAMETERS
1462 {
1463     UINT            AdapterOrdinal;
1464     D3DDEVTYPE      DeviceType;
1465     HWND            hFocusWindow;
1466     DWORD           BehaviorFlags;
1467 } D3DDEVICE_CREATION_PARAMETERS;
1468 
1469 /* SwapEffects */
1470 typedef enum _D3DSWAPEFFECT
1471 {
1472     D3DSWAPEFFECT_DISCARD           = 1,
1473     D3DSWAPEFFECT_FLIP              = 2,
1474     D3DSWAPEFFECT_COPY              = 3,
1475 
1476 /* D3D9Ex only -- */
1477 #if !defined(D3D_DISABLE_9EX)
1478     D3DSWAPEFFECT_OVERLAY           = 4,
1479     D3DSWAPEFFECT_FLIPEX            = 5,
1480 #endif /* !D3D_DISABLE_9EX */
1481 /* -- D3D9Ex only */
1482 
1483     D3DSWAPEFFECT_FORCE_DWORD       = 0x7fffffff
1484 } D3DSWAPEFFECT;
1485 
1486 /* Pool types */
1487 typedef enum _D3DPOOL {
1488     D3DPOOL_DEFAULT                 = 0,
1489     D3DPOOL_MANAGED                 = 1,
1490     D3DPOOL_SYSTEMMEM               = 2,
1491     D3DPOOL_SCRATCH                 = 3,
1492 
1493     D3DPOOL_FORCE_DWORD             = 0x7fffffff
1494 } D3DPOOL;
1495 
1496 /* RefreshRate pre-defines */
1497 #define D3DPRESENT_RATE_DEFAULT         0x00000000
1498 
1499 /* Resize Optional Parameters */
1500 typedef struct _D3DPRESENT_PARAMETERS_
1501 {
1502     UINT                BackBufferWidth;
1503     UINT                BackBufferHeight;
1504     D3DFORMAT           BackBufferFormat;
1505     UINT                BackBufferCount;
1506 
1507     D3DMULTISAMPLE_TYPE MultiSampleType;
1508     DWORD               MultiSampleQuality;
1509 
1510     D3DSWAPEFFECT       SwapEffect;
1511     HWND                hDeviceWindow;
1512     BOOL                Windowed;
1513     BOOL                EnableAutoDepthStencil;
1514     D3DFORMAT           AutoDepthStencilFormat;
1515     DWORD               Flags;
1516 
1517     /* FullScreen_RefreshRateInHz must be zero for Windowed mode */
1518     UINT                FullScreen_RefreshRateInHz;
1519     UINT                PresentationInterval;
1520 } D3DPRESENT_PARAMETERS;
1521 
1522 /* Values for D3DPRESENT_PARAMETERS.Flags */
1523 
1524 #define D3DPRESENTFLAG_LOCKABLE_BACKBUFFER      0x00000001
1525 #define D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL     0x00000002
1526 #define D3DPRESENTFLAG_DEVICECLIP               0x00000004
1527 #define D3DPRESENTFLAG_VIDEO                    0x00000010
1528 
1529 /* D3D9Ex only -- */
1530 #if !defined(D3D_DISABLE_9EX)
1531 
1532 #define D3DPRESENTFLAG_NOAUTOROTATE                    0x00000020
1533 #define D3DPRESENTFLAG_UNPRUNEDMODE                    0x00000040
1534 #define D3DPRESENTFLAG_OVERLAY_LIMITEDRGB              0x00000080
1535 #define D3DPRESENTFLAG_OVERLAY_YCbCr_BT709             0x00000100
1536 #define D3DPRESENTFLAG_OVERLAY_YCbCr_xvYCC             0x00000200
1537 #define D3DPRESENTFLAG_RESTRICTED_CONTENT              0x00000400
1538 #define D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER 0x00000800
1539 
1540 #endif /* !D3D_DISABLE_9EX */
1541 /* -- D3D9Ex only */
1542 
1543 /* Gamma Ramp: Same as DX7 */
1544 
1545 typedef struct _D3DGAMMARAMP
1546 {
1547     WORD                red  [256];
1548     WORD                green[256];
1549     WORD                blue [256];
1550 } D3DGAMMARAMP;
1551 
1552 /* Back buffer types */
1553 typedef enum _D3DBACKBUFFER_TYPE
1554 {
1555     D3DBACKBUFFER_TYPE_MONO         = 0,
1556     D3DBACKBUFFER_TYPE_LEFT         = 1,
1557     D3DBACKBUFFER_TYPE_RIGHT        = 2,
1558 
1559     D3DBACKBUFFER_TYPE_FORCE_DWORD  = 0x7fffffff
1560 } D3DBACKBUFFER_TYPE;
1561 
1562 /* Types */
1563 typedef enum _D3DRESOURCETYPE {
1564     D3DRTYPE_SURFACE                =  1,
1565     D3DRTYPE_VOLUME                 =  2,
1566     D3DRTYPE_TEXTURE                =  3,
1567     D3DRTYPE_VOLUMETEXTURE          =  4,
1568     D3DRTYPE_CUBETEXTURE            =  5,
1569     D3DRTYPE_VERTEXBUFFER           =  6,
1570     D3DRTYPE_INDEXBUFFER            =  7, /* if this changes, change _D3DDEVINFO_RESOURCEMANAGER definition */
1571 
1572     D3DRTYPE_FORCE_DWORD            = 0x7fffffff
1573 } D3DRESOURCETYPE;
1574 
1575 /* Usages */
1576 #define D3DUSAGE_RENDERTARGET       (0x00000001L)
1577 #define D3DUSAGE_DEPTHSTENCIL       (0x00000002L)
1578 #define D3DUSAGE_DYNAMIC            (0x00000200L)
1579 
1580 /* D3D9Ex only -- */
1581 #if !defined(D3D_DISABLE_9EX)
1582 
1583 #define D3DUSAGE_NONSECURE          (0x00800000L)
1584 
1585 #endif /* !D3D_DISABLE_9EX */
1586 /* -- D3D9Ex only */
1587 
1588 /* When passed to CheckDeviceFormat, D3DUSAGE_AUTOGENMIPMAP may return
1589  * D3DOK_NOAUTOGEN if the device doesn't support autogeneration for that format.
1590  * D3DOK_NOAUTOGEN is a success code, not a failure code... the SUCCEEDED and FAILED macros
1591  * will return true and false respectively for this code.
1592  */
1593 #define D3DUSAGE_AUTOGENMIPMAP      (0x00000400L)
1594 #define D3DUSAGE_DMAP               (0x00004000L)
1595 
1596 /* The following usages are valid only for querying CheckDeviceFormat */
1597 #define D3DUSAGE_QUERY_LEGACYBUMPMAP            (0x00008000L)
1598 #define D3DUSAGE_QUERY_SRGBREAD                 (0x00010000L)
1599 #define D3DUSAGE_QUERY_FILTER                   (0x00020000L)
1600 #define D3DUSAGE_QUERY_SRGBWRITE                (0x00040000L)
1601 #define D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING (0x00080000L)
1602 #define D3DUSAGE_QUERY_VERTEXTEXTURE            (0x00100000L)
1603 #define D3DUSAGE_QUERY_WRAPANDMIP	            (0x00200000L)
1604 
1605 /* Usages for Vertex/Index buffers */
1606 #define D3DUSAGE_WRITEONLY          (0x00000008L)
1607 #define D3DUSAGE_SOFTWAREPROCESSING (0x00000010L)
1608 #define D3DUSAGE_DONOTCLIP          (0x00000020L)
1609 #define D3DUSAGE_POINTS             (0x00000040L)
1610 #define D3DUSAGE_RTPATCHES          (0x00000080L)
1611 #define D3DUSAGE_NPATCHES           (0x00000100L)
1612 
1613 /* D3D9Ex only -- */
1614 #if !defined(D3D_DISABLE_9EX)
1615 
1616 #define D3DUSAGE_TEXTAPI                         (0x10000000L)
1617 #define D3DUSAGE_RESTRICTED_CONTENT              (0x00000800L)
1618 #define D3DUSAGE_RESTRICT_SHARED_RESOURCE        (0x00002000L)
1619 #define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER (0x00001000L)
1620 
1621 #endif /* !D3D_DISABLE_9EX */
1622 /* -- D3D9Ex only */
1623 
1624 /* CubeMap Face identifiers */
1625 typedef enum _D3DCUBEMAP_FACES
1626 {
1627     D3DCUBEMAP_FACE_POSITIVE_X     = 0,
1628     D3DCUBEMAP_FACE_NEGATIVE_X     = 1,
1629     D3DCUBEMAP_FACE_POSITIVE_Y     = 2,
1630     D3DCUBEMAP_FACE_NEGATIVE_Y     = 3,
1631     D3DCUBEMAP_FACE_POSITIVE_Z     = 4,
1632     D3DCUBEMAP_FACE_NEGATIVE_Z     = 5,
1633 
1634     D3DCUBEMAP_FACE_FORCE_DWORD    = 0x7fffffff
1635 } D3DCUBEMAP_FACES;
1636 
1637 /* Lock flags */
1638 
1639 #define D3DLOCK_READONLY           0x00000010L
1640 #define D3DLOCK_DISCARD            0x00002000L
1641 #define D3DLOCK_NOOVERWRITE        0x00001000L
1642 #define D3DLOCK_NOSYSLOCK          0x00000800L
1643 #define D3DLOCK_DONOTWAIT          0x00004000L
1644 
1645 #define D3DLOCK_NO_DIRTY_UPDATE     0x00008000L
1646 
1647 /* Vertex Buffer Description */
1648 typedef struct _D3DVERTEXBUFFER_DESC
1649 {
1650     D3DFORMAT           Format;
1651     D3DRESOURCETYPE     Type;
1652     DWORD               Usage;
1653     D3DPOOL             Pool;
1654     UINT                Size;
1655 
1656     DWORD               FVF;
1657 
1658 } D3DVERTEXBUFFER_DESC;
1659 
1660 /* Index Buffer Description */
1661 typedef struct _D3DINDEXBUFFER_DESC
1662 {
1663     D3DFORMAT           Format;
1664     D3DRESOURCETYPE     Type;
1665     DWORD               Usage;
1666     D3DPOOL             Pool;
1667     UINT                Size;
1668 } D3DINDEXBUFFER_DESC;
1669 
1670 /* Surface Description */
1671 typedef struct _D3DSURFACE_DESC
1672 {
1673     D3DFORMAT           Format;
1674     D3DRESOURCETYPE     Type;
1675     DWORD               Usage;
1676     D3DPOOL             Pool;
1677 
1678     D3DMULTISAMPLE_TYPE MultiSampleType;
1679     DWORD               MultiSampleQuality;
1680     UINT                Width;
1681     UINT                Height;
1682 } D3DSURFACE_DESC;
1683 
1684 typedef struct _D3DVOLUME_DESC
1685 {
1686     D3DFORMAT           Format;
1687     D3DRESOURCETYPE     Type;
1688     DWORD               Usage;
1689     D3DPOOL             Pool;
1690 
1691     UINT                Width;
1692     UINT                Height;
1693     UINT                Depth;
1694 } D3DVOLUME_DESC;
1695 
1696 /* Structure for LockRect */
1697 typedef struct _D3DLOCKED_RECT
1698 {
1699     INT                 Pitch;
1700     void*               pBits;
1701 } D3DLOCKED_RECT;
1702 
1703 /* Structures for LockBox */
1704 typedef struct _D3DBOX
1705 {
1706     UINT                Left;
1707     UINT                Top;
1708     UINT                Right;
1709     UINT                Bottom;
1710     UINT                Front;
1711     UINT                Back;
1712 } D3DBOX;
1713 
1714 typedef struct _D3DLOCKED_BOX
1715 {
1716     INT                 RowPitch;
1717     INT                 SlicePitch;
1718     void*               pBits;
1719 } D3DLOCKED_BOX;
1720 
1721 /* Structures for LockRange */
1722 typedef struct _D3DRANGE
1723 {
1724     UINT                Offset;
1725     UINT                Size;
1726 } D3DRANGE;
1727 
1728 /* Structures for high order primitives */
1729 typedef struct _D3DRECTPATCH_INFO
1730 {
1731     UINT                StartVertexOffsetWidth;
1732     UINT                StartVertexOffsetHeight;
1733     UINT                Width;
1734     UINT                Height;
1735     UINT                Stride;
1736     D3DBASISTYPE        Basis;
1737     D3DDEGREETYPE       Degree;
1738 } D3DRECTPATCH_INFO;
1739 
1740 typedef struct _D3DTRIPATCH_INFO
1741 {
1742     UINT                StartVertexOffset;
1743     UINT                NumVertices;
1744     D3DBASISTYPE        Basis;
1745     D3DDEGREETYPE       Degree;
1746 } D3DTRIPATCH_INFO;
1747 
1748 /* Adapter Identifier */
1749 
1750 #define MAX_DEVICE_IDENTIFIER_STRING        512
1751 typedef struct _D3DADAPTER_IDENTIFIER9
1752 {
1753     char            Driver[MAX_DEVICE_IDENTIFIER_STRING];
1754     char            Description[MAX_DEVICE_IDENTIFIER_STRING];
1755     char            DeviceName[32];         /* Device name for GDI (ex. \\.\DISPLAY1) */
1756 
1757 #ifdef _WIN32
1758     LARGE_INTEGER   DriverVersion;          /* Defined for 32 bit components */
1759 #else
1760     DWORD           DriverVersionLowPart;   /* Defined for 16 bit driver components */
1761     DWORD           DriverVersionHighPart;
1762 #endif
1763 
1764     DWORD           VendorId;
1765     DWORD           DeviceId;
1766     DWORD           SubSysId;
1767     DWORD           Revision;
1768 
1769     GUID            DeviceIdentifier;
1770 
1771     DWORD           WHQLLevel;
1772 
1773 } D3DADAPTER_IDENTIFIER9;
1774 
1775 /* Raster Status structure returned by GetRasterStatus */
1776 typedef struct _D3DRASTER_STATUS
1777 {
1778     BOOL            InVBlank;
1779     UINT            ScanLine;
1780 } D3DRASTER_STATUS;
1781 
1782 /* Debug monitor tokens (DEBUG only)
1783 
1784    Note that if D3DRS_DEBUGMONITORTOKEN is set, the call is treated as
1785    passing a token to the debug monitor.  For example, if, after passing
1786    D3DDMT_ENABLE/DISABLE to D3DRS_DEBUGMONITORTOKEN other token values
1787    are passed in, the enabled/disabled state of the debug
1788    monitor will still persist.
1789 
1790    The debug monitor defaults to enabled.
1791 
1792    Calling GetRenderState on D3DRS_DEBUGMONITORTOKEN is not of any use.
1793 */
1794 
1795 typedef enum _D3DDEBUGMONITORTOKENS {
1796     D3DDMT_ENABLE            = 0,    /* enable debug monitor */
1797     D3DDMT_DISABLE           = 1,    /* disable debug monitor */
1798     D3DDMT_FORCE_DWORD     = 0x7fffffff
1799 } D3DDEBUGMONITORTOKENS;
1800 
1801 /* Async feedback */
1802 
1803 typedef enum _D3DQUERYTYPE {
1804     D3DQUERYTYPE_VCACHE                 = 4, /* D3DISSUE_END */
1805     D3DQUERYTYPE_RESOURCEMANAGER        = 5, /* D3DISSUE_END */
1806     D3DQUERYTYPE_VERTEXSTATS            = 6, /* D3DISSUE_END */
1807     D3DQUERYTYPE_EVENT                  = 8, /* D3DISSUE_END */
1808     D3DQUERYTYPE_OCCLUSION              = 9, /* D3DISSUE_BEGIN, D3DISSUE_END */
1809     D3DQUERYTYPE_TIMESTAMP              = 10, /* D3DISSUE_END */
1810     D3DQUERYTYPE_TIMESTAMPDISJOINT      = 11, /* D3DISSUE_BEGIN, D3DISSUE_END */
1811     D3DQUERYTYPE_TIMESTAMPFREQ          = 12, /* D3DISSUE_END */
1812     D3DQUERYTYPE_PIPELINETIMINGS        = 13, /* D3DISSUE_BEGIN, D3DISSUE_END */
1813     D3DQUERYTYPE_INTERFACETIMINGS       = 14, /* D3DISSUE_BEGIN, D3DISSUE_END */
1814     D3DQUERYTYPE_VERTEXTIMINGS          = 15, /* D3DISSUE_BEGIN, D3DISSUE_END */
1815     D3DQUERYTYPE_PIXELTIMINGS           = 16, /* D3DISSUE_BEGIN, D3DISSUE_END */
1816     D3DQUERYTYPE_BANDWIDTHTIMINGS       = 17, /* D3DISSUE_BEGIN, D3DISSUE_END */
1817     D3DQUERYTYPE_CACHEUTILIZATION       = 18, /* D3DISSUE_BEGIN, D3DISSUE_END */
1818 /* D3D9Ex only -- */
1819 #if !defined(D3D_DISABLE_9EX)
1820     D3DQUERYTYPE_MEMORYPRESSURE         = 19 /* D3DISSUE_BEGIN, D3DISSUE_END */
1821 #endif /* !D3D_DISABLE_9EX */
1822 } D3DQUERYTYPE;
1823 
1824 /* Flags field for Issue */
1825 #define D3DISSUE_END (1 << 0) /* Tells the runtime to issue the end of a query, changing it's state to "non-signaled". */
1826 #define D3DISSUE_BEGIN (1 << 1) /* Tells the runtime to issue the beginng of a query. */
1827 
1828 /* Flags field for GetData */
1829 #define D3DGETDATA_FLUSH (1 << 0) /* Tells the runtime to flush if the query is outstanding. */
1830 
1831 typedef struct _D3DRESOURCESTATS
1832 {
1833    /* Data collected since last Present() */
1834    BOOL    bThrashing;             /* indicates if thrashing */
1835    DWORD   ApproxBytesDownloaded;  /* Approximate number of bytes downloaded by resource manager */
1836    DWORD   NumEvicts;              /* number of objects evicted */
1837    DWORD   NumVidCreates;          /* number of objects created in video memory */
1838    DWORD   LastPri;                /* priority of last object evicted */
1839    DWORD   NumUsed;                /* number of objects set to the device */
1840    DWORD   NumUsedInVidMem;        /* number of objects set to the device, which are already in video memory */
1841    /* Persistent data */
1842    DWORD   WorkingSet;             /* number of objects in video memory */
1843    DWORD   WorkingSetBytes;        /* number of bytes in video memory */
1844    DWORD   TotalManaged;           /* total number of managed objects */
1845    DWORD   TotalBytes;             /* total number of bytes of managed objects */
1846 } D3DRESOURCESTATS;
1847 
1848 #define D3DRTYPECOUNT (D3DRTYPE_INDEXBUFFER+1)
1849 
1850 typedef struct _D3DDEVINFO_RESOURCEMANAGER
1851 {
1852 #ifndef WOW64_ENUM_WORKAROUND
1853     D3DRESOURCESTATS    stats[D3DRTYPECOUNT];
1854 #else
1855     D3DRESOURCESTATS    stats[8];
1856 #endif
1857 } D3DDEVINFO_RESOURCEMANAGER, *LPD3DDEVINFO_RESOURCEMANAGER;
1858 
1859 typedef struct _D3DDEVINFO_D3DVERTEXSTATS
1860 {
1861     DWORD   NumRenderedTriangles;       /* total number of triangles that are not clipped in this frame */
1862     DWORD   NumExtraClippingTriangles;  /* Number of new triangles generated by clipping */
1863 } D3DDEVINFO_D3DVERTEXSTATS, *LPD3DDEVINFO_D3DVERTEXSTATS;
1864 
1865 typedef struct _D3DDEVINFO_VCACHE {
1866     DWORD   Pattern;                    /* bit pattern, return value must be FOUR_CC('C', 'A', 'C', 'H') */
1867     DWORD   OptMethod;                  /* optimization method 0 means longest strips, 1 means vertex cache based */
1868     DWORD   CacheSize;                  /* cache size to optimize for  (only required if type is 1) */
1869     DWORD   MagicNumber;                /* used to determine when to restart strips (only required if type is 1)*/
1870 } D3DDEVINFO_VCACHE, *LPD3DDEVINFO_VCACHE;
1871 
1872 typedef struct _D3DDEVINFO_D3D9PIPELINETIMINGS
1873 {
1874     FLOAT VertexProcessingTimePercent;
1875     FLOAT PixelProcessingTimePercent;
1876     FLOAT OtherGPUProcessingTimePercent;
1877     FLOAT GPUIdleTimePercent;
1878 } D3DDEVINFO_D3D9PIPELINETIMINGS;
1879 
1880 typedef struct _D3DDEVINFO_D3D9INTERFACETIMINGS
1881 {
1882     FLOAT WaitingForGPUToUseApplicationResourceTimePercent;
1883     FLOAT WaitingForGPUToAcceptMoreCommandsTimePercent;
1884     FLOAT WaitingForGPUToStayWithinLatencyTimePercent;
1885     FLOAT WaitingForGPUExclusiveResourceTimePercent;
1886     FLOAT WaitingForGPUOtherTimePercent;
1887 } D3DDEVINFO_D3D9INTERFACETIMINGS;
1888 
1889 typedef struct _D3DDEVINFO_D3D9STAGETIMINGS
1890 {
1891     FLOAT MemoryProcessingPercent;
1892     FLOAT ComputationProcessingPercent;
1893 } D3DDEVINFO_D3D9STAGETIMINGS;
1894 
1895 typedef struct _D3DDEVINFO_D3D9BANDWIDTHTIMINGS
1896 {
1897     FLOAT MaxBandwidthUtilized;
1898     FLOAT FrontEndUploadMemoryUtilizedPercent;
1899     FLOAT VertexRateUtilizedPercent;
1900     FLOAT TriangleSetupRateUtilizedPercent;
1901     FLOAT FillRateUtilizedPercent;
1902 } D3DDEVINFO_D3D9BANDWIDTHTIMINGS;
1903 
1904 typedef struct _D3DDEVINFO_D3D9CACHEUTILIZATION
1905 {
1906    FLOAT TextureCacheHitRate; /* Percentage of cache hits */
1907    FLOAT PostTransformVertexCacheHitRate;
1908 } D3DDEVINFO_D3D9CACHEUTILIZATION;
1909 
1910 /* D3D9Ex only -- */
1911 #if !defined(D3D_DISABLE_9EX)
1912 
1913 typedef struct _D3DMEMORYPRESSURE
1914 {
1915     UINT64  BytesEvictedFromProcess;
1916     UINT64  SizeOfInefficientAllocation;
1917     DWORD   LevelOfEfficiency;
1918 } D3DMEMORYPRESSURE;
1919 
1920 typedef enum _D3DCOMPOSERECTSOP{
1921     D3DCOMPOSERECTS_COPY     = 1,
1922     D3DCOMPOSERECTS_OR       = 2,
1923     D3DCOMPOSERECTS_AND      = 3,
1924     D3DCOMPOSERECTS_NEG      = 4,
1925     D3DCOMPOSERECTS_FORCE_DWORD    = 0x7fffffff /* force 32-bit size enum */
1926 } D3DCOMPOSERECTSOP;
1927 
1928 typedef struct _D3DCOMPOSERECTDESC
1929 {
1930     USHORT  X, Y;           /* Top-left coordinates of a rect in the source surface */
1931     USHORT  Width, Height;  /* Dimensions of the rect */
1932 } D3DCOMPOSERECTDESC;
1933 
1934 typedef struct _D3DCOMPOSERECTDESTINATION
1935 {
1936     USHORT SrcRectIndex;    /* Index of D3DCOMPOSERECTDESC */
1937     USHORT Reserved;        /* For alignment */
1938     SHORT  X, Y;            /* Top-left coordinates of the rect in the destination surface */
1939 } D3DCOMPOSERECTDESTINATION;
1940 
1941 #define D3DCOMPOSERECTS_MAXNUMRECTS 0xFFFF
1942 #define D3DCONVOLUTIONMONO_MAXWIDTH  7
1943 #define D3DCONVOLUTIONMONO_MAXHEIGHT D3DCONVOLUTIONMONO_MAXWIDTH
1944 #define D3DFMT_A1_SURFACE_MAXWIDTH  8192
1945 #define D3DFMT_A1_SURFACE_MAXHEIGHT 2048
1946 
1947 typedef struct _D3DPRESENTSTATS {
1948     UINT PresentCount;
1949     UINT PresentRefreshCount;
1950     UINT SyncRefreshCount;
1951     LARGE_INTEGER SyncQPCTime;
1952     LARGE_INTEGER SyncGPUTime;
1953 } D3DPRESENTSTATS;
1954 
1955 typedef enum D3DSCANLINEORDERING
1956 {
1957     D3DSCANLINEORDERING_UNKNOWN                    = 0,
1958     D3DSCANLINEORDERING_PROGRESSIVE                = 1,
1959     D3DSCANLINEORDERING_INTERLACED                 = 2
1960 } D3DSCANLINEORDERING;
1961 
1962 typedef struct D3DDISPLAYMODEEX
1963 {
1964     UINT                    Size;
1965     UINT                    Width;
1966     UINT                    Height;
1967     UINT                    RefreshRate;
1968     D3DFORMAT               Format;
1969     D3DSCANLINEORDERING     ScanLineOrdering;
1970 } D3DDISPLAYMODEEX;
1971 
1972 typedef struct D3DDISPLAYMODEFILTER
1973 {
1974     UINT                    Size;
1975     D3DFORMAT               Format;
1976     D3DSCANLINEORDERING     ScanLineOrdering;
1977 } D3DDISPLAYMODEFILTER;
1978 
1979 typedef enum D3DDISPLAYROTATION
1980 {
1981     D3DDISPLAYROTATION_IDENTITY = 1, /* No rotation. */
1982     D3DDISPLAYROTATION_90       = 2, /* Rotated 90 degrees. */
1983     D3DDISPLAYROTATION_180      = 3, /* Rotated 180 degrees. */
1984     D3DDISPLAYROTATION_270      = 4  /* Rotated 270 degrees. */
1985 } D3DDISPLAYROTATION;
1986 
1987 /* For use in ID3DResource9::SetPriority calls */
1988 #define D3D9_RESOURCE_PRIORITY_MINIMUM       0x28000000
1989 #define D3D9_RESOURCE_PRIORITY_LOW           0x50000000
1990 #define D3D9_RESOURCE_PRIORITY_NORMAL        0x78000000
1991 #define D3D9_RESOURCE_PRIORITY_HIGH          0xa0000000
1992 #define D3D9_RESOURCE_PRIORITY_MAXIMUM       0xc8000000
1993 
1994 #define D3D_OMAC_SIZE    16
1995 
1996 typedef struct _D3D_OMAC
1997 {
1998     BYTE Omac[D3D_OMAC_SIZE];
1999 } D3D_OMAC;
2000 
2001 typedef enum _D3DAUTHENTICATEDCHANNELTYPE
2002 {
2003     D3DAUTHENTICATEDCHANNEL_D3D9            = 1,
2004     D3DAUTHENTICATEDCHANNEL_DRIVER_SOFTWARE = 2,
2005     D3DAUTHENTICATEDCHANNEL_DRIVER_HARDWARE = 3
2006 } D3DAUTHENTICATEDCHANNELTYPE;
2007 
2008 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_INPUT
2009 {
2010     GUID                               QueryType;
2011     HANDLE                             hChannel;
2012     UINT                               SequenceNumber;
2013 } D3DAUTHENTICATEDCHANNEL_QUERY_INPUT;
2014 
2015 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT
2016 {
2017     D3D_OMAC                           omac;
2018     GUID                               QueryType;
2019     HANDLE                             hChannel;
2020     UINT                               SequenceNumber;
2021     HRESULT                            ReturnCode;
2022 } D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT;
2023 
2024 DEFINE_GUID(D3DAUTHENTICATEDQUERY_PROTECTION,
2025 0xa84eb584, 0xc495, 0x48aa, 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x5);
2026 
2027 typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS
2028 {
2029     union
2030     {
2031         struct
2032         {
2033             UINT ProtectionEnabled                       : 1;
2034             UINT OverlayOrFullscreenRequired             : 1;
2035             UINT Reserved                                : 30;
2036         };
2037         UINT  Value;
2038     };
2039 
2040 } D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS;
2041 
2042 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT
2043 {
2044     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2045 
2046     D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS ProtectionFlags;
2047 
2048 } D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT;
2049 
2050 DEFINE_GUID(D3DAUTHENTICATEDQUERY_CHANNELTYPE,
2051 0xbc1b18a5, 0xb1fb, 0x42ab, 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe);
2052 
2053 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT
2054 {
2055     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2056 
2057     D3DAUTHENTICATEDCHANNELTYPE ChannelType;
2058 
2059 } D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT;
2060 
2061 DEFINE_GUID(D3DAUTHENTICATEDQUERY_DEVICEHANDLE,
2062 0xec1c539d, 0x8cff, 0x4e2a, 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80);
2063 
2064 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT
2065 {
2066     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2067 
2068     HANDLE   DeviceHandle;
2069 
2070 } D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT;
2071 
2072 DEFINE_GUID(D3DAUTHENTICATEDQUERY_CRYPTOSESSION,
2073 0x2634499e, 0xd018, 0x4d74, 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d);
2074 
2075 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT
2076 {
2077     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
2078 
2079     HANDLE   DXVA2DecodeHandle;
2080 
2081 } D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT;
2082 
2083 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT
2084 {
2085     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2086 
2087     HANDLE   DXVA2DecodeHandle;
2088     HANDLE   CryptoSessionHandle;
2089     HANDLE   DeviceHandle;
2090 
2091 } D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT;
2092 
2093 DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT,
2094 0xdb207b3, 0x9450, 0x46a6, 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2);
2095 
2096 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT
2097 {
2098     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2099 
2100     UINT   NumRestrictedSharedResourceProcesses;
2101 
2102 } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT;
2103 
2104 DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS,
2105 0x649bbadb, 0xf0f4, 0x4639, 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac);
2106 
2107 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT
2108 {
2109     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
2110 
2111     UINT     ProcessIndex;
2112 
2113 } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT;
2114 
2115 typedef enum _D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE
2116 {
2117     PROCESSIDTYPE_UNKNOWN  = 0,
2118     PROCESSIDTYPE_DWM      = 1,
2119     PROCESSIDTYPE_HANDLE   = 2
2120 } D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE;
2121 
2122 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT
2123 {
2124     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2125 
2126     UINT                                          ProcessIndex;
2127     D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE ProcessIdentifer;
2128     HANDLE                                        ProcessHandle;
2129 
2130 } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT;
2131 
2132 DEFINE_GUID(D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT,
2133 0x12f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d);
2134 
2135 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT
2136 {
2137     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2138 
2139     UINT   NumUnrestrictedProtectedSharedResources;
2140 
2141 } D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT;
2142 
2143 DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT,
2144 0x2c042b5e, 0x8c07, 0x46d5, 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31);
2145 
2146 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT
2147 {
2148     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
2149 
2150     HANDLE  DeviceHandle;
2151     HANDLE  CryptoSessionHandle;
2152 
2153 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT;
2154 
2155 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT
2156 {
2157     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2158 
2159     HANDLE  DeviceHandle;
2160     HANDLE  CryptoSessionHandle;
2161     UINT    NumOutputIDs;
2162 
2163 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT;
2164 
2165 DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTID,
2166 0x839ddca3, 0x9b4e, 0x41e4, 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7);
2167 
2168 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT
2169 {
2170     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
2171 
2172     HANDLE  DeviceHandle;
2173     HANDLE  CryptoSessionHandle;
2174     UINT    OutputIDIndex;
2175 
2176 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT;
2177 
2178 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT
2179 {
2180     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2181 
2182     HANDLE  DeviceHandle;
2183     HANDLE  CryptoSessionHandle;
2184     UINT    OutputIDIndex;
2185     UINT64  OutputID;
2186 
2187 } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT;
2188 
2189 DEFINE_GUID(D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES,
2190 0x6214d9d2, 0x432c, 0x4abb, 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b);
2191 
2192 typedef enum _D3DBUSTYPE
2193 {
2194     D3DBUSTYPE_OTHER                                     = 0x00000000,
2195     D3DBUSTYPE_PCI                                       = 0x00000001,
2196     D3DBUSTYPE_PCIX                                      = 0x00000002,
2197     D3DBUSTYPE_PCIEXPRESS                                = 0x00000003,
2198     D3DBUSTYPE_AGP                                       = 0x00000004,
2199     D3DBUSIMPL_MODIFIER_INSIDE_OF_CHIPSET                = 0x00010000,
2200     D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP   = 0x00020000,
2201     D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000,
2202     D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR         = 0x00040000,
2203     D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000,
2204     D3DBUSIMPL_MODIFIER_NON_STANDARD                     = 0x80000000
2205 } D3DBUSTYPE;
2206 
2207 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT
2208 {
2209     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2210 
2211     D3DBUSTYPE BusType;
2212     BOOL bAccessibleInContiguousBlocks;
2213     BOOL bAccessibleInNonContiguousBlocks;
2214 
2215 } D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT;
2216 
2217 DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT,
2218 0xb30f7066, 0x203c, 0x4b07, 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e);
2219 
2220 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT
2221 {
2222     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2223 
2224     UINT   NumEncryptionGuids;
2225 
2226 } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT;
2227 
2228 DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID,
2229 0xf83a5958, 0xe986, 0x4bda, 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x1, 0xb7);
2230 
2231 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT
2232 {
2233     D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input;
2234 
2235     UINT EncryptionGuidIndex;
2236 
2237 } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT;
2238 
2239 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT
2240 {
2241     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2242 
2243     UINT       EncryptionGuidIndex;
2244     GUID       EncryptionGuid;
2245 
2246 } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT;
2247 
2248 DEFINE_GUID(D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE,
2249 0xec1791c7, 0xdad3, 0x4f15, 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0);
2250 
2251 typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT
2252 {
2253     D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output;
2254 
2255     GUID       EncryptionGuid;
2256 
2257 } D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT;
2258 
2259 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT
2260 {
2261     D3D_OMAC                            omac;
2262     GUID                                ConfigureType;
2263     HANDLE                              hChannel;
2264     UINT                                SequenceNumber;
2265 
2266 } D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT;
2267 
2268 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT
2269 {
2270     D3D_OMAC                            omac;
2271     GUID                                ConfigureType;
2272     HANDLE                              hChannel;
2273     UINT                                SequenceNumber;
2274     HRESULT                             ReturnCode;
2275 
2276 } D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT;
2277 
2278 DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_INITIALIZE,
2279 0x6114bdb, 0x3523, 0x470a, 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0);
2280 
2281 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE
2282 {
2283     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT   Parameters;
2284 
2285     UINT   StartSequenceQuery;
2286     UINT   StartSequenceConfigure;
2287 
2288 } D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE;
2289 
2290 DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_PROTECTION,
2291 0x50455658, 0x3f47, 0x4362, 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29);
2292 
2293 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION
2294 {
2295     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT   Parameters;
2296 
2297     D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS Protections;
2298 
2299 } D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION;
2300 
2301 DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION,
2302 0x6346cc54, 0x2cfc, 0x4ad4, 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x0);
2303 
2304 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION
2305 {
2306     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT   Parameters;
2307 
2308     HANDLE      DXVA2DecodeHandle;
2309     HANDLE      CryptoSessionHandle;
2310     HANDLE      DeviceHandle;
2311 
2312 } D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION;
2313 
2314 DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE,
2315 0x772d047, 0x1b40, 0x48e8, 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x1);
2316 
2317 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE
2318 {
2319     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT       Parameters;
2320 
2321     D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE ProcessIdentiferType;
2322     HANDLE                                        ProcessHandle;
2323     BOOL                                          AllowAccess;
2324 
2325 } D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE;
2326 
2327 DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE,
2328 0x41fff286, 0x6ae0, 0x4d43, 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a);
2329 
2330 typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION
2331 {
2332     D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT   Parameters;
2333 
2334     GUID                                      EncryptionGuid;
2335 
2336 } D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION;
2337 
2338 typedef struct _D3DENCRYPTED_BLOCK_INFO
2339 {
2340     UINT NumEncryptedBytesAtBeginning;
2341     UINT NumBytesInSkipPattern;
2342     UINT NumBytesInEncryptPattern;
2343 } D3DENCRYPTED_BLOCK_INFO;
2344 
2345 typedef struct _D3DAES_CTR_IV
2346 {
2347     UINT64   IV;         /* Big-Endian IV */
2348     UINT64   Count;      /* Big-Endian Block Count */
2349 } D3DAES_CTR_IV;
2350 
2351 #endif /* !D3D_DISABLE_9EX */
2352 /* -- D3D9Ex only */
2353 
2354 #pragma pack()
2355 #if _MSC_VER >= 1200
2356 #pragma warning(pop)
2357 #endif
2358 
2359 #endif /* (DIRECT3D_VERSION >= 0x0900) */
2360 #endif /* _d3d9TYPES(P)_H_ */
2361