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.

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