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.

131 lines
4.5 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995-2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: vshader.h
  6. * Content: Direct3D Vertex Shader header
  7. *
  8. *
  9. ***************************************************************************/
  10. #ifndef _VSHADER_H
  11. #define _VSHADER_H
  12. //---------------------------------------------------------------------
  13. // Forward defines
  14. //---------------------------------------------------------------------
  15. class RDVShaderCode;
  16. //---------------------------------------------------------------------
  17. // Constants
  18. //---------------------------------------------------------------------
  19. // Register sets
  20. const DWORD RD_MAX_NUMINPUTREG = 16;
  21. const DWORD RD_MAX_NUMTMPREG = 12;
  22. const DWORD RD_MAX_NUMCONSTREG = 96;
  23. const DWORD RD_MAX_NUMADDRREG = 1;
  24. const DWORD RD_MAX_NUMCOLREG = 2;
  25. const DWORD RD_MAX_NUMTEXREG = 8;
  26. // The version of the Vertex shader supported in Reference Device.
  27. const DWORD RDVS_CODEMAJORVERSION = 1;
  28. const DWORD RDVS_CODEMINORVERSION = 0;
  29. const DWORD RDVS_CODEVERSIONTOKEN = D3DPS_VERSION( RDVS_CODEMAJORVERSION,
  30. RDVS_CODEMINORVERSION );
  31. //---------------------------------------------------------------------
  32. //
  33. // RDVVMREG: Register set of the Reference Rasterizer Vertex
  34. // virtual machine.
  35. //
  36. //---------------------------------------------------------------------
  37. struct RDVVMREG
  38. {
  39. RDVECTOR4 m_i[RD_MAX_NUMINPUTREG];
  40. RDVECTOR4 m_t[RD_MAX_NUMTMPREG];
  41. RDVECTOR4 m_c[RD_MAX_NUMCONSTREG];
  42. RDVECTOR4 m_a[RD_MAX_NUMADDRREG];
  43. // Output registers
  44. RDVECTOR4 m_out[3];
  45. RDVECTOR4 m_col[RD_MAX_NUMCOLREG];
  46. RDVECTOR4 m_tex[RD_MAX_NUMTEXREG];
  47. };
  48. //-----------------------------------------------------------------------------
  49. //
  50. // RefVM
  51. // Vertex Virtual Machine object
  52. //
  53. //-----------------------------------------------------------------------------
  54. class RefDev;
  55. class RefVM
  56. {
  57. public:
  58. RefVM() { memset( this, 0, sizeof( this ) ); }
  59. ~RefVM(){};
  60. RDVVMREG* GetRegisters(){ return &m_reg; }
  61. // Parses binary shader representation, compiles is and returns
  62. // compiled object
  63. RDVShaderCode* CompileCode( DWORD dwSize, LPDWORD pBits );
  64. HRESULT SetActiveShaderCode( RDVShaderCode* pCode )
  65. { m_pCurrentShaderCode = pCode; return S_OK; }
  66. RDVShaderCode* GetActiveShaderCode() {return m_pCurrentShaderCode;}
  67. HRESULT ExecuteShader(RefDev* pRD);
  68. // HRESULT GetDataPointer(DWORD dwMemType, VVM_WORD ** pData);
  69. // Set internal registers to user data
  70. HRESULT SetData(DWORD RegType, DWORD start, DWORD count, LPVOID buffer);
  71. // Get data from internal registers
  72. HRESULT GetData(DWORD RegType, DWORD start, DWORD count, LPVOID buffer);
  73. inline RDVECTOR4* GetDataAddr( DWORD dwRegType, DWORD dwElementIndex );
  74. inline UINT GetCurrentInstIndex( void ) { return m_CurInstIndex; }
  75. protected:
  76. inline void InstMov();
  77. inline void InstAdd();
  78. inline void InstMad();
  79. inline void InstMul();
  80. inline void InstRcp();
  81. inline void InstRsq();
  82. inline void InstDP3();
  83. inline void InstDP4();
  84. inline void InstMin();
  85. inline void InstMax();
  86. inline void InstSlt();
  87. inline void InstSge();
  88. inline void InstExp();
  89. inline void InstLog();
  90. inline void InstExpP();
  91. inline void InstLogP();
  92. inline void InstLit();
  93. inline void InstDst();
  94. inline void InstFrc();
  95. inline void InstM4x4();
  96. inline void InstM4x3();
  97. inline void InstM3x4();
  98. inline void InstM3x3();
  99. inline void InstM3x2();
  100. inline void WriteResult();
  101. inline HRESULT SetDestReg();
  102. inline HRESULT SetSrcReg( DWORD index );
  103. inline HRESULT SetSrcReg( DWORD index, DWORD count );
  104. RDVVMREG m_reg; // Virtual machine reg set
  105. RDVShaderCode* m_pCurrentShaderCode; // Current shader
  106. DWORD* m_pCurToken; // Current token during parsing
  107. DWORD m_dwRegOffset; // Offset in the register file for
  108. // destination operand
  109. DWORD m_WriteMask; // Write mask for destination operand
  110. UINT m_CurInstIndex; // Current instruction index
  111. RDVECTOR4* m_pDest; // Pointer to destination operand
  112. RDVECTOR4 m_Source[5]; // Source operands
  113. RDVECTOR4 m_TmpReg; // Temporary register for the first
  114. // The pointer to the driver object to obtain state
  115. RefDev* m_pDev;
  116. friend class RefDev;
  117. };
  118. #endif //_VSHADER_H