d3d8types.h 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690
  1. /*==========================================================================;
  2. *
  3. * Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: d3d8types.h
  6. * Content: Direct3D capabilities include file
  7. *
  8. ***************************************************************************/
  9. #ifndef _D3D8TYPES_H_
  10. #define _D3D8TYPES_H_
  11. #ifndef DIRECT3D_VERSION
  12. #define DIRECT3D_VERSION 0x0800
  13. #endif //DIRECT3D_VERSION
  14. // include this file content only if compiling for DX8 interfaces
  15. #if(DIRECT3D_VERSION >= 0x0800)
  16. #include <float.h>
  17. #if _MSC_VER >= 1200
  18. #pragma warning(push)
  19. #endif
  20. #ifdef _MSC_VER
  21. #pragma warning(disable:4201) // anonymous unions warning
  22. #endif
  23. #if defined(_X86_) || defined(_IA64_)
  24. #pragma pack(4)
  25. #endif
  26. // D3DCOLOR is equivalent to D3DFMT_A8R8G8B8
  27. #ifndef D3DCOLOR_DEFINED
  28. typedef DWORD D3DCOLOR;
  29. #define D3DCOLOR_DEFINED
  30. #endif
  31. // maps unsigned 8 bits/channel to D3DCOLOR
  32. #define D3DCOLOR_ARGB(a,r,g,b) \
  33. ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
  34. #define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b)
  35. #define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b)
  36. // maps floating point channels (0.f to 1.f range) to D3DCOLOR
  37. #define D3DCOLOR_COLORVALUE(r,g,b,a) \
  38. D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f))
  39. #ifndef D3DVECTOR_DEFINED
  40. typedef struct _D3DVECTOR {
  41. float x;
  42. float y;
  43. float z;
  44. } D3DVECTOR;
  45. #define D3DVECTOR_DEFINED
  46. #endif
  47. #ifndef D3DCOLORVALUE_DEFINED
  48. typedef struct _D3DCOLORVALUE {
  49. float r;
  50. float g;
  51. float b;
  52. float a;
  53. } D3DCOLORVALUE;
  54. #define D3DCOLORVALUE_DEFINED
  55. #endif
  56. #ifndef D3DRECT_DEFINED
  57. typedef struct _D3DRECT {
  58. LONG x1;
  59. LONG y1;
  60. LONG x2;
  61. LONG y2;
  62. } D3DRECT;
  63. #define D3DRECT_DEFINED
  64. #endif
  65. #ifndef D3DMATRIX_DEFINED
  66. typedef struct _D3DMATRIX {
  67. union {
  68. struct {
  69. float _11, _12, _13, _14;
  70. float _21, _22, _23, _24;
  71. float _31, _32, _33, _34;
  72. float _41, _42, _43, _44;
  73. };
  74. float m[4][4];
  75. };
  76. } D3DMATRIX;
  77. #define D3DMATRIX_DEFINED
  78. #endif
  79. typedef struct _D3DVIEWPORT8 {
  80. DWORD X;
  81. DWORD Y; /* Viewport Top left */
  82. DWORD Width;
  83. DWORD Height; /* Viewport Dimensions */
  84. float MinZ; /* Min/max of clip Volume */
  85. float MaxZ;
  86. } D3DVIEWPORT8;
  87. /*
  88. * Values for clip fields.
  89. */
  90. // Max number of user clipping planes, supported in D3D.
  91. #define D3DMAXUSERCLIPPLANES 32
  92. // These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE
  93. //
  94. #define D3DCLIPPLANE0 (1 << 0)
  95. #define D3DCLIPPLANE1 (1 << 1)
  96. #define D3DCLIPPLANE2 (1 << 2)
  97. #define D3DCLIPPLANE3 (1 << 3)
  98. #define D3DCLIPPLANE4 (1 << 4)
  99. #define D3DCLIPPLANE5 (1 << 5)
  100. // The following bits are used in the ClipUnion and ClipIntersection
  101. // members of the D3DCLIPSTATUS8
  102. //
  103. #define D3DCS_LEFT 0x00000001L
  104. #define D3DCS_RIGHT 0x00000002L
  105. #define D3DCS_TOP 0x00000004L
  106. #define D3DCS_BOTTOM 0x00000008L
  107. #define D3DCS_FRONT 0x00000010L
  108. #define D3DCS_BACK 0x00000020L
  109. #define D3DCS_PLANE0 0x00000040L
  110. #define D3DCS_PLANE1 0x00000080L
  111. #define D3DCS_PLANE2 0x00000100L
  112. #define D3DCS_PLANE3 0x00000200L
  113. #define D3DCS_PLANE4 0x00000400L
  114. #define D3DCS_PLANE5 0x00000800L
  115. #define D3DCS_ALL (D3DCS_LEFT | \
  116. D3DCS_RIGHT | \
  117. D3DCS_TOP | \
  118. D3DCS_BOTTOM | \
  119. D3DCS_FRONT | \
  120. D3DCS_BACK | \
  121. D3DCS_PLANE0 | \
  122. D3DCS_PLANE1 | \
  123. D3DCS_PLANE2 | \
  124. D3DCS_PLANE3 | \
  125. D3DCS_PLANE4 | \
  126. D3DCS_PLANE5)
  127. typedef struct _D3DCLIPSTATUS8 {
  128. DWORD ClipUnion;
  129. DWORD ClipIntersection;
  130. } D3DCLIPSTATUS8;
  131. typedef struct _D3DMATERIAL8 {
  132. D3DCOLORVALUE Diffuse; /* Diffuse color RGBA */
  133. D3DCOLORVALUE Ambient; /* Ambient color RGB */
  134. D3DCOLORVALUE Specular; /* Specular 'shininess' */
  135. D3DCOLORVALUE Emissive; /* Emissive color RGB */
  136. float Power; /* Sharpness if specular highlight */
  137. } D3DMATERIAL8;
  138. typedef enum _D3DLIGHTTYPE {
  139. D3DLIGHT_POINT = 1,
  140. D3DLIGHT_SPOT = 2,
  141. D3DLIGHT_DIRECTIONAL = 3,
  142. D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  143. } D3DLIGHTTYPE;
  144. typedef struct _D3DLIGHT8 {
  145. D3DLIGHTTYPE Type; /* Type of light source */
  146. D3DCOLORVALUE Diffuse; /* Diffuse color of light */
  147. D3DCOLORVALUE Specular; /* Specular color of light */
  148. D3DCOLORVALUE Ambient; /* Ambient color of light */
  149. D3DVECTOR Position; /* Position in world space */
  150. D3DVECTOR Direction; /* Direction in world space */
  151. float Range; /* Cutoff range */
  152. float Falloff; /* Falloff */
  153. float Attenuation0; /* Constant attenuation */
  154. float Attenuation1; /* Linear attenuation */
  155. float Attenuation2; /* Quadratic attenuation */
  156. float Theta; /* Inner angle of spotlight cone */
  157. float Phi; /* Outer angle of spotlight cone */
  158. } D3DLIGHT8;
  159. /*
  160. * Options for clearing
  161. */
  162. #define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */
  163. #define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */
  164. #define D3DCLEAR_STENCIL 0x00000004l /* Clear stencil planes */
  165. /*
  166. * The following defines the rendering states
  167. */
  168. typedef enum _D3DSHADEMODE {
  169. D3DSHADE_FLAT = 1,
  170. D3DSHADE_GOURAUD = 2,
  171. D3DSHADE_PHONG = 3,
  172. D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  173. } D3DSHADEMODE;
  174. typedef enum _D3DFILLMODE {
  175. D3DFILL_POINT = 1,
  176. D3DFILL_WIREFRAME = 2,
  177. D3DFILL_SOLID = 3,
  178. D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  179. } D3DFILLMODE;
  180. typedef struct _D3DLINEPATTERN {
  181. WORD wRepeatFactor;
  182. WORD wLinePattern;
  183. } D3DLINEPATTERN;
  184. typedef enum _D3DBLEND {
  185. D3DBLEND_ZERO = 1,
  186. D3DBLEND_ONE = 2,
  187. D3DBLEND_SRCCOLOR = 3,
  188. D3DBLEND_INVSRCCOLOR = 4,
  189. D3DBLEND_SRCALPHA = 5,
  190. D3DBLEND_INVSRCALPHA = 6,
  191. D3DBLEND_DESTALPHA = 7,
  192. D3DBLEND_INVDESTALPHA = 8,
  193. D3DBLEND_DESTCOLOR = 9,
  194. D3DBLEND_INVDESTCOLOR = 10,
  195. D3DBLEND_SRCALPHASAT = 11,
  196. D3DBLEND_BOTHSRCALPHA = 12,
  197. D3DBLEND_BOTHINVSRCALPHA = 13,
  198. D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  199. } D3DBLEND;
  200. typedef enum _D3DBLENDOP {
  201. D3DBLENDOP_ADD = 1,
  202. D3DBLENDOP_SUBTRACT = 2,
  203. D3DBLENDOP_REVSUBTRACT = 3,
  204. D3DBLENDOP_MIN = 4,
  205. D3DBLENDOP_MAX = 5,
  206. D3DBLENDOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  207. } D3DBLENDOP;
  208. typedef enum _D3DTEXTUREADDRESS {
  209. D3DTADDRESS_WRAP = 1,
  210. D3DTADDRESS_MIRROR = 2,
  211. D3DTADDRESS_CLAMP = 3,
  212. D3DTADDRESS_BORDER = 4,
  213. D3DTADDRESS_MIRRORONCE = 5,
  214. D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  215. } D3DTEXTUREADDRESS;
  216. typedef enum _D3DCULL {
  217. D3DCULL_NONE = 1,
  218. D3DCULL_CW = 2,
  219. D3DCULL_CCW = 3,
  220. D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  221. } D3DCULL;
  222. typedef enum _D3DCMPFUNC {
  223. D3DCMP_NEVER = 1,
  224. D3DCMP_LESS = 2,
  225. D3DCMP_EQUAL = 3,
  226. D3DCMP_LESSEQUAL = 4,
  227. D3DCMP_GREATER = 5,
  228. D3DCMP_NOTEQUAL = 6,
  229. D3DCMP_GREATEREQUAL = 7,
  230. D3DCMP_ALWAYS = 8,
  231. D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  232. } D3DCMPFUNC;
  233. typedef enum _D3DSTENCILOP {
  234. D3DSTENCILOP_KEEP = 1,
  235. D3DSTENCILOP_ZERO = 2,
  236. D3DSTENCILOP_REPLACE = 3,
  237. D3DSTENCILOP_INCRSAT = 4,
  238. D3DSTENCILOP_DECRSAT = 5,
  239. D3DSTENCILOP_INVERT = 6,
  240. D3DSTENCILOP_INCR = 7,
  241. D3DSTENCILOP_DECR = 8,
  242. D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  243. } D3DSTENCILOP;
  244. typedef enum _D3DFOGMODE {
  245. D3DFOG_NONE = 0,
  246. D3DFOG_EXP = 1,
  247. D3DFOG_EXP2 = 2,
  248. D3DFOG_LINEAR = 3,
  249. D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  250. } D3DFOGMODE;
  251. typedef enum _D3DZBUFFERTYPE {
  252. D3DZB_FALSE = 0,
  253. D3DZB_TRUE = 1, // Z buffering
  254. D3DZB_USEW = 2, // W buffering
  255. D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  256. } D3DZBUFFERTYPE;
  257. // Primitives supported by draw-primitive API
  258. typedef enum _D3DPRIMITIVETYPE {
  259. D3DPT_POINTLIST = 1,
  260. D3DPT_LINELIST = 2,
  261. D3DPT_LINESTRIP = 3,
  262. D3DPT_TRIANGLELIST = 4,
  263. D3DPT_TRIANGLESTRIP = 5,
  264. D3DPT_TRIANGLEFAN = 6,
  265. D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  266. } D3DPRIMITIVETYPE;
  267. typedef enum _D3DTRANSFORMSTATETYPE {
  268. D3DTS_VIEW = 2,
  269. D3DTS_PROJECTION = 3,
  270. D3DTS_TEXTURE0 = 16,
  271. D3DTS_TEXTURE1 = 17,
  272. D3DTS_TEXTURE2 = 18,
  273. D3DTS_TEXTURE3 = 19,
  274. D3DTS_TEXTURE4 = 20,
  275. D3DTS_TEXTURE5 = 21,
  276. D3DTS_TEXTURE6 = 22,
  277. D3DTS_TEXTURE7 = 23,
  278. D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  279. } D3DTRANSFORMSTATETYPE;
  280. #define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
  281. #define D3DTS_WORLD D3DTS_WORLDMATRIX(0)
  282. #define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1)
  283. #define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2)
  284. #define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3)
  285. typedef enum _D3DRENDERSTATETYPE {
  286. D3DRS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
  287. D3DRS_FILLMODE = 8, /* D3DFILLMODE */
  288. D3DRS_SHADEMODE = 9, /* D3DSHADEMODE */
  289. D3DRS_LINEPATTERN = 10, /* D3DLINEPATTERN */
  290. D3DRS_ZWRITEENABLE = 14, /* TRUE to enable z writes */
  291. D3DRS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */
  292. D3DRS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */
  293. D3DRS_SRCBLEND = 19, /* D3DBLEND */
  294. D3DRS_DESTBLEND = 20, /* D3DBLEND */
  295. D3DRS_CULLMODE = 22, /* D3DCULL */
  296. D3DRS_ZFUNC = 23, /* D3DCMPFUNC */
  297. D3DRS_ALPHAREF = 24, /* D3DFIXED */
  298. D3DRS_ALPHAFUNC = 25, /* D3DCMPFUNC */
  299. D3DRS_DITHERENABLE = 26, /* TRUE to enable dithering */
  300. D3DRS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */
  301. D3DRS_FOGENABLE = 28, /* TRUE to enable fog blending */
  302. D3DRS_SPECULARENABLE = 29, /* TRUE to enable specular */
  303. D3DRS_ZVISIBLE = 30, /* TRUE to enable z checking */
  304. D3DRS_FOGCOLOR = 34, /* D3DCOLOR */
  305. D3DRS_FOGTABLEMODE = 35, /* D3DFOGMODE */
  306. D3DRS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */
  307. D3DRS_FOGEND = 37, /* Fog end */
  308. D3DRS_FOGDENSITY = 38, /* Fog density */
  309. D3DRS_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */
  310. D3DRS_ZBIAS = 47, /* LONG Z bias */
  311. D3DRS_RANGEFOGENABLE = 48, /* Enables range-based fog */
  312. D3DRS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */
  313. D3DRS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */
  314. D3DRS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */
  315. D3DRS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */
  316. D3DRS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
  317. D3DRS_STENCILREF = 57, /* Reference value used in stencil test */
  318. D3DRS_STENCILMASK = 58, /* Mask value used in stencil test */
  319. D3DRS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */
  320. D3DRS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */
  321. D3DRS_WRAP0 = 128, /* wrap for 1st texture coord. set */
  322. D3DRS_WRAP1 = 129, /* wrap for 2nd texture coord. set */
  323. D3DRS_WRAP2 = 130, /* wrap for 3rd texture coord. set */
  324. D3DRS_WRAP3 = 131, /* wrap for 4th texture coord. set */
  325. D3DRS_WRAP4 = 132, /* wrap for 5th texture coord. set */
  326. D3DRS_WRAP5 = 133, /* wrap for 6th texture coord. set */
  327. D3DRS_WRAP6 = 134, /* wrap for 7th texture coord. set */
  328. D3DRS_WRAP7 = 135, /* wrap for 8th texture coord. set */
  329. D3DRS_CLIPPING = 136,
  330. D3DRS_LIGHTING = 137,
  331. D3DRS_AMBIENT = 139,
  332. D3DRS_FOGVERTEXMODE = 140,
  333. D3DRS_COLORVERTEX = 141,
  334. D3DRS_LOCALVIEWER = 142,
  335. D3DRS_NORMALIZENORMALS = 143,
  336. D3DRS_DIFFUSEMATERIALSOURCE = 145,
  337. D3DRS_SPECULARMATERIALSOURCE = 146,
  338. D3DRS_AMBIENTMATERIALSOURCE = 147,
  339. D3DRS_EMISSIVEMATERIALSOURCE = 148,
  340. D3DRS_VERTEXBLEND = 151,
  341. D3DRS_CLIPPLANEENABLE = 152,
  342. D3DRS_SOFTWAREVERTEXPROCESSING = 153,
  343. D3DRS_POINTSIZE = 154, /* float point size */
  344. D3DRS_POINTSIZE_MIN = 155, /* float point size min threshold */
  345. D3DRS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */
  346. D3DRS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */
  347. D3DRS_POINTSCALE_A = 158, /* float point attenuation A value */
  348. D3DRS_POINTSCALE_B = 159, /* float point attenuation B value */
  349. D3DRS_POINTSCALE_C = 160, /* float point attenuation C value */
  350. D3DRS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer
  351. D3DRS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable
  352. D3DRS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation
  353. D3DRS_PATCHSEGMENTS = 164, // Number of segments per edge when drawing patches
  354. D3DRS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor
  355. D3DRS_POINTSIZE_MAX = 166, /* float point size max threshold */
  356. D3DRS_INDEXEDVERTEXBLENDENABLE = 167,
  357. D3DRS_COLORWRITEENABLE = 168, // per-channel write enable
  358. D3DRS_TWEENFACTOR = 170, // float tween factor
  359. D3DRS_BLENDOP = 171, // D3DBLENDOP setting
  360. D3DRS_POSITIONORDER = 172, // NPatch position interpolation order. D3DORDER_LINEAR or D3DORDER_CUBIC (default)
  361. D3DRS_NORMALORDER = 173, // NPatch normal interpolation order. D3DORDER_LINEAR (default) or D3DORDER_QUADRATIC
  362. D3DRS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  363. } D3DRENDERSTATETYPE;
  364. // Values for material source
  365. typedef enum _D3DMATERIALCOLORSOURCE
  366. {
  367. D3DMCS_MATERIAL = 0, // Color from material is used
  368. D3DMCS_COLOR1 = 1, // Diffuse vertex color is used
  369. D3DMCS_COLOR2 = 2, // Specular vertex color is used
  370. D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  371. } D3DMATERIALCOLORSOURCE;
  372. // Bias to apply to the texture coordinate set to apply a wrap to.
  373. #define D3DRENDERSTATE_WRAPBIAS 128UL
  374. /* Flags to construct the WRAP render states */
  375. #define D3DWRAP_U 0x00000001L
  376. #define D3DWRAP_V 0x00000002L
  377. #define D3DWRAP_W 0x00000004L
  378. /* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */
  379. #define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U
  380. #define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V
  381. #define D3DWRAPCOORD_2 0x00000004L // same as D3DWRAP_W
  382. #define D3DWRAPCOORD_3 0x00000008L
  383. /* Flags to construct D3DRS_COLORWRITEENABLE */
  384. #define D3DCOLORWRITEENABLE_RED (1L<<0)
  385. #define D3DCOLORWRITEENABLE_GREEN (1L<<1)
  386. #define D3DCOLORWRITEENABLE_BLUE (1L<<2)
  387. #define D3DCOLORWRITEENABLE_ALPHA (1L<<3)
  388. /*
  389. * State enumerants for per-stage texture processing.
  390. */
  391. typedef enum _D3DTEXTURESTAGESTATETYPE
  392. {
  393. D3DTSS_COLOROP = 1, /* D3DTEXTUREOP - per-stage blending controls for color channels */
  394. D3DTSS_COLORARG1 = 2, /* D3DTA_* (texture arg) */
  395. D3DTSS_COLORARG2 = 3, /* D3DTA_* (texture arg) */
  396. D3DTSS_ALPHAOP = 4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */
  397. D3DTSS_ALPHAARG1 = 5, /* D3DTA_* (texture arg) */
  398. D3DTSS_ALPHAARG2 = 6, /* D3DTA_* (texture arg) */
  399. D3DTSS_BUMPENVMAT00 = 7, /* float (bump mapping matrix) */
  400. D3DTSS_BUMPENVMAT01 = 8, /* float (bump mapping matrix) */
  401. D3DTSS_BUMPENVMAT10 = 9, /* float (bump mapping matrix) */
  402. D3DTSS_BUMPENVMAT11 = 10, /* float (bump mapping matrix) */
  403. D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */
  404. D3DTSS_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */
  405. D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */
  406. D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */
  407. D3DTSS_MAGFILTER = 16, /* D3DTEXTUREFILTER filter to use for magnification */
  408. D3DTSS_MINFILTER = 17, /* D3DTEXTUREFILTER filter to use for minification */
  409. D3DTSS_MIPFILTER = 18, /* D3DTEXTUREFILTER filter to use between mipmaps during minification */
  410. D3DTSS_MIPMAPLODBIAS = 19, /* float Mipmap LOD bias */
  411. D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */
  412. D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */
  413. D3DTSS_BUMPENVLSCALE = 22, /* float scale for bump map luminance */
  414. D3DTSS_BUMPENVLOFFSET = 23, /* float offset for bump map luminance */
  415. D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */
  416. D3DTSS_ADDRESSW = 25, /* D3DTEXTUREADDRESS for W coordinate */
  417. D3DTSS_COLORARG0 = 26, /* D3DTA_* third arg for triadic ops */
  418. D3DTSS_ALPHAARG0 = 27, /* D3DTA_* third arg for triadic ops */
  419. D3DTSS_RESULTARG = 28, /* D3DTA_* arg for result (CURRENT or TEMP) */
  420. D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  421. } D3DTEXTURESTAGESTATETYPE;
  422. // Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position
  423. // and normal in the camera space) should be taken as texture coordinates
  424. // Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from
  425. //
  426. #define D3DTSS_TCI_PASSTHRU 0x00000000
  427. #define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000
  428. #define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000
  429. #define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000
  430. /*
  431. * Enumerations for COLOROP and ALPHAOP texture blending operations set in
  432. * texture processing stage controls in D3DTSS.
  433. */
  434. typedef enum _D3DTEXTUREOP
  435. {
  436. // Control
  437. D3DTOP_DISABLE = 1, // disables stage
  438. D3DTOP_SELECTARG1 = 2, // the default
  439. D3DTOP_SELECTARG2 = 3,
  440. // Modulate
  441. D3DTOP_MODULATE = 4, // multiply args together
  442. D3DTOP_MODULATE2X = 5, // multiply and 1 bit
  443. D3DTOP_MODULATE4X = 6, // multiply and 2 bits
  444. // Add
  445. D3DTOP_ADD = 7, // add arguments together
  446. D3DTOP_ADDSIGNED = 8, // add with -0.5 bias
  447. D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit
  448. D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation
  449. D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product
  450. // Arg1 + Arg2 - Arg1*Arg2
  451. // = Arg1 + (1-Arg1)*Arg2
  452. // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
  453. D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha
  454. D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha
  455. D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRS_TEXTUREFACTOR
  456. // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
  457. D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha
  458. D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color
  459. // Specular mapping
  460. D3DTOP_PREMODULATE = 17, // modulate with next texture before use
  461. D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB
  462. // COLOROP only
  463. D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A
  464. // COLOROP only
  465. D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, // (1-Arg1.A)*Arg2.RGB + Arg1.RGB
  466. // COLOROP only
  467. D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, // (1-Arg1.RGB)*Arg2.RGB + Arg1.A
  468. // COLOROP only
  469. // Bump mapping
  470. D3DTOP_BUMPENVMAP = 22, // per pixel env map perturbation
  471. D3DTOP_BUMPENVMAPLUMINANCE = 23, // with luminance channel
  472. // This can do either diffuse or specular bump mapping with correct input.
  473. // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
  474. // where each component has been scaled and offset to make it signed.
  475. // The result is replicated into all four (including alpha) channels.
  476. // This is a valid COLOROP only.
  477. D3DTOP_DOTPRODUCT3 = 24,
  478. // Triadic ops
  479. D3DTOP_MULTIPLYADD = 25, // Arg0 + Arg1*Arg2
  480. D3DTOP_LERP = 26, // (Arg0)*Arg1 + (1-Arg0)*Arg2
  481. D3DTOP_FORCE_DWORD = 0x7fffffff,
  482. } D3DTEXTUREOP;
  483. /*
  484. * Values for COLORARG0,1,2, ALPHAARG0,1,2, and RESULTARG texture blending
  485. * operations set in texture processing stage controls in D3DRENDERSTATE.
  486. */
  487. #define D3DTA_SELECTMASK 0x0000000f // mask for arg selector
  488. #define D3DTA_DIFFUSE 0x00000000 // select diffuse color (read only)
  489. #define D3DTA_CURRENT 0x00000001 // select stage destination register (read/write)
  490. #define D3DTA_TEXTURE 0x00000002 // select texture color (read only)
  491. #define D3DTA_TFACTOR 0x00000003 // select D3DRS_TEXTUREFACTOR (read only)
  492. #define D3DTA_SPECULAR 0x00000004 // select specular color (read only)
  493. #define D3DTA_TEMP 0x00000005 // select temporary register color (read/write)
  494. #define D3DTA_COMPLEMENT 0x00000010 // take 1.0 - x (read modifier)
  495. #define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components (read modifier)
  496. //
  497. // Values for D3DTSS_***FILTER texture stage states
  498. //
  499. typedef enum _D3DTEXTUREFILTERTYPE
  500. {
  501. D3DTEXF_NONE = 0, // filtering disabled (valid for mip filter only)
  502. D3DTEXF_POINT = 1, // nearest
  503. D3DTEXF_LINEAR = 2, // linear interpolation
  504. D3DTEXF_ANISOTROPIC = 3, // anisotropic
  505. D3DTEXF_FLATCUBIC = 4, // cubic
  506. D3DTEXF_GAUSSIANCUBIC = 5, // different cubic kernel
  507. D3DTEXF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  508. } D3DTEXTUREFILTERTYPE;
  509. /* Bits for Flags in ProcessVertices call */
  510. #define D3DPV_DONOTCOPYDATA (1 << 0)
  511. //-------------------------------------------------------------------
  512. // Flexible vertex format bits
  513. //
  514. #define D3DFVF_RESERVED0 0x001
  515. #define D3DFVF_POSITION_MASK 0x00E
  516. #define D3DFVF_XYZ 0x002
  517. #define D3DFVF_XYZRHW 0x004
  518. #define D3DFVF_XYZB1 0x006
  519. #define D3DFVF_XYZB2 0x008
  520. #define D3DFVF_XYZB3 0x00a
  521. #define D3DFVF_XYZB4 0x00c
  522. #define D3DFVF_XYZB5 0x00e
  523. #define D3DFVF_NORMAL 0x010
  524. #define D3DFVF_PSIZE 0x020
  525. #define D3DFVF_DIFFUSE 0x040
  526. #define D3DFVF_SPECULAR 0x080
  527. #define D3DFVF_TEXCOUNT_MASK 0xf00
  528. #define D3DFVF_TEXCOUNT_SHIFT 8
  529. #define D3DFVF_TEX0 0x000
  530. #define D3DFVF_TEX1 0x100
  531. #define D3DFVF_TEX2 0x200
  532. #define D3DFVF_TEX3 0x300
  533. #define D3DFVF_TEX4 0x400
  534. #define D3DFVF_TEX5 0x500
  535. #define D3DFVF_TEX6 0x600
  536. #define D3DFVF_TEX7 0x700
  537. #define D3DFVF_TEX8 0x800
  538. #define D3DFVF_LASTBETA_UBYTE4 0x1000
  539. #define D3DFVF_RESERVED2 0xE000 // 4 reserved bits
  540. //---------------------------------------------------------------------
  541. // Vertex Shaders
  542. //
  543. /*
  544. Vertex Shader Declaration
  545. The declaration portion of a vertex shader defines the static external
  546. interface of the shader. The information in the declaration includes:
  547. - Assignments of vertex shader input registers to data streams. These
  548. assignments bind a specific vertex register to a single component within a
  549. vertex stream. A vertex stream element is identified by a byte offset
  550. within the stream and a type. The type specifies the arithmetic data type
  551. plus the dimensionality (1, 2, 3, or 4 values). Stream data which is
  552. less than 4 values are always expanded out to 4 values with zero or more
  553. 0.F values and one 1.F value.
  554. - Assignment of vertex shader input registers to implicit data from the
  555. primitive tessellator. This controls the loading of vertex data which is
  556. not loaded from a stream, but rather is generated during primitive
  557. tessellation prior to the vertex shader.
  558. - Loading data into the constant memory at the time a shader is set as the
  559. current shader. Each token specifies values for one or more contiguous 4
  560. DWORD constant registers. This allows the shader to update an arbitrary
  561. subset of the constant memory, overwriting the device state (which
  562. contains the current values of the constant memory). Note that these
  563. values can be subsequently overwritten (between DrawPrimitive calls)
  564. during the time a shader is bound to a device via the
  565. SetVertexShaderConstant method.
  566. Declaration arrays are single-dimensional arrays of DWORDs composed of
  567. multiple tokens each of which is one or more DWORDs. The single-DWORD
  568. token value 0xFFFFFFFF is a special token used to indicate the end of the
  569. declaration array. The single DWORD token value 0x00000000 is a NOP token
  570. with is ignored during the declaration parsing. Note that 0x00000000 is a
  571. valid value for DWORDs following the first DWORD for multiple word tokens.
  572. [31:29] TokenType
  573. 0x0 - NOP (requires all DWORD bits to be zero)
  574. 0x1 - stream selector
  575. 0x2 - stream data definition (map to vertex input memory)
  576. 0x3 - vertex input memory from tessellator
  577. 0x4 - constant memory from shader
  578. 0x5 - extension
  579. 0x6 - reserved
  580. 0x7 - end-of-array (requires all DWORD bits to be 1)
  581. NOP Token (single DWORD token)
  582. [31:29] 0x0
  583. [28:00] 0x0
  584. Stream Selector (single DWORD token)
  585. [31:29] 0x1
  586. [28] indicates whether this is a tessellator stream
  587. [27:04] 0x0
  588. [03:00] stream selector (0..15)
  589. Stream Data Definition (single DWORD token)
  590. Vertex Input Register Load
  591. [31:29] 0x2
  592. [28] 0x0
  593. [27:20] 0x0
  594. [19:16] type (dimensionality and data type)
  595. [15:04] 0x0
  596. [03:00] vertex register address (0..15)
  597. Data Skip (no register load)
  598. [31:29] 0x2
  599. [28] 0x1
  600. [27:20] 0x0
  601. [19:16] count of DWORDS to skip over (0..15)
  602. [15:00] 0x0
  603. Vertex Input Memory from Tessellator Data (single DWORD token)
  604. [31:29] 0x3
  605. [28] indicates whether data is normals or u/v
  606. [27:24] 0x0
  607. [23:20] vertex register address (0..15)
  608. [19:16] type (dimensionality)
  609. [15:04] 0x0
  610. [03:00] vertex register address (0..15)
  611. Constant Memory from Shader (multiple DWORD token)
  612. [31:29] 0x4
  613. [28:25] count of 4*DWORD constants to load (0..15)
  614. [24:07] 0x0
  615. [06:00] constant memory address (0..95)
  616. Extension Token (single or multiple DWORD token)
  617. [31:29] 0x5
  618. [28:24] count of additional DWORDs in token (0..31)
  619. [23:00] extension-specific information
  620. End-of-array token (single DWORD token)
  621. [31:29] 0x7
  622. [28:00] 0x1fffffff
  623. The stream selector token must be immediately followed by a contiguous set of stream data definition tokens. This token sequence fully defines that stream, including the set of elements within the stream, the order in which the elements appear, the type of each element, and the vertex register into which to load an element.
  624. Streams are allowed to include data which is not loaded into a vertex register, thus allowing data which is not used for this shader to exist in the vertex stream. This skipped data is defined only by a count of DWORDs to skip over, since the type information is irrelevant.
  625. The token sequence:
  626. Stream Select: stream=0
  627. Stream Data Definition (Load): type=FLOAT3; register=3
  628. Stream Data Definition (Load): type=FLOAT3; register=4
  629. Stream Data Definition (Skip): count=2
  630. Stream Data Definition (Load): type=FLOAT2; register=7
  631. defines stream zero to consist of 4 elements, 3 of which are loaded into registers and the fourth skipped over. Register 3 is loaded with the first three DWORDs in each vertex interpreted as FLOAT data. Register 4 is loaded with the 4th, 5th, and 6th DWORDs interpreted as FLOAT data. The next two DWORDs (7th and 8th) are skipped over and not loaded into any vertex input register. Register 7 is loaded with the 9th and 10th DWORDS interpreted as FLOAT data.
  632. Placing of tokens other than NOPs between the Stream Selector and Stream Data Definition tokens is disallowed.
  633. */
  634. typedef enum _D3DVSD_TOKENTYPE
  635. {
  636. D3DVSD_TOKEN_NOP = 0, // NOP or extension
  637. D3DVSD_TOKEN_STREAM, // stream selector
  638. D3DVSD_TOKEN_STREAMDATA, // stream data definition (map to vertex input memory)
  639. D3DVSD_TOKEN_TESSELLATOR, // vertex input memory from tessellator
  640. D3DVSD_TOKEN_CONSTMEM, // constant memory from shader
  641. D3DVSD_TOKEN_EXT, // extension
  642. D3DVSD_TOKEN_END = 7, // end-of-array (requires all DWORD bits to be 1)
  643. D3DVSD_FORCE_DWORD = 0x7fffffff,// force 32-bit size enum
  644. } D3DVSD_TOKENTYPE;
  645. #define D3DVSD_TOKENTYPESHIFT 29
  646. #define D3DVSD_TOKENTYPEMASK (7 << D3DVSD_TOKENTYPESHIFT)
  647. #define D3DVSD_STREAMNUMBERSHIFT 0
  648. #define D3DVSD_STREAMNUMBERMASK (0xF << D3DVSD_STREAMNUMBERSHIFT)
  649. #define D3DVSD_DATALOADTYPESHIFT 28
  650. #define D3DVSD_DATALOADTYPEMASK (0x1 << D3DVSD_DATALOADTYPESHIFT)
  651. #define D3DVSD_DATATYPESHIFT 16
  652. #define D3DVSD_DATATYPEMASK (0xF << D3DVSD_DATATYPESHIFT)
  653. #define D3DVSD_SKIPCOUNTSHIFT 16
  654. #define D3DVSD_SKIPCOUNTMASK (0xF << D3DVSD_SKIPCOUNTSHIFT)
  655. #define D3DVSD_VERTEXREGSHIFT 0
  656. #define D3DVSD_VERTEXREGMASK (0x1F << D3DVSD_VERTEXREGSHIFT)
  657. #define D3DVSD_VERTEXREGINSHIFT 20
  658. #define D3DVSD_VERTEXREGINMASK (0xF << D3DVSD_VERTEXREGINSHIFT)
  659. #define D3DVSD_CONSTCOUNTSHIFT 25
  660. #define D3DVSD_CONSTCOUNTMASK (0xF << D3DVSD_CONSTCOUNTSHIFT)
  661. #define D3DVSD_CONSTADDRESSSHIFT 0
  662. #define D3DVSD_CONSTADDRESSMASK (0x7F << D3DVSD_CONSTADDRESSSHIFT)
  663. #define D3DVSD_CONSTRSSHIFT 16
  664. #define D3DVSD_CONSTRSMASK (0x1FFF << D3DVSD_CONSTRSSHIFT)
  665. #define D3DVSD_EXTCOUNTSHIFT 24
  666. #define D3DVSD_EXTCOUNTMASK (0x1F << D3DVSD_EXTCOUNTSHIFT)
  667. #define D3DVSD_EXTINFOSHIFT 0
  668. #define D3DVSD_EXTINFOMASK (0xFFFFFF << D3DVSD_EXTINFOSHIFT)
  669. #define D3DVSD_MAKETOKENTYPE(tokenType) ((tokenType << D3DVSD_TOKENTYPESHIFT) & D3DVSD_TOKENTYPEMASK)
  670. // macros for generation of CreateVertexShader Declaration token array
  671. // Set current stream
  672. // _StreamNumber [0..(MaxStreams-1)] stream to get data from
  673. //
  674. #define D3DVSD_STREAM( _StreamNumber ) \
  675. (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (_StreamNumber))
  676. // Set tessellator stream
  677. //
  678. #define D3DVSD_STREAMTESSSHIFT 28
  679. #define D3DVSD_STREAMTESSMASK (1 << D3DVSD_STREAMTESSSHIFT)
  680. #define D3DVSD_STREAM_TESS( ) \
  681. (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (D3DVSD_STREAMTESSMASK))
  682. // bind single vertex register to vertex element from vertex stream
  683. //
  684. // _VertexRegister [0..15] address of the vertex register
  685. // _Type [D3DVSDT_*] dimensionality and arithmetic data type
  686. #define D3DVSD_REG( _VertexRegister, _Type ) \
  687. (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | \
  688. ((_Type) << D3DVSD_DATATYPESHIFT) | (_VertexRegister))
  689. // Skip _DWORDCount DWORDs in vertex
  690. //
  691. #define D3DVSD_SKIP( _DWORDCount ) \
  692. (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | 0x10000000 | \
  693. ((_DWORDCount) << D3DVSD_SKIPCOUNTSHIFT))
  694. // load data into vertex shader constant memory
  695. //
  696. // _ConstantAddress [0..95] - address of constant array to begin filling data
  697. // _Count [0..15] - number of constant vectors to load (4 DWORDs each)
  698. // followed by 4*_Count DWORDS of data
  699. //
  700. #define D3DVSD_CONST( _ConstantAddress, _Count ) \
  701. (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) | \
  702. ((_Count) << D3DVSD_CONSTCOUNTSHIFT) | (_ConstantAddress))
  703. // enable tessellator generated normals
  704. //
  705. // _VertexRegisterIn [0..15] address of vertex register whose input stream
  706. // will be used in normal computation
  707. // _VertexRegisterOut [0..15] address of vertex register to output the normal to
  708. //
  709. #define D3DVSD_TESSNORMAL( _VertexRegisterIn, _VertexRegisterOut ) \
  710. (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | \
  711. ((_VertexRegisterIn) << D3DVSD_VERTEXREGINSHIFT) | \
  712. ((0x02) << D3DVSD_DATATYPESHIFT) | (_VertexRegisterOut))
  713. // enable tessellator generated surface parameters
  714. //
  715. // _VertexRegister [0..15] address of vertex register to output parameters
  716. //
  717. #define D3DVSD_TESSUV( _VertexRegister ) \
  718. (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | 0x10000000 | \
  719. ((0x01) << D3DVSD_DATATYPESHIFT) | (_VertexRegister))
  720. // Generates END token
  721. //
  722. #define D3DVSD_END() 0xFFFFFFFF
  723. // Generates NOP token
  724. #define D3DVSD_NOP() 0x00000000
  725. // bit declarations for _Type fields
  726. #define D3DVSDT_FLOAT1 0x00 // 1D float expanded to (value, 0., 0., 1.)
  727. #define D3DVSDT_FLOAT2 0x01 // 2D float expanded to (value, value, 0., 1.)
  728. #define D3DVSDT_FLOAT3 0x02 // 3D float expanded to (value, value, value, 1.)
  729. #define D3DVSDT_FLOAT4 0x03 // 4D float
  730. #define D3DVSDT_D3DCOLOR 0x04 // 4D packed unsigned bytes mapped to 0. to 1. range
  731. // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A)
  732. #define D3DVSDT_UBYTE4 0x05 // 4D unsigned byte
  733. #define D3DVSDT_SHORT2 0x06 // 2D signed short expanded to (value, value, 0., 1.)
  734. #define D3DVSDT_SHORT4 0x07 // 4D signed short
  735. // assignments of vertex input registers for fixed function vertex shader
  736. //
  737. #define D3DVSDE_POSITION 0
  738. #define D3DVSDE_BLENDWEIGHT 1
  739. #define D3DVSDE_BLENDINDICES 2
  740. #define D3DVSDE_NORMAL 3
  741. #define D3DVSDE_PSIZE 4
  742. #define D3DVSDE_DIFFUSE 5
  743. #define D3DVSDE_SPECULAR 6
  744. #define D3DVSDE_TEXCOORD0 7
  745. #define D3DVSDE_TEXCOORD1 8
  746. #define D3DVSDE_TEXCOORD2 9
  747. #define D3DVSDE_TEXCOORD3 10
  748. #define D3DVSDE_TEXCOORD4 11
  749. #define D3DVSDE_TEXCOORD5 12
  750. #define D3DVSDE_TEXCOORD6 13
  751. #define D3DVSDE_TEXCOORD7 14
  752. #define D3DVSDE_POSITION2 15
  753. #define D3DVSDE_NORMAL2 16
  754. // Maximum supported number of texture coordinate sets
  755. #define D3DDP_MAXTEXCOORD 8
  756. //
  757. // Instruction Token Bit Definitions
  758. //
  759. #define D3DSI_OPCODE_MASK 0x0000FFFF
  760. typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE
  761. {
  762. D3DSIO_NOP = 0, // PS/VS
  763. D3DSIO_MOV , // PS/VS
  764. D3DSIO_ADD , // PS/VS
  765. D3DSIO_SUB , // PS
  766. D3DSIO_MAD , // PS/VS
  767. D3DSIO_MUL , // PS/VS
  768. D3DSIO_RCP , // VS
  769. D3DSIO_RSQ , // VS
  770. D3DSIO_DP3 , // PS/VS
  771. D3DSIO_DP4 , // PS/VS
  772. D3DSIO_MIN , // VS
  773. D3DSIO_MAX , // VS
  774. D3DSIO_SLT , // VS
  775. D3DSIO_SGE , // VS
  776. D3DSIO_EXP , // VS
  777. D3DSIO_LOG , // VS
  778. D3DSIO_LIT , // VS
  779. D3DSIO_DST , // VS
  780. D3DSIO_LRP , // PS
  781. D3DSIO_FRC , // VS
  782. D3DSIO_M4x4 , // VS
  783. D3DSIO_M4x3 , // VS
  784. D3DSIO_M3x4 , // VS
  785. D3DSIO_M3x3 , // VS
  786. D3DSIO_M3x2 , // VS
  787. D3DSIO_TEXCOORD = 64, // PS
  788. D3DSIO_TEXKILL , // PS
  789. D3DSIO_TEX , // PS
  790. D3DSIO_TEXBEM , // PS
  791. D3DSIO_TEXBEML , // PS
  792. D3DSIO_TEXREG2AR , // PS
  793. D3DSIO_TEXREG2GB , // PS
  794. D3DSIO_TEXM3x2PAD , // PS
  795. D3DSIO_TEXM3x2TEX , // PS
  796. D3DSIO_TEXM3x3PAD , // PS
  797. D3DSIO_TEXM3x3TEX , // PS
  798. D3DSIO_TEXM3x3DIFF , // PS
  799. D3DSIO_TEXM3x3SPEC , // PS
  800. D3DSIO_TEXM3x3VSPEC , // PS
  801. D3DSIO_EXPP , // VS
  802. D3DSIO_LOGP , // VS
  803. D3DSIO_CND , // PS
  804. D3DSIO_DEF , // PS
  805. D3DSIO_TEXREG2RGB , // PS
  806. D3DSIO_TEXDP3TEX , // PS
  807. D3DSIO_TEXM3x2DEPTH , // PS
  808. D3DSIO_TEXDP3 , // PS
  809. D3DSIO_TEXM3x3 , // PS
  810. D3DSIO_TEXDEPTH , // PS
  811. D3DSIO_CMP , // PS
  812. D3DSIO_BEM , // PS
  813. D3DSIO_PHASE = 0xFFFD,
  814. D3DSIO_COMMENT = 0xFFFE,
  815. D3DSIO_END = 0xFFFF,
  816. D3DSIO_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  817. } D3DSHADER_INSTRUCTION_OPCODE_TYPE;
  818. //
  819. // Co-Issue Instruction Modifier - if set then this instruction is to be
  820. // issued in parallel with the previous instruction(s) for which this bit
  821. // is not set.
  822. //
  823. #define D3DSI_COISSUE 0x40000000
  824. //
  825. // Parameter Token Bit Definitions
  826. //
  827. #define D3DSP_REGNUM_MASK 0x00001FFF
  828. // destination parameter write mask
  829. #define D3DSP_WRITEMASK_0 0x00010000 // Component 0 (X;Red)
  830. #define D3DSP_WRITEMASK_1 0x00020000 // Component 1 (Y;Green)
  831. #define D3DSP_WRITEMASK_2 0x00040000 // Component 2 (Z;Blue)
  832. #define D3DSP_WRITEMASK_3 0x00080000 // Component 3 (W;Alpha)
  833. #define D3DSP_WRITEMASK_ALL 0x000F0000 // All Components
  834. // destination parameter modifiers
  835. #define D3DSP_DSTMOD_SHIFT 20
  836. #define D3DSP_DSTMOD_MASK 0x00F00000
  837. typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE
  838. {
  839. D3DSPDM_NONE = 0<<D3DSP_DSTMOD_SHIFT, // nop
  840. D3DSPDM_SATURATE= 1<<D3DSP_DSTMOD_SHIFT, // clamp to 0. to 1. range
  841. D3DSPDM_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  842. } D3DSHADER_PARAM_DSTMOD_TYPE;
  843. // destination parameter
  844. #define D3DSP_DSTSHIFT_SHIFT 24
  845. #define D3DSP_DSTSHIFT_MASK 0x0F000000
  846. // destination/source parameter register type
  847. #define D3DSP_REGTYPE_SHIFT 28
  848. #define D3DSP_REGTYPE_MASK 0x70000000
  849. typedef enum _D3DSHADER_PARAM_REGISTER_TYPE
  850. {
  851. D3DSPR_TEMP = 0<<D3DSP_REGTYPE_SHIFT, // Temporary Register File
  852. D3DSPR_INPUT = 1<<D3DSP_REGTYPE_SHIFT, // Input Register File
  853. D3DSPR_CONST = 2<<D3DSP_REGTYPE_SHIFT, // Constant Register File
  854. D3DSPR_ADDR = 3<<D3DSP_REGTYPE_SHIFT, // Address Register (VS)
  855. D3DSPR_TEXTURE = 3<<D3DSP_REGTYPE_SHIFT, // Texture Register File (PS)
  856. D3DSPR_RASTOUT = 4<<D3DSP_REGTYPE_SHIFT, // Rasterizer Register File
  857. D3DSPR_ATTROUT = 5<<D3DSP_REGTYPE_SHIFT, // Attribute Output Register File
  858. D3DSPR_TEXCRDOUT= 6<<D3DSP_REGTYPE_SHIFT, // Texture Coordinate Output Register File
  859. D3DSPR_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  860. } D3DSHADER_PARAM_REGISTER_TYPE;
  861. // Register offsets in the Rasterizer Register File
  862. //
  863. typedef enum _D3DVS_RASTOUT_OFFSETS
  864. {
  865. D3DSRO_POSITION = 0,
  866. D3DSRO_FOG,
  867. D3DSRO_POINT_SIZE,
  868. D3DSRO_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  869. } D3DVS_RASTOUT_OFFSETS;
  870. // Source operand addressing modes
  871. #define D3DVS_ADDRESSMODE_SHIFT 13
  872. #define D3DVS_ADDRESSMODE_MASK (1 << D3DVS_ADDRESSMODE_SHIFT)
  873. typedef enum _D3DVS_ADDRESSMODE_TYPE
  874. {
  875. D3DVS_ADDRMODE_ABSOLUTE = (0 << D3DVS_ADDRESSMODE_SHIFT),
  876. D3DVS_ADDRMODE_RELATIVE = (1 << D3DVS_ADDRESSMODE_SHIFT), // Relative to register A0
  877. D3DVS_ADDRMODE_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  878. } D3DVS_ADDRESSMODE_TYPE;
  879. // Source operand swizzle definitions
  880. //
  881. #define D3DVS_SWIZZLE_SHIFT 16
  882. #define D3DVS_SWIZZLE_MASK 0x00FF0000
  883. // The following bits define where to take component X from:
  884. #define D3DVS_X_X (0 << D3DVS_SWIZZLE_SHIFT)
  885. #define D3DVS_X_Y (1 << D3DVS_SWIZZLE_SHIFT)
  886. #define D3DVS_X_Z (2 << D3DVS_SWIZZLE_SHIFT)
  887. #define D3DVS_X_W (3 << D3DVS_SWIZZLE_SHIFT)
  888. // The following bits define where to take component Y from:
  889. #define D3DVS_Y_X (0 << (D3DVS_SWIZZLE_SHIFT + 2))
  890. #define D3DVS_Y_Y (1 << (D3DVS_SWIZZLE_SHIFT + 2))
  891. #define D3DVS_Y_Z (2 << (D3DVS_SWIZZLE_SHIFT + 2))
  892. #define D3DVS_Y_W (3 << (D3DVS_SWIZZLE_SHIFT + 2))
  893. // The following bits define where to take component Z from:
  894. #define D3DVS_Z_X (0 << (D3DVS_SWIZZLE_SHIFT + 4))
  895. #define D3DVS_Z_Y (1 << (D3DVS_SWIZZLE_SHIFT + 4))
  896. #define D3DVS_Z_Z (2 << (D3DVS_SWIZZLE_SHIFT + 4))
  897. #define D3DVS_Z_W (3 << (D3DVS_SWIZZLE_SHIFT + 4))
  898. // The following bits define where to take component W from:
  899. #define D3DVS_W_X (0 << (D3DVS_SWIZZLE_SHIFT + 6))
  900. #define D3DVS_W_Y (1 << (D3DVS_SWIZZLE_SHIFT + 6))
  901. #define D3DVS_W_Z (2 << (D3DVS_SWIZZLE_SHIFT + 6))
  902. #define D3DVS_W_W (3 << (D3DVS_SWIZZLE_SHIFT + 6))
  903. // Value when there is no swizzle (X is taken from X, Y is taken from Y,
  904. // Z is taken from Z, W is taken from W
  905. //
  906. #define D3DVS_NOSWIZZLE (D3DVS_X_X | D3DVS_Y_Y | D3DVS_Z_Z | D3DVS_W_W)
  907. // source parameter swizzle
  908. #define D3DSP_SWIZZLE_SHIFT 16
  909. #define D3DSP_SWIZZLE_MASK 0x00FF0000
  910. #define D3DSP_NOSWIZZLE \
  911. ( (0 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
  912. (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
  913. (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
  914. (3 << (D3DSP_SWIZZLE_SHIFT + 6)) )
  915. // pixel-shader swizzle ops
  916. #define D3DSP_REPLICATERED \
  917. ( (0 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
  918. (0 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
  919. (0 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
  920. (0 << (D3DSP_SWIZZLE_SHIFT + 6)) )
  921. #define D3DSP_REPLICATEGREEN \
  922. ( (1 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
  923. (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
  924. (1 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
  925. (1 << (D3DSP_SWIZZLE_SHIFT + 6)) )
  926. #define D3DSP_REPLICATEBLUE \
  927. ( (2 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
  928. (2 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
  929. (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
  930. (2 << (D3DSP_SWIZZLE_SHIFT + 6)) )
  931. #define D3DSP_REPLICATEALPHA \
  932. ( (3 << (D3DSP_SWIZZLE_SHIFT + 0)) | \
  933. (3 << (D3DSP_SWIZZLE_SHIFT + 2)) | \
  934. (3 << (D3DSP_SWIZZLE_SHIFT + 4)) | \
  935. (3 << (D3DSP_SWIZZLE_SHIFT + 6)) )
  936. // source parameter modifiers
  937. #define D3DSP_SRCMOD_SHIFT 24
  938. #define D3DSP_SRCMOD_MASK 0x0F000000
  939. typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE
  940. {
  941. D3DSPSM_NONE = 0<<D3DSP_SRCMOD_SHIFT, // nop
  942. D3DSPSM_NEG = 1<<D3DSP_SRCMOD_SHIFT, // negate
  943. D3DSPSM_BIAS = 2<<D3DSP_SRCMOD_SHIFT, // bias
  944. D3DSPSM_BIASNEG = 3<<D3DSP_SRCMOD_SHIFT, // bias and negate
  945. D3DSPSM_SIGN = 4<<D3DSP_SRCMOD_SHIFT, // sign
  946. D3DSPSM_SIGNNEG = 5<<D3DSP_SRCMOD_SHIFT, // sign and negate
  947. D3DSPSM_COMP = 6<<D3DSP_SRCMOD_SHIFT, // complement
  948. D3DSPSM_X2 = 7<<D3DSP_SRCMOD_SHIFT, // *2
  949. D3DSPSM_X2NEG = 8<<D3DSP_SRCMOD_SHIFT, // *2 and negate
  950. D3DSPSM_DZ = 9<<D3DSP_SRCMOD_SHIFT, // divide through by z component
  951. D3DSPSM_DW = 10<<D3DSP_SRCMOD_SHIFT, // divide through by w component
  952. D3DSPSM_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  953. } D3DSHADER_PARAM_SRCMOD_TYPE;
  954. // pixel shader version token
  955. #define D3DPS_VERSION(_Major,_Minor) (0xFFFF0000|((_Major)<<8)|(_Minor))
  956. // vertex shader version token
  957. #define D3DVS_VERSION(_Major,_Minor) (0xFFFE0000|((_Major)<<8)|(_Minor))
  958. // extract major/minor from version cap
  959. #define D3DSHADER_VERSION_MAJOR(_Version) (((_Version)>>8)&0xFF)
  960. #define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF)
  961. // destination/source parameter register type
  962. #define D3DSI_COMMENTSIZE_SHIFT 16
  963. #define D3DSI_COMMENTSIZE_MASK 0x7FFF0000
  964. #define D3DSHADER_COMMENT(_DWordSize) \
  965. ((((_DWordSize)<<D3DSI_COMMENTSIZE_SHIFT)&D3DSI_COMMENTSIZE_MASK)|D3DSIO_COMMENT)
  966. // pixel/vertex shader end token
  967. #define D3DPS_END() 0x0000FFFF
  968. #define D3DVS_END() 0x0000FFFF
  969. //---------------------------------------------------------------------
  970. // High order surfaces
  971. //
  972. typedef enum _D3DBASISTYPE
  973. {
  974. D3DBASIS_BEZIER = 0,
  975. D3DBASIS_BSPLINE = 1,
  976. D3DBASIS_INTERPOLATE = 2,
  977. D3DBASIS_FORCE_DWORD = 0x7fffffff,
  978. } D3DBASISTYPE;
  979. typedef enum _D3DORDERTYPE
  980. {
  981. D3DORDER_LINEAR = 1,
  982. D3DORDER_QUADRATIC = 2,
  983. D3DORDER_CUBIC = 3,
  984. D3DORDER_QUINTIC = 5,
  985. D3DORDER_FORCE_DWORD = 0x7fffffff,
  986. } D3DORDERTYPE;
  987. typedef enum _D3DPATCHEDGESTYLE
  988. {
  989. D3DPATCHEDGE_DISCRETE = 0,
  990. D3DPATCHEDGE_CONTINUOUS = 1,
  991. D3DPATCHEDGE_FORCE_DWORD = 0x7fffffff,
  992. } D3DPATCHEDGESTYLE;
  993. typedef enum _D3DSTATEBLOCKTYPE
  994. {
  995. D3DSBT_ALL = 1, // capture all state
  996. D3DSBT_PIXELSTATE = 2, // capture pixel state
  997. D3DSBT_VERTEXSTATE = 3, // capture vertex state
  998. D3DSBT_FORCE_DWORD = 0x7fffffff,
  999. } D3DSTATEBLOCKTYPE;
  1000. // The D3DVERTEXBLENDFLAGS type is used with D3DRS_VERTEXBLEND state.
  1001. //
  1002. typedef enum _D3DVERTEXBLENDFLAGS
  1003. {
  1004. D3DVBF_DISABLE = 0, // Disable vertex blending
  1005. D3DVBF_1WEIGHTS = 1, // 2 matrix blending
  1006. D3DVBF_2WEIGHTS = 2, // 3 matrix blending
  1007. D3DVBF_3WEIGHTS = 3, // 4 matrix blending
  1008. D3DVBF_TWEENING = 255, // blending using D3DRS_TWEENFACTOR
  1009. D3DVBF_0WEIGHTS = 256, // one matrix is used with weight 1.0
  1010. D3DVBF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  1011. } D3DVERTEXBLENDFLAGS;
  1012. typedef enum _D3DTEXTURETRANSFORMFLAGS {
  1013. D3DTTFF_DISABLE = 0, // texture coordinates are passed directly
  1014. D3DTTFF_COUNT1 = 1, // rasterizer should expect 1-D texture coords
  1015. D3DTTFF_COUNT2 = 2, // rasterizer should expect 2-D texture coords
  1016. D3DTTFF_COUNT3 = 3, // rasterizer should expect 3-D texture coords
  1017. D3DTTFF_COUNT4 = 4, // rasterizer should expect 4-D texture coords
  1018. D3DTTFF_PROJECTED = 256, // texcoords to be divided by COUNTth element
  1019. D3DTTFF_FORCE_DWORD = 0x7fffffff,
  1020. } D3DTEXTURETRANSFORMFLAGS;
  1021. // Macros to set texture coordinate format bits in the FVF id
  1022. #define D3DFVF_TEXTUREFORMAT2 0 // Two floating point values
  1023. #define D3DFVF_TEXTUREFORMAT1 3 // One floating point value
  1024. #define D3DFVF_TEXTUREFORMAT3 1 // Three floating point values
  1025. #define D3DFVF_TEXTUREFORMAT4 2 // Four floating point values
  1026. #define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
  1027. #define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
  1028. #define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
  1029. #define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
  1030. //---------------------------------------------------------------------
  1031. /* Direct3D8 Device types */
  1032. typedef enum _D3DDEVTYPE
  1033. {
  1034. D3DDEVTYPE_HAL = 1,
  1035. D3DDEVTYPE_REF = 2,
  1036. D3DDEVTYPE_SW = 3,
  1037. D3DDEVTYPE_FORCE_DWORD = 0x7fffffff
  1038. } D3DDEVTYPE;
  1039. /* Multi-Sample buffer types */
  1040. typedef enum _D3DMULTISAMPLE_TYPE
  1041. {
  1042. D3DMULTISAMPLE_NONE = 0,
  1043. D3DMULTISAMPLE_2_SAMPLES = 2,
  1044. D3DMULTISAMPLE_3_SAMPLES = 3,
  1045. D3DMULTISAMPLE_4_SAMPLES = 4,
  1046. D3DMULTISAMPLE_5_SAMPLES = 5,
  1047. D3DMULTISAMPLE_6_SAMPLES = 6,
  1048. D3DMULTISAMPLE_7_SAMPLES = 7,
  1049. D3DMULTISAMPLE_8_SAMPLES = 8,
  1050. D3DMULTISAMPLE_9_SAMPLES = 9,
  1051. D3DMULTISAMPLE_10_SAMPLES = 10,
  1052. D3DMULTISAMPLE_11_SAMPLES = 11,
  1053. D3DMULTISAMPLE_12_SAMPLES = 12,
  1054. D3DMULTISAMPLE_13_SAMPLES = 13,
  1055. D3DMULTISAMPLE_14_SAMPLES = 14,
  1056. D3DMULTISAMPLE_15_SAMPLES = 15,
  1057. D3DMULTISAMPLE_16_SAMPLES = 16,
  1058. D3DMULTISAMPLE_FORCE_DWORD = 0x7fffffff
  1059. } D3DMULTISAMPLE_TYPE;
  1060. /* Formats
  1061. * Most of these names have the following convention:
  1062. * A = Alpha
  1063. * R = Red
  1064. * G = Green
  1065. * B = Blue
  1066. * X = Unused Bits
  1067. * P = Palette
  1068. * L = Luminance
  1069. * U = dU coordinate for BumpMap
  1070. * V = dV coordinate for BumpMap
  1071. * S = Stencil
  1072. * D = Depth (e.g. Z or W buffer)
  1073. *
  1074. * Further, the order of the pieces are from MSB first; hence
  1075. * D3DFMT_A8L8 indicates that the high byte of this two byte
  1076. * format is alpha.
  1077. *
  1078. * D16 indicates:
  1079. * - An integer 16-bit value.
  1080. * - An app-lockable surface.
  1081. *
  1082. * All Depth/Stencil formats except D3DFMT_D16_LOCKABLE indicate:
  1083. * - no particular bit ordering per pixel, and
  1084. * - are not app lockable, and
  1085. * - the driver is allowed to consume more than the indicated
  1086. * number of bits per Depth channel (but not Stencil channel).
  1087. */
  1088. #ifndef MAKEFOURCC
  1089. #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
  1090. ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
  1091. ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
  1092. #endif /* defined(MAKEFOURCC) */
  1093. typedef enum _D3DFORMAT
  1094. {
  1095. D3DFMT_UNKNOWN = 0,
  1096. D3DFMT_R8G8B8 = 20,
  1097. D3DFMT_A8R8G8B8 = 21,
  1098. D3DFMT_X8R8G8B8 = 22,
  1099. D3DFMT_R5G6B5 = 23,
  1100. D3DFMT_X1R5G5B5 = 24,
  1101. D3DFMT_A1R5G5B5 = 25,
  1102. D3DFMT_A4R4G4B4 = 26,
  1103. D3DFMT_R3G3B2 = 27,
  1104. D3DFMT_A8 = 28,
  1105. D3DFMT_A8R3G3B2 = 29,
  1106. D3DFMT_X4R4G4B4 = 30,
  1107. D3DFMT_A2B10G10R10 = 31,
  1108. D3DFMT_G16R16 = 34,
  1109. D3DFMT_A8P8 = 40,
  1110. D3DFMT_P8 = 41,
  1111. D3DFMT_L8 = 50,
  1112. D3DFMT_A8L8 = 51,
  1113. D3DFMT_A4L4 = 52,
  1114. D3DFMT_V8U8 = 60,
  1115. D3DFMT_L6V5U5 = 61,
  1116. D3DFMT_X8L8V8U8 = 62,
  1117. D3DFMT_Q8W8V8U8 = 63,
  1118. D3DFMT_V16U16 = 64,
  1119. D3DFMT_W11V11U10 = 65,
  1120. D3DFMT_A2W10V10U10 = 67,
  1121. D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
  1122. D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
  1123. D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
  1124. D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
  1125. D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
  1126. D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
  1127. D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
  1128. D3DFMT_D16_LOCKABLE = 70,
  1129. D3DFMT_D32 = 71,
  1130. D3DFMT_D15S1 = 73,
  1131. D3DFMT_D24S8 = 75,
  1132. D3DFMT_D16 = 80,
  1133. D3DFMT_D24X8 = 77,
  1134. D3DFMT_D24X4S4 = 79,
  1135. D3DFMT_VERTEXDATA =100,
  1136. D3DFMT_INDEX16 =101,
  1137. D3DFMT_INDEX32 =102,
  1138. D3DFMT_FORCE_DWORD =0x7fffffff
  1139. } D3DFORMAT;
  1140. /* Display Modes */
  1141. typedef struct _D3DDISPLAYMODE
  1142. {
  1143. UINT Width;
  1144. UINT Height;
  1145. UINT RefreshRate;
  1146. D3DFORMAT Format;
  1147. } D3DDISPLAYMODE;
  1148. /* Creation Parameters */
  1149. typedef struct _D3DDEVICE_CREATION_PARAMETERS
  1150. {
  1151. UINT AdapterOrdinal;
  1152. D3DDEVTYPE DeviceType;
  1153. HWND hFocusWindow;
  1154. DWORD BehaviorFlags;
  1155. } D3DDEVICE_CREATION_PARAMETERS;
  1156. /* SwapEffects */
  1157. typedef enum _D3DSWAPEFFECT
  1158. {
  1159. D3DSWAPEFFECT_DISCARD = 1,
  1160. D3DSWAPEFFECT_FLIP = 2,
  1161. D3DSWAPEFFECT_COPY = 3,
  1162. D3DSWAPEFFECT_COPY_VSYNC = 4,
  1163. D3DSWAPEFFECT_FORCE_DWORD = 0x7fffffff
  1164. } D3DSWAPEFFECT;
  1165. /* Pool types */
  1166. typedef enum _D3DPOOL {
  1167. D3DPOOL_DEFAULT = 0,
  1168. D3DPOOL_MANAGED = 1,
  1169. D3DPOOL_SYSTEMMEM = 2,
  1170. D3DPOOL_SCRATCH = 3,
  1171. D3DPOOL_FORCE_DWORD = 0x7fffffff
  1172. } D3DPOOL;
  1173. /* RefreshRate pre-defines */
  1174. #define D3DPRESENT_RATE_DEFAULT 0x00000000
  1175. #define D3DPRESENT_RATE_UNLIMITED 0x7fffffff
  1176. /* Resize Optional Parameters */
  1177. typedef struct _D3DPRESENT_PARAMETERS_
  1178. {
  1179. UINT BackBufferWidth;
  1180. UINT BackBufferHeight;
  1181. D3DFORMAT BackBufferFormat;
  1182. UINT BackBufferCount;
  1183. D3DMULTISAMPLE_TYPE MultiSampleType;
  1184. D3DSWAPEFFECT SwapEffect;
  1185. HWND hDeviceWindow;
  1186. BOOL Windowed;
  1187. BOOL EnableAutoDepthStencil;
  1188. D3DFORMAT AutoDepthStencilFormat;
  1189. DWORD Flags;
  1190. /* Following elements must be zero for Windowed mode */
  1191. UINT FullScreen_RefreshRateInHz;
  1192. UINT FullScreen_PresentationInterval;
  1193. } D3DPRESENT_PARAMETERS;
  1194. // Values for D3DPRESENT_PARAMETERS.Flags
  1195. #define D3DPRESENTFLAG_LOCKABLE_BACKBUFFER 0x00000001
  1196. /* Gamma Ramp: Same as DX7 */
  1197. typedef struct _D3DGAMMARAMP
  1198. {
  1199. WORD red [256];
  1200. WORD green[256];
  1201. WORD blue [256];
  1202. } D3DGAMMARAMP;
  1203. /* Back buffer types */
  1204. typedef enum _D3DBACKBUFFER_TYPE
  1205. {
  1206. D3DBACKBUFFER_TYPE_MONO = 0,
  1207. D3DBACKBUFFER_TYPE_LEFT = 1,
  1208. D3DBACKBUFFER_TYPE_RIGHT = 2,
  1209. D3DBACKBUFFER_TYPE_FORCE_DWORD = 0x7fffffff
  1210. } D3DBACKBUFFER_TYPE;
  1211. /* Types */
  1212. typedef enum _D3DRESOURCETYPE {
  1213. D3DRTYPE_SURFACE = 1,
  1214. D3DRTYPE_VOLUME = 2,
  1215. D3DRTYPE_TEXTURE = 3,
  1216. D3DRTYPE_VOLUMETEXTURE = 4,
  1217. D3DRTYPE_CUBETEXTURE = 5,
  1218. D3DRTYPE_VERTEXBUFFER = 6,
  1219. D3DRTYPE_INDEXBUFFER = 7,
  1220. D3DRTYPE_FORCE_DWORD = 0x7fffffff
  1221. } D3DRESOURCETYPE;
  1222. /* Usages */
  1223. #define D3DUSAGE_RENDERTARGET (0x00000001L)
  1224. #define D3DUSAGE_DEPTHSTENCIL (0x00000002L)
  1225. /* Usages for Vertex/Index buffers */
  1226. #define D3DUSAGE_WRITEONLY (0x00000008L)
  1227. #define D3DUSAGE_SOFTWAREPROCESSING (0x00000010L)
  1228. #define D3DUSAGE_DONOTCLIP (0x00000020L)
  1229. #define D3DUSAGE_POINTS (0x00000040L)
  1230. #define D3DUSAGE_RTPATCHES (0x00000080L)
  1231. #define D3DUSAGE_NPATCHES (0x00000100L)
  1232. #define D3DUSAGE_DYNAMIC (0x00000200L)
  1233. /* CubeMap Face identifiers */
  1234. typedef enum _D3DCUBEMAP_FACES
  1235. {
  1236. D3DCUBEMAP_FACE_POSITIVE_X = 0,
  1237. D3DCUBEMAP_FACE_NEGATIVE_X = 1,
  1238. D3DCUBEMAP_FACE_POSITIVE_Y = 2,
  1239. D3DCUBEMAP_FACE_NEGATIVE_Y = 3,
  1240. D3DCUBEMAP_FACE_POSITIVE_Z = 4,
  1241. D3DCUBEMAP_FACE_NEGATIVE_Z = 5,
  1242. D3DCUBEMAP_FACE_FORCE_DWORD = 0x7fffffff
  1243. } D3DCUBEMAP_FACES;
  1244. /* Lock flags */
  1245. #define D3DLOCK_READONLY 0x00000010L
  1246. #define D3DLOCK_DISCARD 0x00002000L
  1247. #define D3DLOCK_NOOVERWRITE 0x00001000L
  1248. #define D3DLOCK_NOSYSLOCK 0x00000800L
  1249. #define D3DLOCK_NO_DIRTY_UPDATE 0x00008000L
  1250. /* Vertex Buffer Description */
  1251. typedef struct _D3DVERTEXBUFFER_DESC
  1252. {
  1253. D3DFORMAT Format;
  1254. D3DRESOURCETYPE Type;
  1255. DWORD Usage;
  1256. D3DPOOL Pool;
  1257. UINT Size;
  1258. DWORD FVF;
  1259. } D3DVERTEXBUFFER_DESC;
  1260. /* Index Buffer Description */
  1261. typedef struct _D3DINDEXBUFFER_DESC
  1262. {
  1263. D3DFORMAT Format;
  1264. D3DRESOURCETYPE Type;
  1265. DWORD Usage;
  1266. D3DPOOL Pool;
  1267. UINT Size;
  1268. } D3DINDEXBUFFER_DESC;
  1269. /* Surface Description */
  1270. typedef struct _D3DSURFACE_DESC
  1271. {
  1272. D3DFORMAT Format;
  1273. D3DRESOURCETYPE Type;
  1274. DWORD Usage;
  1275. D3DPOOL Pool;
  1276. UINT Size;
  1277. D3DMULTISAMPLE_TYPE MultiSampleType;
  1278. UINT Width;
  1279. UINT Height;
  1280. } D3DSURFACE_DESC;
  1281. typedef struct _D3DVOLUME_DESC
  1282. {
  1283. D3DFORMAT Format;
  1284. D3DRESOURCETYPE Type;
  1285. DWORD Usage;
  1286. D3DPOOL Pool;
  1287. UINT Size;
  1288. UINT Width;
  1289. UINT Height;
  1290. UINT Depth;
  1291. } D3DVOLUME_DESC;
  1292. /* Structure for LockRect */
  1293. typedef struct _D3DLOCKED_RECT
  1294. {
  1295. INT Pitch;
  1296. void* pBits;
  1297. } D3DLOCKED_RECT;
  1298. /* Structures for LockBox */
  1299. typedef struct _D3DBOX
  1300. {
  1301. UINT Left;
  1302. UINT Top;
  1303. UINT Right;
  1304. UINT Bottom;
  1305. UINT Front;
  1306. UINT Back;
  1307. } D3DBOX;
  1308. typedef struct _D3DLOCKED_BOX
  1309. {
  1310. INT RowPitch;
  1311. INT SlicePitch;
  1312. void* pBits;
  1313. } D3DLOCKED_BOX;
  1314. /* Structures for LockRange */
  1315. typedef struct _D3DRANGE
  1316. {
  1317. UINT Offset;
  1318. UINT Size;
  1319. } D3DRANGE;
  1320. /* Structures for high order primitives */
  1321. typedef struct _D3DRECTPATCH_INFO
  1322. {
  1323. UINT StartVertexOffsetWidth;
  1324. UINT StartVertexOffsetHeight;
  1325. UINT Width;
  1326. UINT Height;
  1327. UINT Stride;
  1328. D3DBASISTYPE Basis;
  1329. D3DORDERTYPE Order;
  1330. } D3DRECTPATCH_INFO;
  1331. typedef struct _D3DTRIPATCH_INFO
  1332. {
  1333. UINT StartVertexOffset;
  1334. UINT NumVertices;
  1335. D3DBASISTYPE Basis;
  1336. D3DORDERTYPE Order;
  1337. } D3DTRIPATCH_INFO;
  1338. /* Adapter Identifier */
  1339. #define MAX_DEVICE_IDENTIFIER_STRING 512
  1340. typedef struct _D3DADAPTER_IDENTIFIER8
  1341. {
  1342. char Driver[MAX_DEVICE_IDENTIFIER_STRING];
  1343. char Description[MAX_DEVICE_IDENTIFIER_STRING];
  1344. #ifdef _WIN32
  1345. LARGE_INTEGER DriverVersion; /* Defined for 32 bit components */
  1346. #else
  1347. DWORD DriverVersionLowPart; /* Defined for 16 bit driver components */
  1348. DWORD DriverVersionHighPart;
  1349. #endif
  1350. DWORD VendorId;
  1351. DWORD DeviceId;
  1352. DWORD SubSysId;
  1353. DWORD Revision;
  1354. GUID DeviceIdentifier;
  1355. DWORD WHQLLevel;
  1356. } D3DADAPTER_IDENTIFIER8;
  1357. /* Raster Status structure returned by GetRasterStatus */
  1358. typedef struct _D3DRASTER_STATUS
  1359. {
  1360. BOOL InVBlank;
  1361. UINT ScanLine;
  1362. } D3DRASTER_STATUS;
  1363. /* Debug monitor tokens (DEBUG only)
  1364. Note that if D3DRS_DEBUGMONITORTOKEN is set, the call is treated as
  1365. passing a token to the debug monitor. For example, if, after passing
  1366. D3DDMT_ENABLE/DISABLE to D3DRS_DEBUGMONITORTOKEN other token values
  1367. are passed in, the enabled/disabled state of the debug
  1368. monitor will still persist.
  1369. The debug monitor defaults to enabled.
  1370. Calling GetRenderState on D3DRS_DEBUGMONITORTOKEN is not of any use.
  1371. */
  1372. typedef enum _D3DDEBUGMONITORTOKENS {
  1373. D3DDMT_ENABLE = 0, // enable debug monitor
  1374. D3DDMT_DISABLE = 1, // disable debug monitor
  1375. D3DDMT_FORCE_DWORD = 0x7fffffff,
  1376. } D3DDEBUGMONITORTOKENS;
  1377. // GetInfo IDs
  1378. #define D3DDEVINFOID_RESOURCEMANAGER 5 /* Used with D3DDEVINFO_RESOURCEMANAGER */
  1379. #define D3DDEVINFOID_VERTEXSTATS 6 /* Used with D3DDEVINFO_D3DVERTEXSTATS */
  1380. typedef struct _D3DRESOURCESTATS
  1381. {
  1382. // Data collected since last Present()
  1383. BOOL bThrashing; /* indicates if thrashing */
  1384. DWORD ApproxBytesDownloaded; /* Approximate number of bytes downloaded by resource manager */
  1385. DWORD NumEvicts; /* number of objects evicted */
  1386. DWORD NumVidCreates; /* number of objects created in video memory */
  1387. DWORD LastPri; /* priority of last object evicted */
  1388. DWORD NumUsed; /* number of objects set to the device */
  1389. DWORD NumUsedInVidMem; /* number of objects set to the device, which are already in video memory */
  1390. // Persistent data
  1391. DWORD WorkingSet; /* number of objects in video memory */
  1392. DWORD WorkingSetBytes; /* number of bytes in video memory */
  1393. DWORD TotalManaged; /* total number of managed objects */
  1394. DWORD TotalBytes; /* total number of bytes of managed objects */
  1395. } D3DRESOURCESTATS;
  1396. #define D3DRTYPECOUNT (D3DRTYPE_INDEXBUFFER+1)
  1397. typedef struct _D3DDEVINFO_RESOURCEMANAGER
  1398. {
  1399. D3DRESOURCESTATS stats[D3DRTYPECOUNT];
  1400. } D3DDEVINFO_RESOURCEMANAGER, *LPD3DDEVINFO_RESOURCEMANAGER;
  1401. typedef struct _D3DDEVINFO_D3DVERTEXSTATS
  1402. {
  1403. DWORD NumRenderedTriangles; /* total number of triangles that are not clipped in this frame */
  1404. DWORD NumExtraClippingTriangles; /* Number of new triangles generated by clipping */
  1405. } D3DDEVINFO_D3DVERTEXSTATS, *LPD3DDEVINFO_D3DVERTEXSTATS;
  1406. #pragma pack()
  1407. #if _MSC_VER >= 1200
  1408. #pragma warning(pop)
  1409. #else
  1410. #ifdef _MSC_VER
  1411. #pragma warning(default:4201)
  1412. #endif
  1413. #endif
  1414. #endif /* (DIRECT3D_VERSION >= 0x0800) */
  1415. #endif /* _D3D8TYPES(P)_H_ */