Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1752 lines
66 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: d3dhal.h
  6. * Content: Direct3D HAL include file
  7. *
  8. ***************************************************************************/
  9. #ifndef _D3DHAL_H_
  10. #define _D3DHAL_H_
  11. #include "ddraw.h"
  12. #include "d3dtypes.h"
  13. #include "d3dcaps.h"
  14. #include "d3d.h"
  15. #include "d3d8.h"
  16. struct _D3DHAL_CALLBACKS;
  17. typedef struct _D3DHAL_CALLBACKS D3DHAL_CALLBACKS, *LPD3DHAL_CALLBACKS;
  18. struct _D3DHAL_CALLBACKS2;
  19. typedef struct _D3DHAL_CALLBACKS2 D3DHAL_CALLBACKS2, *LPD3DHAL_CALLBACKS2;
  20. struct _D3DHAL_CALLBACKS3;
  21. typedef struct _D3DHAL_CALLBACKS3 D3DHAL_CALLBACKS3, *LPD3DHAL_CALLBACKS3;
  22. typedef struct _DDRAWI_DIRECTDRAW_GBL FAR *LPDDRAWI_DIRECTDRAW_GBL;
  23. typedef struct _DDRAWI_DIRECTDRAW_LCL FAR *LPDDRAWI_DIRECTDRAW_LCL;
  24. struct _DDRAWI_DDRAWSURFACE_LCL;
  25. typedef struct _DDRAWI_DDRAWSURFACE_LCL FAR *LPDDRAWI_DDRAWSURFACE_LCL;
  26. /*
  27. * If the HAL driver does not implement clipping, it must reserve at least
  28. * this much space at the end of the LocalVertexBuffer for use by the HEL
  29. * clipping. I.e. the vertex buffer contain dwNumVertices+dwNumClipVertices
  30. * vertices. No extra space is needed by the HEL clipping in the
  31. * LocalHVertexBuffer.
  32. */
  33. #define D3DHAL_NUMCLIPVERTICES 20
  34. /*
  35. * These are a few special internal renderstates etc. that would
  36. * logically be in d3dtypes.h, but that file is external, so they are
  37. * here.
  38. */
  39. #define D3DTSS_MAX ((D3DTEXTURESTAGESTATETYPE)29)
  40. /*
  41. * If DX8 driver wants to support pre-DX8 applications, it should use these
  42. * definitions for pre-DX8 world matrices
  43. */
  44. #define D3DTRANSFORMSTATE_WORLD_DX7 1
  45. #define D3DTRANSFORMSTATE_WORLD1_DX7 4
  46. #define D3DTRANSFORMSTATE_WORLD2_DX7 5
  47. #define D3DTRANSFORMSTATE_WORLD3_DX7 6
  48. /*
  49. * Generally needed maximum state structure sizes. Note that the copy of
  50. * these in refrasti.hpp must be kept in sync with these.
  51. */
  52. #define D3DHAL_MAX_RSTATES (D3DRENDERSTATE_WRAPBIAS + 128)
  53. /* Last state offset for combined render state and texture stage array + 1 */
  54. #define D3DHAL_MAX_RSTATES_AND_STAGES \
  55. (D3DHAL_TSS_RENDERSTATEBASE + \
  56. D3DHAL_TSS_MAXSTAGES * D3DHAL_TSS_STATESPERSTAGE)
  57. /* Last texture state ID */
  58. #define D3DHAL_MAX_TEXTURESTATES (13)
  59. /* Last texture state ID + 1 */
  60. #define D3DHAL_TEXTURESTATEBUF_SIZE (D3DHAL_MAX_TEXTURESTATES+1)
  61. /*
  62. * If no dwNumVertices is given, this is what will be used.
  63. */
  64. #define D3DHAL_DEFAULT_TL_NUM ((32 * 1024) / sizeof (D3DTLVERTEX))
  65. #define D3DHAL_DEFAULT_H_NUM ((32 * 1024) / sizeof (D3DHVERTEX))
  66. /*
  67. * Description for a device.
  68. * This is used to describe a device that is to be created or to query
  69. * the current device.
  70. *
  71. * For DX5 and subsequent runtimes, D3DDEVICEDESC is a user-visible
  72. * structure that is not seen by the device drivers. The runtime
  73. * stitches a D3DDEVICEDESC together using the D3DDEVICEDESC_V1
  74. * embedded in the GLOBALDRIVERDATA and the extended caps queried
  75. * from the driver using GetDriverInfo.
  76. */
  77. typedef struct _D3DDeviceDesc_V1 {
  78. DWORD dwSize; /* Size of D3DDEVICEDESC structure */
  79. DWORD dwFlags; /* Indicates which fields have valid data */
  80. D3DCOLORMODEL dcmColorModel; /* Color model of device */
  81. DWORD dwDevCaps; /* Capabilities of device */
  82. D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */
  83. BOOL bClipping; /* Device can do 3D clipping */
  84. D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */
  85. D3DPRIMCAPS dpcLineCaps;
  86. D3DPRIMCAPS dpcTriCaps;
  87. DWORD dwDeviceRenderBitDepth; /* One of DDBD_16, etc.. */
  88. DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
  89. DWORD dwMaxBufferSize; /* Maximum execute buffer size */
  90. DWORD dwMaxVertexCount; /* Maximum vertex count */
  91. } D3DDEVICEDESC_V1, *LPD3DDEVICEDESC_V1;
  92. #define D3DDEVICEDESCSIZE_V1 (sizeof(D3DDEVICEDESC_V1))
  93. /*
  94. * This is equivalent to the D3DDEVICEDESC understood by DX5, available only
  95. * from DX6. It is the same as D3DDEVICEDESC structure in DX5.
  96. * D3DDEVICEDESC is still the user-visible structure that is not seen by the
  97. * device drivers. The runtime stitches a D3DDEVICEDESC together using the
  98. * D3DDEVICEDESC_V1 embedded in the GLOBALDRIVERDATA and the extended caps
  99. * queried from the driver using GetDriverInfo.
  100. */
  101. typedef struct _D3DDeviceDesc_V2 {
  102. DWORD dwSize; /* Size of D3DDEVICEDESC structure */
  103. DWORD dwFlags; /* Indicates which fields have valid data */
  104. D3DCOLORMODEL dcmColorModel; /* Color model of device */
  105. DWORD dwDevCaps; /* Capabilities of device */
  106. D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */
  107. BOOL bClipping; /* Device can do 3D clipping */
  108. D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */
  109. D3DPRIMCAPS dpcLineCaps;
  110. D3DPRIMCAPS dpcTriCaps;
  111. DWORD dwDeviceRenderBitDepth; /* One of DDBD_16, etc.. */
  112. DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
  113. DWORD dwMaxBufferSize; /* Maximum execute buffer size */
  114. DWORD dwMaxVertexCount; /* Maximum vertex count */
  115. DWORD dwMinTextureWidth, dwMinTextureHeight;
  116. DWORD dwMaxTextureWidth, dwMaxTextureHeight;
  117. DWORD dwMinStippleWidth, dwMaxStippleWidth;
  118. DWORD dwMinStippleHeight, dwMaxStippleHeight;
  119. } D3DDEVICEDESC_V2, *LPD3DDEVICEDESC_V2;
  120. #define D3DDEVICEDESCSIZE_V2 (sizeof(D3DDEVICEDESC_V2))
  121. #if(DIRECT3D_VERSION >= 0x0700)
  122. /*
  123. * This is equivalent to the D3DDEVICEDESC understood by DX6, available only
  124. * from DX6. It is the same as D3DDEVICEDESC structure in DX6.
  125. * D3DDEVICEDESC is still the user-visible structure that is not seen by the
  126. * device drivers. The runtime stitches a D3DDEVICEDESC together using the
  127. * D3DDEVICEDESC_V1 embedded in the GLOBALDRIVERDATA and the extended caps
  128. * queried from the driver using GetDriverInfo.
  129. */
  130. typedef struct _D3DDeviceDesc_V3 {
  131. DWORD dwSize; /* Size of D3DDEVICEDESC structure */
  132. DWORD dwFlags; /* Indicates which fields have valid data */
  133. D3DCOLORMODEL dcmColorModel; /* Color model of device */
  134. DWORD dwDevCaps; /* Capabilities of device */
  135. D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */
  136. BOOL bClipping; /* Device can do 3D clipping */
  137. D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */
  138. D3DPRIMCAPS dpcLineCaps;
  139. D3DPRIMCAPS dpcTriCaps;
  140. DWORD dwDeviceRenderBitDepth; /* One of DDBD_16, etc.. */
  141. DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
  142. DWORD dwMaxBufferSize; /* Maximum execute buffer size */
  143. DWORD dwMaxVertexCount; /* Maximum vertex count */
  144. DWORD dwMinTextureWidth, dwMinTextureHeight;
  145. DWORD dwMaxTextureWidth, dwMaxTextureHeight;
  146. DWORD dwMinStippleWidth, dwMaxStippleWidth;
  147. DWORD dwMinStippleHeight, dwMaxStippleHeight;
  148. DWORD dwMaxTextureRepeat;
  149. DWORD dwMaxTextureAspectRatio;
  150. DWORD dwMaxAnisotropy;
  151. D3DVALUE dvGuardBandLeft;
  152. D3DVALUE dvGuardBandTop;
  153. D3DVALUE dvGuardBandRight;
  154. D3DVALUE dvGuardBandBottom;
  155. D3DVALUE dvExtentsAdjust;
  156. DWORD dwStencilCaps;
  157. DWORD dwFVFCaps; /* low 4 bits: 0 implies TLVERTEX only, 1..8 imply FVF aware */
  158. DWORD dwTextureOpCaps;
  159. WORD wMaxTextureBlendStages;
  160. WORD wMaxSimultaneousTextures;
  161. } D3DDEVICEDESC_V3, *LPD3DDEVICEDESC_V3;
  162. #define D3DDEVICEDESCSIZE_V3 (sizeof(D3DDEVICEDESC_V3))
  163. #endif /* DIRECT3D_VERSION >= 0x0700 */
  164. /* --------------------------------------------------------------
  165. * Instantiated by the HAL driver on driver connection.
  166. */
  167. typedef struct _D3DHAL_GLOBALDRIVERDATA {
  168. DWORD dwSize; // Size of this structure
  169. D3DDEVICEDESC_V1 hwCaps; // Capabilities of the hardware
  170. DWORD dwNumVertices; // see following comment
  171. DWORD dwNumClipVertices; // see following comment
  172. DWORD dwNumTextureFormats; // Number of texture formats
  173. LPDDSURFACEDESC lpTextureFormats; // Pointer to texture formats
  174. } D3DHAL_GLOBALDRIVERDATA;
  175. typedef D3DHAL_GLOBALDRIVERDATA *LPD3DHAL_GLOBALDRIVERDATA;
  176. #define D3DHAL_GLOBALDRIVERDATASIZE (sizeof(D3DHAL_GLOBALDRIVERDATA))
  177. #if(DIRECT3D_VERSION >= 0x0700)
  178. /* --------------------------------------------------------------
  179. * Extended caps introduced with DX5 and queried with
  180. * GetDriverInfo (GUID_D3DExtendedCaps).
  181. */
  182. typedef struct _D3DHAL_D3DDX6EXTENDEDCAPS {
  183. DWORD dwSize; // Size of this structure
  184. DWORD dwMinTextureWidth, dwMaxTextureWidth;
  185. DWORD dwMinTextureHeight, dwMaxTextureHeight;
  186. DWORD dwMinStippleWidth, dwMaxStippleWidth;
  187. DWORD dwMinStippleHeight, dwMaxStippleHeight;
  188. /* fields added for DX6 */
  189. DWORD dwMaxTextureRepeat;
  190. DWORD dwMaxTextureAspectRatio;
  191. DWORD dwMaxAnisotropy;
  192. D3DVALUE dvGuardBandLeft;
  193. D3DVALUE dvGuardBandTop;
  194. D3DVALUE dvGuardBandRight;
  195. D3DVALUE dvGuardBandBottom;
  196. D3DVALUE dvExtentsAdjust;
  197. DWORD dwStencilCaps;
  198. DWORD dwFVFCaps; /* low 4 bits: 0 implies TLVERTEX only, 1..8 imply FVF aware */
  199. DWORD dwTextureOpCaps;
  200. WORD wMaxTextureBlendStages;
  201. WORD wMaxSimultaneousTextures;
  202. } D3DHAL_D3DDX6EXTENDEDCAPS;
  203. #endif /* DIRECT3D_VERSION >= 0x0700 */
  204. /* --------------------------------------------------------------
  205. * Extended caps introduced with DX5 and queried with
  206. * GetDriverInfo (GUID_D3DExtendedCaps).
  207. */
  208. typedef struct _D3DHAL_D3DEXTENDEDCAPS {
  209. DWORD dwSize; // Size of this structure
  210. DWORD dwMinTextureWidth, dwMaxTextureWidth;
  211. DWORD dwMinTextureHeight, dwMaxTextureHeight;
  212. DWORD dwMinStippleWidth, dwMaxStippleWidth;
  213. DWORD dwMinStippleHeight, dwMaxStippleHeight;
  214. /* fields added for DX6 */
  215. DWORD dwMaxTextureRepeat;
  216. DWORD dwMaxTextureAspectRatio;
  217. DWORD dwMaxAnisotropy;
  218. D3DVALUE dvGuardBandLeft;
  219. D3DVALUE dvGuardBandTop;
  220. D3DVALUE dvGuardBandRight;
  221. D3DVALUE dvGuardBandBottom;
  222. D3DVALUE dvExtentsAdjust;
  223. DWORD dwStencilCaps;
  224. DWORD dwFVFCaps; /* low 4 bits: 0 implies TLVERTEX only, 1..8 imply FVF aware */
  225. DWORD dwTextureOpCaps;
  226. WORD wMaxTextureBlendStages;
  227. WORD wMaxSimultaneousTextures;
  228. #if(DIRECT3D_VERSION >= 0x0700)
  229. /* fields added for DX7 */
  230. DWORD dwMaxActiveLights;
  231. D3DVALUE dvMaxVertexW;
  232. WORD wMaxUserClipPlanes;
  233. WORD wMaxVertexBlendMatrices;
  234. DWORD dwVertexProcessingCaps;
  235. DWORD dwReserved1;
  236. DWORD dwReserved2;
  237. DWORD dwReserved3;
  238. DWORD dwReserved4;
  239. #endif /* DIRECT3D_VERSION >= 0x0700 */
  240. } D3DHAL_D3DEXTENDEDCAPS;
  241. typedef D3DHAL_D3DEXTENDEDCAPS *LPD3DHAL_D3DEXTENDEDCAPS;
  242. #define D3DHAL_D3DEXTENDEDCAPSSIZE (sizeof(D3DHAL_D3DEXTENDEDCAPS))
  243. #if(DIRECT3D_VERSION >= 0x0700)
  244. typedef D3DHAL_D3DDX6EXTENDEDCAPS *LPD3DHAL_D3DDX6EXTENDEDCAPS;
  245. #define D3DHAL_D3DDX6EXTENDEDCAPSSIZE (sizeof(D3DHAL_D3DDX6EXTENDEDCAPS))
  246. #endif /* DIRECT3D_VERSION >= 0x0700 */
  247. /* --------------------------------------------------------------
  248. * Argument to the HAL functions.
  249. *
  250. * !!! When this structure is changed, D3DHAL_CONTEXTCREATEDATA in
  251. * windows\published\ntgdistr.h also must be changed to be the same size !!!
  252. *
  253. */
  254. typedef struct _D3DHAL_CONTEXTCREATEDATA
  255. {
  256. union
  257. {
  258. LPDDRAWI_DIRECTDRAW_GBL lpDDGbl; // in: Driver struct (legacy)
  259. LPDDRAWI_DIRECTDRAW_LCL lpDDLcl; // in: For DX7 driver onwards
  260. };
  261. union
  262. {
  263. LPDIRECTDRAWSURFACE lpDDS; // in: Surface to be used as target
  264. LPDDRAWI_DDRAWSURFACE_LCL lpDDSLcl; // For DX7 onwards
  265. };
  266. union
  267. {
  268. LPDIRECTDRAWSURFACE lpDDSZ; // in: Surface to be used as Z
  269. LPDDRAWI_DDRAWSURFACE_LCL lpDDSZLcl; // For DX7 onwards
  270. };
  271. union
  272. {
  273. DWORD dwPID; // in: Current process id
  274. ULONG_PTR dwrstates; // Must be larger enough to hold a pointer as
  275. // we can return a pointer in this field
  276. };
  277. ULONG_PTR dwhContext; // out: Context handle
  278. HRESULT ddrval; // out: Return value
  279. } D3DHAL_CONTEXTCREATEDATA;
  280. typedef D3DHAL_CONTEXTCREATEDATA *LPD3DHAL_CONTEXTCREATEDATA;
  281. typedef struct _D3DHAL_CONTEXTDESTROYDATA
  282. {
  283. ULONG_PTR dwhContext; // in: Context handle
  284. HRESULT ddrval; // out: Return value
  285. } D3DHAL_CONTEXTDESTROYDATA;
  286. typedef D3DHAL_CONTEXTDESTROYDATA *LPD3DHAL_CONTEXTDESTROYDATA;
  287. typedef struct _D3DHAL_CONTEXTDESTROYALLDATA
  288. {
  289. DWORD dwPID; // in: Process id to destroy contexts for
  290. HRESULT ddrval; // out: Return value
  291. } D3DHAL_CONTEXTDESTROYALLDATA;
  292. typedef D3DHAL_CONTEXTDESTROYALLDATA *LPD3DHAL_CONTEXTDESTROYALLDATA;
  293. typedef struct _D3DHAL_SCENECAPTUREDATA
  294. {
  295. ULONG_PTR dwhContext; // in: Context handle
  296. DWORD dwFlag; // in: Indicates beginning or end
  297. HRESULT ddrval; // out: Return value
  298. } D3DHAL_SCENECAPTUREDATA;
  299. typedef D3DHAL_SCENECAPTUREDATA *LPD3DHAL_SCENECAPTUREDATA;
  300. typedef struct _D3DHAL_RENDERSTATEDATA
  301. {
  302. ULONG_PTR dwhContext; // in: Context handle
  303. DWORD dwOffset; // in: Where to find states in buffer
  304. DWORD dwCount; // in: How many states to process
  305. LPDIRECTDRAWSURFACE lpExeBuf; // in: Execute buffer containing data
  306. HRESULT ddrval; // out: Return value
  307. } D3DHAL_RENDERSTATEDATA;
  308. typedef D3DHAL_RENDERSTATEDATA *LPD3DHAL_RENDERSTATEDATA;
  309. typedef struct _D3DHAL_RENDERPRIMITIVEDATA
  310. {
  311. ULONG_PTR dwhContext; // in: Context handle
  312. DWORD dwOffset; // in: Where to find primitive data in buffer
  313. DWORD dwStatus; // in/out: Condition branch status
  314. LPDIRECTDRAWSURFACE lpExeBuf; // in: Execute buffer containing data
  315. DWORD dwTLOffset; // in: Byte offset in lpTLBuf for start of vertex data
  316. LPDIRECTDRAWSURFACE lpTLBuf; // in: Execute buffer containing TLVertex data
  317. D3DINSTRUCTION diInstruction; // in: Primitive instruction
  318. HRESULT ddrval; // out: Return value
  319. } D3DHAL_RENDERPRIMITIVEDATA;
  320. typedef D3DHAL_RENDERPRIMITIVEDATA *LPD3DHAL_RENDERPRIMITIVEDATA;
  321. typedef struct _D3DHAL_TEXTURECREATEDATA
  322. {
  323. ULONG_PTR dwhContext; // in: Context handle
  324. LPDIRECTDRAWSURFACE lpDDS; // in: Pointer to surface object
  325. DWORD dwHandle; // out: Handle to texture
  326. HRESULT ddrval; // out: Return value
  327. } D3DHAL_TEXTURECREATEDATA;
  328. typedef D3DHAL_TEXTURECREATEDATA *LPD3DHAL_TEXTURECREATEDATA;
  329. typedef struct _D3DHAL_TEXTUREDESTROYDATA
  330. {
  331. ULONG_PTR dwhContext; // in: Context handle
  332. DWORD dwHandle; // in: Handle to texture
  333. HRESULT ddrval; // out: Return value
  334. } D3DHAL_TEXTUREDESTROYDATA;
  335. typedef D3DHAL_TEXTUREDESTROYDATA *LPD3DHAL_TEXTUREDESTROYDATA;
  336. typedef struct _D3DHAL_TEXTURESWAPDATA
  337. {
  338. ULONG_PTR dwhContext; // in: Context handle
  339. DWORD dwHandle1; // in: Handle to texture 1
  340. DWORD dwHandle2; // in: Handle to texture 2
  341. HRESULT ddrval; // out: Return value
  342. } D3DHAL_TEXTURESWAPDATA;
  343. typedef D3DHAL_TEXTURESWAPDATA *LPD3DHAL_TEXTURESWAPDATA;
  344. typedef struct _D3DHAL_TEXTUREGETSURFDATA
  345. {
  346. ULONG_PTR dwhContext; // in: Context handle
  347. ULONG_PTR lpDDS; // out: Pointer to surface object
  348. DWORD dwHandle; // in: Handle to texture
  349. HRESULT ddrval; // out: Return value
  350. } D3DHAL_TEXTUREGETSURFDATA;
  351. typedef D3DHAL_TEXTUREGETSURFDATA *LPD3DHAL_TEXTUREGETSURFDATA;
  352. typedef struct _D3DHAL_GETSTATEDATA
  353. {
  354. ULONG_PTR dwhContext; // in: Context handle
  355. DWORD dwWhich; // in: Transform, lighting or render?
  356. D3DSTATE ddState; // in/out: State.
  357. HRESULT ddrval; // out: Return value
  358. } D3DHAL_GETSTATEDATA;
  359. typedef D3DHAL_GETSTATEDATA *LPD3DHAL_GETSTATEDATA;
  360. /* --------------------------------------------------------------
  361. * Direct3D HAL Table.
  362. * Instantiated by the HAL driver on connection.
  363. *
  364. * Calls take the form of:
  365. * retcode = HalCall(HalCallData* lpData);
  366. */
  367. typedef DWORD (__stdcall *LPD3DHAL_CONTEXTCREATECB) (LPD3DHAL_CONTEXTCREATEDATA);
  368. typedef DWORD (__stdcall *LPD3DHAL_CONTEXTDESTROYCB) (LPD3DHAL_CONTEXTDESTROYDATA);
  369. typedef DWORD (__stdcall *LPD3DHAL_CONTEXTDESTROYALLCB) (LPD3DHAL_CONTEXTDESTROYALLDATA);
  370. typedef DWORD (__stdcall *LPD3DHAL_SCENECAPTURECB) (LPD3DHAL_SCENECAPTUREDATA);
  371. typedef DWORD (__stdcall *LPD3DHAL_RENDERSTATECB) (LPD3DHAL_RENDERSTATEDATA);
  372. typedef DWORD (__stdcall *LPD3DHAL_RENDERPRIMITIVECB) (LPD3DHAL_RENDERPRIMITIVEDATA);
  373. typedef DWORD (__stdcall *LPD3DHAL_TEXTURECREATECB) (LPD3DHAL_TEXTURECREATEDATA);
  374. typedef DWORD (__stdcall *LPD3DHAL_TEXTUREDESTROYCB) (LPD3DHAL_TEXTUREDESTROYDATA);
  375. typedef DWORD (__stdcall *LPD3DHAL_TEXTURESWAPCB) (LPD3DHAL_TEXTURESWAPDATA);
  376. typedef DWORD (__stdcall *LPD3DHAL_TEXTUREGETSURFCB) (LPD3DHAL_TEXTUREGETSURFDATA);
  377. typedef DWORD (__stdcall *LPD3DHAL_GETSTATECB) (LPD3DHAL_GETSTATEDATA);
  378. /*
  379. * Regarding dwNumVertices, specify 0 if you are relying on the HEL to do
  380. * everything and you do not need the resultant TLVertex buffer to reside
  381. * in device memory.
  382. * The HAL driver will be asked to allocate dwNumVertices + dwNumClipVertices
  383. * in the case described above.
  384. */
  385. typedef struct _D3DHAL_CALLBACKS
  386. {
  387. DWORD dwSize;
  388. // Device context
  389. LPD3DHAL_CONTEXTCREATECB ContextCreate;
  390. LPD3DHAL_CONTEXTDESTROYCB ContextDestroy;
  391. LPD3DHAL_CONTEXTDESTROYALLCB ContextDestroyAll;
  392. // Scene Capture
  393. LPD3DHAL_SCENECAPTURECB SceneCapture;
  394. LPVOID lpReserved10; // Must be zero
  395. LPVOID lpReserved11; // Must be zero
  396. // Execution
  397. LPD3DHAL_RENDERSTATECB RenderState;
  398. LPD3DHAL_RENDERPRIMITIVECB RenderPrimitive;
  399. DWORD dwReserved; // Must be zero
  400. // Textures
  401. LPD3DHAL_TEXTURECREATECB TextureCreate;
  402. LPD3DHAL_TEXTUREDESTROYCB TextureDestroy;
  403. LPD3DHAL_TEXTURESWAPCB TextureSwap;
  404. LPD3DHAL_TEXTUREGETSURFCB TextureGetSurf;
  405. LPVOID lpReserved12; // Must be zero
  406. LPVOID lpReserved13; // Must be zero
  407. LPVOID lpReserved14; // Must be zero
  408. LPVOID lpReserved15; // Must be zero
  409. LPVOID lpReserved16; // Must be zero
  410. LPVOID lpReserved17; // Must be zero
  411. LPVOID lpReserved18; // Must be zero
  412. LPVOID lpReserved19; // Must be zero
  413. LPVOID lpReserved20; // Must be zero
  414. LPVOID lpReserved21; // Must be zero
  415. // Pipeline state
  416. LPD3DHAL_GETSTATECB GetState;
  417. DWORD dwReserved0; // Must be zero
  418. DWORD dwReserved1; // Must be zero
  419. DWORD dwReserved2; // Must be zero
  420. DWORD dwReserved3; // Must be zero
  421. DWORD dwReserved4; // Must be zero
  422. DWORD dwReserved5; // Must be zero
  423. DWORD dwReserved6; // Must be zero
  424. DWORD dwReserved7; // Must be zero
  425. DWORD dwReserved8; // Must be zero
  426. DWORD dwReserved9; // Must be zero
  427. } D3DHAL_CALLBACKS;
  428. typedef D3DHAL_CALLBACKS *LPD3DHAL_CALLBACKS;
  429. #define D3DHAL_SIZE_V1 sizeof( D3DHAL_CALLBACKS )
  430. typedef struct _D3DHAL_SETRENDERTARGETDATA
  431. {
  432. ULONG_PTR dwhContext; // in: Context handle
  433. union
  434. {
  435. LPDIRECTDRAWSURFACE lpDDS; // in: new render target
  436. LPDDRAWI_DDRAWSURFACE_LCL lpDDSLcl;
  437. };
  438. union
  439. {
  440. LPDIRECTDRAWSURFACE lpDDSZ; // in: new Z buffer
  441. LPDDRAWI_DDRAWSURFACE_LCL lpDDSZLcl;
  442. };
  443. HRESULT ddrval; // out: Return value
  444. } D3DHAL_SETRENDERTARGETDATA;
  445. typedef D3DHAL_SETRENDERTARGETDATA FAR *LPD3DHAL_SETRENDERTARGETDATA;
  446. // This bit is the same as D3DCLEAR_RESERVED0 in d3d8types.h
  447. // When set it means that driver has to cull rects against current viewport.
  448. // The bit is set only for pure devices
  449. //
  450. #define D3DCLEAR_COMPUTERECTS 0x00000008l
  451. typedef struct _D3DHAL_CLEARDATA
  452. {
  453. ULONG_PTR dwhContext; // in: Context handle
  454. // dwFlags can contain D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER
  455. DWORD dwFlags; // in: surfaces to clear
  456. DWORD dwFillColor; // in: Color value for rtarget
  457. DWORD dwFillDepth; // in: Depth value for Z buffer
  458. LPD3DRECT lpRects; // in: Rectangles to clear
  459. DWORD dwNumRects; // in: Number of rectangles
  460. HRESULT ddrval; // out: Return value
  461. } D3DHAL_CLEARDATA;
  462. typedef D3DHAL_CLEARDATA FAR *LPD3DHAL_CLEARDATA;
  463. typedef struct _D3DHAL_DRAWONEPRIMITIVEDATA
  464. {
  465. ULONG_PTR dwhContext; // in: Context handle
  466. DWORD dwFlags; // in: flags
  467. D3DPRIMITIVETYPE PrimitiveType; // in: type of primitive to draw
  468. union{
  469. D3DVERTEXTYPE VertexType; // in: type of vertices
  470. DWORD dwFVFControl; // in: FVF control DWORD
  471. };
  472. LPVOID lpvVertices; // in: pointer to vertices
  473. DWORD dwNumVertices; // in: number of vertices
  474. DWORD dwReserved; // in: reserved
  475. HRESULT ddrval; // out: Return value
  476. } D3DHAL_DRAWONEPRIMITIVEDATA;
  477. typedef D3DHAL_DRAWONEPRIMITIVEDATA *LPD3DHAL_DRAWONEPRIMITIVEDATA;
  478. typedef struct _D3DHAL_DRAWONEINDEXEDPRIMITIVEDATA
  479. {
  480. ULONG_PTR dwhContext; // in: Context handle
  481. DWORD dwFlags; // in: flags word
  482. // Primitive and vertex type
  483. D3DPRIMITIVETYPE PrimitiveType; // in: primitive type
  484. union{
  485. D3DVERTEXTYPE VertexType; // in: vertex type
  486. DWORD dwFVFControl; // in: FVF control DWORD
  487. };
  488. // Vertices
  489. LPVOID lpvVertices; // in: vertex data
  490. DWORD dwNumVertices; // in: vertex count
  491. // Indices
  492. LPWORD lpwIndices; // in: index data
  493. DWORD dwNumIndices; // in: index count
  494. HRESULT ddrval; // out: Return value
  495. } D3DHAL_DRAWONEINDEXEDPRIMITIVEDATA;
  496. typedef D3DHAL_DRAWONEINDEXEDPRIMITIVEDATA *LPD3DHAL_DRAWONEINDEXEDPRIMITIVEDATA;
  497. typedef struct _D3DHAL_DRAWPRIMCOUNTS
  498. {
  499. WORD wNumStateChanges;
  500. WORD wPrimitiveType;
  501. WORD wVertexType;
  502. WORD wNumVertices;
  503. } D3DHAL_DRAWPRIMCOUNTS, *LPD3DHAL_DRAWPRIMCOUNTS;
  504. typedef struct _D3DHAL_DRAWPRIMITIVESDATA
  505. {
  506. ULONG_PTR dwhContext; // in: Context handle
  507. DWORD dwFlags;
  508. //
  509. // Data block:
  510. //
  511. // Consists of interleaved D3DHAL_DRAWPRIMCOUNTS, state change pairs,
  512. // and primitive drawing commands.
  513. //
  514. // D3DHAL_DRAWPRIMCOUNTS: gives number of state change pairs and
  515. // the information on the primitive to draw.
  516. // wPrimitiveType is of type D3DPRIMITIVETYPE. Drivers
  517. // must support all 7 of the primitive types specified
  518. // in the DrawPrimitive API.
  519. // Currently, wVertexType will always be D3DVT_TLVERTEX.
  520. // If the wNumVertices member is 0, then the driver should
  521. // return after doing the state changing. This is the
  522. // terminator for the command stream.
  523. // state change pairs: DWORD pairs specify the state changes that
  524. // the driver should effect before drawing the primitive.
  525. // wNumStateChanges can be 0, in which case the next primitive
  526. // should be drawn without any state changes in between.
  527. // If present, the state change pairs are NOT aligned, they
  528. // immediately follow the PRIMCOUNTS structure.
  529. // vertex data (if any): is 32-byte aligned.
  530. //
  531. // If a primcounts structure follows (i.e. if wNumVertices was nonzero
  532. // in the previous one), then it will immediately follow the state
  533. // changes or vertex data with no alignment padding.
  534. //
  535. LPVOID lpvData;
  536. DWORD dwFVFControl; // in: FVF control DWORD
  537. HRESULT ddrval; // out: Return value
  538. } D3DHAL_DRAWPRIMITIVESDATA;
  539. typedef D3DHAL_DRAWPRIMITIVESDATA *LPD3DHAL_DRAWPRIMITIVESDATA;
  540. typedef DWORD (CALLBACK *LPD3DHAL_SETRENDERTARGETCB) (LPD3DHAL_SETRENDERTARGETDATA);
  541. typedef DWORD (CALLBACK *LPD3DHAL_CLEARCB) (LPD3DHAL_CLEARDATA);
  542. typedef DWORD (CALLBACK *LPD3DHAL_DRAWONEPRIMITIVECB) (LPD3DHAL_DRAWONEPRIMITIVEDATA);
  543. typedef DWORD (CALLBACK *LPD3DHAL_DRAWONEINDEXEDPRIMITIVECB) (LPD3DHAL_DRAWONEINDEXEDPRIMITIVEDATA);
  544. typedef DWORD (CALLBACK *LPD3DHAL_DRAWPRIMITIVESCB) (LPD3DHAL_DRAWPRIMITIVESDATA);
  545. typedef struct _D3DHAL_CALLBACKS2
  546. {
  547. DWORD dwSize; // size of struct
  548. DWORD dwFlags; // flags for callbacks
  549. LPD3DHAL_SETRENDERTARGETCB SetRenderTarget;
  550. LPD3DHAL_CLEARCB Clear;
  551. LPD3DHAL_DRAWONEPRIMITIVECB DrawOnePrimitive;
  552. LPD3DHAL_DRAWONEINDEXEDPRIMITIVECB DrawOneIndexedPrimitive;
  553. LPD3DHAL_DRAWPRIMITIVESCB DrawPrimitives;
  554. } D3DHAL_CALLBACKS2;
  555. typedef D3DHAL_CALLBACKS2 *LPD3DHAL_CALLBACKS2;
  556. #define D3DHAL_CALLBACKS2SIZE sizeof(D3DHAL_CALLBACKS2)
  557. #define D3DHAL2_CB32_SETRENDERTARGET 0x00000001L
  558. #define D3DHAL2_CB32_CLEAR 0x00000002L
  559. #define D3DHAL2_CB32_DRAWONEPRIMITIVE 0x00000004L
  560. #define D3DHAL2_CB32_DRAWONEINDEXEDPRIMITIVE 0x00000008L
  561. #define D3DHAL2_CB32_DRAWPRIMITIVES 0x00000010L
  562. /* --------------------------------------------------------------
  563. * D3DCallbacks3 - queried with GetDriverInfo (GUID_D3DCallbacks3).
  564. *
  565. * Clear2 - enables stencil clears (exposed to the API in
  566. * IDirect3DViewport3::Clear2
  567. * ValidateTextureStageState - evaluates the context's current state (including
  568. * multitexture) and returns an error if the hardware cannot
  569. * accelerate the current state vector.
  570. * DrawPrimitives2 - Renders primitives, and changes device state specified
  571. * in the command buffer.
  572. *
  573. * Multitexture-aware drivers must implement both ValidateTextureStageState.
  574. */
  575. typedef struct _D3DHAL_CLEAR2DATA
  576. {
  577. ULONG_PTR dwhContext; // in: Context handle
  578. // dwFlags can contain D3DCLEAR_TARGET, D3DCLEAR_ZBUFFER, and/or D3DCLEAR_STENCIL
  579. DWORD dwFlags; // in: surfaces to clear
  580. DWORD dwFillColor; // in: Color value for rtarget
  581. D3DVALUE dvFillDepth; // in: Depth value for Z buffer (0.0-1.0)
  582. DWORD dwFillStencil; // in: value used to clear stencil buffer
  583. LPD3DRECT lpRects; // in: Rectangles to clear
  584. DWORD dwNumRects; // in: Number of rectangles
  585. HRESULT ddrval; // out: Return value
  586. } D3DHAL_CLEAR2DATA;
  587. typedef D3DHAL_CLEAR2DATA FAR *LPD3DHAL_CLEAR2DATA;
  588. typedef struct _D3DHAL_VALIDATETEXTURESTAGESTATEDATA
  589. {
  590. ULONG_PTR dwhContext; // in: Context handle
  591. DWORD dwFlags; // in: Flags, currently set to 0
  592. ULONG_PTR dwReserved; //
  593. DWORD dwNumPasses; // out: Number of passes the hardware
  594. // can perform the operation in
  595. HRESULT ddrval; // out: return value
  596. } D3DHAL_VALIDATETEXTURESTAGESTATEDATA;
  597. typedef D3DHAL_VALIDATETEXTURESTAGESTATEDATA *LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA;
  598. //-----------------------------------------------------------------------------
  599. // DrawPrimitives2 DDI
  600. //-----------------------------------------------------------------------------
  601. //
  602. // Command structure for vertex buffer rendering
  603. //
  604. typedef struct _D3DHAL_DP2COMMAND
  605. {
  606. BYTE bCommand; // vertex command
  607. BYTE bReserved;
  608. union
  609. {
  610. WORD wPrimitiveCount; // primitive count for unconnected primitives
  611. WORD wStateCount; // count of render states to follow
  612. };
  613. } D3DHAL_DP2COMMAND, *LPD3DHAL_DP2COMMAND;
  614. //
  615. // DrawPrimitives2 commands:
  616. //
  617. typedef enum _D3DHAL_DP2OPERATION
  618. {
  619. D3DDP2OP_POINTS = 1,
  620. D3DDP2OP_INDEXEDLINELIST = 2,
  621. D3DDP2OP_INDEXEDTRIANGLELIST = 3,
  622. D3DDP2OP_RESERVED0 = 4, // Used by the front-end only
  623. D3DDP2OP_RENDERSTATE = 8,
  624. D3DDP2OP_LINELIST = 15,
  625. D3DDP2OP_LINESTRIP = 16,
  626. D3DDP2OP_INDEXEDLINESTRIP = 17,
  627. D3DDP2OP_TRIANGLELIST = 18,
  628. D3DDP2OP_TRIANGLESTRIP = 19,
  629. D3DDP2OP_INDEXEDTRIANGLESTRIP = 20,
  630. D3DDP2OP_TRIANGLEFAN = 21,
  631. D3DDP2OP_INDEXEDTRIANGLEFAN = 22,
  632. D3DDP2OP_TRIANGLEFAN_IMM = 23,
  633. D3DDP2OP_LINELIST_IMM = 24,
  634. D3DDP2OP_TEXTURESTAGESTATE = 25, // Has edge flags and called from Execute
  635. D3DDP2OP_INDEXEDTRIANGLELIST2 = 26,
  636. D3DDP2OP_INDEXEDLINELIST2 = 27,
  637. D3DDP2OP_VIEWPORTINFO = 28,
  638. D3DDP2OP_WINFO = 29,
  639. // two below are for pre-DX7 interface apps running DX7 driver
  640. D3DDP2OP_SETPALETTE = 30,
  641. D3DDP2OP_UPDATEPALETTE = 31,
  642. #if(DIRECT3D_VERSION >= 0x0700)
  643. // New for DX7
  644. D3DDP2OP_ZRANGE = 32,
  645. D3DDP2OP_SETMATERIAL = 33,
  646. D3DDP2OP_SETLIGHT = 34,
  647. D3DDP2OP_CREATELIGHT = 35,
  648. D3DDP2OP_SETTRANSFORM = 36,
  649. D3DDP2OP_EXT = 37,
  650. D3DDP2OP_TEXBLT = 38,
  651. D3DDP2OP_STATESET = 39,
  652. D3DDP2OP_SETPRIORITY = 40,
  653. #endif /* DIRECT3D_VERSION >= 0x0700 */
  654. D3DDP2OP_SETRENDERTARGET = 41,
  655. D3DDP2OP_CLEAR = 42,
  656. #if(DIRECT3D_VERSION >= 0x0700)
  657. D3DDP2OP_SETTEXLOD = 43,
  658. D3DDP2OP_SETCLIPPLANE = 44,
  659. #endif /* DIRECT3D_VERSION >= 0x0700 */
  660. #if(DIRECT3D_VERSION >= 0x0800)
  661. D3DDP2OP_CREATEVERTEXSHADER = 45,
  662. D3DDP2OP_DELETEVERTEXSHADER = 46,
  663. D3DDP2OP_SETVERTEXSHADER = 47,
  664. D3DDP2OP_SETVERTEXSHADERCONST = 48,
  665. D3DDP2OP_SETSTREAMSOURCE = 49,
  666. D3DDP2OP_SETSTREAMSOURCEUM = 50,
  667. D3DDP2OP_SETINDICES = 51,
  668. D3DDP2OP_DRAWPRIMITIVE = 52,
  669. D3DDP2OP_DRAWINDEXEDPRIMITIVE = 53,
  670. D3DDP2OP_CREATEPIXELSHADER = 54,
  671. D3DDP2OP_DELETEPIXELSHADER = 55,
  672. D3DDP2OP_SETPIXELSHADER = 56,
  673. D3DDP2OP_SETPIXELSHADERCONST = 57,
  674. D3DDP2OP_CLIPPEDTRIANGLEFAN = 58,
  675. D3DDP2OP_DRAWPRIMITIVE2 = 59,
  676. D3DDP2OP_DRAWINDEXEDPRIMITIVE2= 60,
  677. D3DDP2OP_DRAWRECTPATCH = 61,
  678. D3DDP2OP_DRAWTRIPATCH = 62,
  679. D3DDP2OP_VOLUMEBLT = 63,
  680. D3DDP2OP_BUFFERBLT = 64,
  681. D3DDP2OP_MULTIPLYTRANSFORM = 65,
  682. D3DDP2OP_ADDDIRTYRECT = 66,
  683. D3DDP2OP_ADDDIRTYBOX = 67
  684. #endif /* DIRECT3D_VERSION >= 0x0800 */
  685. } D3DHAL_DP2OPERATION;
  686. //
  687. // DrawPrimitives2 point primitives
  688. //
  689. typedef struct _D3DHAL_DP2POINTS
  690. {
  691. WORD wCount;
  692. WORD wVStart;
  693. } D3DHAL_DP2POINTS, *LPD3DHAL_DP2POINTS;
  694. //
  695. // DrawPrimitives2 line primitives
  696. //
  697. typedef struct _D3DHAL_DP2STARTVERTEX
  698. {
  699. WORD wVStart;
  700. } D3DHAL_DP2STARTVERTEX, *LPD3DHAL_DP2STARTVERTEX;
  701. typedef struct _D3DHAL_DP2LINELIST
  702. {
  703. WORD wVStart;
  704. } D3DHAL_DP2LINELIST, *LPD3DHAL_DP2LINELIST;
  705. typedef struct _D3DHAL_DP2INDEXEDLINELIST
  706. {
  707. WORD wV1;
  708. WORD wV2;
  709. } D3DHAL_DP2INDEXEDLINELIST, *LPD3DHAL_DP2INDEXEDLINELIST;
  710. typedef struct _D3DHAL_DP2LINESTRIP
  711. {
  712. WORD wVStart;
  713. } D3DHAL_DP2LINESTRIP, *LPD3DHAL_DP2LINESTRIP;
  714. typedef struct _D3DHAL_DP2INDEXEDLINESTRIP
  715. {
  716. WORD wV[2];
  717. } D3DHAL_DP2INDEXEDLINESTRIP, *LPD3DHAL_DP2INDEXEDLINESTRIP;
  718. //
  719. // DrawPrimitives2 triangle primitives
  720. //
  721. typedef struct _D3DHAL_DP2TRIANGLELIST
  722. {
  723. WORD wVStart;
  724. } D3DHAL_DP2TRIANGLELIST, *LPD3DHAL_DP2TRIANGLELIST;
  725. typedef struct _D3DHAL_DP2INDEXEDTRIANGLELIST
  726. {
  727. WORD wV1;
  728. WORD wV2;
  729. WORD wV3;
  730. WORD wFlags;
  731. } D3DHAL_DP2INDEXEDTRIANGLELIST, *LPD3DHAL_DP2INDEXEDTRIANGLELIST;
  732. typedef struct _D3DHAL_DP2INDEXEDTRIANGLELIST2
  733. {
  734. WORD wV1;
  735. WORD wV2;
  736. WORD wV3;
  737. } D3DHAL_DP2INDEXEDTRIANGLELIST2, *LPD3DHAL_DP2INDEXEDTRIANGLELIST2;
  738. typedef struct _D3DHAL_DP2TRIANGLESTRIP
  739. {
  740. WORD wVStart;
  741. } D3DHAL_DP2TRIANGLESTRIP, *LPD3DHAL_DP2TRIANGLESTRIP;
  742. typedef struct _D3DHAL_DP2INDEXEDTRIANGLESTRIP
  743. {
  744. WORD wV[3];
  745. } D3DHAL_DP2INDEXEDTRIANGLESTRIP, *LPD3DHAL_DP2INDEXEDTRIANGLESTRIP;
  746. typedef struct _D3DHAL_DP2TRIANGLEFAN
  747. {
  748. WORD wVStart;
  749. } D3DHAL_DP2TRIANGLEFAN, *LPD3DHAL_DP2TRIANGLEFAN;
  750. typedef struct _D3DHAL_DP2INDEXEDTRIANGLEFAN
  751. {
  752. WORD wV[3];
  753. } D3DHAL_DP2INDEXEDTRIANGLEFAN, *LPD3DHAL_DP2INDEXEDTRIANGLEFAN;
  754. typedef struct _D3DHAL_DP2TRIANGLEFAN_IMM
  755. {
  756. DWORD dwEdgeFlags;
  757. } D3DHAL_DP2TRIANGLEFAN_IMM;
  758. typedef D3DHAL_DP2TRIANGLEFAN_IMM *LPD3DHAL_DP2TRIANGLEFAN_IMM;
  759. //
  760. // DrawPrimitives2 Renderstate changes
  761. //
  762. typedef struct _D3DHAL_DP2RENDERSTATE
  763. {
  764. D3DRENDERSTATETYPE RenderState;
  765. union
  766. {
  767. D3DVALUE dvState;
  768. DWORD dwState;
  769. };
  770. } D3DHAL_DP2RENDERSTATE;
  771. typedef D3DHAL_DP2RENDERSTATE * LPD3DHAL_DP2RENDERSTATE;
  772. typedef struct _D3DHAL_DP2TEXTURESTAGESTATE
  773. {
  774. WORD wStage;
  775. WORD TSState;
  776. DWORD dwValue;
  777. } D3DHAL_DP2TEXTURESTAGESTATE;
  778. typedef D3DHAL_DP2TEXTURESTAGESTATE *LPD3DHAL_DP2TEXTURESTAGESTATE;
  779. typedef struct _D3DHAL_DP2VIEWPORTINFO
  780. {
  781. DWORD dwX;
  782. DWORD dwY;
  783. DWORD dwWidth;
  784. DWORD dwHeight;
  785. } D3DHAL_DP2VIEWPORTINFO;
  786. typedef D3DHAL_DP2VIEWPORTINFO *LPD3DHAL_DP2VIEWPORTINFO;
  787. typedef struct _D3DHAL_DP2WINFO
  788. {
  789. D3DVALUE dvWNear;
  790. D3DVALUE dvWFar;
  791. } D3DHAL_DP2WINFO;
  792. typedef D3DHAL_DP2WINFO *LPD3DHAL_DP2WINFO;
  793. typedef struct _D3DHAL_DP2SETPALETTE
  794. {
  795. DWORD dwPaletteHandle;
  796. DWORD dwPaletteFlags;
  797. DWORD dwSurfaceHandle;
  798. } D3DHAL_DP2SETPALETTE;
  799. typedef D3DHAL_DP2SETPALETTE *LPD3DHAL_DP2SETPALETTE;
  800. typedef struct _D3DHAL_DP2UPDATEPALETTE
  801. {
  802. DWORD dwPaletteHandle;
  803. WORD wStartIndex;
  804. WORD wNumEntries;
  805. } D3DHAL_DP2UPDATEPALETTE;
  806. typedef D3DHAL_DP2UPDATEPALETTE *LPD3DHAL_DP2UPDATEPALETTE;
  807. typedef struct _D3DHAL_DP2SETRENDERTARGET
  808. {
  809. DWORD hRenderTarget;
  810. DWORD hZBuffer;
  811. } D3DHAL_DP2SETRENDERTARGET;
  812. typedef D3DHAL_DP2SETRENDERTARGET *LPD3DHAL_DP2SETRENDERTARGET;
  813. #if(DIRECT3D_VERSION >= 0x0700)
  814. // Values for dwOperations in the D3DHAL_DP2STATESET
  815. #define D3DHAL_STATESETBEGIN 0
  816. #define D3DHAL_STATESETEND 1
  817. #define D3DHAL_STATESETDELETE 2
  818. #define D3DHAL_STATESETEXECUTE 3
  819. #define D3DHAL_STATESETCAPTURE 4
  820. #endif /* DIRECT3D_VERSION >= 0x0700 */
  821. #if(DIRECT3D_VERSION >= 0x0800)
  822. #define D3DHAL_STATESETCREATE 5
  823. #endif /* DIRECT3D_VERSION >= 0x0800 */
  824. #if(DIRECT3D_VERSION >= 0x0700)
  825. typedef struct _D3DHAL_DP2STATESET
  826. {
  827. DWORD dwOperation;
  828. DWORD dwParam; // State set handle passed with D3DHAL_STATESETBEGIN,
  829. // D3DHAL_STATESETEXECUTE, D3DHAL_STATESETDELETE
  830. // D3DHAL_STATESETCAPTURE
  831. D3DSTATEBLOCKTYPE sbType; // Type use with D3DHAL_STATESETBEGIN/END
  832. } D3DHAL_DP2STATESET;
  833. typedef D3DHAL_DP2STATESET *LPD3DHAL_DP2STATESET;
  834. //
  835. // T&L Hal specific stuff
  836. //
  837. typedef struct _D3DHAL_DP2ZRANGE
  838. {
  839. D3DVALUE dvMinZ;
  840. D3DVALUE dvMaxZ;
  841. } D3DHAL_DP2ZRANGE;
  842. typedef D3DHAL_DP2ZRANGE *LPD3DHAL_DP2ZRANGE;
  843. typedef D3DMATERIAL7 D3DHAL_DP2SETMATERIAL, *LPD3DHAL_DP2SETMATERIAL;
  844. // Values for dwDataType in D3DHAL_DP2SETLIGHT
  845. #define D3DHAL_SETLIGHT_ENABLE 0
  846. #define D3DHAL_SETLIGHT_DISABLE 1
  847. // If this is set, light data will be passed in after the
  848. // D3DLIGHT7 structure
  849. #define D3DHAL_SETLIGHT_DATA 2
  850. typedef struct _D3DHAL_DP2SETLIGHT
  851. {
  852. DWORD dwIndex;
  853. DWORD dwDataType;
  854. } D3DHAL_DP2SETLIGHT;
  855. typedef D3DHAL_DP2SETLIGHT *LPD3DHAL_DP2SETLIGHT;
  856. typedef struct _D3DHAL_DP2SETCLIPPLANE
  857. {
  858. DWORD dwIndex;
  859. D3DVALUE plane[4];
  860. } D3DHAL_DP2SETCLIPPLANE;
  861. typedef D3DHAL_DP2SETCLIPPLANE *LPD3DHAL_DP2SETCLIPPLANE;
  862. typedef struct _D3DHAL_DP2CREATELIGHT
  863. {
  864. DWORD dwIndex;
  865. } D3DHAL_DP2CREATELIGHT;
  866. typedef D3DHAL_DP2CREATELIGHT *LPD3DHAL_DP2CREATELIGHT;
  867. typedef struct _D3DHAL_DP2SETTRANSFORM
  868. {
  869. D3DTRANSFORMSTATETYPE xfrmType;
  870. D3DMATRIX matrix;
  871. } D3DHAL_DP2SETTRANSFORM;
  872. typedef D3DHAL_DP2SETTRANSFORM *LPD3DHAL_DP2SETTRANSFORM;
  873. typedef struct _D3DHAL_DP2MULTIPLYTRANSFORM
  874. {
  875. D3DTRANSFORMSTATETYPE xfrmType;
  876. D3DMATRIX matrix;
  877. } D3DHAL_DP2MULTIPLYTRANSFORM;
  878. typedef D3DHAL_DP2MULTIPLYTRANSFORM *LPD3DHAL_DP2MULTIPLYTRANSFORM;
  879. typedef struct _D3DHAL_DP2EXT
  880. {
  881. DWORD dwExtToken;
  882. DWORD dwSize;
  883. } D3DHAL_DP2EXT;
  884. typedef D3DHAL_DP2EXT *LPD3DHAL_DP2EXT;
  885. typedef struct _D3DHAL_DP2TEXBLT
  886. {
  887. DWORD dwDDDestSurface;// dest surface
  888. DWORD dwDDSrcSurface; // src surface
  889. POINT pDest;
  890. RECTL rSrc; // src rect
  891. DWORD dwFlags; // blt flags
  892. } D3DHAL_DP2TEXBLT;
  893. typedef D3DHAL_DP2TEXBLT *LPD3DHAL_DP2TEXBLT;
  894. typedef struct _D3DHAL_DP2SETPRIORITY
  895. {
  896. DWORD dwDDSurface;
  897. DWORD dwPriority;
  898. } D3DHAL_DP2SETPRIORITY;
  899. typedef D3DHAL_DP2SETPRIORITY *LPD3DHAL_DP2SETPRIORITY;
  900. #endif /* DIRECT3D_VERSION >= 0x0700 */
  901. typedef struct _D3DHAL_DP2CLEAR
  902. {
  903. // dwFlags can contain D3DCLEAR_TARGET, D3DCLEAR_ZBUFFER, and/or D3DCLEAR_STENCIL
  904. DWORD dwFlags; // in: surfaces to clear
  905. DWORD dwFillColor; // in: Color value for rtarget
  906. D3DVALUE dvFillDepth; // in: Depth value for Z buffer (0.0-1.0)
  907. DWORD dwFillStencil; // in: value used to clear stencil buffer
  908. RECT Rects[1]; // in: Rectangles to clear
  909. } D3DHAL_DP2CLEAR;
  910. typedef D3DHAL_DP2CLEAR *LPD3DHAL_DP2CLEAR;
  911. #if(DIRECT3D_VERSION >= 0x0700)
  912. typedef struct _D3DHAL_DP2SETTEXLOD
  913. {
  914. DWORD dwDDSurface;
  915. DWORD dwLOD;
  916. } D3DHAL_DP2SETTEXLOD;
  917. typedef D3DHAL_DP2SETTEXLOD *LPD3DHAL_DP2SETTEXLOD;
  918. #endif /* DIRECT3D_VERSION >= 0x0700 */
  919. #if(DIRECT3D_VERSION >= 0x0800)
  920. // Used by SetVertexShader and DeleteVertexShader
  921. typedef struct _D3DHAL_DP2VERTEXSHADER
  922. {
  923. // Vertex shader handle.
  924. // The handle could be 0, meaning that the current vertex shader is invalid
  925. // (not set). When driver recieves handle 0, it should invalidate all
  926. // streams pointer
  927. DWORD dwHandle;
  928. } D3DHAL_DP2VERTEXSHADER;
  929. typedef D3DHAL_DP2VERTEXSHADER *LPD3DHAL_DP2VERTEXSHADER;
  930. typedef struct _D3DHAL_DP2CREATEVERTEXSHADER
  931. {
  932. DWORD dwHandle; // Shader handle
  933. DWORD dwDeclSize; // Shader declaration size in bytes
  934. DWORD dwCodeSize; // Shader code size in bytes
  935. // Declaration follows
  936. // Shader code follows
  937. } D3DHAL_DP2CREATEVERTEXSHADER;
  938. typedef D3DHAL_DP2CREATEVERTEXSHADER *LPD3DHAL_DP2CREATEVERTEXSHADER;
  939. typedef struct _D3DHAL_DP2SETVERTEXSHADERCONST
  940. {
  941. DWORD dwRegister; // Const register to start copying
  942. DWORD dwCount; // Number of 4-float vectors to copy
  943. // Data follows
  944. } D3DHAL_DP2SETVERTEXSHADERCONST;
  945. typedef D3DHAL_DP2SETVERTEXSHADERCONST *LPD3DHAL_DP2SETVERTEXSHADERCONST;
  946. typedef struct _D3DHAL_DP2SETSTREAMSOURCE
  947. {
  948. DWORD dwStream; // Stream index, starting from zero
  949. DWORD dwVBHandle; // Vertex buffer handle
  950. DWORD dwStride; // Vertex size in bytes
  951. } D3DHAL_DP2SETSTREAMSOURCE;
  952. typedef D3DHAL_DP2SETSTREAMSOURCE *LPD3DHAL_DP2SETSTREAMSOURCE;
  953. typedef struct _D3DHAL_DP2SETSTREAMSOURCEUM
  954. {
  955. DWORD dwStream; // Stream index, starting from zero
  956. DWORD dwStride; // Vertex size in bytes
  957. } D3DHAL_DP2SETSTREAMSOURCEUM;
  958. typedef D3DHAL_DP2SETSTREAMSOURCEUM *LPD3DHAL_DP2SETSTREAMSOURCEUM;
  959. typedef struct _D3DHAL_DP2SETINDICES
  960. {
  961. DWORD dwVBHandle; // Index buffer handle
  962. DWORD dwStride; // Index size in bytes (2 or 4)
  963. } D3DHAL_DP2SETINDICES;
  964. typedef D3DHAL_DP2SETINDICES *LPD3DHAL_DP2SETINDICES;
  965. typedef struct _D3DHAL_DP2DRAWPRIMITIVE
  966. {
  967. D3DPRIMITIVETYPE primType;
  968. DWORD VStart;
  969. DWORD PrimitiveCount;
  970. } D3DHAL_DP2DRAWPRIMITIVE;
  971. typedef D3DHAL_DP2DRAWPRIMITIVE *LPD3DHAL_DP2DRAWPRIMITIVE;
  972. typedef struct _D3DHAL_DP2DRAWINDEXEDPRIMITIVE
  973. {
  974. D3DPRIMITIVETYPE primType;
  975. INT BaseVertexIndex; // Vertex which corresponds to index 0
  976. DWORD MinIndex; // Min vertex index in the vertex buffer
  977. DWORD NumVertices; // Number of vertices starting from MinIndex
  978. DWORD StartIndex; // Start index in the index buffer
  979. DWORD PrimitiveCount;
  980. } D3DHAL_DP2DRAWINDEXEDPRIMITIVE;
  981. typedef D3DHAL_DP2DRAWINDEXEDPRIMITIVE *LPD3DHAL_DP2DRAWINDEXEDPRIMITIVE;
  982. typedef struct _D3DHAL_CLIPPEDTRIANGLEFAN
  983. {
  984. DWORD FirstVertexOffset; // Offset in bytes in the current stream 0
  985. DWORD dwEdgeFlags;
  986. DWORD PrimitiveCount;
  987. } D3DHAL_CLIPPEDTRIANGLEFAN;
  988. typedef D3DHAL_CLIPPEDTRIANGLEFAN *LPD3DHAL_CLIPPEDTRIANGLEFAN;
  989. typedef struct _D3DHAL_DP2DRAWPRIMITIVE2
  990. {
  991. D3DPRIMITIVETYPE primType;
  992. DWORD FirstVertexOffset; // Offset in bytes in the stream 0
  993. DWORD PrimitiveCount;
  994. } D3DHAL_DP2DRAWPRIMITIVE2;
  995. typedef D3DHAL_DP2DRAWPRIMITIVE2 *LPD3DHAL_DP2DRAWPRIMITIVE2;
  996. typedef struct _D3DHAL_DP2DRAWINDEXEDPRIMITIVE2
  997. {
  998. D3DPRIMITIVETYPE primType;
  999. INT BaseVertexOffset; // Stream 0 offset of the vertex which
  1000. // corresponds to index 0. This offset could be
  1001. // negative, but when an index is added to the
  1002. // offset the result is positive
  1003. DWORD MinIndex; // Min vertex index in the vertex buffer
  1004. DWORD NumVertices; // Number of vertices starting from MinIndex
  1005. DWORD StartIndexOffset; // Offset of the start index in the index buffer
  1006. DWORD PrimitiveCount; // Number of triangles (points, lines)
  1007. } D3DHAL_DP2DRAWINDEXEDPRIMITIVE2;
  1008. typedef D3DHAL_DP2DRAWINDEXEDPRIMITIVE2 *LPD3DHAL_DP2DRAWINDEXEDPRIMITIVE2;
  1009. // Used by SetPixelShader and DeletePixelShader
  1010. typedef struct _D3DHAL_DP2PIXELSHADER
  1011. {
  1012. // Pixel shader handle.
  1013. // The handle could be 0, meaning that the current pixel shader is invalid
  1014. // (not set).
  1015. DWORD dwHandle;
  1016. } D3DHAL_DP2PIXELSHADER;
  1017. typedef D3DHAL_DP2PIXELSHADER *LPD3DHAL_DP2PIXELSHADER;
  1018. typedef struct _D3DHAL_DP2CREATEPIXELSHADER
  1019. {
  1020. DWORD dwHandle; // Shader handle
  1021. DWORD dwCodeSize; // Shader code size in bytes
  1022. // Shader code follows
  1023. } D3DHAL_DP2CREATEPIXELSHADER;
  1024. typedef D3DHAL_DP2CREATEPIXELSHADER *LPD3DHAL_DP2CREATEPIXELSHADER;
  1025. typedef struct _D3DHAL_DP2SETPIXELSHADERCONST
  1026. {
  1027. DWORD dwRegister; // Const register to start copying
  1028. DWORD dwCount; // Number of 4-float vectors to copy
  1029. // Data follows
  1030. } D3DHAL_DP2SETPIXELSHADERCONST;
  1031. typedef D3DHAL_DP2SETPIXELSHADERCONST *LPD3DHAL_DP2SETPIXELSHADERCONST;
  1032. // Flags that can be supplied to DRAWRECTPATCH and DRAWTRIPATCH
  1033. #define RTPATCHFLAG_HASSEGS 0x00000001L
  1034. #define RTPATCHFLAG_HASINFO 0x00000002L
  1035. typedef struct _D3DHAL_DP2DRAWRECTPATCH
  1036. {
  1037. DWORD Handle;
  1038. DWORD Flags;
  1039. // Optionally followed by D3DFLOAT[4] NumSegments and/or D3DRECTPATCH_INFO
  1040. } D3DHAL_DP2DRAWRECTPATCH;
  1041. typedef D3DHAL_DP2DRAWRECTPATCH *LPD3DHAL_DP2DRAWRECTPATCH;
  1042. typedef struct _D3DHAL_DP2DRAWTRIPATCH
  1043. {
  1044. DWORD Handle;
  1045. DWORD Flags;
  1046. // Optionally followed by D3DFLOAT[3] NumSegments and/or D3DTRIPATCH_INFO
  1047. } D3DHAL_DP2DRAWTRIPATCH;
  1048. typedef D3DHAL_DP2DRAWTRIPATCH *LPD3DHAL_DP2DRAWTRIPATCH;
  1049. typedef struct _D3DHAL_DP2VOLUMEBLT
  1050. {
  1051. DWORD dwDDDestSurface;// dest surface
  1052. DWORD dwDDSrcSurface; // src surface
  1053. DWORD dwDestX; // dest X (width)
  1054. DWORD dwDestY; // dest Y (height)
  1055. DWORD dwDestZ; // dest Z (depth)
  1056. D3DBOX srcBox; // src box
  1057. DWORD dwFlags; // blt flags
  1058. } D3DHAL_DP2VOLUMEBLT;
  1059. typedef D3DHAL_DP2VOLUMEBLT *LPD3DHAL_DP2VOLUMEBLT;
  1060. typedef struct _D3DHAL_DP2BUFFERBLT
  1061. {
  1062. DWORD dwDDDestSurface; // dest surface
  1063. DWORD dwDDSrcSurface; // src surface
  1064. DWORD dwOffset; // Offset in the dest surface (in BYTES)
  1065. D3DRANGE rSrc; // src range
  1066. DWORD dwFlags; // blt flags
  1067. } D3DHAL_DP2BUFFERBLT;
  1068. typedef D3DHAL_DP2BUFFERBLT *LPD3DHAL_DP2BUFFERBLT;
  1069. typedef struct _D3DHAL_DP2ADDDIRTYRECT
  1070. {
  1071. DWORD dwSurface; // Driver managed surface
  1072. RECTL rDirtyArea; // Area marked dirty
  1073. } D3DHAL_DP2ADDDIRTYRECT;
  1074. typedef D3DHAL_DP2ADDDIRTYRECT *LPD3DHAL_DP2ADDDIRTYRECT;
  1075. typedef struct _D3DHAL_DP2ADDDIRTYBOX
  1076. {
  1077. DWORD dwSurface; // Driver managed volume
  1078. D3DBOX DirtyBox; // Box marked dirty
  1079. } D3DHAL_DP2ADDDIRTYBOX;
  1080. typedef D3DHAL_DP2ADDDIRTYBOX *LPD3DHAL_DP2ADDDIRTYBOX;
  1081. #endif /* DIRECT3D_VERSION >= 0x0800 */
  1082. typedef struct _D3DHAL_DRAWPRIMITIVES2DATA {
  1083. ULONG_PTR dwhContext; // in: Context handle
  1084. DWORD dwFlags; // in: flags
  1085. DWORD dwVertexType; // in: vertex type
  1086. LPDDRAWI_DDRAWSURFACE_LCL lpDDCommands; // in: vertex buffer command data
  1087. DWORD dwCommandOffset; // in: offset to start of vertex buffer commands
  1088. DWORD dwCommandLength; // in: number of bytes of command data
  1089. union
  1090. { // based on D3DHALDP2_USERMEMVERTICES flag
  1091. LPDDRAWI_DDRAWSURFACE_LCL lpDDVertex;// in: surface containing vertex data
  1092. LPVOID lpVertices; // in: User mode pointer to vertices
  1093. };
  1094. DWORD dwVertexOffset; // in: offset to start of vertex data
  1095. DWORD dwVertexLength; // in: number of vertices of vertex data
  1096. DWORD dwReqVertexBufSize; // in: number of bytes required for the next vertex buffer
  1097. DWORD dwReqCommandBufSize; // in: number of bytes required for the next commnand buffer
  1098. LPDWORD lpdwRStates; // in: Pointer to the array where render states are updated
  1099. union
  1100. {
  1101. DWORD dwVertexSize; // in: Size of each vertex in bytes
  1102. HRESULT ddrval; // out: return value
  1103. };
  1104. DWORD dwErrorOffset; // out: offset in lpDDCommands to
  1105. // first D3DHAL_COMMAND not handled
  1106. } D3DHAL_DRAWPRIMITIVES2DATA;
  1107. typedef D3DHAL_DRAWPRIMITIVES2DATA *LPD3DHAL_DRAWPRIMITIVES2DATA;
  1108. // Macros to access vertex shader binary code
  1109. #define D3DSI_GETREGTYPE(token) (token & D3DSP_REGTYPE_MASK)
  1110. #define D3DSI_GETREGNUM(token) (token & D3DSP_REGNUM_MASK)
  1111. #define D3DSI_GETOPCODE(command) (command & D3DSI_OPCODE_MASK)
  1112. #define D3DSI_GETWRITEMASK(token) (token & D3DSP_WRITEMASK_ALL)
  1113. #define D3DVS_GETSWIZZLECOMP(source, component) (source >> ((component << 1) + 16) & 0x3)
  1114. #define D3DVS_GETSWIZZLE(token) (token & D3DVS_SWIZZLE_MASK)
  1115. #define D3DVS_GETSRCMODIFIER(token) (token & D3DSP_SRCMOD_MASK)
  1116. #define D3DVS_GETADDRESSMODE(token) (token & D3DVS_ADDRESSMODE_MASK)
  1117. // Indicates that the lpVertices field in the DrawPrimitives2 data is
  1118. // valid, i.e. user allocated memory.
  1119. #define D3DHALDP2_USERMEMVERTICES 0x00000001L
  1120. // Indicates that the command buffer and vertex buffer are a system memory execute buffer
  1121. // resulting from the use of the Execute buffer API.
  1122. #define D3DHALDP2_EXECUTEBUFFER 0x00000002L
  1123. // The swap flags indicate if it is OK for the driver to swap the submitted buffers with new
  1124. // buffers and asyncronously work on the submitted buffers.
  1125. #define D3DHALDP2_SWAPVERTEXBUFFER 0x00000004L
  1126. #define D3DHALDP2_SWAPCOMMANDBUFFER 0x00000008L
  1127. // The requested flags are present if the new buffers which the driver can allocate need to be
  1128. // of atleast a given size. If any of these flags are set, the corresponding dwReq* field in
  1129. // D3DHAL_DRAWPRIMITIVES2DATA will also be set with the requested size in bytes.
  1130. #define D3DHALDP2_REQVERTEXBUFSIZE 0x00000010L
  1131. #define D3DHALDP2_REQCOMMANDBUFSIZE 0x00000020L
  1132. // These flags are set by the driver upon return from DrawPrimitives2 indicating if the new
  1133. // buffers are not in system memory.
  1134. #define D3DHALDP2_VIDMEMVERTEXBUF 0x00000040L
  1135. #define D3DHALDP2_VIDMEMCOMMANDBUF 0x00000080L
  1136. // Used by the driver to ask runtime to parse the execute buffer
  1137. #define D3DERR_COMMAND_UNPARSED MAKE_DDHRESULT(3000)
  1138. typedef DWORD (CALLBACK *LPD3DHAL_CLEAR2CB) (LPD3DHAL_CLEAR2DATA);
  1139. typedef DWORD (CALLBACK *LPD3DHAL_VALIDATETEXTURESTAGESTATECB)(LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA);
  1140. typedef DWORD (CALLBACK *LPD3DHAL_DRAWPRIMITIVES2CB) (LPD3DHAL_DRAWPRIMITIVES2DATA);
  1141. typedef struct _D3DHAL_CALLBACKS3
  1142. {
  1143. DWORD dwSize; // size of struct
  1144. DWORD dwFlags; // flags for callbacks
  1145. LPD3DHAL_CLEAR2CB Clear2;
  1146. LPVOID lpvReserved;
  1147. LPD3DHAL_VALIDATETEXTURESTAGESTATECB ValidateTextureStageState;
  1148. LPD3DHAL_DRAWPRIMITIVES2CB DrawPrimitives2;
  1149. } D3DHAL_CALLBACKS3;
  1150. typedef D3DHAL_CALLBACKS3 *LPD3DHAL_CALLBACKS3;
  1151. #define D3DHAL_CALLBACKS3SIZE sizeof(D3DHAL_CALLBACKS3)
  1152. // bit definitions for D3DHAL
  1153. #define D3DHAL3_CB32_CLEAR2 0x00000001L
  1154. #define D3DHAL3_CB32_RESERVED 0x00000002L
  1155. #define D3DHAL3_CB32_VALIDATETEXTURESTAGESTATE 0x00000004L
  1156. #define D3DHAL3_CB32_DRAWPRIMITIVES2 0x00000008L
  1157. /* --------------------------------------------------------------
  1158. * Texture stage renderstate mapping definitions.
  1159. *
  1160. * 256 renderstate slots [256, 511] are reserved for texture processing
  1161. * stage controls, which provides for 8 texture processing stages each
  1162. * with 32 DWORD controls.
  1163. *
  1164. * The renderstates within each stage are indexed by the
  1165. * D3DTEXTURESTAGESTATETYPE enumerants by adding the appropriate
  1166. * enumerant to the base for a given texture stage.
  1167. *
  1168. * Note, "state overrides" bias the renderstate by 256, so the two
  1169. * ranges overlap. Overrides are enabled for exebufs only, so all
  1170. * this means is that Texture3 cannot be used with exebufs.
  1171. */
  1172. /*
  1173. * Base of all texture stage state values in renderstate array.
  1174. */
  1175. #define D3DHAL_TSS_RENDERSTATEBASE 256UL
  1176. /*
  1177. * Maximum number of stages allowed.
  1178. */
  1179. #define D3DHAL_TSS_MAXSTAGES 8
  1180. /*
  1181. * Number of state DWORDS per stage.
  1182. */
  1183. #define D3DHAL_TSS_STATESPERSTAGE 64
  1184. /*
  1185. * Texture handle's offset into the 32-DWORD cascade state vector
  1186. */
  1187. #define D3DTSS_TEXTUREMAP 0
  1188. /* --------------------------------------------------------------
  1189. * Flags for the data parameters.
  1190. */
  1191. /*
  1192. * SceneCapture()
  1193. * This is used as an indication to the driver that a scene is about to
  1194. * start or end, and that it should capture data if required.
  1195. */
  1196. #define D3DHAL_SCENE_CAPTURE_START 0x00000000L
  1197. #define D3DHAL_SCENE_CAPTURE_END 0x00000001L
  1198. /*
  1199. * Execute()
  1200. */
  1201. /*
  1202. * Use the instruction stream starting at dwOffset.
  1203. */
  1204. #define D3DHAL_EXECUTE_NORMAL 0x00000000L
  1205. /*
  1206. * Use the optional instruction override (diInstruction) and return
  1207. * after completion. dwOffset is the offset to the first primitive.
  1208. */
  1209. #define D3DHAL_EXECUTE_OVERRIDE 0x00000001L
  1210. /*
  1211. * GetState()
  1212. * The driver will get passed a flag in dwWhich specifying which module
  1213. * the state must come from. The driver then fills in ulArg[1] with the
  1214. * appropriate value depending on the state type given in ddState.
  1215. */
  1216. /*
  1217. * The following are used to get the state of a particular stage of the
  1218. * pipeline.
  1219. */
  1220. #define D3DHALSTATE_GET_TRANSFORM 0x00000001L
  1221. #define D3DHALSTATE_GET_LIGHT 0x00000002L
  1222. #define D3DHALSTATE_GET_RENDER 0x00000004L
  1223. /* --------------------------------------------------------------
  1224. * Return values from HAL functions.
  1225. */
  1226. /*
  1227. * The context passed in was bad.
  1228. */
  1229. #define D3DHAL_CONTEXT_BAD 0x000000200L
  1230. /*
  1231. * No more contexts left.
  1232. */
  1233. #define D3DHAL_OUTOFCONTEXTS 0x000000201L
  1234. /*
  1235. * Execute() and ExecuteClipped()
  1236. */
  1237. /*
  1238. * Executed to completion via early out.
  1239. * (e.g. totally clipped)
  1240. */
  1241. #define D3DHAL_EXECUTE_ABORT 0x00000210L
  1242. /*
  1243. * An unhandled instruction code was found (e.g. D3DOP_TRANSFORM).
  1244. * The dwOffset parameter must be set to the offset of the unhandled
  1245. * instruction.
  1246. *
  1247. * Only valid from Execute()
  1248. */
  1249. #define D3DHAL_EXECUTE_UNHANDLED 0x00000211L
  1250. // typedef for the Callback that the drivers can use to parse unknown commands
  1251. // passed to them via the DrawPrimitives2 callback. The driver obtains this
  1252. // callback thru a GetDriverInfo call with GUID_D3DParseUnknownCommandCallback
  1253. // made by ddraw somewhere around the initialization time.
  1254. typedef HRESULT (CALLBACK *PFND3DPARSEUNKNOWNCOMMAND) (LPVOID lpvCommands,
  1255. LPVOID *lplpvReturnedCommand);
  1256. #define D3DRENDERSTATE_EVICTMANAGEDTEXTURES 61 // DDI render state only to Evict textures
  1257. #define D3DRENDERSTATE_SCENECAPTURE 62 // DDI only to replace SceneCapture
  1258. #define D3DRS_DELETERTPATCH 169 // DDI only to delete high order patch
  1259. //-----------------------------------------------------------------------------
  1260. //
  1261. // DirectX 8.0's new driver info querying mechanism.
  1262. //
  1263. // How to handle the new driver info query mechanism.
  1264. //
  1265. // DirectX 8.0 utilizes an extension to GetDriverInfo() to query for
  1266. // additional information from the driver. Currently this mechanism is only
  1267. // used for querying for DX8 style D3D caps but it may be used for other
  1268. // information over time.
  1269. //
  1270. // This extension to GetDriverInfo takes the form of a GetDriverInfo call
  1271. // with the GUID GUID_GetDriverInfo2. When a GetDriverInfo call with this
  1272. // GUID is received by the driver the driver must check the data passed
  1273. // in the lpvData field of the DD_GETDRIVERINFODATA data structure to see
  1274. // what information is being requested.
  1275. //
  1276. // It is important to note that the GUID GUID_GetDriverInfo2 is, in fact,
  1277. // the same as the GUID_DDStereoMode. If you driver doesn't handle
  1278. // GUID_DDStereoMode this is not an issue. However, if you wish your driver
  1279. // to handle GUID_DDStereoMode as well as GUID_GetDriverInfo2 special action
  1280. // must be taken. When a call tp GetDriverInfo with the GUID
  1281. // GUID_GetDriverInfo2/GUID_DDStereoMode is made the runtime sets the
  1282. // dwHeight field of the DD_STEREOMODE structure to the special value
  1283. // D3DGDI2_MAGIC. In this way you can determine when the request is a
  1284. // stereo mode call or a GetDriverInfo2 call. The dwHeight field of
  1285. // DD_STEREOMODE corresponds to the dwMagic field of the
  1286. // DD_GETDRIVERINFO2DATA structure.
  1287. //
  1288. // The dwExpectedSize field of the DD_GETDRIVERINFODATA structure is not
  1289. // used by when a GetDriverInfo2 request is being made and should be
  1290. // ignored. The actual expected size of the data is found in the
  1291. // dwExpectedSize of the DD_GETDRIVERINFO2DATA structure.
  1292. //
  1293. // Once the driver has determined that this is a call to
  1294. // GetDriverInfo2 it must then determine the type of information being
  1295. // requested by the runtime. This type is contained in the dwType field
  1296. // of the DD_GETDRIVERINFO2DATA data structure.
  1297. //
  1298. // Finally, once the driver knows this is a GetDriverInfo2 request of a
  1299. // particular type it can copy the requested data into the data buffer.
  1300. // It is important to note that the lpvData field of the DD_GETDRIVERINFODATA
  1301. // data structure points to data buffer in which to copy your data. lpvData
  1302. // also points to the DD_GETDRIVERINFO2DATA structure. This means that the
  1303. // data returned by the driver will overwrite the DD_GETDRIVERINFO2DATA
  1304. // structure and, hence, the DD_GETDRIVERINFO2DATA structure occupies the
  1305. // first few DWORDs of the buffer.
  1306. //
  1307. // The following code fragment demonstrates how to handle GetDriverInfo2.
  1308. //
  1309. // D3DCAPS8 myD3DCaps8;
  1310. //
  1311. // DWORD CALLBACK
  1312. // DdGetDriverInfo(LPDDHAL_GETDRIVERINFODATA lpData)
  1313. // {
  1314. // if (MATCH_GUID((lpData->guidInfo), GUID_GetDriverInfo2) )
  1315. // {
  1316. // ASSERT(NULL != lpData);
  1317. // ASSERT(NULL != lpData->lpvData);
  1318. //
  1319. // // Is this a call to GetDriverInfo2 or DDStereoMode?
  1320. // if (((DD_GETDRIVERINFO2DATA*)(lpData->lpvData))->dwMagic == D3DGDI2_MAGIC)
  1321. // {
  1322. // // Yes, its a call to GetDriverInfo2, fetch the
  1323. // // DD_GETDRIVERINFO2DATA data structure.
  1324. // DD_GETDRIVERINFO2DATA* pgdi2 = lpData->lpvData;
  1325. // ASSERT(NULL != pgdi2);
  1326. //
  1327. // // What type of request is this?
  1328. // switch (pgdi2->dwType)
  1329. // {
  1330. // case D3DGDI2_TYPE_GETD3DCAPS8:
  1331. // {
  1332. // // The runtime is requesting the DX8 D3D caps so
  1333. // // copy them over now.
  1334. //
  1335. // // It should be noted that the dwExpectedSize field
  1336. // // of DD_GETDRIVERINFODATA is not used for
  1337. // // GetDriverInfo2 calls and should be ignored.
  1338. // size_t copySize = min(sizeof(myD3DCaps8), pgdi2->dwExpectedSize);
  1339. // memcpy(lpData->lpvData, &myD3DCaps8, copySize);
  1340. // lpData->dwActualSize = copySize;
  1341. // lpData->ddRVal = DD_OK;
  1342. // return DDHAL_DRIVER_HANDLED;
  1343. // }
  1344. // default:
  1345. // // For any other GetDriverInfo2 types not handled
  1346. // // or understood by the driver set an ddRVal of
  1347. // // DDERR_CURRENTLYNOTAVAIL and return
  1348. // // DDHAL_DRIVER_HANDLED.
  1349. // return DDHAL_DRIVER_HANDLED;
  1350. // }
  1351. // }
  1352. // else
  1353. // {
  1354. // // It must be a call a request for stereo mode support.
  1355. // // Fetch the stereo mode data
  1356. // DD_STEREOMODE* pStereoMode = lpData->lpvData;
  1357. // ASSERT(NULL != pStereoMode);
  1358. //
  1359. // // Process the stereo mode request...
  1360. // lpData->dwActualSize = sizeof(DD_STEREOMODE);
  1361. // lpData->ddRVal = DD_OK;
  1362. // return DDHAL_DRIVER_HANDLED;
  1363. // }
  1364. // }
  1365. //
  1366. // // Handle any other device GUIDs...
  1367. //
  1368. // } // DdGetDriverInfo
  1369. //
  1370. //-----------------------------------------------------------------------------
  1371. //
  1372. // The data structure which is passed to the driver when GetDriverInfo is
  1373. // called with a GUID of GUID_GetDriverInfo2.
  1374. //
  1375. // NOTE: Although the fields listed below are all read only this data
  1376. // structure is actually the first four DWORDs of the data buffer into
  1377. // which the driver writes the requested infomation. As such, these fields
  1378. // (and the entire data structure) are overwritten by the data returned by
  1379. // the driver.
  1380. //
  1381. typedef struct _DD_GETDRIVERINFO2DATA
  1382. {
  1383. DWORD dwReserved; // Reserved Field.
  1384. // Driver should not read or write this field.
  1385. DWORD dwMagic; // Magic Number. Has the value D3DGDI2_MAGIC if
  1386. // this is a GetDriverInfo2 call. Otherwise
  1387. // this structure is, in fact, a DD_STEREOMODE
  1388. // call.
  1389. // Driver should only read this field.
  1390. DWORD dwType; // Type of information requested. This field
  1391. // contains one of the DDGDI2_TYPE_ #defines
  1392. // listed below.
  1393. // Driver should only read (not write) this
  1394. // field.
  1395. DWORD dwExpectedSize; // Expected size of the information requested.
  1396. // Driver should only read (not write) this
  1397. // field.
  1398. // The remainder of the data buffer (beyond the first four DWORDs)
  1399. // follows here.
  1400. } DD_GETDRIVERINFO2DATA;
  1401. //
  1402. // IMPORTANT NOTE: This GUID has exactly the same value as GUID_DDStereoMode
  1403. // and as such you must be very careful when using it. If your driver needs
  1404. // to handle both GetDriverInfo2 and DDStereoMode it must have a single
  1405. // check for the shared GUID and then distinguish between which use of that
  1406. // GUID is being requested.
  1407. //
  1408. #define GUID_GetDriverInfo2 (GUID_DDStereoMode)
  1409. //
  1410. // Magic value used to determine whether a GetDriverInfo call with the
  1411. // GUID GUID_GetDriverInfo2/GUID_DDStereoMode is a GetDriverInfo2 request
  1412. // or a query about stereo capabilities. This magic number is stored in
  1413. // the dwHeight field of the DD_STEREOMODE data structure.
  1414. //
  1415. #define D3DGDI2_MAGIC (0xFFFFFFFFul)
  1416. //
  1417. // The types of information which can be requested from the driver via
  1418. // GetDriverInfo2.
  1419. //
  1420. #define D3DGDI2_TYPE_GETD3DCAPS8 (0x00000001ul) // Return the D3DCAPS8 data
  1421. #define D3DGDI2_TYPE_GETFORMATCOUNT (0x00000002ul) // Return the number of supported formats
  1422. #define D3DGDI2_TYPE_GETFORMAT (0x00000003ul) // Return a particular format
  1423. #define D3DGDI2_TYPE_DXVERSION (0x00000004ul) // Notify driver of current DX Version
  1424. #define D3DGDI2_TYPE_DEFERRED_AGP_AWARE (0x00000018ul) // Runtime is aware of deferred AGP frees, and will send following (NT only)
  1425. #define D3DGDI2_TYPE_FREE_DEFERRED_AGP (0x00000019ul) // Free any deferred-freed AGP allocations for this process (NT only)
  1426. #define D3DGDI2_TYPE_DEFER_AGP_FREES (0x00000020ul) // Start defering AGP frees for this process
  1427. //
  1428. // This data structure is returned by the driver in response to a
  1429. // GetDriverInfo2 query with the type D3DGDI2_TYPE_GETFORMATCOUNT. It simply
  1430. // gives the number of surface formats supported by the driver. Currently this
  1431. // structure consists of a single member giving the number of supported
  1432. // surface formats.
  1433. //
  1434. typedef struct _DD_GETFORMATCOUNTDATA
  1435. {
  1436. DD_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
  1437. DWORD dwFormatCount; // [out] Number of supported surface formats
  1438. DWORD dwReserved; // Reserved
  1439. } DD_GETFORMATCOUNTDATA;
  1440. //
  1441. // This data structure is used to request a specific surface format from the
  1442. // driver. It is guaranteed that the requested format will be greater than or
  1443. // equal to zero and less that the format count reported by the driver from
  1444. // the preceeding D3DGDI2_TYPE_GETFORMATCOUNT request.
  1445. //
  1446. typedef struct _DD_GETFORMATDATA
  1447. {
  1448. DD_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
  1449. DWORD dwFormatIndex; // [in] The format to return
  1450. DDPIXELFORMAT format; // [out] The actual format
  1451. } DD_GETFORMATDATA;
  1452. //
  1453. // This data structure is used to notify drivers about the DirectX version
  1454. // number. This is the value that is denoted as DD_RUNTIME_VERSION in the
  1455. // DDK headers.
  1456. //
  1457. typedef struct _DD_DXVERSION
  1458. {
  1459. DD_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
  1460. DWORD dwDXVersion; // [in] The Version of DX
  1461. DWORD dwReserved; // Reserved
  1462. } DD_DXVERSION;
  1463. // Informs driver that runtime will send a notification after last outstanding AGP
  1464. // lock has been released.
  1465. typedef struct _DD_DEFERRED_AGP_AWARE_DATA
  1466. {
  1467. DD_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
  1468. } DD_DEFERRED_AGP_AWARE_DATA;
  1469. // Notification that the last AGP lock has been released. Driver can free all deferred AGP
  1470. // allocations for this process.
  1471. typedef struct _DD_FREE_DEFERRED_AGP_DATA
  1472. {
  1473. DD_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
  1474. DWORD dwProcessId; // [in] Process ID for whom to free deferred AGP
  1475. } DD_FREE_DEFERRED_AGP_DATA;
  1476. // New Caps that are not API visible that the driver exposes.
  1477. #define D3DDEVCAPS_HWVERTEXBUFFER 0x02000000L /* Device supports Driver Allocated Vertex Buffers*/
  1478. #define D3DDEVCAPS_HWINDEXBUFFER 0x04000000L /* Device supports Driver Allocated Index Buffers*/
  1479. #define D3DDEVCAPS_SUBVOLUMELOCK 0x08000000L /* Device supports locking a part of volume texture*/
  1480. #ifndef D3DPMISCCAPS_FOGINFVF
  1481. #define D3DPMISCCAPS_FOGINFVF 0x00002000L /* Device supports separate fog value in the FVF */
  1482. #endif
  1483. #ifndef D3DFVF_FOG
  1484. #define D3DFVF_FOG 0x00002000L /* There is a separate fog value in the FVF vertex */
  1485. #endif
  1486. //
  1487. // This stuff is not API visible but should be DDI visible.
  1488. // Should be in Sync with d3d8types.h
  1489. //
  1490. #define D3DFMT_D32 (D3DFORMAT)71
  1491. #define D3DFMT_S1D15 (D3DFORMAT)72
  1492. #define D3DFMT_D15S1 (D3DFORMAT)73
  1493. #define D3DFMT_S8D24 (D3DFORMAT)74
  1494. #define D3DFMT_D24S8 (D3DFORMAT)75
  1495. #define D3DFMT_X8D24 (D3DFORMAT)76
  1496. #define D3DFMT_D24X8 (D3DFORMAT)77
  1497. #define D3DFMT_X4S4D24 (D3DFORMAT)78
  1498. #define D3DFMT_D24X4S4 (D3DFORMAT)79
  1499. // Vertex Shader 1.1 register limits. D3D device must provide at least
  1500. // specified number of registers
  1501. //
  1502. #define D3DVS_INPUTREG_MAX_V1_1 16
  1503. #define D3DVS_TEMPREG_MAX_V1_1 12
  1504. // This max required number. Device could have more registers. Check caps.
  1505. #define D3DVS_CONSTREG_MAX_V1_1 96
  1506. #define D3DVS_TCRDOUTREG_MAX_V1_1 8
  1507. #define D3DVS_ADDRREG_MAX_V1_1 1
  1508. #define D3DVS_ATTROUTREG_MAX_V1_1 2
  1509. #define D3DVS_MAXINSTRUCTIONCOUNT_V1_1 128
  1510. // Pixel Shader DX8 register limits. D3D device will have at most these
  1511. // specified number of registers
  1512. //
  1513. #define D3DPS_INPUTREG_MAX_DX8 8
  1514. #define D3DPS_TEMPREG_MAX_DX8 8
  1515. #define D3DPS_CONSTREG_MAX_DX8 16
  1516. #define D3DPS_TEXTUREREG_MAX_DX8 8
  1517. #endif /* _D3DHAL_H */