Counter Strike : Global Offensive Source Code
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.

150 lines
5.6 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef ISHADERUTIL_H
  9. #define ISHADERUTIL_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "materialsystem/imaterial.h"
  14. #include "appframework/iappsystem.h"
  15. #include "shaderapi/ishaderapi.h"
  16. //-----------------------------------------------------------------------------
  17. // forward declarations
  18. //-----------------------------------------------------------------------------
  19. class ITexture;
  20. struct MaterialSystem_Config_t;
  21. struct ImageFormatInfo_t;
  22. enum Sampler_t;
  23. enum VertexTextureSampler_t;
  24. enum StandardTextureId_t;
  25. class CPrimList;
  26. struct ShaderColorCorrectionInfo_t;
  27. #define SHADER_UTIL_INTERFACE_VERSION "VShaderUtil001"
  28. enum shaderthreadevent_t
  29. {
  30. SHADER_THREAD_RELEASE_RESOURCES = 1,
  31. SHADER_THREAD_ACQUIRE_RESOURCES = 2,
  32. SHADER_THREAD_DEVICE_LOST = 3,
  33. SHADER_THREAD_EVICT_RESOURCES = 4,
  34. SHADER_THREAD_OTHER_APP_START = 5,
  35. SHADER_THREAD_OTHER_APP_END = 6,
  36. SHADER_THREAD_RESET_RENDER_STATE = 7,
  37. };
  38. abstract_class IShaderUtil : public IAppSystem
  39. {
  40. public:
  41. // Method to allow clients access to the MaterialSystem_Config
  42. virtual MaterialSystem_Config_t& GetConfig() = 0;
  43. // Allows us to convert image formats
  44. virtual bool ConvertImageFormat( unsigned char *src, enum ImageFormat srcImageFormat,
  45. unsigned char *dst, enum ImageFormat dstImageFormat,
  46. int width, int height, int srcStride = 0, int dstStride = 0 ) = 0;
  47. // Figures out the amount of memory needed by a bitmap
  48. virtual int GetMemRequired( int width, int height, int depth, ImageFormat format, bool mipmap ) = 0;
  49. // Gets image format info
  50. virtual const ImageFormatInfo_t& ImageFormatInfo( ImageFormat fmt ) const = 0;
  51. // Bind standard textures
  52. virtual void BindStandardTexture( Sampler_t sampler, TextureBindFlags_t nBindFlags, StandardTextureId_t id ) = 0;
  53. #ifdef _PS3
  54. virtual ShaderAPITextureHandle_t GetStandardTexture( StandardTextureId_t id ) = 0;
  55. #endif
  56. // What are the lightmap dimensions?
  57. virtual void GetLightmapDimensions( int *w, int *h ) = 0;
  58. // These methods are called when the shader must eject + restore HW memory
  59. virtual void ReleaseShaderObjects( int nChangeFlags = 0 ) = 0;
  60. virtual void RestoreShaderObjects( CreateInterfaceFn shaderFactory, int nChangeFlags = 0 ) = 0;
  61. // Used to prevent meshes from drawing.
  62. virtual bool IsInStubMode() = 0;
  63. virtual bool InFlashlightMode() const = 0;
  64. virtual bool IsCascadedShadowMapping() const = 0;
  65. // For the shader API to shove the current version of aniso level into the
  66. // "definitive" place (g_config) when the shader API decides to change it.
  67. // Eventually, we should have a better system of who owns the definitive
  68. // versions of config vars.
  69. virtual void NoteAnisotropicLevel( int currentLevel ) = 0;
  70. // NOTE: Stuff after this is added after shipping HL2.
  71. // Are we rendering through the editor?
  72. virtual bool InEditorMode() const = 0;
  73. virtual ITexture *GetRenderTargetEx( int nRenderTargetID ) = 0;
  74. // Tells the material system to draw a buffer clearing quad
  75. virtual void DrawClearBufferQuad( unsigned char r, unsigned char g, unsigned char b, unsigned char a, bool bClearColor, bool bClearAlpha, bool bClearDepth ) = 0;
  76. #ifdef _PS3
  77. virtual void DrawReloadZcullQuad() = 0;
  78. #endif // _PS3
  79. #if defined( _X360 )
  80. virtual void ReadBackBuffer( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *pData, ImageFormat dstFormat, int nDstStride ) = 0;
  81. #endif
  82. // Calls from meshes to material system to handle queing/threading
  83. virtual bool OnDrawMesh( IMesh *pMesh, int firstIndex, int numIndices ) = 0;
  84. virtual bool OnDrawMesh( IMesh *pMesh, CPrimList *pLists, int nLists ) = 0;
  85. virtual bool OnSetFlexMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) = 0;
  86. virtual bool OnSetColorMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) = 0;
  87. virtual bool OnSetPrimitiveType( IMesh *pMesh, MaterialPrimitiveType_t type ) = 0;
  88. virtual void SyncMatrices() = 0;
  89. virtual void SyncMatrix( MaterialMatrixMode_t ) = 0;
  90. virtual void BindStandardVertexTexture( VertexTextureSampler_t sampler, StandardTextureId_t id ) = 0;
  91. virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id ) = 0;
  92. virtual int MaxHWMorphBatchCount() const = 0;
  93. // Interface for mat system to tell shaderapi about color correction
  94. virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo ) = 0;
  95. // Gets texture handles for ITextures
  96. virtual ShaderAPITextureHandle_t GetShaderAPITextureBindHandle( ITexture *pTexture, int nFrame, int nTextureChannel ) = 0;
  97. virtual float GetSubDHeight() = 0;
  98. virtual bool OnDrawMeshModulated( IMesh *pMesh, const Vector4D &diffuseModulation, int firstIndex, int numIndices ) = 0;
  99. // received an event while not in owning thread, handle this outside
  100. virtual void OnThreadEvent( uint32 threadEvent ) = 0;
  101. virtual MaterialThreadMode_t GetThreadMode() = 0;
  102. virtual bool IsRenderThreadSafe( ) = 0;
  103. // Remove any materials from memory that aren't in use as determined
  104. // by the IMaterial's reference count.
  105. virtual void UncacheUnusedMaterials( bool bRecomputeStateSnapshots = false ) = 0;
  106. virtual bool IsInFrame( ) const = 0;
  107. // Returns the texture for a particular lightmap page
  108. virtual ShaderAPITextureHandle_t GetLightmapTexture( ShaderAPITextureHandle_t nLightmapPage ) = 0;
  109. virtual bool IsRenderingPaint() const = 0;
  110. virtual ShaderAPITextureHandle_t GetPaintmapTexture( ShaderAPITextureHandle_t nLightmapPage ) = 0;
  111. virtual ShaderAPITextureHandle_t GetStandardTexture( StandardTextureId_t id ) = 0;
  112. };
  113. #endif // ISHADERUTIL_H