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.

915 lines
31 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // setup.cpp
  4. //
  5. // Generic C++ setup functions.
  6. //
  7. // Copyright (C) Microsoft Corporation, 1997.
  8. //
  9. //----------------------------------------------------------------------------
  10. include(`m4hdr.mh')dnl
  11. #include "pch.cpp"
  12. #pragma hdrstop
  13. DBG_DECLARE_FILE();
  14. #if DBG
  15. #define DBG_OVERFLOW
  16. #endif
  17. //----------------------------------------------------------------------------
  18. //
  19. // ComputeADX/ADY
  20. //
  21. // Computes dAttr/dAxis from given deltas and cached intermediate values.
  22. //
  23. //----------------------------------------------------------------------------
  24. inline FLOAT FASTCALL
  25. ComputeADX(PSETUPCTX pStpCtx, FLOAT fD20, FLOAT fD10)
  26. {
  27. return fD20 * pStpCtx->fNY10 - fD10 * pStpCtx->fNY20;
  28. }
  29. inline FLOAT FASTCALL
  30. ComputeADY(PSETUPCTX pStpCtx, FLOAT fD20, FLOAT fD10)
  31. {
  32. return fD10 * pStpCtx->fNX20 - fD20 * pStpCtx->fNX10;
  33. }
  34. // Given the vertex zero attribute value and gradients,
  35. // subpixel corrects to compute the true
  36. // initial value and computes the span-to-span steps.
  37. #define CORRECT_ATTR(fV0, fDVDX, fDVDY, fVCorrect, fDVNC, fDVCY) \
  38. ((fVCorrect) = (fV0) + pStpCtx->fDX * (fDVDX) + pStpCtx->fDY * (fDVDY), \
  39. (fDVNC) = (fDVDY) + (fDVDX) * pStpCtx->fX20NC, \
  40. (fDVCY) = pStpCtx->X20.iCY > pStpCtx->X20.iNC ? \
  41. (fDVNC) + (fDVDX) : (fDVNC) - (fDVDX))
  42. dnl
  43. dnl d_ZSetup
  44. dnl
  45. dnl Does Z setup.
  46. dnl
  47. dnl $1 is the Z buffer depth.
  48. dnl
  49. define(`d_ZSetup',
  50. `{
  51. FLOAT fZ0;
  52. FLOAT fDZ20, fDZ10;
  53. fZ0 = pV0->dvSZ;
  54. fDZ20 = Z$1_SCALE * (pV2->dvSZ - pV0->dvSZ);
  55. fDZ10 = Z$1_SCALE * (pV1->dvSZ - pV0->dvSZ);
  56. pStpCtx->DAttrDX.fZ = ComputeADX(pStpCtx, fDZ20, fDZ10);
  57. pStpCtx->DAttrDY.fZ = ComputeADY(pStpCtx, fDZ20, fDZ10);
  58. CORRECT_ATTR(fZ0 * Z$1_SCALE,
  59. pStpCtx->DAttrDX.fZ, pStpCtx->DAttrDY.fZ,
  60. pStpCtx->Attr.fZ, pStpCtx->DAttrNC.fZ, pStpCtx->DAttrCY.fZ);
  61. if (pStpCtx->uFlags & TRIF_X_DEC)
  62. {
  63. pStpCtx->DAttrDX.fZ = NEGF(pStpCtx->DAttrDX.fZ);
  64. }
  65. if ((pStpCtx->uFlags & TRIF_RASTPRIM_OVERFLOW) ||
  66. ABSF(pStpCtx->DAttrDX.fZ) >= Z_LIMIT)
  67. {
  68. pStpCtx->uFlags |= TRIF_RASTPRIM_OVERFLOW;
  69. #ifdef DBG_OVERFLOW
  70. RSDPF(("Overflow delta for Z: %f\n", pStpCtx->DAttrDX.fZ));
  71. #endif
  72. }
  73. else
  74. {
  75. pStpCtx->pPrim->iDZDX = FTOI(pStpCtx->DAttrDX.fZ);
  76. }
  77. #ifdef STEP_FIXED
  78. if ((pStpCtx->uFlags & TRIF_FIXED_OVERFLOW) ||
  79. ABSF(pStpCtx->DAttrNC.fZ) >= Z_LIMIT ||
  80. ABSF(pStpCtx->DAttrCY.fZ) >= Z_LIMIT)
  81. {
  82. pStpCtx->uFlags |= TRIF_FIXED_OVERFLOW;
  83. }
  84. #endif
  85. // Call next bead.
  86. pStpCtx->pfnTriSetupZEnd(pStpCtx, pV0, pV1, pV2);
  87. }
  88. ')dnl
  89. dnl
  90. dnl d_TexSetupFinish
  91. dnl
  92. dnl Completes texture coordinate setup. Assumes values in
  93. dnl fUoW0, fVoW0, fDU20, fDV20, fDU10 and fDV10.
  94. dnl
  95. dnl iTex is the index of texture stage to use.
  96. dnl
  97. define(`d_TexSetupFinish',
  98. ` pStpCtx->DAttrDX.fUoW[iTex] = ComputeADX(pStpCtx, fDU20, fDU10);
  99. pStpCtx->DAttrDX.fVoW[iTex] = ComputeADX(pStpCtx, fDV20, fDV10);
  100. pStpCtx->DAttrDY.fUoW[iTex] = ComputeADY(pStpCtx, fDU20, fDU10);
  101. pStpCtx->DAttrDY.fVoW[iTex] = ComputeADY(pStpCtx, fDV20, fDV10);
  102. CORRECT_ATTR(fUoW0 * TEX_SCALE,
  103. pStpCtx->DAttrDX.fUoW[iTex], pStpCtx->DAttrDY.fUoW[iTex],
  104. pStpCtx->Attr.fUoW[iTex],
  105. pStpCtx->DAttrNC.fUoW[iTex], pStpCtx->DAttrCY.fUoW[iTex]);
  106. CORRECT_ATTR(fVoW0 * TEX_SCALE,
  107. pStpCtx->DAttrDX.fVoW[iTex], pStpCtx->DAttrDY.fVoW[iTex],
  108. pStpCtx->Attr.fVoW[iTex],
  109. pStpCtx->DAttrNC.fVoW[iTex], pStpCtx->DAttrCY.fVoW[iTex]);
  110. if (pStpCtx->uFlags & TRIF_X_DEC)
  111. {
  112. pStpCtx->DAttrDX.fUoW[iTex] = NEGF(pStpCtx->DAttrDX.fUoW[iTex]);
  113. pStpCtx->DAttrDX.fVoW[iTex] = NEGF(pStpCtx->DAttrDX.fVoW[iTex]);
  114. }
  115. // ATTENTION - If the delta values cant be represented then
  116. // we need to make sure that the per-pixel mipmapping scan
  117. // routine isnt called since it uses these deltas.
  118. if ((pStpCtx->uFlags & TRIF_RASTPRIM_OVERFLOW) ||
  119. ABSF(pStpCtx->DAttrDX.fUoW[iTex]) >= TEX_LIMIT ||
  120. ABSF(pStpCtx->DAttrDX.fVoW[iTex]) >= TEX_LIMIT ||
  121. ABSF(pStpCtx->DAttrDY.fUoW[iTex]) >= TEX_LIMIT ||
  122. ABSF(pStpCtx->DAttrDY.fVoW[iTex]) >= TEX_LIMIT)
  123. {
  124. pStpCtx->uFlags |= TRIF_RASTPRIM_OVERFLOW;
  125. #ifdef DBG_OVERFLOW
  126. RSDPF(("Overflow delta for tex$1: %f,%f,%f,%f\n",
  127. pStpCtx->DAttrDX.fUoW[iTex], pStpCtx->DAttrDX.fVoW[iTex],
  128. pStpCtx->DAttrDY.fUoW[iTex], pStpCtx->DAttrDY.fVoW[iTex]));
  129. #endif
  130. }
  131. else
  132. {
  133. pStpCtx->pPrim->DUVoWDX[iTex].iDUoWDX = FTOI(pStpCtx->DAttrDX.fUoW[iTex]);
  134. pStpCtx->pPrim->DUVoWDX[iTex].iDVoWDX = FTOI(pStpCtx->DAttrDX.fVoW[iTex]);
  135. pStpCtx->pPrim->DUVoWDY[iTex].iDUoWDY = FTOI(pStpCtx->DAttrDY.fUoW[iTex]);
  136. pStpCtx->pPrim->DUVoWDY[iTex].iDVoWDY = FTOI(pStpCtx->DAttrDY.fVoW[iTex]);
  137. }
  138. #ifdef STEP_FIXED
  139. if ((pStpCtx->uFlags & TRIF_FIXED_OVERFLOW) ||
  140. ABSF(pStpCtx->DAttrNC.fUoW[iTex]) >= TEX_LIMIT ||
  141. ABSF(pStpCtx->DAttrCY.fUoW[iTex]) >= TEX_LIMIT ||
  142. ABSF(pStpCtx->DAttrNC.fVoW[iTex]) >= TEX_LIMIT ||
  143. ABSF(pStpCtx->DAttrCY.fVoW[iTex]) >= TEX_LIMIT)
  144. {
  145. pStpCtx->uFlags |= TRIF_FIXED_OVERFLOW;
  146. }
  147. #endif
  148. ')dnl
  149. dnl
  150. dnl d_PerspTexSetup
  151. dnl
  152. dnl Does perspective-corrected texture coordinate setup.
  153. dnl
  154. dnl $1 is the coordinate index, 1 or 2.
  155. dnl $2 is the vertex coordinate suffix, `' or 2.
  156. dnl
  157. define(`d_PerspTexSetup',
  158. `{
  159. FLOAT fDU20, fDV20;
  160. FLOAT fDU10, fDV10;
  161. FLOAT fUoW0, fVoW0;
  162. INT32 iTex;
  163. for (iTex = 0; iTex < (INT32)pStpCtx->pCtx->cActTex; iTex ++)
  164. {
  165. fUoW0 = ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTU * pV0->dvRHW;
  166. fVoW0 = ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTV * pV0->dvRHW;
  167. fDU20 =
  168. PERSP_TEXTURE_DELTA(((PRAST_GENERIC_VERTEX)pV2)->texCoord[iTex].dvTU, pV2->dvRHW,
  169. ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTU, fUoW0,
  170. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_U) *
  171. TEX_SCALE;
  172. fDU10 =
  173. PERSP_TEXTURE_DELTA(((PRAST_GENERIC_VERTEX)pV1)->texCoord[iTex].dvTU, pV1->dvRHW,
  174. ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTU, fUoW0,
  175. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_U) *
  176. TEX_SCALE;
  177. fDV20 =
  178. PERSP_TEXTURE_DELTA(((PRAST_GENERIC_VERTEX)pV2)->texCoord[iTex].dvTV, pV2->dvRHW,
  179. ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTV, fVoW0,
  180. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_V) *
  181. TEX_SCALE;
  182. fDV10 =
  183. PERSP_TEXTURE_DELTA(((PRAST_GENERIC_VERTEX)pV1)->texCoord[iTex].dvTV, pV1->dvRHW,
  184. ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTV, fVoW0,
  185. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_V) *
  186. TEX_SCALE;
  187. d_TexSetupFinish()dnl
  188. }
  189. }
  190. // This was disabled when changing the rasterizers to support 8 textures
  191. #if 0
  192. RSDPFM((RSM_TEX$1, " APTex$1 %f,%f (%f,%f) (%f,%f)\n",
  193. pStpCtx->Attr.fUoW$1, pStpCtx->Attr.fVoW$1,
  194. pStpCtx->Attr.fUoW$1 * OO_TEX_SCALE,
  195. pStpCtx->Attr.fVoW$1 * OO_TEX_SCALE,
  196. (pStpCtx->Attr.fUoW$1 * OOW_SCALE) /
  197. (pStpCtx->Attr.fOoW * TEX_SCALE),
  198. (pStpCtx->Attr.fVoW$1 * OOW_SCALE) /
  199. (pStpCtx->Attr.fOoW * TEX_SCALE)));
  200. RSDPFM((RSM_TEX$1, " DUoW$1DX %f (%f) DVoW$1DX %f (%f)\n",
  201. pStpCtx->DAttrDX.fUoW$1, pStpCtx->DAttrDX.fUoW$1 * OO_TEX_SCALE,
  202. pStpCtx->DAttrDX.fVoW$1, pStpCtx->DAttrDX.fVoW$1 * OO_TEX_SCALE));
  203. RSDPFM((RSM_TEX$1, " DUoW$1DY %f (%f) DVoW$1DY %f (%f)\n",
  204. pStpCtx->DAttrDY.fUoW$1, pStpCtx->DAttrDY.fUoW$1 * OO_TEX_SCALE,
  205. pStpCtx->DAttrDY.fVoW$1, pStpCtx->DAttrDY.fVoW$1 * OO_TEX_SCALE));
  206. #endif
  207. ')dnl
  208. dnl
  209. dnl d_AffineTexSetup
  210. dnl
  211. dnl Does affine-only texture coordinate setup.
  212. dnl
  213. dnl $1 is the coordinate index, 1 or 2.
  214. dnl $2 is the vertex coordinate suffix, `' or 2.
  215. dnl
  216. define(`d_AffineTexSetup',
  217. `{
  218. FLOAT fDU20, fDV20;
  219. FLOAT fDU10, fDV10;
  220. FLOAT fUoW0, fVoW0;
  221. INT32 iTex;
  222. for (iTex = 0; iTex < (INT32)pStpCtx->pCtx->cActTex; iTex ++)
  223. {
  224. fUoW0 = ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTU;
  225. fVoW0 = ((PRAST_GENERIC_VERTEX)pV0)->texCoord[iTex].dvTV;
  226. fDU20 =
  227. InlTextureDiff(((PRAST_GENERIC_VERTEX)pV2)->texCoord[iTex].dvTU, fUoW0,
  228. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_U) *
  229. TEX_SCALE;
  230. fDU10 =
  231. InlTextureDiff(((PRAST_GENERIC_VERTEX)pV1)->texCoord[iTex].dvTU, fUoW0,
  232. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_U) *
  233. TEX_SCALE;
  234. fDV20 =
  235. InlTextureDiff(((PRAST_GENERIC_VERTEX)pV2)->texCoord[iTex].dvTV, fVoW0,
  236. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_V) *
  237. TEX_SCALE;
  238. fDV10 =
  239. InlTextureDiff(((PRAST_GENERIC_VERTEX)pV1)->texCoord[iTex].dvTV, fVoW0,
  240. pStpCtx->pCtx->pdwWrap[iTex] & D3DWRAP_V) *
  241. TEX_SCALE;
  242. d_TexSetupFinish()dnl
  243. }
  244. }
  245. // This was disabled when changing the rasterizers to support 8 textures
  246. #if 0
  247. RSDPFM((RSM_TEX$1, " AATex$1 %f,%f (%f,%f)\n",
  248. pStpCtx->Attr.fUoW$1, pStpCtx->Attr.fVoW$1,
  249. pStpCtx->Attr.fUoW$1 * OO_TEX_SCALE,
  250. pStpCtx->Attr.fVoW$1 * OO_TEX_SCALE));
  251. RSDPFM((RSM_TEX$1, " DUoW$1DX %f (%f) DVoW$1DX %f (%f)\n",
  252. pStpCtx->DAttrDX.fUoW$1, pStpCtx->DAttrDX.fUoW$1 * OO_TEX_SCALE,
  253. pStpCtx->DAttrDX.fVoW$1, pStpCtx->DAttrDX.fVoW$1 * OO_TEX_SCALE));
  254. RSDPFM((RSM_TEX$1, " DUoW$1DY %f (%f) DVoW$1DY %f (%f)\n",
  255. pStpCtx->DAttrDY.fUoW$1, pStpCtx->DAttrDY.fUoW$1 * OO_TEX_SCALE,
  256. pStpCtx->DAttrDY.fVoW$1, pStpCtx->DAttrDY.fVoW$1 * OO_TEX_SCALE));
  257. #endif
  258. ')dnl
  259. dnl
  260. dnl d_DeclSetup
  261. dnl
  262. dnl Declare a PFN_SETUPATTR from its attribute name.
  263. dnl
  264. dnl $1 is the attribute name.
  265. dnl
  266. define(`d_DeclSetup',
  267. `void FASTCALL
  268. TriSetup_$1(PSETUPCTX pStpCtx,
  269. LPD3DTLVERTEX pV0,
  270. LPD3DTLVERTEX pV1,
  271. LPD3DTLVERTEX pV2)
  272. ')dnl
  273. dnl
  274. //----------------------------------------------------------------------------
  275. //
  276. // Setup_Start
  277. //
  278. // Normalizes edge deltas and calls the first attribute setup bead.
  279. //
  280. //----------------------------------------------------------------------------
  281. d_DeclSetup(`Start')dnl
  282. {
  283. // Fold normalization value into deltas.
  284. pStpCtx->fNX20 = pStpCtx->fOoDet * pStpCtx->fDX20;
  285. pStpCtx->fNX10 = pStpCtx->fOoDet * pStpCtx->fDX10;
  286. pStpCtx->fNY20 = pStpCtx->fOoDet * pStpCtx->fDY20;
  287. pStpCtx->fNY10 = pStpCtx->fOoDet * pStpCtx->fDY10;
  288. // Call first bead.
  289. pStpCtx->pfnTriSetupFirstAttr(pStpCtx, pV0, pV1, pV2);
  290. }
  291. //----------------------------------------------------------------------------
  292. //
  293. // Setup_Z16
  294. //
  295. // Attribute setup for 16-bit Z.
  296. //
  297. //----------------------------------------------------------------------------
  298. d_DeclSetup(`Z16')dnl
  299. d_ZSetup(`16')dnl
  300. //----------------------------------------------------------------------------
  301. //
  302. // Setup_Z32
  303. //
  304. // Attribute setup for 32-bit Z.
  305. //
  306. //----------------------------------------------------------------------------
  307. d_DeclSetup(`Z32')dnl
  308. d_ZSetup(`32')dnl
  309. //----------------------------------------------------------------------------
  310. //
  311. // Setup_Persp_Tex
  312. //
  313. // Attribute setup for OoW and texture coordinates.
  314. // Coordinates are set up for perspective correction.
  315. //
  316. //----------------------------------------------------------------------------
  317. d_DeclSetup(`Persp_Tex')dnl
  318. {
  319. FLOAT fDOoW20, fDOoW10;
  320. fDOoW20 = OOW_SCALE * (pV2->dvRHW - pV0->dvRHW);
  321. fDOoW10 = OOW_SCALE * (pV1->dvRHW - pV0->dvRHW);
  322. pStpCtx->DAttrDX.fOoW = ComputeADX(pStpCtx, fDOoW20, fDOoW10);
  323. pStpCtx->DAttrDY.fOoW = ComputeADY(pStpCtx, fDOoW20, fDOoW10);
  324. CORRECT_ATTR(pV0->dvRHW * OOW_SCALE,
  325. pStpCtx->DAttrDX.fOoW, pStpCtx->DAttrDY.fOoW,
  326. pStpCtx->Attr.fOoW,
  327. pStpCtx->DAttrNC.fOoW, pStpCtx->DAttrCY.fOoW);
  328. if (pStpCtx->uFlags & TRIF_X_DEC)
  329. {
  330. pStpCtx->DAttrDX.fOoW = NEGF(pStpCtx->DAttrDX.fOoW);
  331. }
  332. // ATTENTION - If the delta values cant be represented then
  333. // we need to make sure that the per-pixel mipmapping scan
  334. // routine isnt called since it uses these deltas.
  335. if ((pStpCtx->uFlags & TRIF_RASTPRIM_OVERFLOW) ||
  336. ABSF(pStpCtx->DAttrDX.fOoW) >= OOW_LIMIT ||
  337. ABSF(pStpCtx->DAttrDY.fOoW) >= OOW_LIMIT)
  338. {
  339. pStpCtx->uFlags |= TRIF_RASTPRIM_OVERFLOW;
  340. #ifdef DBG_OVERFLOW
  341. RSDPF(("Overflow delta for OoW: %f, %f\n",
  342. pStpCtx->DAttrDX.fOoW, pStpCtx->DAttrDY.fOoW));
  343. #endif
  344. }
  345. else
  346. {
  347. pStpCtx->pPrim->iDOoWDX = FTOI(pStpCtx->DAttrDX.fOoW);
  348. pStpCtx->pPrim->iDOoWDY = FTOI(pStpCtx->DAttrDY.fOoW);
  349. }
  350. #ifdef STEP_FIXED
  351. if ((pStpCtx->uFlags & TRIF_FIXED_OVERFLOW) ||
  352. ABSF(pStpCtx->DAttrNC.fOoW) >= OOW_LIMIT ||
  353. ABSF(pStpCtx->DAttrCY.fOoW) >= OOW_LIMIT)
  354. {
  355. pStpCtx->uFlags |= TRIF_FIXED_OVERFLOW;
  356. }
  357. #endif
  358. RSDPFM((RSM_OOW, " AOoW %f (%f)\n",
  359. pStpCtx->Attr.fOoW, pStpCtx->Attr.fOoW * OO_OOW_SCALE));
  360. RSDPFM((RSM_OOW, " DOoWDX %f (%f), DOoWDY %f (%f)\n",
  361. pStpCtx->DAttrDX.fOoW, pStpCtx->DAttrDX.fOoW * OO_OOW_SCALE,
  362. pStpCtx->DAttrDY.fOoW, pStpCtx->DAttrDY.fOoW * OO_OOW_SCALE));
  363. d_PerspTexSetup()dnl
  364. // Call next bead.
  365. pStpCtx->pfnTriSetupTexEnd(pStpCtx, pV0, pV1, pV2);
  366. }
  367. //----------------------------------------------------------------------------
  368. //
  369. // Setup_Affine_Tex
  370. //
  371. // Attribute setup for OoW and texture coordinates.
  372. // Coordinates are set up for affine mapping.
  373. //
  374. //----------------------------------------------------------------------------
  375. d_DeclSetup(`Affine_Tex')dnl
  376. {
  377. pStpCtx->Attr.fOoW = OOW_SCALE;
  378. pStpCtx->DAttrDX.fOoW = g_fZero;
  379. pStpCtx->DAttrDY.fOoW = g_fZero;
  380. pStpCtx->DAttrNC.fOoW = g_fZero;
  381. pStpCtx->DAttrCY.fOoW = g_fZero;
  382. pStpCtx->pPrim->iDOoWDX = 0;
  383. pStpCtx->pPrim->iDOoWDY = 0;
  384. d_AffineTexSetup()dnl
  385. // Call next bead.
  386. pStpCtx->pfnTriSetupTexEnd(pStpCtx, pV0, pV1, pV2);
  387. }
  388. //----------------------------------------------------------------------------
  389. //
  390. // Setup_Diff
  391. //
  392. // Attribute setup for interpolated diffuse color.
  393. //
  394. //----------------------------------------------------------------------------
  395. d_DeclSetup(`Diff')dnl
  396. {
  397. UINT uB, uG, uR, uA;
  398. FLOAT fDB20, fDG20, fDR20, fDA20;
  399. FLOAT fDB10, fDG10, fDR10, fDA10;
  400. SPLIT_COLOR(pV0->dcColor, uB, uG, uR, uA);
  401. COLOR_DELTA(pV2->dcColor, uB, uG, uR, uA, fDB20, fDG20, fDR20, fDA20);
  402. COLOR_DELTA(pV1->dcColor, uB, uG, uR, uA, fDB10, fDG10, fDR10, fDA10);
  403. pStpCtx->DAttrDX.fB = ComputeADX(pStpCtx, fDB20, fDB10);
  404. pStpCtx->DAttrDX.fG = ComputeADX(pStpCtx, fDG20, fDG10);
  405. pStpCtx->DAttrDX.fR = ComputeADX(pStpCtx, fDR20, fDR10);
  406. pStpCtx->DAttrDX.fA = ComputeADX(pStpCtx, fDA20, fDA10);
  407. pStpCtx->DAttrDY.fB = ComputeADY(pStpCtx, fDB20, fDB10);
  408. pStpCtx->DAttrDY.fG = ComputeADY(pStpCtx, fDG20, fDG10);
  409. pStpCtx->DAttrDY.fR = ComputeADY(pStpCtx, fDR20, fDR10);
  410. pStpCtx->DAttrDY.fA = ComputeADY(pStpCtx, fDA20, fDA10);
  411. CORRECT_ATTR((FLOAT)(uB << COLOR_SHIFT),
  412. pStpCtx->DAttrDX.fB, pStpCtx->DAttrDY.fB,
  413. pStpCtx->Attr.fB,
  414. pStpCtx->DAttrNC.fB, pStpCtx->DAttrCY.fB);
  415. CORRECT_ATTR((FLOAT)(uG << COLOR_SHIFT),
  416. pStpCtx->DAttrDX.fG, pStpCtx->DAttrDY.fG,
  417. pStpCtx->Attr.fG,
  418. pStpCtx->DAttrNC.fG, pStpCtx->DAttrCY.fG);
  419. CORRECT_ATTR((FLOAT)(uR << COLOR_SHIFT),
  420. pStpCtx->DAttrDX.fR, pStpCtx->DAttrDY.fR,
  421. pStpCtx->Attr.fR,
  422. pStpCtx->DAttrNC.fR, pStpCtx->DAttrCY.fR);
  423. CORRECT_ATTR((FLOAT)(uA << COLOR_SHIFT),
  424. pStpCtx->DAttrDX.fA, pStpCtx->DAttrDY.fA,
  425. pStpCtx->Attr.fA,
  426. pStpCtx->DAttrNC.fA, pStpCtx->DAttrCY.fA);
  427. if (pStpCtx->uFlags & TRIF_X_DEC)
  428. {
  429. pStpCtx->DAttrDX.fB = NEGF(pStpCtx->DAttrDX.fB);
  430. pStpCtx->DAttrDX.fG = NEGF(pStpCtx->DAttrDX.fG);
  431. pStpCtx->DAttrDX.fR = NEGF(pStpCtx->DAttrDX.fR);
  432. pStpCtx->DAttrDX.fA = NEGF(pStpCtx->DAttrDX.fA);
  433. }
  434. if ((pStpCtx->uFlags & TRIF_RASTPRIM_OVERFLOW) ||
  435. ABSF(pStpCtx->DAttrDX.fB) >= COLOR_LIMIT ||
  436. ABSF(pStpCtx->DAttrDX.fG) >= COLOR_LIMIT ||
  437. ABSF(pStpCtx->DAttrDX.fR) >= COLOR_LIMIT ||
  438. ABSF(pStpCtx->DAttrDX.fA) >= COLOR_LIMIT)
  439. {
  440. pStpCtx->uFlags |= TRIF_RASTPRIM_OVERFLOW;
  441. #ifdef DBG_OVERFLOW
  442. RSDPF(("Overflow delta for diffuse: %f,%f,%f,%f\n",
  443. pStpCtx->DAttrDX.fB, pStpCtx->DAttrDX.fG,
  444. pStpCtx->DAttrDX.fR, pStpCtx->DAttrDX.fA));
  445. #endif
  446. }
  447. else
  448. {
  449. pStpCtx->pPrim->iDBDX = (INT16)FTOI(pStpCtx->DAttrDX.fB);
  450. pStpCtx->pPrim->iDGDX = (INT16)FTOI(pStpCtx->DAttrDX.fG);
  451. pStpCtx->pPrim->iDRDX = (INT16)FTOI(pStpCtx->DAttrDX.fR);
  452. pStpCtx->pPrim->iDADX = (INT16)FTOI(pStpCtx->DAttrDX.fA);
  453. }
  454. #ifdef STEP_FIXED
  455. if ((pStpCtx->uFlags & TRIF_FIXED_OVERFLOW) ||
  456. ABSF(pStpCtx->DAttrNC.fB) >= COLOR_LIMIT ||
  457. ABSF(pStpCtx->DAttrCY.fB) >= COLOR_LIMIT ||
  458. ABSF(pStpCtx->DAttrNC.fG) >= COLOR_LIMIT ||
  459. ABSF(pStpCtx->DAttrCY.fG) >= COLOR_LIMIT ||
  460. ABSF(pStpCtx->DAttrNC.fR) >= COLOR_LIMIT ||
  461. ABSF(pStpCtx->DAttrCY.fR) >= COLOR_LIMIT ||
  462. ABSF(pStpCtx->DAttrNC.fA) >= COLOR_LIMIT ||
  463. ABSF(pStpCtx->DAttrCY.fA) >= COLOR_LIMIT)
  464. {
  465. pStpCtx->uFlags |= TRIF_FIXED_OVERFLOW;
  466. }
  467. #endif
  468. RSDPFM((RSM_DIFF, " diff v0 %f,%f,%f,%f\n",
  469. pStpCtx->Attr.fB, pStpCtx->Attr.fG,
  470. pStpCtx->Attr.fR, pStpCtx->Attr.fA));
  471. RSDPFM((RSM_DIFF, " dx %f,%f,%f,%f\n",
  472. pStpCtx->DAttrDX.fB, pStpCtx->DAttrDX.fG,
  473. pStpCtx->DAttrDX.fR, pStpCtx->DAttrDX.fA));
  474. RSDPFM((RSM_DIFF, " dy %f,%f,%f,%f\n",
  475. pStpCtx->DAttrDY.fB, pStpCtx->DAttrDY.fG,
  476. pStpCtx->DAttrDY.fR, pStpCtx->DAttrDY.fA));
  477. RSDPFM((RSM_DIFF, " cy %f,%f,%f,%f\n",
  478. pStpCtx->DAttrCY.fB, pStpCtx->DAttrCY.fG,
  479. pStpCtx->DAttrCY.fR, pStpCtx->DAttrCY.fA));
  480. RSDPFM((RSM_DIFF, " nc %f,%f,%f,%f\n",
  481. pStpCtx->DAttrNC.fB, pStpCtx->DAttrNC.fG,
  482. pStpCtx->DAttrNC.fR, pStpCtx->DAttrNC.fA));
  483. // Call next bead.
  484. pStpCtx->pfnTriSetupDiffEnd(pStpCtx, pV0, pV1, pV2);
  485. }
  486. //----------------------------------------------------------------------------
  487. //
  488. // Setup_DiffFlat
  489. //
  490. // Attribute setup for constant diffuse color.
  491. //
  492. //----------------------------------------------------------------------------
  493. d_DeclSetup(`DiffFlat')dnl
  494. {
  495. UINT uB, uG, uR, uA;
  496. // Use original input pV0 to avoid confusion due to vertex sorting.
  497. SPLIT_COLOR(pStpCtx->pFlatVtx->dcColor, uB, uG, uR, uA);
  498. pStpCtx->Attr.fB = (FLOAT)(uB << COLOR_SHIFT);
  499. pStpCtx->Attr.fG = (FLOAT)(uG << COLOR_SHIFT);
  500. pStpCtx->Attr.fR = (FLOAT)(uR << COLOR_SHIFT);
  501. pStpCtx->Attr.fA = (FLOAT)(uA << COLOR_SHIFT);
  502. pStpCtx->DAttrDX.fB = g_fZero;
  503. pStpCtx->DAttrDX.fG = g_fZero;
  504. pStpCtx->DAttrDX.fR = g_fZero;
  505. pStpCtx->DAttrDX.fA = g_fZero;
  506. pStpCtx->DAttrDY.fB = g_fZero;
  507. pStpCtx->DAttrDY.fG = g_fZero;
  508. pStpCtx->DAttrDY.fR = g_fZero;
  509. pStpCtx->DAttrDY.fA = g_fZero;
  510. pStpCtx->DAttrNC.fB = g_fZero;
  511. pStpCtx->DAttrNC.fG = g_fZero;
  512. pStpCtx->DAttrNC.fR = g_fZero;
  513. pStpCtx->DAttrNC.fA = g_fZero;
  514. pStpCtx->DAttrCY.fB = g_fZero;
  515. pStpCtx->DAttrCY.fG = g_fZero;
  516. pStpCtx->DAttrCY.fR = g_fZero;
  517. pStpCtx->DAttrCY.fA = g_fZero;
  518. pStpCtx->pPrim->iDBDX = 0;
  519. pStpCtx->pPrim->iDGDX = 0;
  520. pStpCtx->pPrim->iDRDX = 0;
  521. pStpCtx->pPrim->iDADX = 0;
  522. // Call next bead.
  523. pStpCtx->pfnTriSetupDiffEnd(pStpCtx, pV0, pV1, pV2);
  524. }
  525. //----------------------------------------------------------------------------
  526. //
  527. // Setup_DIdx
  528. //
  529. // Setup for diffuse indexed color.
  530. //
  531. //----------------------------------------------------------------------------
  532. d_DeclSetup(`DIdx')dnl
  533. {
  534. INT32 iIdx, iA;
  535. FLOAT fDIdx20, fDA20;
  536. FLOAT fDIdx10, fDA10;
  537. SPLIT_IDX_COLOR(pV0->dcColor, iIdx, iA);
  538. IDX_COLOR_DELTA(pV2->dcColor, iIdx, iA, fDIdx20, fDA20);
  539. IDX_COLOR_DELTA(pV1->dcColor, iIdx, iA, fDIdx10, fDA10);
  540. pStpCtx->DAttrDX.fDIdx = ComputeADX(pStpCtx, fDIdx20, fDIdx10);
  541. pStpCtx->DAttrDX.fDIdxA = ComputeADX(pStpCtx, fDA20, fDA10);
  542. pStpCtx->DAttrDY.fDIdx = ComputeADY(pStpCtx, fDIdx20, fDIdx10);
  543. pStpCtx->DAttrDY.fDIdxA = ComputeADY(pStpCtx, fDA20, fDA10);
  544. CORRECT_ATTR((FLOAT)(iIdx << INDEX_COLOR_FIXED_SHIFT),
  545. pStpCtx->DAttrDX.fDIdx, pStpCtx->DAttrDY.fDIdx,
  546. pStpCtx->Attr.fDIdx,
  547. pStpCtx->DAttrNC.fDIdx, pStpCtx->DAttrCY.fDIdx);
  548. CORRECT_ATTR((FLOAT)(iA << INDEX_COLOR_SHIFT),
  549. pStpCtx->DAttrDX.fDIdxA, pStpCtx->DAttrDY.fDIdxA,
  550. pStpCtx->Attr.fDIdxA,
  551. pStpCtx->DAttrNC.fDIdxA, pStpCtx->DAttrCY.fDIdxA);
  552. if (pStpCtx->uFlags & TRIF_X_DEC)
  553. {
  554. pStpCtx->DAttrDX.fDIdx = NEGF(pStpCtx->DAttrDX.fDIdx);
  555. pStpCtx->DAttrDX.fDIdxA = NEGF(pStpCtx->DAttrDX.fDIdxA);
  556. }
  557. if ((pStpCtx->uFlags & TRIF_RASTPRIM_OVERFLOW) ||
  558. ABSF(pStpCtx->DAttrDX.fDIdx) >= INDEX_COLOR_LIMIT ||
  559. ABSF(pStpCtx->DAttrDX.fDIdxA) >= INDEX_COLOR_LIMIT)
  560. {
  561. pStpCtx->uFlags |= TRIF_RASTPRIM_OVERFLOW;
  562. #ifdef DBG_OVERFLOW
  563. RSDPF(("Overflow delta for didx: %f,%f,%f,%f\n",
  564. pStpCtx->DAttrDX.fDIdx, pStpCtx->DAttrDX.fDIdxA));
  565. #endif
  566. }
  567. else
  568. {
  569. pStpCtx->pPrim->iDIdxDX = FTOI(pStpCtx->DAttrDX.fDIdx);
  570. pStpCtx->pPrim->iDIdxADX = FTOI(pStpCtx->DAttrDX.fDIdxA);
  571. }
  572. #ifdef STEP_FIXED
  573. if ((pStpCtx->uFlags & TRIF_FIXED_OVERFLOW) ||
  574. ABSF(pStpCtx->DAttrNC.fDIdx) >= COLOR_LIMIT ||
  575. ABSF(pStpCtx->DAttrCY.fDIdx) >= COLOR_LIMIT ||
  576. ABSF(pStpCtx->DAttrNC.fDIdxA) >= COLOR_LIMIT ||
  577. ABSF(pStpCtx->DAttrCY.fDIdxA) >= COLOR_LIMIT)
  578. {
  579. pStpCtx->uFlags |= TRIF_FIXED_OVERFLOW;
  580. }
  581. #endif
  582. RSDPFM((RSM_DIDX, " didx v0 %f,%f\n",
  583. pStpCtx->Attr.fDIdx, pStpCtx->Attr.fDIdxA));
  584. RSDPFM((RSM_DIDX, " dx %f,%f\n",
  585. pStpCtx->DAttrDX.fDIdx, pStpCtx->DAttrDX.fDIdxA));
  586. RSDPFM((RSM_DIDX, " dy %f,%f\n",
  587. pStpCtx->DAttrDY.fDIdx, pStpCtx->DAttrDY.fDIdxA));
  588. RSDPFM((RSM_DIDX, " cy %f,%f\n",
  589. pStpCtx->DAttrCY.fDIdx, pStpCtx->DAttrCY.fDIdxA));
  590. RSDPFM((RSM_DIDX, " nc %f,%f\n",
  591. pStpCtx->DAttrNC.fDIdx, pStpCtx->DAttrNC.fDIdxA));
  592. // Call next bead.
  593. pStpCtx->pfnTriSetupDiffEnd(pStpCtx, pV0, pV1, pV2);
  594. }
  595. //----------------------------------------------------------------------------
  596. //
  597. // Setup_DIdxFlat
  598. //
  599. // Attribute setup for constant diffuse indexed color.
  600. //
  601. //----------------------------------------------------------------------------
  602. d_DeclSetup(`DIdxFlat')dnl
  603. {
  604. INT32 iIdx, iA;
  605. //
  606. // Use original input pV0 to avoid confusion due to vertex sorting.
  607. //
  608. SPLIT_IDX_COLOR(pStpCtx->pFlatVtx->dcColor, iIdx, iA);
  609. pStpCtx->Attr.fDIdx = (FLOAT)(iIdx << INDEX_COLOR_FIXED_SHIFT);
  610. pStpCtx->Attr.fDIdxA = (FLOAT)(iA << INDEX_COLOR_SHIFT);
  611. pStpCtx->DAttrDX.fDIdx = g_fZero;
  612. pStpCtx->DAttrDX.fDIdxA = g_fZero;
  613. pStpCtx->DAttrDY.fDIdx = g_fZero;
  614. pStpCtx->DAttrDY.fDIdxA = g_fZero;
  615. pStpCtx->DAttrNC.fDIdx = g_fZero;
  616. pStpCtx->DAttrNC.fDIdxA = g_fZero;
  617. pStpCtx->DAttrCY.fDIdx = g_fZero;
  618. pStpCtx->DAttrCY.fDIdxA = g_fZero;
  619. pStpCtx->pPrim->iDIdxDX = 0;
  620. pStpCtx->pPrim->iDIdxADX = 0;
  621. // Call next bead.
  622. pStpCtx->pfnTriSetupDiffEnd(pStpCtx, pV0, pV1, pV2);
  623. }
  624. //----------------------------------------------------------------------------
  625. //
  626. // Setup_Spec
  627. //
  628. // Setup for interpolated specular color.
  629. //
  630. //----------------------------------------------------------------------------
  631. d_DeclSetup(`Spec')dnl
  632. {
  633. UINT uB, uG, uR, uA;
  634. FLOAT fDB20, fDG20, fDR20, fDA20;
  635. FLOAT fDB10, fDG10, fDR10, fDA10;
  636. SPLIT_COLOR(pV0->dcSpecular, uB, uG, uR, uA);
  637. COLOR_DELTA(pV2->dcSpecular, uB, uG, uR, uA, fDB20, fDG20, fDR20, fDA20);
  638. COLOR_DELTA(pV1->dcSpecular, uB, uG, uR, uA, fDB10, fDG10, fDR10, fDA10);
  639. pStpCtx->DAttrDX.fBS = ComputeADX(pStpCtx, fDB20, fDB10);
  640. pStpCtx->DAttrDX.fGS = ComputeADX(pStpCtx, fDG20, fDG10);
  641. pStpCtx->DAttrDX.fRS = ComputeADX(pStpCtx, fDR20, fDR10);
  642. pStpCtx->DAttrDY.fBS = ComputeADY(pStpCtx, fDB20, fDB10);
  643. pStpCtx->DAttrDY.fGS = ComputeADY(pStpCtx, fDG20, fDG10);
  644. pStpCtx->DAttrDY.fRS = ComputeADY(pStpCtx, fDR20, fDR10);
  645. CORRECT_ATTR((FLOAT)(uB << COLOR_SHIFT),
  646. pStpCtx->DAttrDX.fBS, pStpCtx->DAttrDY.fBS, pStpCtx->Attr.fBS,
  647. pStpCtx->DAttrNC.fBS, pStpCtx->DAttrCY.fBS);
  648. CORRECT_ATTR((FLOAT)(uG << COLOR_SHIFT),
  649. pStpCtx->DAttrDX.fGS, pStpCtx->DAttrDY.fGS, pStpCtx->Attr.fGS,
  650. pStpCtx->DAttrNC.fGS, pStpCtx->DAttrCY.fGS);
  651. CORRECT_ATTR((FLOAT)(uR << COLOR_SHIFT),
  652. pStpCtx->DAttrDX.fRS, pStpCtx->DAttrDY.fRS, pStpCtx->Attr.fRS,
  653. pStpCtx->DAttrNC.fRS, pStpCtx->DAttrCY.fRS);
  654. if (pStpCtx->uFlags & TRIF_X_DEC)
  655. {
  656. pStpCtx->DAttrDX.fBS = NEGF(pStpCtx->DAttrDX.fBS);
  657. pStpCtx->DAttrDX.fGS = NEGF(pStpCtx->DAttrDX.fGS);
  658. pStpCtx->DAttrDX.fRS = NEGF(pStpCtx->DAttrDX.fRS);
  659. }
  660. if ((pStpCtx->uFlags & TRIF_RASTPRIM_OVERFLOW) ||
  661. ABSF(pStpCtx->DAttrDX.fBS) >= COLOR_LIMIT ||
  662. ABSF(pStpCtx->DAttrDX.fGS) >= COLOR_LIMIT ||
  663. ABSF(pStpCtx->DAttrDX.fRS) >= COLOR_LIMIT)
  664. {
  665. pStpCtx->uFlags |= TRIF_RASTPRIM_OVERFLOW;
  666. #ifdef DBG_OVERFLOW
  667. RSDPF(("Overflow delta for specular: %f,%f,%f\n",
  668. pStpCtx->DAttrDX.fBS, pStpCtx->DAttrDX.fGS,
  669. pStpCtx->DAttrDX.fRS));
  670. #endif
  671. }
  672. else
  673. {
  674. pStpCtx->pPrim->iDBSDX = (INT16)FTOI(pStpCtx->DAttrDX.fBS);
  675. pStpCtx->pPrim->iDGSDX = (INT16)FTOI(pStpCtx->DAttrDX.fGS);
  676. pStpCtx->pPrim->iDRSDX = (INT16)FTOI(pStpCtx->DAttrDX.fRS);
  677. }
  678. #ifdef STEP_FIXED
  679. if ((pStpCtx->uFlags & TRIF_FIXED_OVERFLOW) ||
  680. ABSF(pStpCtx->DAttrNC.fBS) >= COLOR_LIMIT ||
  681. ABSF(pStpCtx->DAttrCY.fBS) >= COLOR_LIMIT ||
  682. ABSF(pStpCtx->DAttrNC.fGS) >= COLOR_LIMIT ||
  683. ABSF(pStpCtx->DAttrCY.fGS) >= COLOR_LIMIT ||
  684. ABSF(pStpCtx->DAttrNC.fRS) >= COLOR_LIMIT ||
  685. ABSF(pStpCtx->DAttrCY.fRS) >= COLOR_LIMIT)
  686. {
  687. pStpCtx->uFlags |= TRIF_FIXED_OVERFLOW;
  688. }
  689. #endif
  690. // Call next bead.
  691. pStpCtx->pfnTriSetupSpecEnd(pStpCtx, pV0, pV1, pV2);
  692. }
  693. //----------------------------------------------------------------------------
  694. //
  695. // Setup_SpecFlat
  696. //
  697. // Attribute setup for constant specular color.
  698. //
  699. //----------------------------------------------------------------------------
  700. d_DeclSetup(`SpecFlat')dnl
  701. {
  702. UINT uB, uG, uR, uA;
  703. // Use original input pV0 to avoid confusion due to vertex sorting.
  704. SPLIT_COLOR(pStpCtx->pFlatVtx->dcSpecular, uB, uG, uR, uA);
  705. pStpCtx->Attr.fBS = (FLOAT)(uB << COLOR_SHIFT);
  706. pStpCtx->Attr.fGS = (FLOAT)(uG << COLOR_SHIFT);
  707. pStpCtx->Attr.fRS = (FLOAT)(uR << COLOR_SHIFT);
  708. pStpCtx->DAttrDX.fBS = g_fZero;
  709. pStpCtx->DAttrDX.fGS = g_fZero;
  710. pStpCtx->DAttrDX.fRS = g_fZero;
  711. pStpCtx->DAttrDY.fBS = g_fZero;
  712. pStpCtx->DAttrDY.fGS = g_fZero;
  713. pStpCtx->DAttrDY.fRS = g_fZero;
  714. pStpCtx->DAttrNC.fBS = g_fZero;
  715. pStpCtx->DAttrNC.fGS = g_fZero;
  716. pStpCtx->DAttrNC.fRS = g_fZero;
  717. pStpCtx->DAttrCY.fBS = g_fZero;
  718. pStpCtx->DAttrCY.fGS = g_fZero;
  719. pStpCtx->DAttrCY.fRS = g_fZero;
  720. pStpCtx->pPrim->iDBSDX = 0;
  721. pStpCtx->pPrim->iDGSDX = 0;
  722. pStpCtx->pPrim->iDRSDX = 0;
  723. // Call next bead.
  724. pStpCtx->pfnTriSetupSpecEnd(pStpCtx, pV0, pV1, pV2);
  725. }
  726. //----------------------------------------------------------------------------
  727. //
  728. // Setup_Fog
  729. //
  730. // Attribute setup for vertex fog.
  731. //
  732. //----------------------------------------------------------------------------
  733. d_DeclSetup(`Fog')dnl
  734. {
  735. UINT uFog0, uFog1, uFog2;
  736. FLOAT fDFog20, fDFog10;
  737. #ifndef PWL_FOG
  738. // Check for global-into-local fog. If global fog is on,
  739. // compute the local fog values from table fog rather than
  740. // from the vertex.
  741. if (pStpCtx->uFlags & PRIMSF_GLOBAL_FOG_USED)
  742. {
  743. uFog0 = ComputeTableFog(pStpCtx->pCtx->pdwRenderState,
  744. pV0->dvSZ);
  745. uFog1 = ComputeTableFog(pStpCtx->pCtx->pdwRenderState,
  746. pV1->dvSZ);
  747. uFog2 = ComputeTableFog(pStpCtx->pCtx->pdwRenderState,
  748. pV2->dvSZ);
  749. }
  750. else
  751. #endif
  752. {
  753. // Fog value is kept in the alpha of the specular color.
  754. uFog0 = (UINT)RGBA_GETALPHA(pV0->dcSpecular) << FOG_SHIFT;
  755. uFog1 = (UINT)RGBA_GETALPHA(pV1->dcSpecular) << FOG_SHIFT;
  756. uFog2 = (UINT)RGBA_GETALPHA(pV2->dcSpecular) << FOG_SHIFT;
  757. }
  758. fDFog20 = (FLOAT)((INT)uFog2 - (INT)uFog0);
  759. fDFog10 = (FLOAT)((INT)uFog1 - (INT)uFog0);
  760. pStpCtx->DAttrDX.fFog = ComputeADX(pStpCtx, fDFog20, fDFog10);
  761. pStpCtx->DAttrDY.fFog = ComputeADY(pStpCtx, fDFog20, fDFog10);
  762. CORRECT_ATTR((FLOAT)uFog0,
  763. pStpCtx->DAttrDX.fFog, pStpCtx->DAttrDY.fFog,
  764. pStpCtx->Attr.fFog, pStpCtx->DAttrNC.fFog,
  765. pStpCtx->DAttrCY.fFog);
  766. if (pStpCtx->uFlags & TRIF_X_DEC)
  767. {
  768. pStpCtx->DAttrDX.fFog = NEGF(pStpCtx->DAttrDX.fFog);
  769. }
  770. if ((pStpCtx->uFlags & TRIF_RASTPRIM_OVERFLOW) ||
  771. ABSF(pStpCtx->DAttrDX.fFog) >= FOG_LIMIT)
  772. {
  773. pStpCtx->uFlags |= TRIF_RASTPRIM_OVERFLOW;
  774. #ifdef DBG_OVERFLOW
  775. RSDPF(("Overflow delta for fog: %f\n", pStpCtx->DAttrDX.fFog));
  776. #endif
  777. }
  778. else
  779. {
  780. pStpCtx->iDLocalFogDX = FTOI(pStpCtx->DAttrDX.fFog);
  781. }
  782. #ifdef STEP_FIXED
  783. if ((pStpCtx->uFlags & TRIF_FIXED_OVERFLOW) ||
  784. ABSF(pStpCtx->DAttrNC.fFog) >= Fog_LIMIT ||
  785. ABSF(pStpCtx->DAttrCY.fFog) >= Fog_LIMIT)
  786. {
  787. pStpCtx->uFlags |= TRIF_FIXED_OVERFLOW;
  788. }
  789. #endif
  790. // Call next bead.
  791. pStpCtx->pfnTriSetupFogEnd(pStpCtx, pV0, pV1, pV2);
  792. }
  793. //----------------------------------------------------------------------------
  794. //
  795. // Setup_End
  796. //
  797. // Final bead.
  798. //
  799. //----------------------------------------------------------------------------
  800. d_DeclSetup(`End')dnl
  801. {
  802. }