BsRenderTargets.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "BsRenderBeastPrerequisites.h"
  3. #include "BsPixelUtil.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Allocates and handles all the required render targets
  8. * for rendering a scene from a specific viewport.
  9. *
  10. * @note Core thread only.
  11. */
  12. class BS_BSRND_EXPORT RenderTargets
  13. {
  14. public:
  15. /**
  16. * @brief Creates a new set of render targets. This will not actually allocate
  17. * the internal render targets - this happens the first time you call ::bind.
  18. *
  19. * @param viewport Viewport that the render targets will be used for. Determines size of the
  20. * render targets.
  21. * @param hdr Should the render targets support high dynamic range rendering.
  22. * @param numSamples Number of samples to use if multisampling is active. Provide 0 or 1 if
  23. * multisampled targets are not needed.
  24. */
  25. static SPtr<RenderTargets> create(const ViewportCore& viewport, bool hdr, UINT32 numSamples);
  26. /**
  27. * @brief Binds the render targets for rendering. This will also allocate the render
  28. * targets if they aren't already allocated.
  29. */
  30. void bind();
  31. /**
  32. * @brief Frees the render targets so they may be used by another set of render targets. This
  33. * will not release the render target memory. Memory will only released once all
  34. * RenderTarget instances pointing to the render target go out of scope.
  35. */
  36. void unbind();
  37. private:
  38. RenderTargets(const ViewportCore& viewport, bool hdr, UINT32 numSamples);
  39. SPtr<PooledRenderTexture> mDiffuseRT;
  40. SPtr<PooledRenderTexture> mNormalRT;
  41. SPtr<PooledRenderTexture> mDepthRT;
  42. SPtr<MultiRenderTextureCore> mGBuffer;
  43. UINT32 mWidth;
  44. UINT32 mHeight;
  45. PixelFormat mDiffuseFormat;
  46. PixelFormat mNormalFormat;
  47. UINT32 mNumSamples;
  48. };
  49. }