BsPass.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsCoreThreadAccessor.h"
  4. #include "BsColor.h"
  5. #include "BsIReflectable.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Class defining a single pass of a technique (of a material), i.e.
  10. * a single rendering call.
  11. *
  12. * Pass may contain multiple GPU programs (vertex, fragment, geometry, etc.), and
  13. * a set of pipeline states (blend, rasterizer, etc.).
  14. */
  15. class BS_CORE_EXPORT Pass : public IReflectable
  16. {
  17. public:
  18. Pass();
  19. Pass(const Pass& oth);
  20. Pass& operator=(const Pass& oth);
  21. virtual ~Pass();
  22. bool hasVertexProgram() const { return mVertexProgram != nullptr; }
  23. bool hasFragmentProgram() const { return mFragmentProgram != nullptr; }
  24. bool hasGeometryProgram() const { return mGeometryProgram != nullptr; }
  25. bool hasHullProgram() const { return mHullProgram != nullptr; }
  26. bool hasDomainProgram() const { return mDomainProgram != nullptr; }
  27. bool hasComputeProgram() const { return mComputeProgram != nullptr; }
  28. /**
  29. * @brief Returns true if this pass has some element of transparency.
  30. */
  31. bool isTransparent() const;
  32. void setBlendState(HBlendState& blendState);
  33. HBlendState getBlendState() const;
  34. void setRasterizerState(HRasterizerState& rasterizerState);
  35. HRasterizerState getRasterizerState() const;
  36. void setDepthStencilState(HDepthStencilState& depthStencilState);
  37. HDepthStencilState getDepthStencilState() const;
  38. /**
  39. * @brief Sets the stencil reference value that is used when performing operations using the
  40. * stencil buffer.
  41. */
  42. void setStencilRefValue(UINT32 refValue);
  43. /**
  44. * @brief Gets the stencil reference value that is used when performing operations using the
  45. * stencil buffer.
  46. */
  47. UINT32 getStencilRefValue() const;
  48. void setVertexProgram(HGpuProgram gpuProgram) { mVertexProgram = gpuProgram; }
  49. const HGpuProgram& getVertexProgram() const { return mVertexProgram; }
  50. void setFragmentProgram(HGpuProgram gpuProgram) { mFragmentProgram = gpuProgram; }
  51. const HGpuProgram& getFragmentProgram() const { return mFragmentProgram; }
  52. void setGeometryProgram(HGpuProgram gpuProgram) { mGeometryProgram = gpuProgram; }
  53. const HGpuProgram& getGeometryProgram() const { return mGeometryProgram; }
  54. void setHullProgram(HGpuProgram gpuProgram) { mHullProgram = gpuProgram; }
  55. const HGpuProgram& getHullProgram(void) const { return mHullProgram; }
  56. void setDomainProgram(HGpuProgram gpuProgram) { mDomainProgram = gpuProgram;}
  57. const HGpuProgram& getDomainProgram(void) const { return mDomainProgram; }
  58. void setComputeProgram(HGpuProgram gpuProgram) { mComputeProgram = gpuProgram; }
  59. const HGpuProgram& getComputeProgram(void) const { return mComputeProgram; }
  60. protected:
  61. HBlendState mBlendState;
  62. HRasterizerState mRasterizerState;
  63. HDepthStencilState mDepthStencilState;
  64. UINT32 mStencilRefValue;
  65. HGpuProgram mVertexProgram;
  66. HGpuProgram mFragmentProgram;
  67. HGpuProgram mGeometryProgram;
  68. HGpuProgram mHullProgram;
  69. HGpuProgram mDomainProgram;
  70. HGpuProgram mComputeProgram;
  71. /************************************************************************/
  72. /* RTTI */
  73. /************************************************************************/
  74. public:
  75. friend class PassRTTI;
  76. static RTTITypeBase* getRTTIStatic();
  77. virtual RTTITypeBase* getRTTI() const;
  78. };
  79. }