MainRenderer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/Common.h>
  7. #include <AnKi/Resource/Forward.h>
  8. #include <AnKi/Renderer/Renderer.h>
  9. namespace anki {
  10. // Forward
  11. class ResourceManager;
  12. class ConfigSet;
  13. class StagingGpuMemoryPool;
  14. class UiManager;
  15. /// @addtogroup renderer
  16. /// @{
  17. /// MainRenderer statistics.
  18. class MainRendererStats
  19. {
  20. public:
  21. Second m_renderingCpuTime ANKI_DEBUG_CODE(= -1.0);
  22. Second m_renderingGpuTime ANKI_DEBUG_CODE(= -1.0);
  23. Second m_renderingGpuSubmitTimestamp ANKI_DEBUG_CODE(= -1.0);
  24. };
  25. class MainRendererInitInfo
  26. {
  27. public:
  28. UVec2 m_swapchainSize = UVec2(0u);
  29. AllocAlignedCallback m_allocCallback = nullptr;
  30. void* m_allocCallbackUserData = nullptr;
  31. ThreadHive* m_threadHive = nullptr;
  32. ResourceManager* m_resourceManager = nullptr;
  33. GrManager* m_gr = nullptr;
  34. StagingGpuMemoryPool* m_stagingMemory = nullptr;
  35. UiManager* m_ui = nullptr;
  36. ConfigSet* m_config = nullptr;
  37. Timestamp* m_globTimestamp = nullptr;
  38. };
  39. /// Main onscreen renderer
  40. class MainRenderer
  41. {
  42. public:
  43. MainRenderer();
  44. ~MainRenderer();
  45. ANKI_USE_RESULT Error init(const MainRendererInitInfo& inf);
  46. ANKI_USE_RESULT Error render(RenderQueue& rqueue, TexturePtr presentTex);
  47. Dbg& getDbg();
  48. F32 getAspectRatio() const;
  49. const Renderer& getOffscreenRenderer() const
  50. {
  51. return *m_r;
  52. }
  53. Renderer& getOffscreenRenderer()
  54. {
  55. return *m_r;
  56. }
  57. void setStatsEnabled(Bool enabled)
  58. {
  59. m_statsEnabled = enabled;
  60. }
  61. const MainRendererStats& getStats() const
  62. {
  63. return m_stats;
  64. }
  65. private:
  66. HeapAllocator<U8> m_alloc;
  67. StackAllocator<U8> m_frameAlloc;
  68. UniquePtr<Renderer> m_r;
  69. Bool m_rDrawToDefaultFb = false;
  70. ShaderProgramResourcePtr m_blitProg;
  71. ShaderProgramPtr m_blitGrProg;
  72. UVec2 m_swapchainResolution = UVec2(0u);
  73. F32 m_renderScaling = 1.0f;
  74. RenderGraphPtr m_rgraph;
  75. RenderTargetDescription m_tmpRtDesc;
  76. FramebufferDescription m_fbDescr;
  77. MainRendererStats m_stats;
  78. Bool m_statsEnabled = false;
  79. class
  80. {
  81. public:
  82. const RenderingContext* m_ctx = nullptr;
  83. Atomic<U32> m_secondaryTaskId = {0};
  84. } m_runCtx;
  85. };
  86. /// @}
  87. } // end namespace anki