/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace AZ { namespace Render { namespace Bootstrap { class BootstrapSystemComponent : public Component , public TickBus::Handler , public AzFramework::WindowNotificationBus::Handler , public AzFramework::AssetCatalogEventBus::Handler , public AzFramework::WindowSystemNotificationBus::Handler , public AzFramework::WindowSystemRequestBus::Handler , public Render::Bootstrap::DefaultWindowBus::Handler , public Render::Bootstrap::RequestBus::Handler { public: AZ_COMPONENT(BootstrapSystemComponent, "{1EAFD87D-A64A-4612-93D8-B3AFFA70F09B}"); BootstrapSystemComponent(); ~BootstrapSystemComponent() override; static void Reflect(ReflectContext* context); static void GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided); static void GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible); static void GetRequiredServices(ComponentDescriptor::DependencyArrayType& required); static void GetDependentServices(ComponentDescriptor::DependencyArrayType& required); // AzFramework::WindowSystemRequestBus::Handler overrides ... AzFramework::NativeWindowHandle GetDefaultWindowHandle() override; // Render::Bootstrap::DefaultWindowBus::Handler overrides ... AZStd::shared_ptr GetDefaultWindowContext() override; void SetCreateDefaultScene(bool create) override; // Render::Bootstrap::RequestBus::Handler overrides ... AZ::RPI::ScenePtr GetOrCreateAtomSceneFromAzScene(AzFramework::Scene* scene) override; bool EnsureDefaultRenderPipelineInstalledForScene(AZ::RPI::ScenePtr scene, AZ::RPI::ViewportContextPtr viewportContext) override; protected: // Component overrides ... void Activate() override; void Deactivate() override; // WindowNotificationBus::Handler overrides ... void OnWindowClosed() override; // TickBus::Handler overrides ... void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; int GetTickOrder() override; // AzFramework::AssetCatalogEventBus::Handler overrides ... void OnCatalogLoaded(const char* catalogFile) override; // AzFramework::WindowSystemNotificationBus::Handler overrides ... void OnWindowCreated(AzFramework::NativeWindowHandle windowHandle) override; private: void CreateDefaultRenderPipeline(); void CreateDefaultScene(); void DestroyDefaultScene(); void RemoveRenderPipeline(); void CreateWindowContext(); AzFramework::Scene::RemovalEvent::Handler m_sceneRemovalHandler; AZStd::unique_ptr m_nativeWindow; AzFramework::NativeWindowHandle m_windowHandle = nullptr; RPI::ViewportContextPtr m_viewportContext; RPI::ScenePtr m_defaultScene = nullptr; AZStd::shared_ptr m_defaultFrameworkScene = nullptr; float m_simulateTime = 0; float m_deltaTime = 0.016f; bool m_isAssetCatalogLoaded = false; // The id of the render pipeline created by this component RPI::RenderPipelineId m_renderPipelineId; // Variables which are system component configuration AZStd::string m_defaultPipelineAssetPath = "passes/MainRenderPipeline.azasset"; // Save a reference to the image created by the BRDF pipeline so it doesn't get auto deleted if it's ref count goes to zero // For example, if we delete all the passes, we won't have to recreate the BRDF pipeline to recreate the BRDF texture Data::Instance m_brdfTexture; bool m_createDefaultScene = true; // Maps AZ scenes to RPI scene weak pointers to allow looking up a ScenePtr instead of a raw Scene* AZStd::unordered_map> m_azSceneToAtomSceneMap; }; } // namespace Bootstrap } // namespace Render } // namespace AZ