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.

1249 lines
44 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *******************
  4. * * D3D SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: d3dsset.c
  8. *
  9. * Content: State set (block) management
  10. *
  11. * Copyright (c) 1999-2003 Microsoft Corporation. All rights reserved.
  12. \*****************************************************************************/
  13. #include "glint.h"
  14. //-----------------------------------------------------------------------------
  15. // This module implements an emulation mechanism for handling state blocks
  16. // (which are a required feature of the DX7 DDI) for hardware that doesn't
  17. // offer any silicon support of the feature. It works simply by recording the
  18. // render states and texture stage states set during state block recording
  19. // and then "plays" them back when execution of the stage state is requested.
  20. // Internal data structures are interchangeable between an uncompressed
  21. // version (for recording speed) and a compressed format (for memory
  22. // efficiency) since it is anticipated some apps may request thousands of
  23. // state blocks.
  24. //
  25. // The following symbols have to be replaced according to your perticular
  26. // driver implementation:
  27. // - HEAP_ALLOC
  28. // - HEAP_FREE
  29. // - DISPDBG
  30. // - _D3D_ST_ProcessOneRenderState
  31. // - _D3D_TXT_ParseTextureStageStates
  32. //-----------------------------------------------------------------------------
  33. #if DX7_D3DSTATEBLOCKS
  34. //-----------------------------------------------------------------------------
  35. //
  36. // P3StateSetRec *__SB_FindStateSet
  37. //
  38. // Find a state identified by dwHandle starting from pRootSS.
  39. // If not found, returns NULL.
  40. //
  41. //-----------------------------------------------------------------------------
  42. P3StateSetRec *__SB_FindStateSet(P3_D3DCONTEXT *pContext,
  43. DWORD dwHandle)
  44. {
  45. if (dwHandle <= pContext->dwMaxSSIndex)
  46. {
  47. return pContext->pIndexTableSS[dwHandle - 1];
  48. }
  49. else
  50. {
  51. DISPDBG((DBGLVL,"State set %x not found (Max = %x)",
  52. dwHandle, pContext->dwMaxSSIndex));
  53. return NULL;
  54. }
  55. } // __SB_FindStateSet
  56. //-----------------------------------------------------------------------------
  57. //
  58. // void __SB_DumpStateSet
  59. //
  60. // Dump info stored in a state set
  61. //
  62. //-----------------------------------------------------------------------------
  63. #define ELEMS_IN_ARRAY(a) ((sizeof(a)/sizeof(a[0])))
  64. void __SB_DumpStateSet(P3StateSetRec *pSSRec)
  65. {
  66. DWORD i,j;
  67. DISPDBG((DBGLVL,"__SB_DumpStateSet %x, Id=%x dwSSFlags=%x",
  68. pSSRec,pSSRec->dwHandle,pSSRec->dwSSFlags));
  69. if (!(pSSRec->dwSSFlags & SB_COMPRESSED))
  70. {
  71. // uncompressed state set
  72. // Dump render states values
  73. for (i=0; i< MAX_STATE; i++)
  74. {
  75. DISPDBG((DBGLVL,"RS %x = %x",i, pSSRec->uc.RenderStates[i]));
  76. }
  77. // Dump TSS's values
  78. for (j=0; j<= SB_MAX_STAGES; j++)
  79. {
  80. for (i=0; i<= D3DTSS_TEXTURETRANSFORMFLAGS; i++)
  81. {
  82. DISPDBG((DBGLVL,"TSS [%x] %x = %x",
  83. j, i, pSSRec->uc.TssStates[j][i]));
  84. }
  85. }
  86. // Dump RS bit masks
  87. for (i=0; i< ELEMS_IN_ARRAY(pSSRec->uc.bStoredRS); i++)
  88. {
  89. DISPDBG((DBGLVL,"bStoredRS[%x] = %x",
  90. i, pSSRec->uc.bStoredRS[i]));
  91. }
  92. // Dump TSS bit masks
  93. for (j=0; j<= SB_MAX_STAGES; j++)
  94. {
  95. for (i=0; i< ELEMS_IN_ARRAY(pSSRec->uc.bStoredTSS[j]); i++)
  96. {
  97. DISPDBG((DBGLVL,"bStoredTSS[%x][%x] = %x",
  98. j, i, pSSRec->uc.bStoredTSS[j][i]));
  99. }
  100. }
  101. }
  102. else
  103. {
  104. // compressed state set
  105. D3DHAL_DP2COMMAND *pDP2Cmd;
  106. D3DHAL_DP2RENDERSTATE *pDP2RenderState;
  107. D3DHAL_DP2TEXTURESTAGESTATE *pDP2TSState;
  108. pDP2Cmd = pSSRec->cc.pDP2RenderState;
  109. if (pDP2Cmd)
  110. {
  111. DISPDBG((DBGLVL,"dwNumRS =%x", pDP2Cmd->wStateCount));
  112. pDP2RenderState = (D3DHAL_DP2RENDERSTATE *)(pDP2Cmd + 1);
  113. for (i=0; i< pDP2Cmd->wStateCount; i++, pDP2RenderState++)
  114. {
  115. DISPDBG((DBGLVL,"RS %x = %x",
  116. pDP2RenderState->RenderState,
  117. pDP2RenderState->dwState));
  118. }
  119. }
  120. pDP2Cmd = pSSRec->cc.pDP2TextureStageState;
  121. if (pDP2Cmd)
  122. {
  123. DISPDBG((DBGLVL,"dwNumTSS=%x", pDP2Cmd->wStateCount));
  124. pDP2TSState = (D3DHAL_DP2TEXTURESTAGESTATE *)(pDP2Cmd + 1);
  125. for (i = 0; i < pDP2Cmd->wStateCount; i++, pDP2TSState++)
  126. {
  127. DISPDBG((DBGLVL,"TSS [%x] %x = %x",
  128. pDP2TSState->wStage,
  129. pDP2TSState->TSState,
  130. pDP2TSState->dwValue));
  131. }
  132. }
  133. }
  134. } // __SB_DumpStateSet
  135. //-----------------------------------------------------------------------------
  136. //
  137. // void __SB_AddStateSetIndexTableEntry
  138. //
  139. // Add an antry to the index table. If necessary, grow it.
  140. //-----------------------------------------------------------------------------
  141. void __SB_AddStateSetIndexTableEntry(P3_D3DCONTEXT* pContext,
  142. DWORD dwNewHandle,
  143. P3StateSetRec *pNewSSRec)
  144. {
  145. DWORD dwNewSize;
  146. P3StateSetRec **pNewIndexTableSS;
  147. // If the current list is not large enough, we'll have to grow a new one.
  148. if (dwNewHandle > pContext->dwMaxSSIndex)
  149. {
  150. // New size of our index table
  151. // (round up dwNewHandle in steps of SSPTRS_PERPAGE)
  152. dwNewSize = ((dwNewHandle -1 + SSPTRS_PERPAGE) / SSPTRS_PERPAGE)
  153. * SSPTRS_PERPAGE;
  154. // we have to grow our list
  155. pNewIndexTableSS = (P3StateSetRec **)
  156. HEAP_ALLOC( FL_ZERO_MEMORY,
  157. dwNewSize*sizeof(P3StateSetRec *),
  158. ALLOC_TAG_DX(2));
  159. if (!pNewIndexTableSS)
  160. {
  161. // we weren't able to grow the list so we will keep the old one
  162. // and (sigh) forget about this state set since that is the
  163. // safest thing to do. We will delete also the state set structure
  164. // since no one will otherwise be able to find it later.
  165. DISPDBG((ERRLVL,"Out of mem growing state set list,"
  166. " droping current state set"));
  167. HEAP_FREE(pNewSSRec);
  168. return;
  169. }
  170. if (pContext->pIndexTableSS)
  171. {
  172. // if we already had a previous list, we must transfer its data
  173. memcpy(pNewIndexTableSS,
  174. pContext->pIndexTableSS,
  175. pContext->dwMaxSSIndex*sizeof(P3StateSetRec *));
  176. //and get rid of it
  177. HEAP_FREE(pContext->pIndexTableSS);
  178. }
  179. // New index table data
  180. pContext->pIndexTableSS = pNewIndexTableSS;
  181. pContext->dwMaxSSIndex = dwNewSize;
  182. }
  183. // Store our state set pointer into our access list
  184. pContext->pIndexTableSS[dwNewHandle - 1] = pNewSSRec;
  185. } // __SB_AddStateSetIndexTableEntry
  186. //-----------------------------------------------------------------------------
  187. //
  188. // int __SB_GetCompressedSize
  189. //
  190. // Calculate the size of the compressed state set
  191. //
  192. //-----------------------------------------------------------------------------
  193. int __SB_GetCompressedSize(P3_D3DCONTEXT* pContext,
  194. P3StateSetRec* pUncompressedSS,
  195. OffsetsCompSS* offsetSS)
  196. {
  197. DWORD dwSize;
  198. DWORD dwCount;
  199. int i, j;
  200. // Calculate the size of fixed part
  201. dwSize = sizeof(CompressedStateSet) + 2*sizeof(DWORD);
  202. // Calculate size of the render states
  203. dwCount = 0;
  204. for (i = 0; i < MAX_STATE; i++)
  205. {
  206. if (IS_FLAG_SET(pUncompressedSS->uc.bStoredRS , i))
  207. {
  208. dwCount++;
  209. }
  210. }
  211. if (dwCount)
  212. {
  213. offsetSS->dwOffDP2RenderState = dwSize;
  214. dwSize += (sizeof(D3DHAL_DP2COMMAND) + dwCount * sizeof(D3DHAL_DP2RENDERSTATE));
  215. }
  216. // Calculate size of the texture stage states
  217. dwCount = 0;
  218. for (j = 0; j <= SB_MAX_STAGES; j++)
  219. {
  220. for (i = 0; i <= D3DTSS_TEXTURETRANSFORMFLAGS; i++)
  221. {
  222. if (IS_FLAG_SET(pUncompressedSS->uc.bStoredTSS[j] , i))
  223. {
  224. dwCount++;
  225. }
  226. }
  227. }
  228. if (dwCount)
  229. {
  230. offsetSS->dwOffDP2TextureStageState = dwSize;
  231. dwSize += (sizeof(D3DHAL_DP2COMMAND) + dwCount * sizeof(D3DHAL_DP2TEXTURESTAGESTATE));
  232. }
  233. // Calculate size of Viewport and ZRange
  234. if (pUncompressedSS->uc.dwFlags & SB_VIEWPORT_CHANGED)
  235. {
  236. offsetSS->dwOffDP2Viewport = dwSize;
  237. dwSize += (sizeof(D3DHAL_DP2COMMAND) + sizeof(D3DHAL_DP2VIEWPORTINFO));
  238. }
  239. if (pUncompressedSS->uc.dwFlags & SB_ZRANGE_CHANGED)
  240. {
  241. offsetSS->dwOffDP2ZRange = dwSize;
  242. dwSize += (sizeof(D3DHAL_DP2COMMAND) + sizeof(D3DHAL_DP2ZRANGE));
  243. }
  244. #if DX8_DDI
  245. if (pUncompressedSS->uc.dwFlags & SB_INDICES_CHANGED)
  246. {
  247. offsetSS->dwOffDP2SetIndices = dwSize;
  248. dwSize += (sizeof(D3DHAL_DP2COMMAND) + sizeof(D3DHAL_DP2SETINDICES));
  249. }
  250. dwCount = 0;
  251. for (i = 0; i < D3DVS_INPUTREG_MAX_V1_1; i++)
  252. {
  253. if (pUncompressedSS->uc.dwFlags & (SB_STREAMSRC_CHANGED << i))
  254. {
  255. dwCount++;
  256. }
  257. }
  258. if (dwCount)
  259. {
  260. offsetSS->dwOffDP2SetStreamSources = dwSize;
  261. dwSize += (sizeof(D3DHAL_DP2COMMAND) + dwCount * sizeof(D3DHAL_DP2SETSTREAMSOURCE));
  262. }
  263. #endif // DX8_DDI
  264. #if DX7_SB_TNL
  265. // TODO, Calculate size needed for lights, clip planes, material, transformation
  266. #endif // DX7_SB_TNL
  267. #if DX7_SB_TNL
  268. // TODO, Calculate size needed for {V|P} shader constants
  269. #endif // DX7_SB_TNL
  270. #if DX8_DDI
  271. if (pUncompressedSS->uc.dwFlags & SB_CUR_VS_CHANGED)
  272. {
  273. offsetSS->dwOffDP2SetVertexShader = dwSize;
  274. dwSize += (sizeof(D3DHAL_DP2COMMAND) + sizeof(D3DHAL_DP2VERTEXSHADER));
  275. }
  276. #endif // DX8_DDI
  277. return (dwSize);
  278. } // __SB_GetCompressedSize
  279. //-----------------------------------------------------------------------------
  280. //
  281. // void __SB_CompressStateSet
  282. //
  283. // Compress a state set so it uses the minimum necessary space. Since we expect
  284. // some apps to make extensive use of state sets we want to keep things tidy.
  285. // Returns address of new structure (ir old, if it wasn't compressed)
  286. //
  287. //-----------------------------------------------------------------------------
  288. P3StateSetRec * __SB_CompressStateSet(P3_D3DCONTEXT* pContext,
  289. P3StateSetRec *pUncompressedSS)
  290. {
  291. P3StateSetRec *pCompressedSS;
  292. LPBYTE pTmp;
  293. OffsetsCompSS offsetSS;
  294. DWORD i, j, dwSize, dwCount;
  295. D3DHAL_DP2COMMAND* pDP2Cmd;
  296. // Initialize the offset structure
  297. memset(&offsetSS, 0, sizeof(OffsetsCompSS));
  298. // Create a new state set of just the right size we need
  299. dwSize = __SB_GetCompressedSize(pContext, pUncompressedSS, &offsetSS);
  300. if (dwSize >= pUncompressedSS->uc.dwSize)
  301. {
  302. // it is not efficient to compress, leave uncompressed !
  303. pUncompressedSS->dwSSFlags &= (~SB_COMPRESSED);
  304. return pUncompressedSS;
  305. }
  306. pTmp = HEAP_ALLOC(FL_ZERO_MEMORY, dwSize, ALLOC_TAG_DX(3));
  307. if (! pTmp)
  308. {
  309. DISPDBG((ERRLVL,"Not enough memory left to compress D3D state set"));
  310. pUncompressedSS->dwSSFlags &= (~SB_COMPRESSED);
  311. return pUncompressedSS;
  312. }
  313. pCompressedSS = (P3StateSetRec *)pTmp;
  314. // Adjust data in new compressed state set
  315. pCompressedSS->dwSSFlags |= SB_COMPRESSED;
  316. pCompressedSS->dwHandle = pUncompressedSS->dwHandle;
  317. // Set up render state in the compressed state set
  318. if (offsetSS.dwOffDP2RenderState)
  319. {
  320. D3DHAL_DP2RENDERSTATE* pDP2RS;
  321. pDP2Cmd = (D3DHAL_DP2COMMAND *)(pTmp + offsetSS.dwOffDP2RenderState);
  322. pCompressedSS->cc.pDP2RenderState = pDP2Cmd;
  323. pDP2Cmd->bCommand = D3DDP2OP_RENDERSTATE;
  324. pDP2RS = (D3DHAL_DP2RENDERSTATE *)(pDP2Cmd + 1);
  325. for (i = 0; i < MAX_STATE; i++)
  326. {
  327. if (IS_FLAG_SET(pUncompressedSS->uc.bStoredRS , i))
  328. {
  329. pDP2RS->RenderState = i;
  330. pDP2RS->dwState = pUncompressedSS->uc.RenderStates[i];
  331. pDP2RS++;
  332. }
  333. }
  334. pDP2Cmd->wStateCount = (WORD)(pDP2RS - ((D3DHAL_DP2RENDERSTATE *)(pDP2Cmd + 1)));
  335. }
  336. // Set up texture stage state in the compress state set
  337. if (offsetSS.dwOffDP2TextureStageState)
  338. {
  339. D3DHAL_DP2TEXTURESTAGESTATE* pDP2TSS;
  340. pDP2Cmd = (D3DHAL_DP2COMMAND *)(pTmp + offsetSS.dwOffDP2TextureStageState);
  341. pCompressedSS->cc.pDP2TextureStageState = pDP2Cmd;
  342. pDP2Cmd->bCommand = D3DDP2OP_TEXTURESTAGESTATE;
  343. pDP2TSS = (D3DHAL_DP2TEXTURESTAGESTATE *)(pDP2Cmd + 1);
  344. for (j = 0; j < SB_MAX_STAGES; j++)
  345. {
  346. for (i = 0; i <= D3DTSS_TEXTURETRANSFORMFLAGS; i++)
  347. {
  348. if (IS_FLAG_SET(pUncompressedSS->uc.bStoredTSS[j] , i))
  349. {
  350. pDP2TSS->wStage = (WORD)j;
  351. pDP2TSS->TSState = (WORD)i;
  352. pDP2TSS->dwValue = pUncompressedSS->uc.TssStates[j][i];
  353. pDP2TSS++;
  354. }
  355. }
  356. }
  357. pDP2Cmd->wStateCount = (WORD)(pDP2TSS - ((D3DHAL_DP2TEXTURESTAGESTATE *)(pDP2Cmd + 1)));
  358. }
  359. // Set up the viewport and zrange in the compressed state set
  360. if (offsetSS.dwOffDP2Viewport)
  361. {
  362. D3DHAL_DP2VIEWPORTINFO* pDP2ViewPort;
  363. pDP2Cmd = (D3DHAL_DP2COMMAND *)(pTmp + offsetSS.dwOffDP2Viewport);
  364. pCompressedSS->cc.pDP2Viewport = pDP2Cmd;
  365. pDP2Cmd->bCommand = D3DDP2OP_VIEWPORTINFO;
  366. pDP2ViewPort = (D3DHAL_DP2VIEWPORTINFO *)(pDP2Cmd + 1);
  367. *pDP2ViewPort = pUncompressedSS->uc.viewport;
  368. }
  369. if (offsetSS.dwOffDP2ZRange)
  370. {
  371. D3DHAL_DP2ZRANGE* pDP2ZRange;
  372. pDP2Cmd = (D3DHAL_DP2COMMAND *)(pTmp + offsetSS.dwOffDP2ZRange);
  373. pCompressedSS->cc.pDP2ZRange = pDP2Cmd;
  374. pDP2Cmd->bCommand = D3DDP2OP_ZRANGE;
  375. pDP2ZRange = (D3DHAL_DP2ZRANGE *)(pDP2Cmd + 1);
  376. *pDP2ZRange = pUncompressedSS->uc.zRange;
  377. }
  378. #if DX8_DDI
  379. // Set up the vertex shader in the compressed state set
  380. if (offsetSS.dwOffDP2SetIndices)
  381. {
  382. D3DHAL_DP2SETINDICES* pDP2SetIndices;
  383. pDP2Cmd = (D3DHAL_DP2COMMAND *)(pTmp + offsetSS.dwOffDP2SetIndices);
  384. pCompressedSS->cc.pDP2SetIndices = pDP2Cmd;
  385. pDP2Cmd->bCommand = D3DDP2OP_SETINDICES;
  386. pDP2SetIndices = (D3DHAL_DP2SETINDICES *)(pDP2Cmd + 1);
  387. *pDP2SetIndices = pUncompressedSS->uc.vertexIndex;
  388. pDP2Cmd->wStateCount = 1;
  389. }
  390. // Set up the vertex shader in the compressed state set
  391. if (offsetSS.dwOffDP2SetStreamSources)
  392. {
  393. D3DHAL_DP2SETSTREAMSOURCE* pDP2SetStmSrc;
  394. pDP2Cmd = (D3DHAL_DP2COMMAND *)(pTmp + offsetSS.dwOffDP2SetStreamSources);
  395. pCompressedSS->cc.pDP2SetStreamSources = pDP2Cmd;
  396. pDP2Cmd->bCommand = D3DDP2OP_SETSTREAMSOURCE;
  397. pDP2SetStmSrc = (D3DHAL_DP2SETSTREAMSOURCE *)(pDP2Cmd + 1);
  398. for (i = 0; i < D3DVS_INPUTREG_MAX_V1_1; i++)
  399. {
  400. if (pUncompressedSS->uc.dwFlags & (SB_STREAMSRC_CHANGED << i))
  401. {
  402. *pDP2SetStmSrc = pUncompressedSS->uc.streamSource[i];
  403. pDP2SetStmSrc++;
  404. }
  405. }
  406. pDP2Cmd->wPrimitiveCount = (WORD)(pDP2SetStmSrc - ((D3DHAL_DP2SETSTREAMSOURCE *)(pDP2Cmd + 1)) );
  407. }
  408. #endif // DX8_DDI
  409. #if DX7_SB_TNL
  410. // TODO, set up light, material, transform, clip plane
  411. #endif // DX7_SB_TNL
  412. #if DX8_SB_SHADERS
  413. // TODO, set up shader constants
  414. #endif // DX8_SB_SHADERS
  415. #if DX8_DDI
  416. // Set up the vertex shader in the compressed state set
  417. if (offsetSS.dwOffDP2SetVertexShader)
  418. {
  419. D3DHAL_DP2VERTEXSHADER* pDP2SetVtxShader;
  420. pDP2Cmd = (D3DHAL_DP2COMMAND *)(pTmp + offsetSS.dwOffDP2SetVertexShader);
  421. pCompressedSS->cc.pDP2SetVertexShader = pDP2Cmd;
  422. pDP2Cmd->bCommand = D3DDP2OP_SETVERTEXSHADER;
  423. pDP2SetVtxShader = (D3DHAL_DP2VERTEXSHADER *)(pDP2Cmd + 1);
  424. pDP2SetVtxShader->dwHandle = pUncompressedSS->uc.dwCurVertexShader;
  425. }
  426. #endif // DX8_DDI
  427. // Get rid of the old(uncompressed) one
  428. HEAP_FREE(pUncompressedSS);
  429. return pCompressedSS;
  430. } // __SB_CompressStateSet
  431. //-----------------------------------------------------------------------------
  432. //
  433. // void _D3D_SB_DeleteAllStateSets
  434. //
  435. // Delete any remaining state sets for cleanup purpouses
  436. //
  437. //-----------------------------------------------------------------------------
  438. void _D3D_SB_DeleteAllStateSets(P3_D3DCONTEXT* pContext)
  439. {
  440. P3StateSetRec *pSSRec;
  441. DWORD dwSSIndex;
  442. DISPDBG((DBGLVL,"_D3D_SB_DeleteAllStateSets"));
  443. if (pContext->pIndexTableSS)
  444. {
  445. for(dwSSIndex = 0; dwSSIndex < pContext->dwMaxSSIndex; dwSSIndex++)
  446. {
  447. if (pSSRec = pContext->pIndexTableSS[dwSSIndex])
  448. {
  449. HEAP_FREE(pSSRec);
  450. }
  451. }
  452. // free fast index table
  453. HEAP_FREE(pContext->pIndexTableSS);
  454. }
  455. } // _D3D_SB_DeleteAllStateSets
  456. //-----------------------------------------------------------------------------
  457. //
  458. // void _D3D_SB_BeginStateSet
  459. //
  460. // Create a new state set identified by dwParam and start recording states
  461. //
  462. //-----------------------------------------------------------------------------
  463. void _D3D_SB_BeginStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam)
  464. {
  465. DWORD dwSSSize;
  466. P3StateSetRec *pSSRec;
  467. DISPDBG((DBGLVL,"_D3D_SB_BeginStateSet dwParam=%08lx",dwParam));
  468. // Calculate the maximum size of the state set
  469. dwSSSize = sizeof(P3StateSetRec);
  470. #if DX7_SB_TNL
  471. // TODO, Size depends on number of lights, clip planes
  472. #endif // DX7_SB_TNL
  473. #if DX8_SB_SHADERS
  474. // TODO, size depends on number of vertext/pixel shaders
  475. #endif // DX8_SB_SHADERS
  476. // Create a new state set
  477. pSSRec = (P3StateSetRec *)HEAP_ALLOC(FL_ZERO_MEMORY,
  478. dwSSSize,
  479. ALLOC_TAG_DX(4));
  480. if (!pSSRec)
  481. {
  482. DISPDBG((ERRLVL,"Run out of memory for additional state sets"));
  483. return;
  484. }
  485. // Remember handle to current state set
  486. pSSRec->dwHandle = dwParam;
  487. pSSRec->dwSSFlags &= (~SB_COMPRESSED);
  488. // Remember the size of the uncompressed state set
  489. pSSRec->uc.dwSize = dwSSSize;
  490. #if DX7_SB_TNL
  491. // TODO, Set up pointers for data used for lights, clip planes
  492. #endif // DX7_SB_TNL
  493. #if DX8_SB_SHADERS
  494. // TODO, Set up pointers for data used for {V|P} shader constants
  495. #endif // DX8_SB_SHADERS
  496. // Get pointer to current recording state set
  497. pContext->pCurrSS = pSSRec;
  498. // Start recording mode
  499. pContext->bStateRecMode = TRUE;
  500. } // _D3D_SB_BeginStateSet
  501. //-----------------------------------------------------------------------------
  502. //
  503. // void _D3D_SB_EndStateSet
  504. //
  505. // stop recording states - revert to executing them.
  506. //
  507. //-----------------------------------------------------------------------------
  508. void _D3D_SB_EndStateSet(P3_D3DCONTEXT* pContext)
  509. {
  510. DWORD dwHandle;
  511. P3StateSetRec *pNewSSRec;
  512. DISPDBG((DBGLVL,"_D3D_SB_EndStateSet"));
  513. if (pContext->pCurrSS)
  514. {
  515. dwHandle = pContext->pCurrSS->dwHandle;
  516. // compress the current state set
  517. // Note: after being compressed the uncompressed version is free'd.
  518. pNewSSRec = __SB_CompressStateSet(pContext, pContext->pCurrSS);
  519. __SB_AddStateSetIndexTableEntry(pContext, dwHandle, pNewSSRec);
  520. }
  521. // No state set being currently recorded
  522. pContext->pCurrSS = NULL;
  523. // End recording mode
  524. pContext->bStateRecMode = FALSE;
  525. } // _D3D_SB_EndStateSet
  526. //-----------------------------------------------------------------------------
  527. //
  528. // void _D3D_SB_DeleteStateSet
  529. //
  530. // Delete the recorder state ste identified by dwParam
  531. //
  532. //-----------------------------------------------------------------------------
  533. void _D3D_SB_DeleteStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam)
  534. {
  535. P3StateSetRec *pSSRec;
  536. DWORD i;
  537. DISPDBG((DBGLVL,"_D3D_SB_DeleteStateSet dwParam=%08lx",dwParam));
  538. if (pSSRec = __SB_FindStateSet(pContext, dwParam))
  539. {
  540. // Clear index table entry
  541. pContext->pIndexTableSS[dwParam - 1] = NULL;
  542. // Now delete the actual state set structure
  543. HEAP_FREE(pSSRec);
  544. }
  545. } // _D3D_SB_DeleteStateSet
  546. //-----------------------------------------------------------------------------
  547. //
  548. // void _D3D_SB_ExecuteStateSet
  549. //
  550. // Execute the render states and texture stage states of which a given
  551. // state set is comprised. Distinguish between the compressed and
  552. // uncomressed representations of records.
  553. //
  554. //-----------------------------------------------------------------------------
  555. void _D3D_SB_ExecuteStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam)
  556. {
  557. P3StateSetRec *pSSRec;
  558. DWORD i,j;
  559. DISPDBG((DBGLVL,"_D3D_SB_ExecuteStateSet dwParam=%08lx",dwParam));
  560. if (pSSRec = __SB_FindStateSet(pContext, dwParam))
  561. {
  562. if (!(pSSRec->dwSSFlags & SB_COMPRESSED))
  563. {
  564. // uncompressed state set
  565. // Execute any necessary render states
  566. for (i=0; i< MAX_STATE; i++)
  567. {
  568. if (IS_FLAG_SET(pSSRec->uc.bStoredRS , i))
  569. {
  570. DWORD dwRSType, dwRSVal;
  571. dwRSType = i;
  572. dwRSVal = pSSRec->uc.RenderStates[dwRSType];
  573. // Store the state in the context
  574. pContext->RenderStates[dwRSType] = dwRSVal;
  575. DISPDBG((DBGLVL,"_D3D_SB_ExecuteStateSet RS %x = %x",
  576. dwRSType, dwRSVal));
  577. // Process it
  578. _D3D_ST_ProcessOneRenderState(pContext, dwRSType, dwRSVal);
  579. }
  580. }
  581. // Execute any necessary TSS's
  582. for (j=0; j<SB_MAX_STAGES; j++)
  583. {
  584. for (i=0; i<= D3DTSS_TEXTURETRANSFORMFLAGS; i++)
  585. {
  586. if (IS_FLAG_SET(pSSRec->uc.bStoredTSS[j] , i))
  587. {
  588. D3DHAL_DP2TEXTURESTAGESTATE dp2TSS;
  589. dp2TSS.TSState = (WORD)i;
  590. dp2TSS.wStage = (WORD)j;
  591. dp2TSS.dwValue = pSSRec->uc.TssStates[j][i];
  592. DISPDBG((DBGLVL,
  593. "_D3D_SB_ExecuteStateSet TSS %x [%x] = %x",
  594. dp2TSS.TSState,
  595. dp2TSS.wStage,
  596. dp2TSS.dwValue));
  597. // If a state set is changed by _D3D_SB_CaptureStateSet(),
  598. // then texture filter values in it are DX6 semantic, otherwise
  599. // it is DX8
  600. if (pSSRec->dwSSFlags & SB_VAL_CAPTURED)
  601. {
  602. _D3D_TXT_ParseTextureStageStates(pContext,
  603. &dp2TSS,
  604. 1,
  605. FALSE); //It is already DX6
  606. }
  607. else
  608. {
  609. _D3D_TXT_ParseTextureStageStates(pContext,
  610. &dp2TSS,
  611. 1,
  612. TRUE);
  613. }
  614. }
  615. }
  616. }
  617. // Excute viewport info, z range
  618. if (pSSRec->uc.dwFlags & SB_VIEWPORT_CHANGED)
  619. {
  620. _D3D_OP_Viewport(pContext, &pSSRec->uc.viewport);
  621. }
  622. if (pSSRec->uc.dwFlags & SB_ZRANGE_CHANGED)
  623. {
  624. _D3D_OP_ZRange(pContext, &pSSRec->uc.zRange);
  625. }
  626. #if DX8_DDI
  627. // Excute vertex indices and stream sources
  628. if (pSSRec->uc.dwFlags & SB_INDICES_CHANGED)
  629. {
  630. _D3D_OP_MStream_SetIndices(pContext,
  631. pSSRec->uc.vertexIndex.dwVBHandle,
  632. pSSRec->uc.vertexIndex.dwStride);
  633. }
  634. for (i = 0; i < D3DVS_INPUTREG_MAX_V1_1; i++)
  635. {
  636. if (pSSRec->uc.dwFlags & (SB_STREAMSRC_CHANGED << i))
  637. {
  638. _D3D_OP_MStream_SetSrc(pContext,
  639. pSSRec->uc.streamSource[i].dwStream,
  640. pSSRec->uc.streamSource[i].dwVBHandle,
  641. pSSRec->uc.streamSource[i].dwStride);
  642. }
  643. }
  644. #endif // DX8_DDI
  645. #if DX7_SB_TNL
  646. // TODO, Execute any necessary state for lights, materials,
  647. // transforms, clip planes
  648. #endif // DX7_SB_TNL
  649. #if DX8_SB_SHADERS
  650. // TODO, Execute any necessary set current shader and set shader
  651. // constants pairs
  652. #endif // DX8_SB_SHADERS
  653. #if DX8_DDI
  654. // Note : This should be done after setting shader constants, since
  655. // current shader may have to be set before changing constants
  656. if (pSSRec->uc.dwFlags & SB_CUR_VS_CHANGED)
  657. {
  658. _D3D_OP_VertexShader_Set(pContext,
  659. pSSRec->uc.dwCurVertexShader);
  660. }
  661. #endif // DX8_DDI
  662. }
  663. else
  664. {
  665. // compressed state set
  666. // Execute any necessary RS's
  667. if (pSSRec->cc.pDP2RenderState)
  668. {
  669. DISPDBG((DBGLVL, "_D3D_SB_ExecuteStateSet RenderState"));
  670. _D3D_ST_ProcessRenderStates(pContext,
  671. pSSRec->cc.pDP2RenderState->wStateCount,
  672. (LPD3DSTATE)(pSSRec->cc.pDP2RenderState + 1),
  673. FALSE);
  674. }
  675. // Execute any necessary TSS's
  676. if (pSSRec->cc.pDP2TextureStageState)
  677. {
  678. DISPDBG((DBGLVL,"_D3D_SB_ExecuteStateSet TSS"));
  679. // If a state set is changed by _D3D_SB_CaptureStateSet(),
  680. // then texture filter values in it are DX6 semantic, otherwise
  681. // it is DX8
  682. if (pSSRec->dwSSFlags & SB_VAL_CAPTURED)
  683. {
  684. _D3D_TXT_ParseTextureStageStates(pContext,
  685. (D3DHAL_DP2TEXTURESTAGESTATE *)(pSSRec->cc.pDP2TextureStageState + 1),
  686. pSSRec->cc.pDP2TextureStageState->wStateCount,
  687. FALSE); // It is already DX6
  688. }
  689. else
  690. {
  691. _D3D_TXT_ParseTextureStageStates(pContext,
  692. (D3DHAL_DP2TEXTURESTAGESTATE *)(pSSRec->cc.pDP2TextureStageState + 1),
  693. pSSRec->cc.pDP2TextureStageState->wStateCount,
  694. TRUE);
  695. }
  696. }
  697. // execute viewport info, z range
  698. if (pSSRec->cc.pDP2Viewport)
  699. {
  700. _D3D_OP_Viewport(pContext,
  701. ((D3DHAL_DP2VIEWPORTINFO *)(pSSRec->cc.pDP2Viewport + 1))
  702. );
  703. }
  704. if (pSSRec->cc.pDP2ZRange)
  705. {
  706. _D3D_OP_ZRange(pContext,
  707. ((D3DHAL_DP2ZRANGE *)(pSSRec->cc.pDP2ZRange + 1))
  708. );
  709. }
  710. #if DX8_DDI
  711. // Execute vertex index, stream, shader
  712. if (pSSRec->cc.pDP2SetIndices)
  713. {
  714. D3DHAL_DP2SETINDICES* pDP2SetIndices;
  715. pDP2SetIndices = (D3DHAL_DP2SETINDICES *)(pSSRec->cc.pDP2SetIndices + 1);
  716. _D3D_OP_MStream_SetIndices(pContext,
  717. pDP2SetIndices->dwVBHandle,
  718. pDP2SetIndices->dwStride);
  719. }
  720. if (pSSRec->cc.pDP2SetStreamSources)
  721. {
  722. D3DHAL_DP2SETSTREAMSOURCE *pDP2SetStmSrc;
  723. DISPDBG((DBGLVL,"More than 1 stream (%d)",
  724. pSSRec->cc.pDP2SetStreamSources->wStateCount));
  725. pDP2SetStmSrc = (D3DHAL_DP2SETSTREAMSOURCE *)(pSSRec->cc.pDP2SetStreamSources + 1);
  726. ASSERTDD(pDP2SetStmSrc->dwStream == 0, "Wrong vertex stream");
  727. for (i = 0; i < pSSRec->cc.pDP2SetStreamSources->wStateCount; i++, pDP2SetStmSrc++)
  728. {
  729. _D3D_OP_MStream_SetSrc(pContext,
  730. pDP2SetStmSrc->dwStream,
  731. pDP2SetStmSrc->dwVBHandle,
  732. pDP2SetStmSrc->dwStride);
  733. }
  734. }
  735. #endif // DX8_DDI
  736. #if DX7_SB_TNL
  737. // TODO, Execute any necessary state for lights, materials,
  738. // transforms, clip planes
  739. #endif // DX7_SB_TNL
  740. #if DX8_SB_SHADERS
  741. // TODO, Execute any necessary state for setting {V|P} shader constants
  742. #endif // DX8_SB_SHADERS
  743. #if DX8_DDI
  744. // Execute current pixel shader (legacy FVF code)
  745. if (pSSRec->cc.pDP2SetVertexShader)
  746. {
  747. _D3D_OP_VertexShader_Set(pContext,
  748. ((D3DHAL_DP2VERTEXSHADER *)(pSSRec->cc.pDP2SetVertexShader + 1))->dwHandle);
  749. }
  750. #endif // DX8_DDI
  751. }
  752. }
  753. } // _D3D_SB_ExecuteStateSet
  754. //-----------------------------------------------------------------------------
  755. //
  756. // void _D3D_SB_CaptureStateSet
  757. //
  758. // Capture the render states and texture stage states of which a given
  759. // state set is comprised. Distinguish between the compressed and
  760. // uncomressed representations of records. This functionality allows the
  761. // app to have a push/pop state feature.
  762. //
  763. //-----------------------------------------------------------------------------
  764. void _D3D_SB_CaptureStateSet(P3_D3DCONTEXT* pContext, DWORD dwParam)
  765. {
  766. P3StateSetRec *pSSRec;
  767. DWORD i, j;
  768. DISPDBG((DBGLVL,"_D3D_SB_CaptureStateSet dwParam=%08lx",dwParam));
  769. if (pSSRec = __SB_FindStateSet(pContext, dwParam))
  770. {
  771. // Mark it as having DX6 texture filter values instead of DX8,
  772. // so that _D3D_SB_ExecuteStateSet() uses the FALSE for the
  773. // bTranslateDX8FilterValueToDX6 of _D3D_TXT_ParseTextureStageStates()
  774. pSSRec->dwSSFlags |= SB_VAL_CAPTURED;
  775. // Actually capture the values
  776. if (!(pSSRec->dwSSFlags & SB_COMPRESSED))
  777. {
  778. // uncompressed state set
  779. // Capture any necessary render states
  780. for (i=0; i< MAX_STATE; i++)
  781. if (IS_FLAG_SET(pSSRec->uc.bStoredRS , i))
  782. {
  783. pSSRec->uc.RenderStates[i] = pContext->RenderStates[i];
  784. }
  785. // Capture any necessary TSS's
  786. for (j=0; j<SB_MAX_STAGES; j++)
  787. {
  788. for (i=0; i<= D3DTSS_TEXTURETRANSFORMFLAGS; i++)
  789. {
  790. if (IS_FLAG_SET(pSSRec->uc.bStoredTSS[j] , i))
  791. {
  792. pSSRec->uc.TssStates[j][i] =
  793. pContext->TextureStageState[j].m_dwVal[i];
  794. }
  795. }
  796. }
  797. // Capture viewport info, z range
  798. if (pSSRec->uc.dwFlags & SB_VIEWPORT_CHANGED)
  799. {
  800. pSSRec->uc.viewport = pContext->ViewportInfo;
  801. }
  802. if (pSSRec->uc.dwFlags & SB_ZRANGE_CHANGED)
  803. {
  804. pSSRec->uc.zRange = pContext->ZRange;
  805. }
  806. #if DX8_DDI
  807. // Capture vertex indices and stream sources
  808. if (pSSRec->uc.dwFlags & SB_INDICES_CHANGED)
  809. {
  810. pSSRec->uc.vertexIndex.dwVBHandle = pContext->dwIndexHandle;
  811. pSSRec->uc.vertexIndex.dwStride = pContext->dwIndicesStride;
  812. }
  813. // Note : P3 supports only one stream
  814. for (i = 0; i < D3DVS_INPUTREG_MAX_V1_1; i++)
  815. {
  816. ASSERTDD(i == 0, "Wrong vertex stream");
  817. if (pSSRec->uc.dwFlags & (SB_STREAMSRC_CHANGED << i))
  818. {
  819. pSSRec->uc.streamSource[i].dwStream = 0;
  820. pSSRec->uc.streamSource[i].dwVBHandle = pContext->dwVBHandle;
  821. pSSRec->uc.streamSource[i].dwStride = pContext->dwVerticesStride;
  822. }
  823. }
  824. #endif // DX8_DDI
  825. #if DX7_SB_TNL
  826. // TODO, Capture any necessary state for lights, materials,
  827. // transforms, clip planes
  828. #endif // DX7_SB_TNL
  829. #if DX8_SB_SHADERS
  830. // TODO, Capture any necessary state for {V|P} shader constants
  831. #endif // DX8_SB_SHADERS
  832. #if DX8_DDI
  833. // Capture the current vertex shader
  834. if (pSSRec->uc.dwFlags & SB_CUR_VS_CHANGED)
  835. {
  836. pSSRec->uc.dwCurVertexShader = pContext->dwVertexType;
  837. }
  838. #endif // DX8_DDI
  839. }
  840. else
  841. {
  842. // compressed state set
  843. // Capture any necessary render states
  844. if (pSSRec->cc.pDP2RenderState)
  845. {
  846. D3DHAL_DP2RENDERSTATE* pDP2RS;
  847. pDP2RS = (D3DHAL_DP2RENDERSTATE *)(pSSRec->cc.pDP2RenderState + 1);
  848. for (i = 0; i < pSSRec->cc.pDP2RenderState->wStateCount; i++, pDP2RS++)
  849. {
  850. pDP2RS->dwState = pContext->RenderStates[pDP2RS->RenderState];
  851. }
  852. }
  853. // Capture any necessary TSS's
  854. if (pSSRec->cc.pDP2TextureStageState)
  855. {
  856. D3DHAL_DP2TEXTURESTAGESTATE* pDP2TSS;
  857. pDP2TSS = (D3DHAL_DP2TEXTURESTAGESTATE *)(pSSRec->cc.pDP2TextureStageState + 1);
  858. for (i = 0; i < pSSRec->cc.pDP2TextureStageState->wStateCount; i++, pDP2TSS++)
  859. {
  860. pDP2TSS->dwValue = pContext->TextureStageState[pDP2TSS->wStage].m_dwVal[pDP2TSS->TSState];
  861. }
  862. }
  863. // Capture viewport info, z range
  864. if (pSSRec->cc.pDP2Viewport)
  865. {
  866. *((D3DHAL_DP2VIEWPORTINFO *)(pSSRec->cc.pDP2Viewport + 1)) = pContext->ViewportInfo;
  867. }
  868. if (pSSRec->cc.pDP2ZRange)
  869. {
  870. *((D3DHAL_DP2ZRANGE *)(pSSRec->cc.pDP2ZRange + 1)) = pContext->ZRange;
  871. }
  872. #if DX8_DDI
  873. // Capture vertex index, stream, shader
  874. if (pSSRec->cc.pDP2SetIndices)
  875. {
  876. D3DHAL_DP2SETINDICES* pDP2SetIndices;
  877. pDP2SetIndices = (D3DHAL_DP2SETINDICES *)(pSSRec->cc.pDP2SetIndices + 1);
  878. pDP2SetIndices->dwVBHandle = pContext->dwIndexHandle;
  879. pDP2SetIndices->dwStride = pContext->dwIndicesStride; // 2 | 4
  880. }
  881. if (pSSRec->cc.pDP2SetStreamSources)
  882. {
  883. D3DHAL_DP2SETSTREAMSOURCE* pDP2SetStmSrc;
  884. pDP2SetStmSrc = (D3DHAL_DP2SETSTREAMSOURCE *)(pSSRec->cc.pDP2SetStreamSources + 1);
  885. pDP2SetStmSrc->dwStream = 0; // Only stream for permedia 3
  886. pDP2SetStmSrc->dwVBHandle = pContext->dwVBHandle;
  887. pDP2SetStmSrc->dwStride = pContext->dwVerticesStride;
  888. }
  889. #endif // DX8_DDI
  890. #if DX7_SB_TNL
  891. // TODO, Capture any necessary state for lights, materials,
  892. // transforms, clip planes
  893. #endif // DX7_SB_TNL
  894. #if DX8_SB_SHADERS
  895. // TODO, Capture any necessary state for {V|P} shader constants
  896. #endif // DX8_SB_SHADERS
  897. #if DX8_DDI
  898. // Capture current vertex shader
  899. if (pSSRec->cc.pDP2SetVertexShader)
  900. {
  901. D3DHAL_DP2VERTEXSHADER* pSetVtxShader;
  902. pSetVtxShader = (D3DHAL_DP2VERTEXSHADER *)(pSSRec->cc.pDP2SetVertexShader + 1);
  903. pSetVtxShader->dwHandle = pContext->dwVertexType;
  904. }
  905. #endif // DX8_DDI
  906. }
  907. }
  908. } // _D3D_SB_CaptureStateSet
  909. //-----------------------------------------------------------------------------
  910. // Recording happens between BeginStateSet and EndStateSet calls so we
  911. // never need to deal with recording into a compressed state set (since
  912. // compression happens in EndStateSet)
  913. //-----------------------------------------------------------------------------
  914. //-----------------------------------------------------------------------------
  915. //
  916. // void _D3D_SB_RecordStateSetRS
  917. //
  918. // Record this render state into the current state set being recorded
  919. //
  920. //-----------------------------------------------------------------------------
  921. void _D3D_SB_RecordStateSetRS(P3_D3DCONTEXT* pContext,
  922. DWORD dwRSType,
  923. DWORD dwRSVal)
  924. {
  925. if (pContext->pCurrSS != NULL)
  926. {
  927. DISPDBG((DBGLVL,"Recording SB # %x : RS %x = %x",
  928. pContext->pCurrSS->dwHandle,dwRSType,dwRSVal));
  929. // Recording the state in an uncompressed stateblock
  930. pContext->pCurrSS->uc.RenderStates[dwRSType] = dwRSVal;
  931. FLAG_SET(pContext->pCurrSS->uc.bStoredRS, dwRSType);
  932. }
  933. } // _D3D_SB_RecordStateSetRS
  934. //-----------------------------------------------------------------------------
  935. //
  936. // void _D3D_SB_RecordStateSetTSS
  937. //
  938. // Record this texture stage state into the current state set being recorded
  939. //
  940. //-----------------------------------------------------------------------------
  941. void _D3D_SB_RecordStateSetTSS(P3_D3DCONTEXT* pContext,
  942. DWORD dwTSStage,
  943. DWORD dwTSState,
  944. DWORD dwTSVal)
  945. {
  946. if (pContext->pCurrSS != NULL)
  947. {
  948. DISPDBG((DBGLVL,"Recording SB # %x : TSS %x [%x] = %x",
  949. pContext->pCurrSS->dwHandle,dwTSState, dwTSStage, dwTSVal));
  950. // Recording the state in an uncompressed stateblock
  951. pContext->pCurrSS->uc.TssStates[dwTSStage][dwTSState] = dwTSVal;
  952. FLAG_SET(pContext->pCurrSS->uc.bStoredTSS[dwTSStage], dwTSState);
  953. }
  954. } // _D3D_SB_RecordStateSetTSS
  955. #if DX8_MULTSTREAMS
  956. //-----------------------------------------------------------------------------
  957. //
  958. // void _D3D_SB_Record_VertexShader_Set
  959. //
  960. // Record this vertex shader set code into the current state set being recorded
  961. //
  962. //-----------------------------------------------------------------------------
  963. void _D3D_SB_Record_VertexShader_Set(P3_D3DCONTEXT* pContext,
  964. DWORD dwVtxShaderHandle)
  965. {
  966. if (pContext->pCurrSS != NULL)
  967. {
  968. ASSERTDD (!(pContext->pCurrSS->dwSSFlags & SB_COMPRESSED),
  969. "ERROR : StateSet compressed");
  970. pContext->pCurrSS->uc.dwCurVertexShader = dwVtxShaderHandle;
  971. pContext->pCurrSS->uc.dwFlags |= SB_CUR_VS_CHANGED;
  972. }
  973. } // _D3D_SB_Record_VertexShader_Set
  974. //-----------------------------------------------------------------------------
  975. //
  976. // void _D3D_SB_Record_MStream_SetSrc
  977. //
  978. // Record this stream src set code into the current state set being recorded
  979. //
  980. //-----------------------------------------------------------------------------
  981. void _D3D_SB_Record_MStream_SetSrc(P3_D3DCONTEXT* pContext,
  982. DWORD dwStream,
  983. DWORD dwVBHandle,
  984. DWORD dwStride)
  985. {
  986. if (pContext->pCurrSS != NULL)
  987. {
  988. ASSERTDD (!(pContext->pCurrSS->dwSSFlags & SB_COMPRESSED),
  989. "ERROR : StateSet compressed");
  990. pContext->pCurrSS->uc.streamSource[dwStream].dwStream = dwStream;
  991. pContext->pCurrSS->uc.streamSource[dwStream].dwVBHandle = dwVBHandle;
  992. pContext->pCurrSS->uc.streamSource[dwStream].dwStride = dwStride;
  993. pContext->pCurrSS->uc.dwFlags |= (SB_STREAMSRC_CHANGED << dwStream);
  994. }
  995. } // _D3D_SB_Record_MStream_SetSrc
  996. //-----------------------------------------------------------------------------
  997. //
  998. // void _D3D_SB_Record_MStream_SetIndices
  999. //
  1000. // Record this stream indices code into the current state set being recorded
  1001. //
  1002. //-----------------------------------------------------------------------------
  1003. void _D3D_SB_Record_MStream_SetIndices(P3_D3DCONTEXT* pContext,
  1004. DWORD dwVBHandle,
  1005. DWORD dwStride)
  1006. {
  1007. if (pContext->pCurrSS != NULL)
  1008. {
  1009. ASSERTDD (!(pContext->pCurrSS->dwSSFlags & SB_COMPRESSED),
  1010. "ERROR : StateSet compressed");
  1011. pContext->pCurrSS->uc.vertexIndex.dwVBHandle = dwVBHandle;
  1012. pContext->pCurrSS->uc.vertexIndex.dwStride = dwStride;
  1013. pContext->pCurrSS->uc.dwFlags |= SB_INDICES_CHANGED;
  1014. }
  1015. } // _D3D_SB_Record_MStream_SetIndices
  1016. #endif // DX8_MULTSTREAMS
  1017. //-----------------------------------------------------------------------------
  1018. //
  1019. // void _D3D_SB_Record_Viewport
  1020. //
  1021. // Record this viewport info into the current state set being recorded
  1022. //
  1023. //-----------------------------------------------------------------------------
  1024. void _D3D_SB_Record_Viewport(P3_D3DCONTEXT* pContext,
  1025. D3DHAL_DP2VIEWPORTINFO* lpvp)
  1026. {
  1027. if (pContext->pCurrSS != NULL)
  1028. {
  1029. ASSERTDD (!(pContext->pCurrSS->dwSSFlags & SB_COMPRESSED),
  1030. "ERROR : StateSet compressed");
  1031. pContext->pCurrSS->uc.viewport = *lpvp;
  1032. pContext->pCurrSS->uc.dwFlags |= SB_VIEWPORT_CHANGED;
  1033. }
  1034. } // _D3D_SB_Record_Viewport
  1035. //-----------------------------------------------------------------------------
  1036. //
  1037. // void _D3D_SB_Record_ZRange
  1038. //
  1039. // Record this z range info into the current state set being recorded
  1040. //
  1041. //-----------------------------------------------------------------------------
  1042. VOID _D3D_SB_Record_ZRange(P3_D3DCONTEXT* pContext,
  1043. D3DHAL_DP2ZRANGE* lpzr)
  1044. {
  1045. if (pContext->pCurrSS != NULL)
  1046. {
  1047. ASSERTDD (!(pContext->pCurrSS->dwSSFlags & SB_COMPRESSED),
  1048. "ERROR : StateSet compressed");
  1049. pContext->pCurrSS->uc.zRange = *lpzr;
  1050. pContext->pCurrSS->uc.dwFlags |= SB_ZRANGE_CHANGED;
  1051. }
  1052. }
  1053. #endif //DX7_D3DSTATEBLOCKS