BsRenderStateManager.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. /**
  97. * @brief Gets a sampler state initialized with default options.
  98. */
  99. const SPtr<SamplerStateCore>& getDefaultSamplerState() const;
  100. /**
  101. * @brief Gets a blend state initialized with default options.
  102. */
  103. const SPtr<BlendStateCore>& getDefaultBlendState() const;
  104. /**
  105. * @brief Gets a rasterizer state initialized with default options.
  106. */
  107. const SPtr<RasterizerStateCore>& getDefaultRasterizerState() const;
  108. /**
  109. * @brief Gets a depth stencil state initialized with default options.
  110. */
  111. const SPtr<DepthStencilStateCore>& getDefaultDepthStencilState() const;
  112. private:
  113. mutable SPtr<SamplerStateCore> mDefaultSamplerState;
  114. mutable SPtr<BlendStateCore> mDefaultBlendState;
  115. mutable SPtr<RasterizerStateCore> mDefaultRasterizerState;
  116. mutable SPtr<DepthStencilStateCore> mDefaultDepthStencilState;
  117. protected:
  118. friend class SamplerState;
  119. friend class BlendState;
  120. friend class RasterizerState;
  121. friend class DepthStencilState;
  122. /**
  123. * @copydoc createSamplerState
  124. */
  125. virtual SPtr<SamplerStateCore> createSamplerStateInternal(const SAMPLER_STATE_DESC& desc) const;
  126. /**
  127. * @copydoc createBlendState
  128. */
  129. virtual SPtr<BlendStateCore> createBlendStateInternal(const BLEND_STATE_DESC& desc) const;
  130. /**
  131. * @copydoc createRasterizerState
  132. */
  133. virtual SPtr<RasterizerStateCore> createRasterizerStateInternal(const RASTERIZER_STATE_DESC& desc) const;
  134. /**
  135. * @copydoc createDepthStencilState
  136. */
  137. virtual SPtr<DepthStencilStateCore> createDepthStencilStateInternal(const DEPTH_STENCIL_STATE_DESC& desc) const;
  138. };
  139. }