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.

230 lines
6.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. // ATTENTION - It may be better to use RASTSPAN. RASTSPAN has some extra
  15. // space that'd go unused but then it'd be possible to memcpy ATTRSETs
  16. // to RASTSPANs during fixed-point edge walking.
  17. typedef struct tagATTRSET
  18. {
  19. union
  20. {
  21. FLOAT fZ;
  22. INT32 iZ;
  23. UINT32 uZ;
  24. };
  25. union
  26. {
  27. FLOAT fOoW;
  28. INT32 iOoW;
  29. };
  30. union
  31. {
  32. struct
  33. {
  34. FLOAT fUoW[D3DHAL_TSS_MAXSTAGES], fVoW[D3DHAL_TSS_MAXSTAGES];
  35. };
  36. struct
  37. {
  38. INT32 iUoW[D3DHAL_TSS_MAXSTAGES], iVoW[D3DHAL_TSS_MAXSTAGES];
  39. };
  40. };
  41. union
  42. {
  43. struct
  44. {
  45. FLOAT fB, fG, fR, fA;
  46. };
  47. struct
  48. {
  49. INT32 iB, iG, iR, iA;
  50. };
  51. struct
  52. {
  53. UINT32 uB, uG, uR, uA;
  54. };
  55. };
  56. union
  57. {
  58. struct
  59. {
  60. FLOAT fBS, fGS, fRS, fFog;
  61. };
  62. struct
  63. {
  64. INT32 iBS, iGS, iRS, iFog;
  65. };
  66. struct
  67. {
  68. UINT32 uBS, uGS, uRS, uFog;
  69. };
  70. };
  71. union
  72. {
  73. struct
  74. {
  75. PUINT8 pSurface, pZ;
  76. };
  77. struct
  78. {
  79. INT32 ipSurface, ipZ;
  80. };
  81. };
  82. } ATTRSET, *PATTRSET;
  83. // Parameters for doing int/carry arithmetic on a value.
  84. typedef struct tagINTCARRYVAL
  85. {
  86. INT iV;
  87. INT iFrac;
  88. INT iDFrac;
  89. INT iCY, iNC;
  90. } INTCARRYVAL, *PINTCARRYVAL;
  91. // Attribute handlers.
  92. typedef void (FASTCALL *PFN_ADDATTRS)(PATTRSET pAttrs, PATTRSET pDelta);
  93. typedef void (FASTCALL *PFN_ADDSCALEDATTRS)
  94. (PATTRSET pAttrs, PATTRSET pDelta, int iScale, FLOAT fNextOoW);
  95. typedef void (FASTCALL *PFN_FILLSPANATTRS)
  96. (PATTRSET pAttr, PD3DI_RASTSPAN pSpan,
  97. struct tagSETUPCTX *pStpCtx, INT cPix);
  98. extern PFN_ADDATTRS g_pfnAddFloatAttrsTable[];
  99. extern PFN_FILLSPANATTRS g_pfnFillSpanFloatAttrsTable[];
  100. #ifdef STEP_FIXED
  101. extern PFN_ADDATTRS g_pfnAddFixedAttrsTable[];
  102. extern PFN_FILLSPANATTRS g_pfnFillSpanFixedAttrsTable[];
  103. #endif
  104. extern PFN_ADDSCALEDATTRS g_pfnAddScaledFloatAttrsTable[];
  105. extern PFN_ADDSCALEDATTRS g_pfnAddScaledFloatAttrsPwlTable[];
  106. // Edge walkers.
  107. typedef HRESULT (FASTCALL *PFN_WALKSPANS)
  108. (UINT uSpans, PINTCARRYVAL pXOther,
  109. struct tagSETUPCTX *pStpCtx, BOOL bAdvanceLast);
  110. extern PFN_WALKSPANS g_pfnWalkFloatSpansClipTable[];
  111. extern PFN_WALKSPANS g_pfnWalkFloatSpansNoClipTable[];
  112. #ifdef STEP_FIXED
  113. extern PFN_WALKSPANS g_pfnWalkFixedSpansNoClipTable[];
  114. #endif
  115. // Float-to-fixed attribute converters.
  116. typedef void (FASTCALL *PFN_FLOATATTRSTOFIXED)
  117. (PATTRSET pfAttrs, PATTRSET piAttrs);
  118. #ifdef STEP_FIXED
  119. extern PFN_FLOATATTRSTOFIXED g_pfnFloatAttrsToFixedTable[];
  120. #endif
  121. // Setup flags.
  122. #define TRIP_DIFF_USED 0x00000001
  123. #define TRIP_SPEC_USED 0x00000002
  124. #define TRIP_TEX1_USED 0x00000004
  125. #define TRIP_TEX2_USED 0x00000008
  126. #define TRIP_Z_USED 0x00000010
  127. #define TRIP_LOD_USED 0x00000020
  128. #define TRIP_FOG_USED 0x00000040
  129. #define TRIP_TRIVIAL_ACCEPT_Y 0x00000080
  130. #define TRIP_TRIVIAL_ACCEPT_X 0x00000100
  131. #define TRIP_X_DEC 0x00000200
  132. #define TRIP_RASTPRIM_OVERFLOW 0x00000400
  133. #define TRIP_FIXED_OVERFLOW 0x00000800
  134. #define TRIP_IN_BEGIN 0x00001000
  135. #define TRIP_COLORS_USED (TRIP_DIFF_USED | TRIP_SPEC_USED)
  136. #define TRIP_TEX_USED (TRIP_TEX1_USED | TRIP_TEX2_USED)
  137. // These flags are set and reset per-triangle, while the other flags are
  138. // set per triangle set.
  139. #define TRIP_PER_TRIANGLE_FLAGS \
  140. (TRIP_TRIVIAL_ACCEPT_Y | TRIP_TRIVIAL_ACCEPT_X | TRIP_X_DEC | \
  141. TRIP_RASTPRIM_OVERFLOW | TRIP_FIXED_OVERFLOW)
  142. #define TRIP_PER_TRIANGLE_SET_FLAGS \
  143. (TRIP_DIFF_USED | TRIP_SPEC_USED | TRIP_TEX1_USED | TRIP_TEX2_USED | \
  144. TRIP_Z_USED | TRIP_LOD_USED | TRIP_FOG_USED)
  145. // Setup information shared between C++ and assembly.
  146. typedef struct tagSETUPCTX
  147. {
  148. // Overall rasterization context.
  149. PD3DI_RASTCTX pCtx;
  150. // Current TriProcessor for span allocator calls.
  151. PVOID TriProcessor;
  152. // Current primitive.
  153. PD3DI_RASTPRIM pPrim;
  154. // Per-triangle flags.
  155. UINT uFlags;
  156. // Maximum span length allowed.
  157. INT cMaxSpan;
  158. // Piecewise-linear support for LOD.
  159. BOOL bNextValid;
  160. FLOAT fNextW;
  161. FLOAT fNextOoW;
  162. INT iNextLOD;
  163. // Attribute handling functions.
  164. PFN_ADDATTRS pfnAddAttrs;
  165. PFN_ADDSCALEDATTRS pfnAddScaledAttrs;
  166. PFN_ADDSCALEDATTRS pfnAddScaledAttrsPwl;
  167. PFN_FILLSPANATTRS pfnFillSpanAttrs;
  168. // Edge walking function.
  169. PFN_WALKSPANS pfnWalkSpans;
  170. // Current Y value.
  171. INT iY;
  172. // Edge X walkers.
  173. INTCARRYVAL X20, X10, X21;
  174. // Floating-point versions of X20 NC and CY values for setup.
  175. FLOAT fX20NC, fX20CY;
  176. // Long edge attribute values.
  177. ATTRSET Attr;
  178. // Attribute X deltas.
  179. ATTRSET DAttrDX;
  180. // Attribute Y deltas.
  181. ATTRSET DAttrDY;
  182. // Attribute span-to-span deltas when X carries a pixel.
  183. ATTRSET DAttrCY;
  184. // Attribute span-to-span deltas when X doesn't carry a pixel.
  185. ATTRSET DAttrNC;
  186. // One over determinant.
  187. FLOAT fOoDet;
  188. // Edge deltas.
  189. FLOAT fDX10, fDY10;
  190. FLOAT fDX20, fDY20;
  191. // Normalized edge deltas.
  192. FLOAT fNX10, fNY10;
  193. FLOAT fNX20, fNY20;
  194. // Subpixel correction amounts.
  195. FLOAT fDX, fDY;
  196. } SETUPCTX, *PSETUPCTX;
  197. #endif // #ifndef _STP_BASE_H_