Subversion Repositories Games.Chess Giants

Rev

Blame | Last modification | View Log | Download | RSS feed

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