BsRenderStateManager.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Handles creation of various render states.
  8. */
  9. class BS_CORE_EXPORT RenderStateManager : public Module <RenderStateManager>
  10. {
  11. public:
  12. /**
  13. * @brief Creates and initializes a new SamplerState.
  14. */
  15. SamplerStatePtr createSamplerState(const SAMPLER_STATE_DESC& desc) const;
  16. /**
  17. * @brief Creates and initializes a new DepthStencilState.
  18. */
  19. DepthStencilStatePtr createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
  20. /**
  21. * @brief Creates and initializes a new RasterizerState.
  22. */
  23. RasterizerStatePtr createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
  24. /**
  25. * @brief Creates and initializes a new BlendState.
  26. */
  27. BlendStatePtr createBlendState(const BLEND_STATE_DESC& desc) const;
  28. /**
  29. * @brief Creates a completely empty and uninitialized SamplerState.
  30. * Should only be used for VERY specific purposes, like deserialization,
  31. * as it requires additional manual initialization that is not required normally.
  32. */
  33. SamplerStatePtr createEmptySamplerState() const;
  34. /**
  35. * @brief Creates a completely empty and uninitialized DepthStencilState.
  36. * Should only be used for VERY specific purposes, like deserialization,
  37. * as it requires additional manual initialization that is not required normally.
  38. */
  39. DepthStencilStatePtr createEmptyDepthStencilState() const;
  40. /**
  41. * @brief Creates a completely empty and uninitialized RasterizerState.
  42. * Should only be used for VERY specific purposes, like deserialization,
  43. * as it requires additional manual initialization that is not required normally.
  44. */
  45. RasterizerStatePtr createEmptyRasterizerState() const;
  46. /**
  47. * @brief Creates a completely empty and uninitialized BlendState.
  48. * Should only be used for VERY specific purposes, like deserialization,
  49. * as it requires additional manual initialization that is not required normally.
  50. */
  51. BlendStatePtr createEmptyBlendState() const;
  52. /**
  53. * @brief Gets a sampler state initialized with default options.
  54. */
  55. const SamplerStatePtr& getDefaultSamplerState() const;
  56. /**
  57. * @brief Gets a blend state initialized with default options.
  58. */
  59. const BlendStatePtr& getDefaultBlendState() const;
  60. /**
  61. * @brief Gets a rasterizer state initialized with default options.
  62. */
  63. const RasterizerStatePtr& getDefaultRasterizerState() const;
  64. /**
  65. * @brief Gets a depth stencil state initialized with default options.
  66. */
  67. const DepthStencilStatePtr& getDefaultDepthStencilState() const;
  68. private:
  69. mutable SamplerStatePtr mDefaultSamplerState;
  70. mutable BlendStatePtr mDefaultBlendState;
  71. mutable RasterizerStatePtr mDefaultRasterizerState;
  72. mutable DepthStencilStatePtr mDefaultDepthStencilState;
  73. };
  74. /**
  75. * @brief Handles creation of various render states.
  76. */
  77. class BS_CORE_EXPORT RenderStateCoreManager : public Module<RenderStateCoreManager>
  78. {
  79. public:
  80. /**
  81. * @copydoc RenderStateManager::createSamplerState
  82. */
  83. SPtr<SamplerStateCore> createSamplerState(const SAMPLER_STATE_DESC& desc) const;
  84. /**
  85. * @copydoc RenderStateManager::createDepthStencilState
  86. */
  87. SPtr<DepthStencilStateCore> createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
  88. /**
  89. * @copydoc RenderStateManager::createRasterizerState
  90. */
  91. SPtr<RasterizerStateCore> createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
  92. /**
  93. * @copydoc RenderStateManager::createBlendState
  94. */
  95. SPtr<BlendStateCore> createBlendState(const BLEND_STATE_DESC& desc) const;
  96. protected:
  97. friend class SamplerState;
  98. friend class BlendState;
  99. friend class RasterizerState;
  100. friend class DepthStencilState;
  101. /**
  102. * @copydoc createSamplerState
  103. */
  104. virtual SPtr<SamplerStateCore> createSamplerStateInternal(const SAMPLER_STATE_DESC& desc) const;
  105. /**
  106. * @copydoc createBlendState
  107. */
  108. virtual SPtr<BlendStateCore> createBlendStateInternal(const BLEND_STATE_DESC& desc) const;
  109. /**
  110. * @copydoc createRasterizerState
  111. */
  112. virtual SPtr<RasterizerStateCore> createRasterizerStateInternal(const RASTERIZER_STATE_DESC& desc) const;
  113. /**
  114. * @copydoc createDepthStencilState
  115. */
  116. virtual SPtr<DepthStencilStateCore> createDepthStencilStateInternal(const DEPTH_STENCIL_STATE_DESC& desc) const;
  117. };
  118. }