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.

367 lines
9.0 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // stp_base.h
  4. //
  5. // Basic types shared between C++ and assembly.
  6. //
  7. // Copyright (C) Microsoft Corporation, 1997.
  8. //
  9. //----------------------------------------------------------------------------
  10. #ifndef _STP_BASE_H_
  11. #define _STP_BASE_H_
  12. // Generic set of attribute values. Used for holding current values
  13. // and deltas.
  14. typedef struct tagATTRSET
  15. {
  16. union
  17. {
  18. struct
  19. {
  20. PUINT8 pSurface, pZ;
  21. };
  22. struct
  23. {
  24. INT32 ipSurface, ipZ;
  25. };
  26. };
  27. union
  28. {
  29. FLOAT fZ;
  30. INT32 iZ;
  31. UINT32 uZ;
  32. };
  33. union
  34. {
  35. FLOAT fOoW;
  36. INT32 iOoW;
  37. };
  38. union
  39. {
  40. struct
  41. {
  42. FLOAT fUoW[D3DHAL_TSS_MAXSTAGES], fVoW[D3DHAL_TSS_MAXSTAGES];
  43. };
  44. struct
  45. {
  46. INT32 iUoW[D3DHAL_TSS_MAXSTAGES], iVoW[D3DHAL_TSS_MAXSTAGES];
  47. };
  48. };
  49. union
  50. {
  51. struct
  52. {
  53. FLOAT fB, fG, fR, fA;
  54. };
  55. struct
  56. {
  57. INT32 iB, iG, iR, iA;
  58. };
  59. struct
  60. {
  61. UINT32 uB, uG, uR, uA;
  62. };
  63. struct
  64. {
  65. FLOAT fDIdx, fDIdxA;
  66. };
  67. struct
  68. {
  69. INT32 iDIdx, iDIdxA;
  70. };
  71. struct
  72. {
  73. UINT32 uDIdx, uDIdxA;
  74. };
  75. };
  76. union
  77. {
  78. struct
  79. {
  80. FLOAT fBS, fGS, fRS;
  81. };
  82. struct
  83. {
  84. INT32 iBS, iGS, iRS;
  85. };
  86. struct
  87. {
  88. UINT32 uBS, uGS, uRS;
  89. };
  90. };
  91. union
  92. {
  93. FLOAT fFog;
  94. INT32 iFog;
  95. UINT32 uFog;
  96. };
  97. } ATTRSET, *PATTRSET;
  98. // Parameters for doing int/carry arithmetic on a value.
  99. typedef struct tagINTCARRYVAL
  100. {
  101. INT iV;
  102. INT iFrac;
  103. INT iDFrac;
  104. INT iCY, iNC;
  105. } INTCARRYVAL, *PINTCARRYVAL;
  106. // Attribute handlers.
  107. typedef struct tagSETUPCTX *PSETUPCTX;
  108. typedef void (FASTCALL *PFN_ADDATTRS)
  109. (PATTRSET pAttrs, PATTRSET pDelta, PSETUPCTX pStpCtx);
  110. typedef void (FASTCALL *PFN_ADDSCALEDATTRS)
  111. (PATTRSET pAttrs, PATTRSET pDelta,
  112. PSETUPCTX pStpCtx, int iScale);
  113. typedef void (FASTCALL *PFN_FILLSPANATTRS)
  114. (PATTRSET pAttr, PD3DI_RASTSPAN pSpan,
  115. PSETUPCTX pStpCtx, INT cPix);
  116. extern PFN_ADDATTRS g_pfnAddFloatAttrsTable[];
  117. extern PFN_ADDATTRS g_pfnRampAddFloatAttrsTable[];
  118. extern PFN_FILLSPANATTRS g_pfnFillSpanFloatAttrsTable[];
  119. extern PFN_FILLSPANATTRS g_pfnRampFillSpanFloatAttrsTable[];
  120. #ifdef STEP_FIXED
  121. extern PFN_ADDATTRS g_pfnAddFixedAttrsTable[];
  122. extern PFN_FILLSPANATTRS g_pfnFillSpanFixedAttrsTable[];
  123. #endif
  124. extern PFN_ADDSCALEDATTRS g_pfnAddScaledFloatAttrsTable[];
  125. extern PFN_ADDSCALEDATTRS g_pfnRampAddScaledFloatAttrsTable[];
  126. // Triangle trapezoid walkers.
  127. typedef HRESULT (FASTCALL *PFN_WALKTRAPSPANS)
  128. (UINT uSpans, PINTCARRYVAL pXOther,
  129. PSETUPCTX pStpCtx, BOOL bAdvanceLast);
  130. extern PFN_WALKTRAPSPANS g_pfnWalkTrapFloatSpansNoClipTable[];
  131. extern PFN_WALKTRAPSPANS g_pfnRampWalkTrapFloatSpansNoClipTable[];
  132. #ifdef STEP_FIXED
  133. extern PFN_WALKTRAPSPANS g_pfnWalkTrapFixedSpansNoClipTable[];
  134. #endif
  135. // Float-to-fixed attribute converters.
  136. typedef void (FASTCALL *PFN_FLOATATTRSTOFIXED)
  137. (PATTRSET pfAttrs, PATTRSET piAttrs, PSETUPCTX pStpCtx);
  138. #ifdef STEP_FIXED
  139. extern PFN_FLOATATTRSTOFIXED g_pfnFloatAttrsToFixedTable[];
  140. #endif
  141. typedef void (FASTCALL *PFN_SETUPTRIATTR)
  142. (PSETUPCTX pStpCtx, LPD3DTLVERTEX pV0, LPD3DTLVERTEX pV1,
  143. LPD3DTLVERTEX pV2);
  144. //
  145. // Setup flags.
  146. //
  147. // Per primitive set.
  148. #define PRIMSF_DIFF_USED 0x00000001
  149. #define PRIMSF_SPEC_USED 0x00000002
  150. #define PRIMSF_TEX1_USED 0x00000004
  151. #define PRIMSF_TEX2_USED 0x00000008
  152. #define PRIMSF_DIDX_USED 0x00000010
  153. #define PRIMSF_LOCAL_FOG_USED 0x00000020
  154. #define PRIMSF_GLOBAL_FOG_USED 0x00000040
  155. #define PRIMSF_Z_USED 0x00000080
  156. #define PRIMSF_LOD_USED 0x00000100
  157. #define PRIMSF_PERSP_USED 0x00000200
  158. #define PRIMSF_FLAT_SHADED 0x00000400
  159. #define PRIMSF_COLORS_USED (PRIMSF_DIFF_USED | PRIMSF_SPEC_USED)
  160. #define PRIMSF_TEX_USED (PRIMSF_TEX1_USED | PRIMSF_TEX2_USED)
  161. #define PRIMSF_ALL_USED \
  162. (PRIMSF_DIFF_USED | PRIMSF_SPEC_USED | PRIMSF_TEX1_USED | \
  163. PRIMSF_TEX2_USED | PRIMSF_Z_USED | PRIMSF_LOD_USED | \
  164. PRIMSF_LOCAL_FOG_USED | PRIMSF_GLOBAL_FOG_USED | PRIMSF_PERSP_USED | \
  165. PRIMSF_DIDX_USED)
  166. #define PRIMSF_SLOW_USED \
  167. (PRIMSF_Z_USED | PRIMSF_LOD_USED | \
  168. PRIMSF_LOCAL_FOG_USED | PRIMSF_GLOBAL_FOG_USED | PRIMSF_TEX2_USED)
  169. #define PRIMSF_ALL \
  170. (PRIMSF_DIFF_USED | PRIMSF_SPEC_USED | PRIMSF_TEX1_USED | \
  171. PRIMSF_TEX2_USED | PRIMSF_DIDX_USED | PRIMSF_LOCAL_FOG_USED |\
  172. PRIMSF_GLOBAL_FOG_USED | PRIMSF_Z_USED | PRIMSF_LOD_USED | \
  173. PRIMSF_PERSP_USED | PRIMSF_FLAT_SHADED)
  174. // Per primitive.
  175. #define PRIMF_FIXED_OVERFLOW 0x00001000
  176. #define PRIMF_TRIVIAL_ACCEPT_Y 0x00002000
  177. #define PRIMF_TRIVIAL_ACCEPT_X 0x00004000
  178. #define PRIMF_ALL \
  179. (PRIMF_TRIVIAL_ACCEPT_Y | PRIMF_TRIVIAL_ACCEPT_X | PRIMF_FIXED_OVERFLOW)
  180. // No point flags right now.
  181. #define PTF_ALL 0
  182. // Per line.
  183. #define LNF_X_MAJOR 0x00008000
  184. #define LNF_ALL \
  185. (LNF_X_MAJOR)
  186. // Per triangle.
  187. #define TRIF_X_DEC 0x00008000
  188. #define TRIF_RASTPRIM_OVERFLOW 0x00010000
  189. #define TRIF_ALL \
  190. (TRIF_X_DEC | TRIF_RASTPRIM_OVERFLOW)
  191. // PWL support flags.
  192. #define PWL_NEXT_LOD 0x00000001
  193. #ifdef PWL_FOG
  194. #define PWL_NEXT_FOG 0x00000002
  195. // Suppress computation of next fog for lines.
  196. // No equivalent flag for LOD since lines don't support LOD.
  197. #define PWL_NO_NEXT_FOG 0x00000004
  198. #endif
  199. // Setup information shared between C++ and assembly.
  200. typedef struct tagSETUPCTX
  201. {
  202. // Overall rasterization context.
  203. PD3DI_RASTCTX pCtx;
  204. // Current PrimProcessor for span allocator calls.
  205. PVOID PrimProcessor;
  206. // Current primitive.
  207. PD3DI_RASTPRIM pPrim;
  208. // Per-primitive flags.
  209. UINT uFlags;
  210. // Flat shading vertex pointer.
  211. LPD3DTLVERTEX pFlatVtx;
  212. // Maximum span length allowed.
  213. INT cMaxSpan;
  214. //
  215. // Piecewise-linear support for LOD and global fog.
  216. //
  217. UINT uPwlFlags;
  218. // LOD.
  219. FLOAT fNextW;
  220. FLOAT fNextOoW;
  221. FLOAT fNextUoW1, fNextVoW1;
  222. INT iNextLOD;
  223. // Local fog X delta. Fog deltas are always sent through RASTSPAN
  224. // instead of RASTPRIM to make the local and global cases the same.
  225. // For the local fog case where the delta doesn't change convert
  226. // it once and keep it here.
  227. INT iDLocalFogDX;
  228. #ifdef PWL_FOG
  229. // Global fog.
  230. FLOAT fNextZ;
  231. UINT uNextFog;
  232. #endif
  233. // Attribute handling functions.
  234. PFN_ADDATTRS pfnAddAttrs;
  235. PFN_ADDSCALEDATTRS pfnAddScaledAttrs;
  236. PFN_FILLSPANATTRS pfnFillSpanAttrs;
  237. // Edge walking function.
  238. PFN_WALKTRAPSPANS pfnWalkTrapSpans;
  239. // Triangle attribute setup beads.
  240. PFN_SETUPTRIATTR pfnTriSetupFirstAttr;
  241. PFN_SETUPTRIATTR pfnTriSetupZEnd;
  242. PFN_SETUPTRIATTR pfnTriSetupTexEnd;
  243. PFN_SETUPTRIATTR pfnTriSetupDiffEnd;
  244. PFN_SETUPTRIATTR pfnTriSetupSpecEnd;
  245. PFN_SETUPTRIATTR pfnTriSetupFogEnd;
  246. // Current X and Y values.
  247. INT iX, iY;
  248. union
  249. {
  250. // Edge fraction and delta for lines.
  251. struct
  252. {
  253. INT iLineFrac, iDLineFrac;
  254. };
  255. // Edge X walkers for triangles.
  256. struct
  257. {
  258. INTCARRYVAL X20, X10, X21;
  259. };
  260. };
  261. // Floating-point versions of X20 NC and CY values for setup.
  262. FLOAT fX20NC, fX20CY;
  263. // Long edge attribute values.
  264. ATTRSET Attr;
  265. union
  266. {
  267. // Attribute major axis deltas for lines.
  268. ATTRSET DAttrDMajor;
  269. // Attribute X deltas for triangles.
  270. ATTRSET DAttrDX;
  271. };
  272. // Attribute Y deltas.
  273. ATTRSET DAttrDY;
  274. // Span-to-span deltas when attribute edge carries a pixel.
  275. INT iDXCY, iDYCY;
  276. ATTRSET DAttrCY;
  277. // Span-to-span deltas when attribute edge doesn't carry a pixel.
  278. INT iDXNC, iDYNC;
  279. ATTRSET DAttrNC;
  280. union
  281. {
  282. // One over length for lines.
  283. FLOAT fOoLen;
  284. // One over determinant for triangles.
  285. FLOAT fOoDet;
  286. };
  287. // Edge deltas.
  288. FLOAT fDX10, fDY10;
  289. FLOAT fDX20, fDY20;
  290. // Normalized edge deltas.
  291. FLOAT fNX10, fNY10;
  292. FLOAT fNX20, fNY20;
  293. // Subpixel correction amounts.
  294. union
  295. {
  296. // Lines.
  297. FLOAT fDMajor;
  298. // Triangles.
  299. struct
  300. {
  301. FLOAT fDX, fDY;
  302. };
  303. };
  304. // Pixel length of line.
  305. INT cLinePix;
  306. } SETUPCTX;
  307. #endif // #ifndef _STP_BASE_H_