Team Fortress 2 Source Code as on 22/4/2020
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.

176 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef SHADERSHADOWDX8_H
  9. #define SHADERSHADOWDX8_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "togl/rendermechanism.h"
  14. #include "locald3dtypes.h"
  15. #include "shaderapi/ishadershadow.h"
  16. class IShaderAPIDX8;
  17. //-----------------------------------------------------------------------------
  18. // Important enumerations
  19. //-----------------------------------------------------------------------------
  20. enum
  21. {
  22. MAX_SAMPLERS = 16,
  23. MAX_TEXTURE_STAGES = 16,
  24. };
  25. //-----------------------------------------------------------------------------
  26. // A structure maintaining the shadowed board state
  27. //-----------------------------------------------------------------------------
  28. struct TextureStageShadowState_t
  29. {
  30. // State shadowing affects these
  31. D3DTEXTUREOP m_ColorOp;
  32. int m_ColorArg1;
  33. int m_ColorArg2;
  34. D3DTEXTUREOP m_AlphaOp;
  35. int m_AlphaArg1;
  36. int m_AlphaArg2;
  37. int m_TexCoordIndex;
  38. };
  39. struct SamplerShadowState_t
  40. {
  41. bool m_TextureEnable : 1;
  42. bool m_SRGBReadEnable : 1;
  43. bool m_Fetch4Enable : 1;
  44. bool m_ShadowFilterEnable : 1;
  45. };
  46. struct ShadowState_t
  47. {
  48. // Depth buffering state
  49. D3DCMPFUNC m_ZFunc;
  50. D3DZBUFFERTYPE m_ZEnable;
  51. // Write enable
  52. DWORD m_ColorWriteEnable;
  53. // Fill mode
  54. D3DFILLMODE m_FillMode;
  55. // Alpha state
  56. D3DBLEND m_SrcBlend;
  57. D3DBLEND m_DestBlend;
  58. D3DBLENDOP m_BlendOp;
  59. // Separate alpha blend state
  60. D3DBLEND m_SrcBlendAlpha;
  61. D3DBLEND m_DestBlendAlpha;
  62. D3DBLENDOP m_BlendOpAlpha;
  63. D3DCMPFUNC m_AlphaFunc;
  64. int m_AlphaRef;
  65. // Texture stage state
  66. TextureStageShadowState_t m_TextureStage[MAX_TEXTURE_STAGES];
  67. // Sampler state
  68. SamplerShadowState_t m_SamplerState[MAX_SAMPLERS];
  69. ShaderFogMode_t m_FogMode;
  70. D3DMATERIALCOLORSOURCE m_DiffuseMaterialSource;
  71. unsigned char m_ZWriteEnable:1;
  72. unsigned char m_ZBias:2;
  73. // Cull State?
  74. unsigned char m_CullEnable:1;
  75. // Lighting in hardware?
  76. unsigned char m_Lighting:1;
  77. unsigned char m_SpecularEnable:1;
  78. unsigned char m_AlphaBlendEnable:1;
  79. unsigned char m_AlphaTestEnable:1;
  80. // Fixed function?
  81. unsigned char m_UsingFixedFunction:1;
  82. // Vertex blending?
  83. unsigned char m_VertexBlendEnable:1;
  84. // Auto-convert from linear to gamma upon writing to the frame buffer?
  85. unsigned char m_SRGBWriteEnable:1;
  86. // Seperate Alpha Blend?
  87. unsigned char m_SeparateAlphaBlendEnable:1;
  88. // Stencil?
  89. unsigned char m_StencilEnable:1;
  90. unsigned char m_bDisableFogGammaCorrection:1;
  91. unsigned char m_EnableAlphaToCoverage:1;
  92. unsigned char m_Reserved : 1;
  93. unsigned short m_nReserved2;
  94. };
  95. //-----------------------------------------------------------------------------
  96. // These are part of the "shadow" since they describe the shading algorithm
  97. // but aren't actually captured in the state transition table
  98. // because it would produce too many transitions
  99. //-----------------------------------------------------------------------------
  100. struct ShadowShaderState_t
  101. {
  102. // The vertex + pixel shader group to use...
  103. VertexShader_t m_VertexShader;
  104. PixelShader_t m_PixelShader;
  105. // The static vertex + pixel shader indices
  106. int m_nStaticVshIndex;
  107. int m_nStaticPshIndex;
  108. // Vertex data used by this snapshot
  109. // Note that the vertex format actually used will be the
  110. // aggregate of the vertex formats used by all snapshots in a material
  111. VertexFormat_t m_VertexUsage;
  112. // Morph data used by this snapshot
  113. // Note that the morph format actually used will be the
  114. // aggregate of the morph formats used by all snapshots in a material
  115. MorphFormat_t m_MorphUsage;
  116. // Modulate constant color into the vertex color
  117. bool m_ModulateConstantColor;
  118. bool m_nReserved[3];
  119. };
  120. //-----------------------------------------------------------------------------
  121. // The shader setup API
  122. //-----------------------------------------------------------------------------
  123. abstract_class IShaderShadowDX8 : public IShaderShadow
  124. {
  125. public:
  126. // Initializes it
  127. virtual void Init() = 0;
  128. // Gets at the shadow state
  129. virtual ShadowState_t const& GetShadowState() = 0;
  130. virtual ShadowShaderState_t const& GetShadowShaderState() = 0;
  131. // This must be called right before taking a snapshot
  132. virtual void ComputeAggregateShadowState( ) = 0;
  133. // Class factory methods
  134. static IShaderShadowDX8* Create( IShaderAPIDX8* pShaderAPIDX8 );
  135. static void Destroy( IShaderShadowDX8* pShaderShadow );
  136. };
  137. extern IShaderShadowDX8 *g_pShaderShadowDx8;
  138. #endif // SHADERSHADOWDX8_H