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.

238 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 fUoW1, fVoW1;
  35. };
  36. struct
  37. {
  38. INT32 iUoW1, iVoW1;
  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. struct
  71. {
  72. FLOAT fUoW2, fVoW2;
  73. };
  74. struct
  75. {
  76. INT32 iUoW2, iVoW2;
  77. };
  78. };
  79. union
  80. {
  81. struct
  82. {
  83. PUINT8 pSurface, pZ;
  84. };
  85. struct
  86. {
  87. INT32 ipSurface, ipZ;
  88. };
  89. };
  90. } ATTRSET, *PATTRSET;
  91. // Parameters for doing int/carry arithmetic on a value.
  92. typedef struct tagINTCARRYVAL
  93. {
  94. INT iV;
  95. INT iFrac;
  96. INT iDFrac;
  97. INT iCY, iNC;
  98. } INTCARRYVAL, *PINTCARRYVAL;
  99. // Attribute handlers.
  100. typedef void (FASTCALL *PFN_ADDATTRS)(PATTRSET pAttrs, PATTRSET pDelta);
  101. typedef void (FASTCALL *PFN_ADDSCALEDATTRS)
  102. (PATTRSET pAttrs, PATTRSET pDelta, int iScale, FLOAT fNextOoW);
  103. typedef void (FASTCALL *PFN_FILLSPANATTRS)
  104. (PATTRSET pAttr, PD3DI_RASTSPAN pSpan,
  105. struct tagSETUPCTX *pStpCtx, INT cPix);
  106. extern PFN_ADDATTRS g_pfnAddFloatAttrsTable[];
  107. extern PFN_FILLSPANATTRS g_pfnFillSpanFloatAttrsTable[];
  108. #ifdef STEP_FIXED
  109. extern PFN_ADDATTRS g_pfnAddFixedAttrsTable[];
  110. extern PFN_FILLSPANATTRS g_pfnFillSpanFixedAttrsTable[];
  111. #endif
  112. extern PFN_ADDSCALEDATTRS g_pfnAddScaledFloatAttrsTable[];
  113. extern PFN_ADDSCALEDATTRS g_pfnAddScaledFloatAttrsPwlTable[];
  114. // Edge walkers.
  115. typedef HRESULT (FASTCALL *PFN_WALKSPANS)
  116. (UINT uSpans, PINTCARRYVAL pXOther,
  117. struct tagSETUPCTX *pStpCtx, BOOL bAdvanceLast);
  118. extern PFN_WALKSPANS g_pfnWalkFloatSpansClipTable[];
  119. extern PFN_WALKSPANS g_pfnWalkFloatSpansNoClipTable[];
  120. #ifdef STEP_FIXED
  121. extern PFN_WALKSPANS g_pfnWalkFixedSpansNoClipTable[];
  122. #endif
  123. // Float-to-fixed attribute converters.
  124. typedef void (FASTCALL *PFN_FLOATATTRSTOFIXED)
  125. (PATTRSET pfAttrs, PATTRSET piAttrs);
  126. #ifdef STEP_FIXED
  127. extern PFN_FLOATATTRSTOFIXED g_pfnFloatAttrsToFixedTable[];
  128. #endif
  129. // Setup flags.
  130. #define TRIP_DIFF_USED 0x00000001
  131. #define TRIP_SPEC_USED 0x00000002
  132. #define TRIP_TEX1_USED 0x00000004
  133. #define TRIP_TEX2_USED 0x00000008
  134. #define TRIP_Z_USED 0x00000010
  135. #define TRIP_LOD_USED 0x00000020
  136. #define TRIP_FOG_USED 0x00000040
  137. #define TRIP_TRIVIAL_ACCEPT_Y 0x00000080
  138. #define TRIP_TRIVIAL_ACCEPT_X 0x00000100
  139. #define TRIP_X_DEC 0x00000200
  140. #define TRIP_RASTPRIM_OVERFLOW 0x00000400
  141. #define TRIP_FIXED_OVERFLOW 0x00000800
  142. #define TRIP_IN_BEGIN 0x00001000
  143. #define TRIP_COLORS_USED (TRIP_DIFF_USED | TRIP_SPEC_USED)
  144. #define TRIP_TEX_USED (TRIP_TEX1_USED | TRIP_TEX2_USED)
  145. // These flags are set and reset per-triangle, while the other flags are
  146. // set per triangle set.
  147. #define TRIP_PER_TRIANGLE_FLAGS \
  148. (TRIP_TRIVIAL_ACCEPT_Y | TRIP_TRIVIAL_ACCEPT_X | TRIP_X_DEC | \
  149. TRIP_RASTPRIM_OVERFLOW | TRIP_FIXED_OVERFLOW)
  150. #define TRIP_PER_TRIANGLE_SET_FLAGS \
  151. (TRIP_DIFF_USED | TRIP_SPEC_USED | TRIP_TEX1_USED | TRIP_TEX2_USED | \
  152. TRIP_Z_USED | TRIP_LOD_USED | TRIP_FOG_USED)
  153. // Setup information shared between C++ and assembly.
  154. typedef struct tagSETUPCTX
  155. {
  156. // Overall rasterization context.
  157. PD3DI_RASTCTX pCtx;
  158. // Current TriProcessor for span allocator calls.
  159. PVOID TriProcessor;
  160. // Current primitive.
  161. PD3DI_RASTPRIM pPrim;
  162. // Per-triangle flags.
  163. UINT uFlags;
  164. // Maximum span length allowed.
  165. INT cMaxSpan;
  166. // Piecewise-linear support for LOD.
  167. BOOL bNextValid;
  168. FLOAT fNextW;
  169. FLOAT fNextOoW;
  170. INT iNextLOD;
  171. // Attribute handling functions.
  172. PFN_ADDATTRS pfnAddAttrs;
  173. PFN_ADDSCALEDATTRS pfnAddScaledAttrs;
  174. PFN_ADDSCALEDATTRS pfnAddScaledAttrsPwl;
  175. PFN_FILLSPANATTRS pfnFillSpanAttrs;
  176. // Edge walking function.
  177. PFN_WALKSPANS pfnWalkSpans;
  178. // Current Y value.
  179. INT iY;
  180. // Edge X walkers.
  181. INTCARRYVAL X20, X10, X21;
  182. // Floating-point versions of X20 NC and CY values for setup.
  183. FLOAT fX20NC, fX20CY;
  184. // Long edge attribute values.
  185. ATTRSET Attr;
  186. // Attribute X deltas.
  187. ATTRSET DAttrDX;
  188. // Attribute Y deltas.
  189. ATTRSET DAttrDY;
  190. // Attribute span-to-span deltas when X carries a pixel.
  191. ATTRSET DAttrCY;
  192. // Attribute span-to-span deltas when X doesn't carry a pixel.
  193. ATTRSET DAttrNC;
  194. // One over determinant.
  195. FLOAT fOoDet;
  196. // Edge deltas.
  197. FLOAT fDX10, fDY10;
  198. FLOAT fDX20, fDY20;
  199. // Normalized edge deltas.
  200. FLOAT fNX10, fNY10;
  201. FLOAT fNX20, fNY20;
  202. // Subpixel correction amounts.
  203. FLOAT fDX, fDY;
  204. } SETUPCTX, *PSETUPCTX;
  205. #endif // #ifndef _STP_BASE_H_