DownscaleBlur.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright (C) 2009-2021, 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. namespace anki {
  8. /// @addtogroup renderer
  9. /// @{
  10. /// Downsample the IS and blur it at the same time.
  11. class DownscaleBlur : public RendererObject
  12. {
  13. public:
  14. DownscaleBlur(Renderer* r)
  15. : RendererObject(r)
  16. {
  17. }
  18. ~DownscaleBlur();
  19. ANKI_USE_RESULT Error init(const ConfigSet& cfg);
  20. /// Import render targets
  21. void importRenderTargets(RenderingContext& ctx);
  22. /// Populate the rendergraph.
  23. void populateRenderGraph(RenderingContext& ctx);
  24. U32 getPassWidth(U32 pass) const
  25. {
  26. return m_rtTex->getWidth() >> min(pass, m_passCount - 1);
  27. }
  28. U32 getPassHeight(U32 pass) const
  29. {
  30. return m_rtTex->getHeight() >> min(pass, m_passCount - 1);
  31. }
  32. U32 getMipmapCount() const
  33. {
  34. return m_passCount;
  35. }
  36. RenderTargetHandle getRt() const
  37. {
  38. return m_runCtx.m_rt;
  39. }
  40. private:
  41. static const Bool m_useCompute = true;
  42. Array<U32, 2> m_workgroupSize = {0, 0};
  43. U32 m_passCount = 0; ///< It's also the mip count of the m_rtTex.
  44. TexturePtr m_rtTex;
  45. DynamicArray<FramebufferDescription> m_fbDescrs;
  46. ShaderProgramResourcePtr m_prog;
  47. ShaderProgramPtr m_grProg;
  48. class
  49. {
  50. public:
  51. RenderTargetHandle m_rt;
  52. } m_runCtx;
  53. ANKI_USE_RESULT Error initInternal(const ConfigSet& cfg);
  54. ANKI_USE_RESULT Error initSubpass(U idx, const UVec2& inputTexSize);
  55. void run(U32 passIdx, RenderPassWorkContext& rgraphCtx);
  56. };
  57. /// @}
  58. } // end namespace anki