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.

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