BsPass.h 3.7 KB

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