DepthDownscale.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Renderer/RendererObject.h>
  7. #include <AnKi/Gr.h>
  8. #include <AnKi/Resource/ImageResource.h>
  9. namespace anki {
  10. /// @addtogroup renderer
  11. /// @{
  12. /// Downscales the depth buffer a few times.
  13. class DepthDownscale : public RendererObject
  14. {
  15. public:
  16. static constexpr TextureSubresourceDesc kQuarterInternalResolution = TextureSubresourceDesc::surface(0, 0, 0);
  17. static constexpr TextureSubresourceDesc kEighthInternalResolution = TextureSubresourceDesc::surface(1, 0, 0);
  18. DepthDownscale() = default;
  19. ~DepthDownscale();
  20. Error init();
  21. /// Populate the rendergraph.
  22. void populateRenderGraph(RenderingContext& ctx);
  23. /// Return a FP color render target with hierarchical Z (min Z) in it's mips.
  24. RenderTargetHandle getRt() const
  25. {
  26. return m_runCtx.m_rt;
  27. }
  28. U8 getMipmapCount() const
  29. {
  30. return m_mipCount;
  31. }
  32. private:
  33. RenderTargetDesc m_rtDescr;
  34. ShaderProgramResourcePtr m_prog;
  35. ShaderProgramPtr m_grProg;
  36. BufferPtr m_counterBuffer;
  37. U8 m_mipCount = 0;
  38. class
  39. {
  40. public:
  41. RenderTargetHandle m_rt;
  42. } m_runCtx; ///< Run context.
  43. Error initInternal();
  44. };
  45. /// @}
  46. } // end namespace anki