Source code of Windows XP (NT5)
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.

636 lines
22 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) Microsoft Corporation, 2000.
  3. //
  4. // refrast.hpp
  5. //
  6. // Direct3D Reference Device - Rasterizer Core
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _REFRAST_HPP
  10. #define _REFRAST_HPP
  11. #include "pshader.h"
  12. inline INT32 FloatToNdot4( FLOAT f )
  13. {
  14. // alternate form if FPU is set up to do double precision
  15. // return AS_INT32( (DOUBLE)f + DOUBLE_4_SNAP );
  16. INT32 i = AS_INT32( f + FLOAT_4_SNAP );
  17. i <<= 10; i >>= 10; // sign extend
  18. return i;
  19. }
  20. inline INT32 FloatToNdot5( FLOAT f )
  21. {
  22. // alternate form if FPU is set up to do double precision
  23. // return AS_INT32( (DOUBLE)f + DOUBLE_5_SNAP );
  24. INT32 i = AS_INT32( f + FLOAT_5_SNAP );
  25. i <<= 10; i >>= 10; // sign extend
  26. return i;
  27. }
  28. //-----------------------------------------------------------------------------
  29. //
  30. // Constants
  31. //
  32. //-----------------------------------------------------------------------------
  33. const DWORD RD_MAX_MULTISAMPLES = 9;
  34. const UINT RDPRIM_MAX_EDGES = 4; // 4 edges for a point sprite
  35. const UINT RDATTR_MAX_DIMENSIONALITY = 4; // up to 4 scalars per attribute
  36. // attribute array assignments
  37. #define RDATTR_DEPTH 0
  38. #define RDATTR_FOG 1
  39. #define RDATTR_COLOR 2
  40. #define RDATTR_SPECULAR 3
  41. #define RDATTR_TEXTURE0 4
  42. #define RDATTR_TEXTURE1 5
  43. #define RDATTR_TEXTURE2 6
  44. #define RDATTR_TEXTURE3 7
  45. #define RDATTR_TEXTURE4 8
  46. #define RDATTR_TEXTURE5 9
  47. #define RDATTR_TEXTURE6 10
  48. #define RDATTR_TEXTURE7 11
  49. const UINT RDPRIM_MAX_ATTRIBUTES = 12;
  50. ///////////////////////////////////////////////////////////////////////////////
  51. // //
  52. // Pixel Component Classes //
  53. // //
  54. ///////////////////////////////////////////////////////////////////////////////
  55. //-----------------------------------------------------------------------------
  56. //
  57. // Color Value Class - Holds an array of floats.
  58. //
  59. //-----------------------------------------------------------------------------
  60. class RDColor
  61. {
  62. public:
  63. FLOAT R,G,B,A;
  64. inline RDColor( void ) { R = G = B = 0.0f; A = 1.0f; }
  65. // assignment constructors
  66. inline RDColor( UINT32 uVal )
  67. {
  68. R = (FLOAT)RGBA_GETRED( uVal )*(1.f/255.f);
  69. G = (FLOAT)RGBA_GETGREEN( uVal )*(1.f/255.f);
  70. B = (FLOAT)RGBA_GETBLUE( uVal )*(1.f/255.f);
  71. A = (FLOAT)RGBA_GETALPHA( uVal )*(1.f/255.f);
  72. }
  73. inline RDColor( FLOAT fR, FLOAT fG, FLOAT fB, FLOAT fA )
  74. {
  75. R = fR; G = fG; B = fB; A = fA;
  76. }
  77. inline RDColor( FLOAT* pC )
  78. {
  79. R = *(pC+0); G = *(pC+1); B= *(pC+2); A = *(pC+3);
  80. }
  81. // UINT32 copy operator
  82. inline void operator=(const UINT32 uVal)
  83. {
  84. R = (FLOAT)RGBA_GETRED( uVal )*(1.f/255.f);
  85. G = (FLOAT)RGBA_GETGREEN( uVal )*(1.f/255.f);
  86. B = (FLOAT)RGBA_GETBLUE( uVal )*(1.f/255.f);
  87. A = (FLOAT)RGBA_GETALPHA( uVal )*(1.f/255.f);
  88. }
  89. // FLOAT array copy operator
  90. inline void operator=(const FLOAT* pFVal)
  91. {
  92. R = *(pFVal+0);
  93. G = *(pFVal+1);
  94. B = *(pFVal+2);
  95. A = *(pFVal+3);
  96. }
  97. // casting operator
  98. inline operator UINT32() const
  99. {
  100. return D3DRGBA( R, G, B, A );
  101. }
  102. // set all channels
  103. inline void SetAllChannels( FLOAT fVal )
  104. {
  105. R = fVal; G = fVal; B = fVal; A = fVal;
  106. }
  107. // clamp to unity
  108. inline void Saturate( void )
  109. {
  110. R = MIN( 1.f, R );
  111. G = MIN( 1.f, G );
  112. B = MIN( 1.f, B );
  113. A = MIN( 1.f, A );
  114. }
  115. inline void Clamp( void )
  116. {
  117. R = MAX( 0.f, MIN( 1.f, R ) );
  118. G = MAX( 0.f, MIN( 1.f, G ) );
  119. B = MAX( 0.f, MIN( 1.f, B ) );
  120. A = MAX( 0.f, MIN( 1.f, A ) );
  121. }
  122. // copy to array of FLOATs
  123. inline void CopyTo( FLOAT* pF )
  124. {
  125. *(pF+0) = R;
  126. *(pF+1) = G;
  127. *(pF+2) = B;
  128. *(pF+3) = A;
  129. }
  130. //
  131. // conversions between surface format and RDColor - these define the
  132. // correct way to map between resolutions
  133. //
  134. // convert from surface type format to RDColor
  135. void ConvertFrom( RDSurfaceFormat Type, const char* pSurfaceBits );
  136. // Convert surface type format to RDColor
  137. void ConvertTo( RDSurfaceFormat Type, float fRoundOffset, char* pSurfaceBits ) const;
  138. };
  139. //-----------------------------------------------------------------------------
  140. //
  141. // RDDepth - Class for storing and manipulating pixel depth values. Underlying
  142. // storage is a double precision floating point, which has sufficient precision
  143. // and range to support 16 and 32 bit fixed point and 32 bit floating point.
  144. //
  145. // The UINT32 methods receive a 24 or 32 bit value, and the UINT16
  146. // methods receive a 15 or 16 bit value.
  147. //
  148. //-----------------------------------------------------------------------------
  149. class RDDepth
  150. {
  151. DOUBLE m_dVal;
  152. RDSurfaceFormat m_DepthSType;
  153. DOUBLE dGetValClamped(void) const { return min(1.,max(0.,m_dVal)); }
  154. DOUBLE dGetCnvScale(void) const
  155. {
  156. switch(m_DepthSType)
  157. {
  158. case RD_SF_Z16S0:
  159. return DOUBLE((1<<16)-1);
  160. case RD_SF_Z24S8:
  161. case RD_SF_Z24X8:
  162. case RD_SF_S8Z24:
  163. case RD_SF_X8Z24:
  164. case RD_SF_Z24X4S4:
  165. case RD_SF_X4S4Z24:
  166. return DOUBLE((1<<24)-1);
  167. case RD_SF_Z15S1:
  168. case RD_SF_S1Z15:
  169. return DOUBLE((1<<15)-1);
  170. case RD_SF_Z32S0:
  171. return DOUBLE(0xffffffff); // too big to be generated as above without INT64's
  172. default:
  173. DPFRR(0, "RDDepth not initialized correctly");
  174. return DOUBLE(0.0);
  175. }
  176. }
  177. DOUBLE dGetCnvInvScale(void) const
  178. {
  179. switch(m_DepthSType)
  180. {
  181. case RD_SF_Z16S0:
  182. return DOUBLE( 1./(DOUBLE)((1<<16)-1) );
  183. case RD_SF_Z24S8:
  184. case RD_SF_Z24X8:
  185. case RD_SF_S8Z24:
  186. case RD_SF_X8Z24:
  187. case RD_SF_Z24X4S4:
  188. case RD_SF_X4S4Z24:
  189. return DOUBLE( 1./(DOUBLE)((1<<24)-1) );
  190. case RD_SF_Z15S1:
  191. case RD_SF_S1Z15:
  192. return DOUBLE( 1./(DOUBLE)((1<<15)-1) );
  193. case RD_SF_Z32S0:
  194. return DOUBLE( 1./(DOUBLE)(0xffffffff) ); // too big to be generated as above without INT64's
  195. default:
  196. DPFRR(0, "RDDepth not initialized correctly");
  197. return DOUBLE(0.0);
  198. }
  199. }
  200. public:
  201. RDDepth() {;}
  202. // assignment constructors
  203. RDDepth(RDSurfaceFormat SType) : m_dVal(0.F), m_DepthSType(SType) {;}
  204. RDDepth(UINT16 uVal, RDSurfaceFormat SType): m_DepthSType(SType), m_dVal((DOUBLE)uVal*dGetCnvInvScale()) {;}
  205. RDDepth(UINT32 uVal, RDSurfaceFormat SType): m_DepthSType(SType), m_dVal((DOUBLE)uVal*dGetCnvInvScale()) {;}
  206. // copy and assignment operators
  207. RDDepth& operator=(const RDDepth& A) { m_dVal = A.m_dVal; m_DepthSType = A.m_DepthSType; return *this; }
  208. RDDepth& operator=(UINT16 uVal) { m_dVal = (DOUBLE)uVal*dGetCnvInvScale(); return *this; }
  209. RDDepth& operator=(UINT32 uVal) { m_dVal = (DOUBLE)uVal*dGetCnvInvScale(); return *this; }
  210. RDDepth& operator=(FLOAT fVal) { m_dVal = (DOUBLE)fVal; return *this; }
  211. // round for integer get operations
  212. operator UINT16() const { return (UINT16)( (dGetValClamped()*dGetCnvScale()) + .5); }
  213. operator UINT32() const { return (UINT32)( (dGetValClamped()*dGetCnvScale()) + .5); }
  214. operator DOUBLE() const { return dGetValClamped(); }
  215. operator FLOAT() const { return (FLOAT)dGetValClamped(); }
  216. void SetSType(RDSurfaceFormat SType) { m_DepthSType = SType; }
  217. RDSurfaceFormat GetSType(void) const { return m_DepthSType; }
  218. };
  219. //-----------------------------------------------------------------------------
  220. //
  221. // Texture
  222. //
  223. //-----------------------------------------------------------------------------
  224. #define RRTEX_LODFRAC 5
  225. #define RRTEX_LODFRACMASK 0x1F
  226. #define RRTEX_LODFRACF .03125f
  227. #define RRTEX_MAPFRAC 5
  228. #define RRTEX_MAPFRACMASK 0x1F
  229. #define RRTEX_MAPFRACF .03125f
  230. typedef struct _TextureSample
  231. {
  232. INT32 iLOD;
  233. FLOAT fWgt;
  234. INT32 iCrd[3];
  235. } TextureSample;
  236. typedef struct _TextureFilterControl
  237. {
  238. int cSamples;
  239. TextureSample pSamples[16*4*2]; // handles 16:1 aniso in two LODs
  240. D3DTEXTUREFILTERTYPE MinFilter;
  241. D3DTEXTUREFILTERTYPE MagFilter;
  242. D3DTEXTUREFILTERTYPE MipFilter;
  243. D3DTEXTUREFILTERTYPE CvgFilter;
  244. FLOAT fCrd[3]; // temporary: to run old filter/sample code
  245. } TextureFilterControl;
  246. typedef struct _TextureCoverage
  247. {
  248. FLOAT fLOD;
  249. FLOAT fAnisoRatio;
  250. FLOAT fAnisoLine[3];
  251. INT16 iLOD; // n.RRTEX_LODFRAC fixed point LOD
  252. BOOL bMagnify;
  253. int cLOD; // 1 or 2, for accessing one or two LOD maps
  254. INT32 iLODMap[2]; // map index for maps adjacent to sample point
  255. FLOAT fLODFrc[2]; // (fractional) weighting for each adjacent map
  256. FLOAT fGradients[3][2]; // need to store gradients for cube maps
  257. } TextureCoverage;
  258. //
  259. // structure containing texture coordinate and gradient information
  260. // for lookup and filtering
  261. //
  262. class RDTextureCoord
  263. {
  264. public:
  265. union { FLOAT C0; FLOAT fNX; FLOAT fU; };
  266. union { FLOAT C1; FLOAT fNY; FLOAT fV; };
  267. union { FLOAT C2; FLOAT fNZ; FLOAT fW; };
  268. union { FLOAT DC0DX; FLOAT fDNXDX; FLOAT fDUDX; };
  269. union { FLOAT DC0DY; FLOAT fDNXDY; FLOAT fDUDY; };
  270. union { FLOAT DC1DX; FLOAT fDNYDX; FLOAT fDVDX; };
  271. union { FLOAT DC1DY; FLOAT fDNYDY; FLOAT fDVDY; };
  272. union { FLOAT DC2DX; FLOAT fDNZDX; };
  273. union { FLOAT DC2DY; FLOAT fDNZDY; };
  274. };
  275. void
  276. ComputeMipCoverage(
  277. const FLOAT (*fGradients)[2],
  278. FLOAT& fLOD, int cDim );
  279. void
  280. ComputeAnisoCoverage(
  281. const FLOAT (*fGradients)[2], FLOAT fMaxAniso,
  282. FLOAT& fLOD, FLOAT& fRatio, FLOAT fDelta[] );
  283. void
  284. ComputeCubeCoverage(
  285. const FLOAT (*fGradients)[2],
  286. FLOAT& fLOD );
  287. void
  288. DoCubeRemap(
  289. INT32 iCrd[], INT32 iCrdMax[],
  290. D3DCUBEMAP_FACES& Face, UINT uOut0, UINT uOut1);
  291. //-----------------------------------------------------------------------------
  292. //
  293. // Primitive edge function - Computes, stores, and evaluates linear function
  294. // for edges. Basic function is stored in fixed point. Gradient sign terms
  295. // are computed and stored separately to adhere to fill rules.
  296. //
  297. // This can evaluate edges to a 1/16th subpixel resolution grid.
  298. //
  299. //-----------------------------------------------------------------------------
  300. class RDEdge
  301. {
  302. public:
  303. INT32 m_iA; // n.4 fixed point
  304. INT32 m_iB; // n.4 fixed point
  305. INT64 m_iC; // n.8 fixed point
  306. BOOL m_bAPos; // carefully computed signs of A,B
  307. BOOL m_bBPos;
  308. void Set(
  309. BOOL bDetSign,
  310. INT32 iX0, INT32 iY0,
  311. INT32 iX1, INT32 iY1);
  312. BOOL Test(INT32 iX, INT32 iY );
  313. };
  314. //-----------------------------------------------------------------------------
  315. //
  316. //-----------------------------------------------------------------------------
  317. class RDAttribute
  318. {
  319. public:
  320. friend class RefRast;
  321. // pointer back to containing refrast object
  322. RefRast* m_pRR;
  323. BOOL m_bPerspective;
  324. BOOL m_bClamp; // clamp to 0..1 if TRUE
  325. UINT m_cDimensionality;
  326. UINT m_cProjection; // project by c'th element (0 == disable)
  327. DWORD m_dwWrapFlags; // wrap flags for each dimension (from LSB)
  328. BOOL m_bFlatShade;
  329. // per-dimension attribute functions
  330. FLOAT m_fA[RDATTR_MAX_DIMENSIONALITY];
  331. FLOAT m_fB[RDATTR_MAX_DIMENSIONALITY];
  332. FLOAT m_fC[RDATTR_MAX_DIMENSIONALITY];
  333. // things generally only set once
  334. void Init(
  335. RefRast* pPrimitive, // RefRast with which this attrib is used
  336. UINT cDimensionality,
  337. BOOL bPerspective,
  338. BOOL bClamp );
  339. // things generally set as RS or TSS changes
  340. void SetFlatShade( BOOL bFlatShade ) { m_bFlatShade = bFlatShade; }
  341. void SetWrapFlags( DWORD dwWrapFlags ) { m_dwWrapFlags = dwWrapFlags; }
  342. void SetProjection( UINT cProjection ) { m_cProjection = cProjection; }
  343. void SetPerspective( BOOL bPerspective) { m_bPerspective = bPerspective; }
  344. void Setup(
  345. const FLOAT* pVtx0, const FLOAT* pVtx1, const FLOAT* pVtx2);
  346. void LineSetup(
  347. const FLOAT* pVtx0, const FLOAT* pVtx1, const FLOAT* pVtxFlat = NULL );
  348. void Setup(
  349. DWORD dwVtx0, DWORD dwVtx1, DWORD dwVtx2);
  350. // fully general sample function
  351. void Sample( FLOAT* pSampleData, FLOAT fX, FLOAT fY,
  352. BOOL bNoProjectionOverride = TRUE, BOOL bClampOverride = FALSE );
  353. // sample scalar attribute at given location; assumes no perspective or projection
  354. // (used for Depth)
  355. FLOAT Sample( FLOAT fX, FLOAT fY );
  356. };
  357. //-----------------------------------------------------------------------------
  358. //
  359. //-----------------------------------------------------------------------------
  360. class RefRast
  361. {
  362. public:
  363. friend class RDAttribute;
  364. friend class RDEdge;
  365. RefDev* m_pRD;
  366. ~RefRast();
  367. void Init( RefDev* pRD );
  368. // used for all primitives
  369. BOOL m_bIsLine; // TRUE if rendering a line
  370. UINT m_iFlatVtx; // 0..2 range; which vertex to use for flat shading color
  371. RDAttribute m_Attr[RDPRIM_MAX_ATTRIBUTES];
  372. FLOAT m_fX0, m_fY0; // first vertex, snapped (for initial evaluation)
  373. FLOAT m_fRHW0, m_fRHW1, m_fRHW2; // 1/W data for perspective correction
  374. FLOAT m_fRHWA, m_fRHWB, m_fRHWC; // linear function for 1/W for perspective correction
  375. FLOAT SampleAndInvertRHW( FLOAT fX, FLOAT fY ); // sample 1/W at current given location, invert, and return
  376. // triangle and point rendering
  377. RDEdge m_Edge[RDPRIM_MAX_EDGES];
  378. INT32 m_iEdgeCount;
  379. // integer x,y coords snapped to n.4 grid
  380. INT32 m_iX0, m_iY0, m_iX1, m_iY1, m_iX2, m_iY2;
  381. INT64 m_iDet; // n.8 determinant
  382. FLOAT m_fDelX10, m_fDelX02; // float x,y deltas
  383. FLOAT m_fDelY01, m_fDelY20; //
  384. FLOAT m_fTriOODet; // 1/determinant for triangle function normalization
  385. // integer x,y scan area, intersected with viewport and guardband
  386. INT32 m_iXMin, m_iXMax, m_iYMin, m_iYMax;
  387. BOOL PerTriangleSetup(
  388. FLOAT* pVtx0, FLOAT* pVtx1, FLOAT* pVtx2,
  389. DWORD CullMode,
  390. RECT* pClip);
  391. BOOL EvalPixelPosition( int iPix );
  392. // line rendering
  393. INT64 m_iLineEdgeFunc[3]; // line function: Pminor = ([0]*Pmajor + [1])/[2]
  394. BOOL m_bLineXMajor; // TRUE if X major for line function
  395. INT32 m_iLineMin, m_iLineMax; // min and max pixel extent in major direction
  396. INT32 m_iLineStep; // +1 or -1 depending on line major direction
  397. FLOAT m_fLineMajorLength; // major length for line function
  398. INT32 m_cLineSteps; // number of steps to take in line iteration
  399. BOOL PerLineSetup(
  400. FLOAT* pVtx0, FLOAT* pVtx1,
  401. BOOL bLastPixel,
  402. RECT* pClip);
  403. void StepLine( void );
  404. INT32 m_iMajorCoord;
  405. // per-pixel data
  406. int m_iPix; // which of 4 pixels are currently being worked on
  407. // per-pixel values
  408. BOOL m_bPixelIn[4];
  409. INT32 m_iX[4], m_iY[4]; // current position
  410. FLOAT m_fW[4];
  411. FLOAT m_FogIntensity[4];
  412. RDDepth m_Depth[4]; // TODO - get rid of this...
  413. // per-(pixel&sample) values
  414. BOOL m_bSampleCovered[RD_MAX_MULTISAMPLES][4];
  415. RDDepth m_SampleDepth[RD_MAX_MULTISAMPLES][4];
  416. // pixel shader stuff
  417. BOOL m_bLegacyPixelShade;
  418. RDPShader* m_pCurrentPixelShader;
  419. UINT m_CurrentPSInst;
  420. BOOL m_bPixelDiscard[4];
  421. // register files
  422. FLOAT m_InputReg[RDPS_MAX_NUMINPUTREG][4][4];
  423. FLOAT m_TempReg[RDPS_MAX_NUMTEMPREG][4][4];
  424. FLOAT m_ConstReg[RDPS_MAX_NUMCONSTREG][4][4];
  425. FLOAT m_TextReg[RDPS_MAX_NUMTEXTUREREG][4][4];
  426. // additional ref-specific registers for holding temporary values in pixel shader
  427. FLOAT m_PostModSrcReg[RDPS_MAX_NUMPOSTMODSRCREG][4][4]; // temporary values holding src mod results for 3 source parameters
  428. FLOAT m_ScratchReg[RDPS_MAX_NUMSCRATCHREG][4][4]; // just a general scratchpad register (example use: storing eye/reflection vector)
  429. FLOAT m_ZeroReg[4][4]; // register containing 0.0f.
  430. FLOAT m_OneReg[4][4]; // register containing 1.0f.
  431. FLOAT m_TwoReg[4][4]; // register containing 2.0f.
  432. FLOAT m_QueuedWriteReg[RDPS_MAX_NUMQUEUEDWRITEREG][4][4]; // staging registers for queued writes
  433. PSQueuedWriteDst m_QueuedWriteDst[RDPS_MAX_NUMQUEUEDWRITEREG]; // destination register on flush for queued write
  434. FLOAT m_Gradients[3][2]; // gradients for texture sampling
  435. void ExecShader( void );
  436. void DoRegToRegOp( PixelShaderInstruction* pInst );
  437. #if DBG
  438. BOOL m_bDebugPrintTranslatedPixelShaderTokens;
  439. #endif
  440. RDPShader* m_pLegacyPixelShader;
  441. void UpdateLegacyPixelShader( void );
  442. // multi-sample stuff
  443. UINT m_SampleCount; // count and deltas for current MS buffer type
  444. INT32 m_SampleDelta[RD_MAX_MULTISAMPLES][2];
  445. DWORD m_SampleMask; // copy of renderstate
  446. UINT m_CurrentSample; // current sample number for 'NextSample' stepper
  447. inline void SetSampleMask( DWORD SampleMask ) { m_SampleMask = SampleMask; }
  448. inline BOOL GetCurrentSampleMask( void )
  449. {
  450. if ( m_SampleCount <= 1 ) return TRUE; // not effective when not MS buffer
  451. return ( (1<<m_CurrentSample) & m_SampleMask ) ? TRUE : FALSE;
  452. }
  453. inline UINT GetCurrentSample( void ) { return m_CurrentSample; }
  454. // returns TRUE until samples exhausted and then resets itself on FALSE return
  455. inline BOOL NextSample( void )
  456. {
  457. if (++m_CurrentSample == m_SampleCount)
  458. {
  459. // done iterating thru samples, so reset and return FALSE
  460. m_CurrentSample = 0;
  461. return FALSE;
  462. }
  463. return TRUE;
  464. }
  465. // returns x,y deltas (n.4 fixed point) of current sample
  466. inline INT32 GetCurrentSampleX( int iPix )
  467. { return (m_iX[iPix]<<4) + m_SampleDelta[m_CurrentSample][0]; }
  468. inline INT32 GetCurrentSampleY( int iPix )
  469. { return (m_iY[iPix]<<4) + m_SampleDelta[m_CurrentSample][1]; }
  470. inline FLOAT GetCurrentSamplefX( int iPix )
  471. { return (FLOAT)GetCurrentSampleX(iPix) * (1./16.); }
  472. inline FLOAT GetCurrentSamplefY( int iPix )
  473. { return (FLOAT)GetCurrentSampleY(iPix) * (1./16.); }
  474. // sets internal sample number and per-sample deltas based on FSAA type
  475. void SetSampleMode( UINT MultiSampleCount, BOOL bAntialias );
  476. UINT GetCurrentNumberOfSamples( void )
  477. { return m_SampleCount; }
  478. // setup.cpp
  479. void SetAttributeFunctions(
  480. const RDVertex& Vtx0,
  481. const RDVertex& Vtx1,
  482. const RDVertex& Vtx2 );
  483. // scancnv.cpp
  484. FLOAT ComputeFogIntensity( FLOAT fX, FLOAT fY );
  485. void SnapDepth( void );
  486. void DoScanCnvGenPixels( void );
  487. void DoScanCnvTri( int iEdgeCount );
  488. void DoScanCnvLine( void );
  489. // texture filtering
  490. TextureCoverage m_TexCvg[D3DHAL_TSS_MAXSTAGES];
  491. TextureFilterControl m_TexFlt[D3DHAL_TSS_MAXSTAGES];
  492. void UpdateTextureControls( void );
  493. void ComputeTextureCoverage( int iStage, FLOAT (*fGradients)[2] );
  494. void ComputePerLODControls( int iStage );
  495. void ComputePointSampleCoords(
  496. int iStage, INT32 iLOD, FLOAT fCrd[],
  497. INT32 iCrd[] );
  498. void ComputeLinearSampleCoords(
  499. int iStage, INT32 iLOD, FLOAT fCrd[],
  500. INT32 iCrdFlr[], INT32 iCrdClg[], FLOAT fCrdFrcF[], FLOAT fCrdFrcC[] );
  501. void SetUp1DTextureSample(
  502. int iStage, int Start,
  503. INT32 iLODMap, FLOAT fLODScale,
  504. INT32 iCrdF, INT32 iCrdC,
  505. FLOAT fCrdFrcF, FLOAT fCrdFrcC );
  506. void SetUp2DTextureSample(
  507. int iStage, int Start,
  508. INT32 iLODMap, FLOAT fLODScale,
  509. INT32 iCrdF[], INT32 iCrdC[],
  510. FLOAT fCrdFrcF[], FLOAT fCrdFrcC[] );
  511. void SetUp3DTextureSample(
  512. int iStage, int Start,
  513. INT32 iLODMap, FLOAT fLODScale,
  514. INT32 iCrdF[], INT32 iCrdC[],
  515. FLOAT fCrdFrcF[], FLOAT fCrdFrcC[] );
  516. void SetUpCubeMapLinearSample(
  517. int iStage, D3DCUBEMAP_FACES Face,
  518. INT32 iLODMap, FLOAT fLODScale,
  519. INT32 (*iCrd)[2], FLOAT (*fFrc)[2] );
  520. void ComputeTextureFilter( int iStage, FLOAT fCrd[] );
  521. void ComputeCubeTextureFilter( int iStage, FLOAT fCrd[] );
  522. void SampleTexture( INT32 iStage, FLOAT fCol[] );
  523. // texstage.cpp
  524. void ComputeTextureBlendArg(
  525. DWORD dwArgCtl, BOOL bAlphaOnly,
  526. const RDColor& DiffuseColor,
  527. const RDColor& SpecularColor,
  528. const RDColor& CurrentColor,
  529. const RDColor& TextureColor,
  530. const RDColor& TempColor,
  531. RDColor& BlendArg);
  532. void DoTextureBlendStage(
  533. int iStage,
  534. const RDColor& DiffuseColor,
  535. const RDColor& SpecularColor,
  536. const RDColor& CurrentColor,
  537. const RDColor& TextureColor,
  538. RDColor& TempColor,
  539. RDColor& OutputColor);
  540. // pixproc.cpp
  541. void DoPixels( void );
  542. BOOL DepthCloser( const RDDepth& DepthVal, const RDDepth& DepthBuf );
  543. BOOL AlphaTest( FLOAT fAlpha );
  544. BOOL DoStencil( UINT8 uStncBuf, BOOL bDepthTest, RDSurfaceFormat DepthSFormat, UINT8& uStncRet );
  545. void DoAlphaBlend( const RDColor& SrcColor, const RDColor& DstColor, RDColor& ResColor );
  546. // pixref.cpp
  547. void WritePixel( INT32 iX, INT32 iY, UINT Sample, const RDColor& Color, const RDDepth& Depth);
  548. };
  549. ///////////////////////////////////////////////////////////////////////////////
  550. #endif // _REFRAST_HPP