Source code of Windows XP (NT5)
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.

1765 lines
65 KiB

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