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.

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