PerViewportDynamicDrawManager.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AtomBridge/PerViewportDynamicDrawInterface.h>
  10. namespace AZ::AtomBridge
  11. {
  12. class PerViewportDynamicDrawManager final : public PerViewportDynamicDrawInterface
  13. {
  14. public:
  15. AZ_TYPE_INFO(PerViewportDynamicDrawManager, "{BED66185-00A7-43F7-BD28-C56BC8E4C535}");
  16. PerViewportDynamicDrawManager();
  17. ~PerViewportDynamicDrawManager();
  18. // PerViewportDynamicDrawInterface overrides...
  19. void RegisterDynamicDrawContext(AZ::Name name, DrawContextFactory contextInitializer) override;
  20. void UnregisterDynamicDrawContext(AZ::Name name) override;
  21. RHI::Ptr<RPI::DynamicDrawContext> GetDynamicDrawContextForViewport(AZ::Name name, AzFramework::ViewportId viewportId) override;
  22. private:
  23. struct ViewportData
  24. {
  25. AZStd::unordered_map<AZ::Name, RHI::Ptr<RPI::DynamicDrawContext>> m_dynamicDrawContexts;
  26. // Event handlers
  27. AZ::Event<RPI::RenderPipelinePtr>::Handler m_pipelineChangedHandler;
  28. AZ::Event<AzFramework::ViewportId>::Handler m_viewportDestroyedHandler;
  29. // Cached state
  30. bool m_initialized = false;
  31. };
  32. AZStd::map<AzFramework::ViewportId, ViewportData> m_viewportData;
  33. AZStd::unordered_map<AZ::Name, DrawContextFactory> m_registeredDrawContexts;
  34. AZStd::mutex m_mutexDrawContexts;
  35. };
  36. } //namespace AZ::AtomBridge