MultiGPURPIExampleComponent.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 <CommonSampleComponentBase.h>
  10. #include <Atom/Bootstrap/DefaultWindowBus.h>
  11. #include <Atom/Feature/ImGui/ImGuiUtils.h>
  12. #include <Atom/RPI.Public/Base.h>
  13. #include <Atom/RPI.Public/WindowContext.h>
  14. #include <AzCore/Asset/AssetCommon.h>
  15. #include <AzCore/Component/TickBus.h>
  16. #include <AzFramework/Windowing/WindowBus.h>
  17. #include <AzFramework/Windowing/NativeWindow.h>
  18. #include <Atom/Feature/CoreLights/DirectionalLightFeatureProcessorInterface.h>
  19. #include <Atom/Feature/CoreLights/DiskLightFeatureProcessorInterface.h>
  20. #include <Atom/Feature/CoreLights/ShadowConstants.h>
  21. #include <Atom/Feature/SkyBox/SkyBoxFeatureProcessorInterface.h>
  22. #include <Atom/Feature/PostProcess/PostProcessFeatureProcessorInterface.h>
  23. #include <Utils/ImGuiSidebar.h>
  24. #include <Utils/Utils.h>
  25. struct ImGuiContext;
  26. namespace AtomSampleViewer
  27. {
  28. //! A sample component which render the same scene with different render pipelines in different windows
  29. //! It has a imgui menu to switch on/off the second render pipeline as well as turn on/off different graphics features
  30. //! There is also an option to have the second render pipeline to use the second camera.
  31. class MultiGPURPIExampleComponent final
  32. : public CommonSampleComponentBase
  33. , public AZ::TickBus::Handler
  34. , public AZ::Render::Bootstrap::DefaultWindowNotificationBus::Handler
  35. {
  36. public:
  37. AZ_COMPONENT(MultiGPURPIExampleComponent, "{F7DD0D21-A0EF-4B66-98FA-2DB6B19A8C35}", CommonSampleComponentBase);
  38. static void Reflect(AZ::ReflectContext* context);
  39. MultiGPURPIExampleComponent();
  40. ~MultiGPURPIExampleComponent() final = default;
  41. // AZ::Component
  42. void Activate() override;
  43. void Deactivate() override;
  44. private:
  45. // AZ::TickBus::Handler overrides ...
  46. void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
  47. // DefaultWindowNotificationBus::Handler overrides...
  48. void DefaultWindowCreated() override;
  49. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
  50. AZ::RPI::RenderPipelinePtr m_pipeline;
  51. AZ::RPI::RenderPipelinePtr m_copyPipeline;
  52. AZ::RPI::RenderPipelinePtr m_originalPipeline;
  53. AZStd::shared_ptr<AZ::RPI::WindowContext> m_windowContext;
  54. AZ::Render::ImGuiActiveContextScope m_imguiScope;
  55. ImGuiSidebar m_imguiSidebar;
  56. bool m_useCopyPipeline = false;
  57. bool m_currentlyUsingCopyPipline = false;
  58. };
  59. } // namespace AtomSampleViewer