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.

105 lines
4.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef ISHADER_H
  9. #define ISHADER_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. //==================================================================================================
  14. // **this goes into both platforms which run the translator, either the real Mac client or
  15. // the Windows client running with r_emulategl mode **
  16. //
  17. // size of the VS register bank in ARB / GLSL we expose
  18. // it's not 256, because you can't use all 256 slots in 10.5.x.
  19. // use this constant everywhere you might normally use "256" in reference to a parameter array size.
  20. // The highest shader constant is c218, plus we allocate c219 and c220 for two clip planes
  21. #define DXABSTRACT_VS_PARAM_SLOTS 228
  22. #define DXABSTRACT_VS_FIRST_BONE_SLOT VERTEX_SHADER_MODEL
  23. #define DXABSTRACT_VS_LAST_BONE_SLOT (VERTEX_SHADER_SHADER_SPECIFIC_CONST_13-1)
  24. // user clip plane 0 goes in DXABSTRACT_VS_CLIP_PLANE_BASE... plane 1 goes in the slot after that
  25. // dxabstract uses these constants to check plane index limit and to deliver planes to shader for DP4 -> oCLP[n]
  26. #define DXABSTRACT_VS_CLIP_PLANE_BASE (DXABSTRACT_VS_PARAM_SLOTS-2)
  27. //==================================================================================================
  28. #include "materialsystem/imaterialsystem.h"
  29. #include "materialsystem/ishaderapi.h"
  30. #include "materialsystem/ishadersystem_declarations.h"
  31. //-----------------------------------------------------------------------------
  32. // forward declarations
  33. //-----------------------------------------------------------------------------
  34. class IMaterialVar;
  35. class IShaderShadow;
  36. class IShaderDynamicAPI;
  37. class IShaderInit;
  38. class CBasePerMaterialContextData;
  39. //-----------------------------------------------------------------------------
  40. // Information about each shader parameter
  41. //-----------------------------------------------------------------------------
  42. struct ShaderParamInfo_t
  43. {
  44. const char *m_pName;
  45. const char *m_pHelp;
  46. ShaderParamType_t m_Type;
  47. const char *m_pDefaultValue;
  48. int m_nFlags;
  49. };
  50. #define VERTEX_SHADER_BONE_TRANSFORM( k ) ( VERTEX_SHADER_MODEL + 3 * (k) )
  51. // The public methods exposed by each shader
  52. //-----------------------------------------------------------------------------
  53. abstract_class IShader
  54. {
  55. public:
  56. // Returns the shader name
  57. virtual char const* GetName( ) const = 0;
  58. // returns the shader fallbacks
  59. virtual char const* GetFallbackShader( IMaterialVar** params ) const = 0;
  60. // Shader parameters
  61. virtual int GetNumParams( ) const = 0;
  62. // These functions must be implemented by the shader
  63. virtual void InitShaderParams( IMaterialVar** ppParams, const char *pMaterialName ) = 0;
  64. virtual void InitShaderInstance( IMaterialVar** ppParams, IShaderInit *pShaderInit, const char *pMaterialName, const char *pTextureGroupName ) = 0;
  65. virtual void DrawElements( IMaterialVar **params, int nModulationFlags,
  66. IShaderShadow* pShaderShadow, IShaderDynamicAPI* pShaderAPI, VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr ) = 0;
  67. virtual char const* GetParamName( int paramIndex ) const = 0;
  68. virtual char const* GetParamHelp( int paramIndex ) const = 0;
  69. virtual ShaderParamType_t GetParamType( int paramIndex ) const = 0;
  70. virtual char const* GetParamDefault( int paramIndex ) const = 0;
  71. // FIXME: Figure out a better way to do this?
  72. virtual int ComputeModulationFlags( IMaterialVar** params, IShaderDynamicAPI* pShaderAPI ) = 0;
  73. virtual bool NeedsPowerOfTwoFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame = true ) const = 0;
  74. virtual bool NeedsFullFrameBufferTexture( IMaterialVar **params, bool bCheckSpecificToThisFrame ) const = 0;
  75. virtual bool IsTranslucent( IMaterialVar **params ) const = 0;
  76. virtual int GetParamFlags( int paramIndex ) const = 0;
  77. virtual int GetFlags() const = 0;
  78. // FIXME: Remove GetParamName, etc. above
  79. // virtual const ShaderParamInfo_t& GetParamInfo( int paramIndex ) const = 0;
  80. };
  81. #endif // ISHADER_H