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.

122 lines
4.0 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) Microsoft Corporation, 1998.
  3. //
  4. // AttrFunc.hpp
  5. //
  6. // Direct3D Reference Rasterizer - Attribute Function Processing
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _ATTRFUNC_HPP
  10. #define _ATTRFUNC_HPP
  11. enum RRPrimType { RR_POINT, RR_LINE, RR_TRIANGLE };
  12. //-----------------------------------------------------------------------------
  13. //
  14. // RRAttribFuncStatic - static data for attribute functions. This is
  15. // per-primitive data (as opposed to per-attribute data which is in arrays of
  16. // RRAttribFunc objects). This would be more elegantly done as static
  17. // data in the RRAttribFunc class, but we need to be able to multiply instance
  18. // the ReferenceRasterizer object and cannot have variable global state.
  19. //
  20. //-----------------------------------------------------------------------------
  21. class RRAttribFuncStatic
  22. {
  23. private:
  24. RRPrimType m_PrimType;
  25. // per-primitive data
  26. FLOAT m_fX0, m_fY0; // first vertex (for initial evaluation)
  27. FLOAT m_fRHW0, m_fRHW1, m_fRHW2; // 1/W data for perspective correction
  28. FLOAT m_fRHQW0[D3DHAL_TSS_MAXSTAGES]; // Q/W data for texture perspective correction
  29. FLOAT m_fRHQW1[D3DHAL_TSS_MAXSTAGES];
  30. FLOAT m_fRHQW2[D3DHAL_TSS_MAXSTAGES];
  31. FLOAT m_fDelX10, m_fDelX02; // x,y deltas
  32. FLOAT m_fDelY01, m_fDelY20; //
  33. FLOAT m_fTriOODet; // 1/determinant for triangle function normalization
  34. FLOAT m_fLineMajorLength; // major length for line function
  35. BOOL m_bLineXMajor; // TRUE if X major for line function
  36. FLOAT m_fRHWA, m_fRHWB, m_fRHWC; // linear function for 1/W
  37. INT32 m_cTextureStages;
  38. FLOAT m_fRHQWA[D3DHAL_TSS_MAXSTAGES]; // linear function for texture Q/W
  39. FLOAT m_fRHQWB[D3DHAL_TSS_MAXSTAGES];
  40. FLOAT m_fRHQWC[D3DHAL_TSS_MAXSTAGES];
  41. // per-pixel data
  42. INT16 m_iX, m_iY;
  43. FLOAT m_fPixelW;
  44. FLOAT m_fPixelQW[D3DHAL_TSS_MAXSTAGES];
  45. friend class RRAttribFunc;
  46. public:
  47. // Set/Get Per-primitive Data
  48. void SetPerTriangleData(
  49. FLOAT fX0, FLOAT fY0, FLOAT fRHW0,
  50. FLOAT fX1, FLOAT fY1, FLOAT fRHW1,
  51. FLOAT fX2, FLOAT fY2, FLOAT fRHW2,
  52. INT32 cTextureStages,
  53. FLOAT* pfRHQW,
  54. FLOAT fDet );
  55. void SetPerLineData(
  56. FLOAT fX0, FLOAT fY0, FLOAT fRHW0,
  57. FLOAT fX1, FLOAT fY1, FLOAT fRHW1,
  58. INT32 cTextureStages,
  59. FLOAT* pfRHQW,
  60. FLOAT fMajorExtent, BOOL bXMajor );
  61. void SetPerPixelData( INT16 iX, INT16 iY );
  62. FLOAT GetPixelW( void );
  63. FLOAT GetPixelQW( INT32 iStage );
  64. FLOAT GetRhqwXGradient( INT32 iStage );
  65. FLOAT GetRhqwYGradient( INT32 iStage );
  66. };
  67. //-----------------------------------------------------------------------------
  68. //
  69. // Primitive attribute function - Stores linear function of form
  70. // `F = A*x + B*y + C' computed during setup and used to compute primitive
  71. // attributes at each pixel location. One of these is used per scalar vertex
  72. // attribute (i.e. one per Red,Green,Blue,Alpha,Z, ...)
  73. //
  74. //-----------------------------------------------------------------------------
  75. class RRAttribFunc
  76. {
  77. private:
  78. // pointer to static data structure
  79. RRAttribFuncStatic* m_pSD;
  80. // attribute function
  81. FLOAT m_fA;
  82. FLOAT m_fB;
  83. FLOAT m_fC;
  84. // flags
  85. BOOL m_bIsPerspective;
  86. public:
  87. void SetStaticDataPointer( RRAttribFuncStatic* pSD ) { m_pSD = pSD; }
  88. // DEFINE
  89. void SetConstant( FLOAT fVal );
  90. void SetLinearFunc( FLOAT fVal0, FLOAT fVal1, FLOAT fVal2 );
  91. void SetPerspFunc( FLOAT fVal0, FLOAT fVal1, FLOAT fVal2 );
  92. void SetPerspFunc( FLOAT fVal0, FLOAT fVal1, FLOAT fVal2, BOOL bWrap, BOOL bIsShadowMap );
  93. FLOAT GetXGradient( void ) { return m_fA; }
  94. FLOAT GetYGradient( void ) { return m_fB; }
  95. // EVALUATE
  96. FLOAT Eval( void );
  97. FLOAT Eval( INT32 iStage );
  98. };
  99. //////////////////////////////////////////////////////////////////////////////
  100. #endif // _ATTRFUNC_HPP