CmPass.h 3.5 KB

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