CmPass.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 CamelotFramework
  8. {
  9. /** Class defining a single pass of a Technique (of a Material), i.e.
  10. a single rendering call.
  11. @remarks
  12. Rendering can be repeated with many passes for more complex effects.
  13. Each pass is a programmable pass (meaning it does
  14. use either a vertex and fragment program, or both).
  15. */
  16. class CM_EXPORT Pass : public IReflectable
  17. {
  18. protected:
  19. HBlendState mBlendState;
  20. HRasterizerState mRasterizerState;
  21. HDepthStencilState mDepthStencilState;
  22. UINT32 mStencilRefValue;
  23. HGpuProgram mVertexProgram;
  24. HGpuProgram mFragmentProgram;
  25. HGpuProgram mGeometryProgram;
  26. HGpuProgram mHullProgram;
  27. HGpuProgram mDomainProgram;
  28. HGpuProgram mComputeProgram;
  29. public:
  30. /// Default constructor
  31. Pass();
  32. /// Copy constructor
  33. Pass(const Pass& oth );
  34. /// Operator = overload
  35. Pass& operator=(const Pass& oth);
  36. virtual ~Pass();
  37. bool hasVertexProgram() const { return mVertexProgram != nullptr; }
  38. bool hasFragmentProgram() const { return mFragmentProgram != nullptr; }
  39. bool hasGeometryProgram() const { return mGeometryProgram != nullptr; }
  40. bool hasHullProgram() const { return mHullProgram != nullptr; }
  41. bool hasDomainProgram() const { return mDomainProgram != nullptr; }
  42. bool hasComputeProgram() const { return mComputeProgram != nullptr; }
  43. /** Returns true if this pass has some element of transparency. */
  44. bool isTransparent(void) const;
  45. /**
  46. * @brief Sets a blend state used for all active render targets.
  47. */
  48. void setBlendState(HBlendState& blendState);
  49. HBlendState getBlendState() const;
  50. void setRasterizerState(HRasterizerState& rasterizerState);
  51. HRasterizerState getRasterizerState() const;
  52. void setDepthStencilState(HDepthStencilState& depthStencilState);
  53. HDepthStencilState getDepthStencilState() const;
  54. void setStencilRefValue(UINT32 refValue);
  55. UINT32 getStencilRefValue() const;
  56. /** Sets the details of the vertex program to use.
  57. */
  58. void setVertexProgram(HGpuProgram gpuProgram) { mVertexProgram = gpuProgram; }
  59. /** Gets the vertex program used by this pass. */
  60. const HGpuProgram& getVertexProgram(void) const { return mVertexProgram; }
  61. /** Sets the details of the fragment program to use.
  62. */
  63. void setFragmentProgram(HGpuProgram gpuProgram) { mFragmentProgram = gpuProgram; }
  64. /** Gets the fragment program used by this pass. */
  65. const HGpuProgram& getFragmentProgram(void) const { return mFragmentProgram; }
  66. /** Sets the details of the geometry program to use.
  67. */
  68. void setGeometryProgram(HGpuProgram gpuProgram) { mGeometryProgram = gpuProgram; }
  69. /** Gets the geometry program used by this pass. */
  70. const HGpuProgram& getGeometryProgram(void) const { return mGeometryProgram; }
  71. /** Sets the details of the hull program to use.
  72. */
  73. void setHullProgram(HGpuProgram gpuProgram) { mHullProgram = gpuProgram; }
  74. /** Gets the hull program used by this pass. */
  75. const HGpuProgram& getHullProgram(void) const { return mHullProgram; }
  76. /** Sets the details of the domain program to use.
  77. */
  78. void setDomainProgram(HGpuProgram gpuProgram) { mDomainProgram = gpuProgram;}
  79. /** Gets the domain program used by this pass. */
  80. const HGpuProgram& getDomainProgram(void) const { return mDomainProgram; }
  81. /** Sets the details of the compute program to use.
  82. */
  83. void setComputeProgram(HGpuProgram gpuProgram) { mComputeProgram = gpuProgram; }
  84. /** Gets the compute program used by this pass. */
  85. const HGpuProgram& getComputeProgram(void) const { return mComputeProgram; }
  86. /**
  87. * @brief Makes this pass active. Anything rendered after this command will use this pass.
  88. */
  89. void activate(CoreAccessor& coreAccessor) const;
  90. /**
  91. * @brief Applies specified parameters to the active pass.
  92. */
  93. void bindParameters(CoreAccessor& coreAccessor, const PassParametersPtr& params) const;
  94. /************************************************************************/
  95. /* RTTI */
  96. /************************************************************************/
  97. public:
  98. friend class PassRTTI;
  99. static RTTITypeBase* getRTTIStatic();
  100. virtual RTTITypeBase* getRTTI() const;
  101. };
  102. }