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.

375 lines
16 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *******************
  4. * * D3D SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: direct3d.h
  8. *
  9. * Content: Global direct3d definitions
  10. *
  11. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  13. \*****************************************************************************/
  14. #ifndef __DIRECT3D_H
  15. #define __DIRECT3D_H
  16. #include "directx.h"
  17. // ************************ Auxiliary D3D declarations ************************
  18. // We define this here because DX7 headers don't have it
  19. #ifndef D3DTSS_MAX
  20. #define D3DTSS_MAX ((D3DTEXTURESTAGESTATETYPE)29)
  21. #endif
  22. #ifndef D3DHAL_TSS_MAXSTAGES
  23. #define D3DHAL_TSS_MAXSTAGES 8
  24. #endif
  25. #if DX8_DDI
  26. // In DX8 D3DTSS_ADDRESS is obsolete, but we need it for DX7 apps that call us
  27. #define D3DTSS_ADDRESS 12
  28. #endif
  29. // *********************** Helper function declarations ***********************
  30. typedef struct _p3_d3dcontext P3_D3DCONTEXT;
  31. typedef struct _p3_SURF_INTERNAL P3_SURF_INTERNAL;
  32. // Initialization functions
  33. void _D3DHALCreateDriver(struct tagThunkedData* pThisDisplay);
  34. void _D3DGetDriverInfo(LPDDHAL_GETDRIVERINFODATA lpData);
  35. // Primitives renderers
  36. extern void _D3D_R3_PickVertexProcessor( P3_D3DCONTEXT *pC );
  37. typedef void R3_DP2_PRIM_TYPE( P3_D3DCONTEXT *,
  38. DWORD,
  39. LPBYTE,
  40. LPD3DTLVERTEX,
  41. DWORD,
  42. BOOL *);
  43. typedef R3_DP2_PRIM_TYPE *PFNP3TRI;
  44. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_Points;
  45. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_Points_DWCount;
  46. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_LineList;
  47. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_LineListImm;
  48. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_LineStrip;
  49. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_IndexedLineList;
  50. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_IndexedLineList2;
  51. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_IndexedLineStrip;
  52. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_TriangleList;
  53. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_TriangleFan;
  54. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_TriangleFanImm;
  55. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_TriangleStrip;
  56. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_IndexedTriangleList;
  57. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_IndexedTriangleList2;
  58. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_IndexedTriangleFan;
  59. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_IndexedTriangleStrip;
  60. #if DX8_POINTSPRITES
  61. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_TriangleListPointSprite;
  62. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_TriangleFanPointSprite;
  63. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_TriangleStripPointSprite;
  64. extern R3_DP2_PRIM_TYPE _D3D_R3_DP2_PointsSprite_DWCount;
  65. #endif //DX8_POINTSPRITES
  66. #if DX8_MULTSTREAMS
  67. typedef void R3_DP2_PRIM_TYPE_MS( P3_D3DCONTEXT *,
  68. DWORD,
  69. LPBYTE,
  70. LPD3DTLVERTEX,
  71. INT,
  72. DWORD,
  73. BOOL *);
  74. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedLineList_MS_16IND;
  75. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedLineStrip_MS_16IND;
  76. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedTriangleList_MS_16IND;
  77. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedTriangleStrip_MS_16IND;
  78. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedTriangleFan_MS_16IND;
  79. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedLineList_MS_32IND;
  80. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedLineStrip_MS_32IND;
  81. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedTriangleList_MS_32IND;
  82. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedTriangleStrip_MS_32IND;
  83. extern R3_DP2_PRIM_TYPE_MS _D3D_R3_DP2_IndexedTriangleFan_MS_32IND;
  84. #endif // DX8_MULTSTREAMS
  85. // Texture functions
  86. void _D3DChangeTextureP3RX(P3_D3DCONTEXT* pContext);
  87. void _D3D_TXT_ParseTextureStageStates(struct _p3_d3dcontext* pContext,
  88. D3DHAL_DP2TEXTURESTAGESTATE* pState,
  89. DWORD dwCount,
  90. BOOL bTranslateDX8FilterValueToDX6);
  91. void _D3D_SU_SurfInternalSetMipMapLevelData(P3_THUNKEDDATA* pThisDisplay,
  92. struct _p3_SURF_INTERNAL* pTexture,
  93. LPDDRAWI_DDRAWSURFACE_LCL pSurf,
  94. int LOD);
  95. // D3D Context Functions
  96. VOID _D3D_CTX_HandleInitialization(VOID);
  97. P3_D3DCONTEXT* _D3D_CTX_HandleToPtr(ULONG_PTR hHandle);
  98. // Rendering State Functions
  99. DWORD _D3D_ST_ProcessRenderStates(P3_D3DCONTEXT* pContext,
  100. DWORD dwStateCount,
  101. D3DSTATE *pState,
  102. BOOL bDoOverride);
  103. DWORD _D3D_ST_ProcessOneRenderState(P3_D3DCONTEXT* pContext,
  104. DWORD dwRSType,
  105. DWORD dwRSVal);
  106. BOOL _D3D_ST_RealizeHWStateChanges(P3_D3DCONTEXT* pContext);
  107. BOOL _D3D_ST_CanRenderAntialiased(P3_D3DCONTEXT* pContext,
  108. BOOL bNewAliasBuffer);
  109. //@@BEGIN_DDKSPLIT
  110. #if DX7_VERTEXBUFFERS
  111. // Functions for handling vertex/execute/command buffers
  112. void _D3D_EB_FlushAllBuffers(P3_THUNKEDDATA* pThisDisplay, BOOL bWait);
  113. void
  114. _D3D_EB_GetAndWaitForBuffers(
  115. P3_THUNKEDDATA* pThisDisplay,
  116. LPD3DHAL_DRAWPRIMITIVES2DATA pdp2d ,
  117. P3_VERTEXBUFFERINFO** ppVertexBufferInfo,
  118. P3_VERTEXBUFFERINFO** ppCommandBufferInfo);
  119. void
  120. _D3D_EB_UpdateSwapBuffers(
  121. P3_THUNKEDDATA* pThisDisplay,
  122. LPD3DHAL_DRAWPRIMITIVES2DATA pdp2d ,
  123. P3_VERTEXBUFFERINFO* pVertexBufferInfo,
  124. P3_VERTEXBUFFERINFO* pCommandBufferInfo);
  125. #endif //DX7_VERTEXBUFFERS
  126. //@@END_DDKSPLIT
  127. // D3D Surfaces
  128. HRESULT _D3D_SU_SurfInternalSetDataRecursive(P3_THUNKEDDATA* pThisDisplay,
  129. PointerArray* pSurfaceArray,
  130. LPDDRAWI_DIRECTDRAW_LCL pDDLcl,
  131. LPDDRAWI_DDRAWSURFACE_LCL pRootDDSurfLcl,
  132. LPDDRAWI_DDRAWSURFACE_LCL pCurDDSurfLcl);
  133. BOOL _D3D_SU_SurfInternalSetData(P3_THUNKEDDATA* pThisDisplay,
  134. P3_SURF_INTERNAL *pSurface,
  135. LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl,
  136. DWORD dwSurfaceHandle);
  137. void
  138. _D3D_SU_DumpSurfInternal(DWORD lvl,
  139. char *psHeader,
  140. P3_SURF_INTERNAL *pSurface);
  141. // State blocks management functions
  142. void _D3D_SB_DeleteAllStateSets(P3_D3DCONTEXT* pContext);
  143. void _D3D_SB_BeginStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam);
  144. void _D3D_SB_EndStateSet(P3_D3DCONTEXT* pContext);
  145. void _D3D_SB_DeleteStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam);
  146. void _D3D_SB_ExecuteStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam);
  147. void _D3D_SB_CaptureStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam);
  148. void _D3D_SB_RecordStateSetRS(P3_D3DCONTEXT* pContext,
  149. DWORD dwRSType,
  150. DWORD dwRSVal);
  151. void _D3D_SB_RecordStateSetTSS(P3_D3DCONTEXT* pContext,
  152. DWORD dwTSStage,
  153. DWORD dwTSState,
  154. DWORD dwTSVal);
  155. void _D3D_SB_Record_VertexShader_Set(P3_D3DCONTEXT* pContext,
  156. DWORD dwVtxShaderHandle);
  157. void _D3D_SB_Record_MStream_SetSrc(P3_D3DCONTEXT* pContext,
  158. DWORD dwStream,
  159. DWORD dwVBHandle,
  160. DWORD dwStride);
  161. void _D3D_SB_Record_MStream_SetIndices(P3_D3DCONTEXT* pContext,
  162. DWORD dwVBHandle,
  163. DWORD dwStride);
  164. void _D3D_SB_Record_Viewport(P3_D3DCONTEXT* pContext,
  165. D3DHAL_DP2VIEWPORTINFO* lpvp);
  166. VOID _D3D_SB_Record_ZRange(P3_D3DCONTEXT* pContext,
  167. D3DHAL_DP2ZRANGE* lpzr);
  168. // D3D Command Buffer Operations
  169. HRESULT _D3D_OP_SetRenderTarget(P3_D3DCONTEXT* pContext,
  170. P3_SURF_INTERNAL* pRender,
  171. P3_SURF_INTERNAL* pZBuffer,
  172. BOOL bNewAliasBuffers);
  173. VOID _D3D_OP_SceneCapture(P3_D3DCONTEXT *pContext,
  174. DWORD dwFlag);
  175. VOID _D3D_OP_Viewport(P3_D3DCONTEXT* pContext,
  176. D3DHAL_DP2VIEWPORTINFO* lpvp);
  177. VOID _D3D_OP_ZRange(P3_D3DCONTEXT* pContext,
  178. D3DHAL_DP2ZRANGE* lpzr);
  179. VOID _D3D_OP_Clear2(P3_D3DCONTEXT* pContext,
  180. D3DHAL_DP2CLEAR* lpcd2,
  181. DWORD dwNumRects);
  182. VOID _D3D_OP_TextureBlt(P3_D3DCONTEXT* pContext,
  183. P3_THUNKEDDATA* pThisDisplay,
  184. D3DHAL_DP2TEXBLT* pBlt);
  185. HRESULT _D3D_OP_UpdatePalette(P3_D3DCONTEXT* pContext,
  186. D3DHAL_DP2UPDATEPALETTE* pUpdatePalette,
  187. DWORD* pdwPalEntries);
  188. HRESULT _D3D_OP_SetPalettes(P3_D3DCONTEXT* pContext,
  189. D3DHAL_DP2SETPALETTE* pSetPalettes,
  190. int iNumSetPalettes);
  191. #if DX7_TEXMANAGEMENT
  192. VOID _D3D_OP_SetTexLod(P3_D3DCONTEXT *pContext,
  193. D3DHAL_DP2SETTEXLOD* pSetTexLod);
  194. VOID _D3D_OP_SetPriority(P3_D3DCONTEXT *pContext,
  195. D3DHAL_DP2SETPRIORITY* pSetPriority);
  196. #if DX8_DDI
  197. VOID _D3D_OP_AddDirtyRect(P3_D3DCONTEXT *pContext,
  198. D3DHAL_DP2ADDDIRTYRECT* pAddDirtyRect);
  199. VOID _D3D_OP_AddDirtyBox(P3_D3DCONTEXT *pContext,
  200. D3DHAL_DP2ADDDIRTYBOX* pAddDirtyBox);
  201. #endif
  202. #endif // DX7_TEXMANAGEMENT
  203. #if DX8_3DTEXTURES
  204. VOID _D3D_OP_VolumeBlt(P3_D3DCONTEXT* pContext,
  205. P3_THUNKEDDATA*pThisDisplay,
  206. D3DHAL_DP2VOLUMEBLT* pBlt);
  207. #endif // DX8_3DTEXTURES
  208. #if DX8_DDI
  209. VOID _D3D_OP_BufferBlt(P3_D3DCONTEXT* pContext,
  210. P3_THUNKEDDATA*pThisDisplay,
  211. D3DHAL_DP2BUFFERBLT* pBlt);
  212. #endif // DX8_DDI
  213. #if DX8_VERTEXSHADERS
  214. HRESULT _D3D_OP_VertexShader_Create(P3_D3DCONTEXT* pContext,
  215. DWORD dwVtxShaderHandle,
  216. DWORD dwDeclSize,
  217. DWORD dwCodeSize,
  218. BYTE *pShader);
  219. VOID _D3D_OP_VertexShader_Delete(P3_D3DCONTEXT* pContext,
  220. DWORD dwVtxShaderHandle);
  221. VOID _D3D_OP_VertexShader_Set(P3_D3DCONTEXT* pContext,
  222. DWORD dwVtxShaderHandle);
  223. VOID _D3D_OP_VertexShader_SetConst(P3_D3DCONTEXT* pContext,
  224. DWORD dwRegister,
  225. DWORD dwValue,
  226. DWORD *pdwValues);
  227. #endif // DX8_VERTEXSHADERS
  228. #if DX8_PIXELSHADERS
  229. HRESULT _D3D_OP_PixelShader_Create(P3_D3DCONTEXT* pContext,
  230. DWORD dwPxlShaderHandle,
  231. DWORD dwCodeSize,
  232. BYTE *pShader);
  233. VOID _D3D_OP_PixelShader_Delete(P3_D3DCONTEXT* pContext,
  234. DWORD dwPxlShaderHandle);
  235. VOID _D3D_OP_PixelShader_Set(P3_D3DCONTEXT* pContext,
  236. DWORD dwPxlShaderHandle);
  237. VOID _D3D_OP_PixelShader_SetConst(P3_D3DCONTEXT* pContext,
  238. DWORD dwRegister,
  239. DWORD dwCount,
  240. DWORD *pdwValues);
  241. #endif // DX8_PIXELSHADERS
  242. #if DX8_MULTSTREAMS
  243. VOID _D3D_OP_MStream_SetSrc(P3_D3DCONTEXT* pContext,
  244. DWORD dwStream,
  245. DWORD dwVBHandle,
  246. DWORD dwStride);
  247. VOID _D3D_OP_MStream_SetSrcUM(P3_D3DCONTEXT* pContext,
  248. DWORD dwStream,
  249. DWORD dwStride,
  250. LPBYTE pUMVtx,
  251. DWORD dwVBSize);
  252. VOID _D3D_OP_MStream_SetIndices(P3_D3DCONTEXT* pContext,
  253. DWORD dwVBHandle,
  254. DWORD dwStride);
  255. VOID _D3D_OP_MStream_DrawPrim(P3_D3DCONTEXT* pContext,
  256. D3DPRIMITIVETYPE primType,
  257. DWORD VStart,
  258. DWORD PrimitiveCount);
  259. VOID _D3D_OP_MStream_DrawIndxP(P3_D3DCONTEXT* pContext,
  260. D3DPRIMITIVETYPE primType,
  261. DWORD BaseVertexIndex,
  262. DWORD MinIndex,
  263. DWORD NumVertices,
  264. DWORD StartIndex,
  265. DWORD PrimitiveCount);
  266. VOID _D3D_OP_MStream_DrawPrim2(P3_D3DCONTEXT* pContext,
  267. D3DPRIMITIVETYPE primType,
  268. DWORD FirstVertexOffset,
  269. DWORD PrimitiveCount);
  270. VOID _D3D_OP_MStream_DrawIndxP2(P3_D3DCONTEXT* pContext,
  271. D3DPRIMITIVETYPE primType,
  272. INT BaseVertexOffset,
  273. DWORD MinIndex,
  274. DWORD NumVertices,
  275. DWORD StartIndexOffset,
  276. DWORD PrimitiveCount);
  277. VOID _D3D_OP_MStream_ClipTriFan(P3_D3DCONTEXT* pContext,
  278. DWORD FirstVertexOffset,
  279. DWORD dwEdgeFlags,
  280. DWORD PrimitiveCount);
  281. VOID _D3D_OP_MStream_DrawRectSurface(P3_D3DCONTEXT* pContext,
  282. DWORD Handle,
  283. DWORD Flags,
  284. PVOID lpPrim);
  285. VOID _D3D_OP_MStream_DrawTriSurface(P3_D3DCONTEXT* pContext,
  286. DWORD Handle,
  287. DWORD Flags,
  288. PVOID lpPrim);
  289. #endif // DX8_MULTSTREAMS
  290. // Other
  291. void _D3DDisplayWholeTSSPipe ( P3_D3DCONTEXT* pContext, int iDebugNumber );
  292. // ************************** D3D HAL Callbacks ********************************
  293. DWORD CALLBACK D3DCreateSurfaceEx( LPDDHAL_CREATESURFACEEXDATA lpcsxd );
  294. DWORD CALLBACK D3DDestroyDDLocal(LPDDHAL_DESTROYDDLOCALDATA pddl);
  295. DWORD CALLBACK D3DContextCreate(LPD3DHAL_CONTEXTCREATEDATA pccd);
  296. DWORD CALLBACK D3DContextDestroy(LPD3DHAL_CONTEXTDESTROYDATA pccd);
  297. DWORD CALLBACK D3DDrawPrimitives2_P3( LPD3DHAL_DRAWPRIMITIVES2DATA pdp2d );
  298. DWORD CALLBACK D3DValidateDeviceP3( LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA pvtssd);
  299. DWORD CALLBACK D3DGetDriverState(LPDDHAL_GETDRIVERSTATEDATA pGS);
  300. DWORD CALLBACK D3DCanCreateD3DBuffer(LPDDHAL_CANCREATESURFACEDATA pccsd);
  301. DWORD CALLBACK D3DCreateD3DBuffer(LPDDHAL_CREATESURFACEDATA pcsd);
  302. DWORD CALLBACK D3DDestroyD3DBuffer(LPDDHAL_DESTROYSURFACEDATA pdd);
  303. DWORD CALLBACK D3DLockD3DBuffer(LPDDHAL_LOCKDATA pld);
  304. DWORD CALLBACK D3DUnlockD3DBuffer(LPDDHAL_UNLOCKDATA puld);
  305. #endif // __DIRECT3D_H