Dbg.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include <AnKi/Gr.h>
  8. #include <AnKi/Util/Enum.h>
  9. #include <AnKi/Renderer/RenderQueue.h>
  10. namespace anki
  11. {
  12. /// @addtogroup renderer
  13. /// @{
  14. /// Debugging stage
  15. class Dbg : public RendererObject
  16. {
  17. public:
  18. Dbg(Renderer* r);
  19. ~Dbg();
  20. ANKI_USE_RESULT Error init(const ConfigSet& initializer);
  21. /// Populate the rendergraph.
  22. void populateRenderGraph(RenderingContext& ctx);
  23. RenderTargetHandle getRt() const
  24. {
  25. return m_runCtx.m_rt;
  26. }
  27. Bool getEnabled() const
  28. {
  29. return m_enabled;
  30. }
  31. void setEnabled(Bool e)
  32. {
  33. m_enabled = e;
  34. }
  35. Bool getDepthTestEnabled() const
  36. {
  37. return m_debugDrawFlags.get(RenderQueueDebugDrawFlag::DEPTH_TEST_ON);
  38. }
  39. void setDepthTestEnabled(Bool enable)
  40. {
  41. m_debugDrawFlags.set(RenderQueueDebugDrawFlag::DEPTH_TEST_ON, enable);
  42. }
  43. void switchDepthTestEnabled()
  44. {
  45. m_debugDrawFlags.flip(RenderQueueDebugDrawFlag::DEPTH_TEST_ON);
  46. }
  47. Bool getDitheredDepthTestEnabled() const
  48. {
  49. return m_debugDrawFlags.get(RenderQueueDebugDrawFlag::DITHERED_DEPTH_TEST_ON);
  50. }
  51. void setDitheredDepthTestEnabled(Bool enable)
  52. {
  53. m_debugDrawFlags.set(RenderQueueDebugDrawFlag::DITHERED_DEPTH_TEST_ON, enable);
  54. }
  55. void switchDitheredDepthTestEnabled()
  56. {
  57. m_debugDrawFlags.flip(RenderQueueDebugDrawFlag::DITHERED_DEPTH_TEST_ON);
  58. }
  59. private:
  60. Bool m_enabled = false;
  61. Bool m_initialized = false; ///< Lazily initialize.
  62. RenderTargetDescription m_rtDescr;
  63. FramebufferDescription m_fbDescr;
  64. BitSet<U(RenderQueueDebugDrawFlag::COUNT), U32> m_debugDrawFlags = {false};
  65. class
  66. {
  67. public:
  68. RenderTargetHandle m_rt;
  69. RenderingContext* m_ctx = nullptr;
  70. } m_runCtx;
  71. ANKI_USE_RESULT Error lazyInit();
  72. void run(RenderPassWorkContext& rgraphCtx, const RenderingContext& ctx);
  73. };
  74. /// @}
  75. } // end namespace anki