From 76b4dafbb3e848ad0f7f48b392ec97bbf0974ff9 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Fri, 8 Oct 2021 04:33:45 -0500 Subject: [PATCH] Everything compiling again after moving preview renderer to atom tools framework Signed-off-by: Guthrie Adams --- .../AtomToolsFramework/Code/CMakeLists.txt | 1 + .../PreviewRenderer/PreviewContent.h | 34 +- .../PreviewRenderer/PreviewRenderer.h | 157 ++++--- .../PreviewRenderer/PreviewRendererState.h | 35 ++ .../PreviewerFeatureProcessorProviderBus.h | 25 ++ .../Viewport/RenderViewportWidget.h | 4 +- .../PreviewRenderer/PreviewRenderer.cpp | 417 +++++++++--------- .../PreviewRendererCaptureState.cpp | 74 ++-- .../PreviewRendererCaptureState.h | 47 +- .../PreviewRendererIdleState.cpp | 44 +- .../PreviewRendererIdleState.h | 39 +- .../PreviewRendererLoadState.cpp | 64 ++- .../PreviewRendererLoadState.h | 41 +- .../PreviewRenderer/PreviewRendererState.h | 37 -- .../Code/atomtoolsframework_files.cmake | 11 + .../PreviewerFeatureProcessorProviderBus.h | 33 -- .../CommonThumbnailPreviewContent.h | 4 +- .../Thumbnails/CommonThumbnailRenderer.h | 4 +- .../Thumbnails/Preview/CommonPreviewer.cpp | 8 +- ...egration_commonfeatures_editor_files.cmake | 11 - 20 files changed, 511 insertions(+), 579 deletions(-) create mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRendererState.h create mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewerFeatureProcessorProviderBus.h delete mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererState.h delete mode 100644 Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Thumbnails/PreviewerFeatureProcessorProviderBus.h diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/CMakeLists.txt b/Gems/Atom/Tools/AtomToolsFramework/Code/CMakeLists.txt index add499f080..ea5b65be7c 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/CMakeLists.txt +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/CMakeLists.txt @@ -36,6 +36,7 @@ ly_add_target( Gem::Atom_RPI.Edit Gem::Atom_RPI.Public Gem::Atom_RHI.Reflect + Gem::Atom_Feature_Common.Static Gem::Atom_Bootstrap.Headers ) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewContent.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewContent.h index 891c7f2d01..17445835ba 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewContent.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewContent.h @@ -10,26 +10,20 @@ #include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + //! Provides custom rendering of previefw images + class PreviewContent { - namespace Thumbnails - { - //! Provides custom rendering of preeview images - class CommonPreviewContent - { - public: - AZ_CLASS_ALLOCATOR(CommonPreviewContent, AZ::SystemAllocator, 0); + public: + AZ_CLASS_ALLOCATOR(PreviewContent, AZ::SystemAllocator, 0); - CommonPreviewContent() = default; - virtual ~CommonPreviewContent() = default; - virtual void Load() = 0; - virtual bool IsReady() const = 0; - virtual bool IsError() const = 0; - virtual void ReportErrors() = 0; - virtual void UpdateScene() = 0; - }; - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + PreviewContent() = default; + virtual ~PreviewContent() = default; + virtual void Load() = 0; + virtual bool IsReady() const = 0; + virtual bool IsError() const = 0; + virtual void ReportErrors() = 0; + virtual void UpdateScene() = 0; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRenderer.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRenderer.h index dd0c3c4898..b772bfcaf2 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRenderer.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRenderer.h @@ -10,10 +10,10 @@ #include #include -#include +#include +#include +#include #include -#include -#include namespace AzFramework { @@ -22,85 +22,78 @@ namespace AzFramework class QImage; -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + //! Provides custom rendering of preview images + class PreviewRenderer final : public PreviewerFeatureProcessorProviderBus::Handler { - namespace Thumbnails + public: + AZ_CLASS_ALLOCATOR(PreviewRenderer, AZ::SystemAllocator, 0); + + PreviewRenderer(); + ~PreviewRenderer(); + + struct CaptureRequest final + { + int m_size = 512; + AZStd::shared_ptr m_content; + AZStd::function m_captureFailedCallback; + AZStd::function m_captureCompleteCallback; + }; + + AZ::RPI::ScenePtr GetScene() const; + AZ::RPI::ViewPtr GetView() const; + AZ::Uuid GetEntityContextId() const; + + void AddCaptureRequest(const CaptureRequest& captureRequest); + + enum class State : AZ::s8 { - //! Provides custom rendering of material and model thumbnails - class CommonPreviewRenderer final - : public PreviewerFeatureProcessorProviderBus::Handler - { - public: - AZ_CLASS_ALLOCATOR(CommonPreviewRenderer, AZ::SystemAllocator, 0); - - CommonPreviewRenderer(); - ~CommonPreviewRenderer(); - - struct CaptureRequest final - { - int m_size = 512; - AZStd::shared_ptr m_content; - AZStd::function m_captureFailedCallback; - AZStd::function m_captureCompleteCallback; - }; - - RPI::ScenePtr GetScene() const; - RPI::ViewPtr GetView() const; - AZ::Uuid GetEntityContextId() const; - - void AddCaptureRequest(const CaptureRequest& captureRequest); - - enum class State : AZ::s8 - { - None, - IdleState, - LoadState, - CaptureState - }; - - void SetState(State state); - State GetState() const; - - void SelectCaptureRequest(); - void CancelCaptureRequest(); - void CompleteCaptureRequest(); - - void LoadAssets(); - void UpdateLoadAssets(); - void CancelLoadAssets(); - - void UpdateScene(); - - bool StartCapture(); - void EndCapture(); - - private: - //! Render::PreviewerFeatureProcessorProviderBus::Handler interface overrides... - void GetRequiredFeatureProcessors(AZStd::unordered_set& featureProcessors) const override; - - static constexpr float AspectRatio = 1.0f; - static constexpr float NearDist = 0.001f; - static constexpr float FarDist = 100.0f; - static constexpr float FieldOfView = Constants::HalfPi; - - RPI::ScenePtr m_scene; - AZStd::string m_sceneName = "Material Thumbnail Scene"; - AZStd::string m_pipelineName = "Material Thumbnail Pipeline"; - AZStd::shared_ptr m_frameworkScene; - RPI::RenderPipelinePtr m_renderPipeline; - RPI::ViewPtr m_view; - AZStd::vector m_passHierarchy; - AZStd::unique_ptr m_entityContext; - - //! Incoming requests are appended to this queue and processed one at a time in OnTick function. - AZStd::queue m_captureRequestQueue; - CaptureRequest m_currentCaptureRequest; - - AZStd::unordered_map> m_states; - State m_currentState = CommonPreviewRenderer::State::None; - }; - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + None, + IdleState, + LoadState, + CaptureState + }; + + void SetState(State state); + State GetState() const; + + void SelectCaptureRequest(); + void CancelCaptureRequest(); + void CompleteCaptureRequest(); + + void LoadAssets(); + void UpdateLoadAssets(); + void CancelLoadAssets(); + + void UpdateScene(); + + bool StartCapture(); + void EndCapture(); + + private: + //! AZ::Render::PreviewerFeatureProcessorProviderBus::Handler interface overrides... + void GetRequiredFeatureProcessors(AZStd::unordered_set& featureProcessors) const override; + + static constexpr float AspectRatio = 1.0f; + static constexpr float NearDist = 0.001f; + static constexpr float FarDist = 100.0f; + static constexpr float FieldOfView = AZ::Constants::HalfPi; + + AZ::RPI::ScenePtr m_scene; + AZStd::string m_sceneName = "Preview Renderer Scene"; + AZStd::string m_pipelineName = "Preview Renderer Pipeline"; + AZStd::shared_ptr m_frameworkScene; + AZ::RPI::RenderPipelinePtr m_renderPipeline; + AZ::RPI::ViewPtr m_view; + AZStd::vector m_passHierarchy; + AZStd::unique_ptr m_entityContext; + + //! Incoming requests are appended to this queue and processed one at a time in OnTick function. + AZStd::queue m_captureRequestQueue; + CaptureRequest m_currentCaptureRequest; + + AZStd::unordered_map> m_states; + State m_currentState = PreviewRenderer::State::None; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRendererState.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRendererState.h new file mode 100644 index 0000000000..264c37a122 --- /dev/null +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewRendererState.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +namespace AtomToolsFramework +{ + class PreviewRenderer; + + //! PreviewRendererState decouples PreviewRenderer logic into easy-to-understand and debug pieces + class PreviewRendererState + { + public: + explicit PreviewRendererState(PreviewRenderer* renderer) + : m_renderer(renderer) + { + } + + virtual ~PreviewRendererState() = default; + + //! Start is called when state begins execution + virtual void Start() = 0; + + //! Stop is called when state ends execution + virtual void Stop() = 0; + + protected: + PreviewRenderer* m_renderer = {}; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewerFeatureProcessorProviderBus.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewerFeatureProcessorProviderBus.h new file mode 100644 index 0000000000..fe1980b39b --- /dev/null +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/PreviewRenderer/PreviewerFeatureProcessorProviderBus.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#pragma once + +#include +#include +#include + +namespace AtomToolsFramework +{ + //! PreviewerFeatureProcessorProviderRequests allows registering custom Feature Processors for preview image generation + class PreviewerFeatureProcessorProviderRequests : public AZ::EBusTraits + { + public: + //! Get a list of custom feature processors to register with preview image renderer + virtual void GetRequiredFeatureProcessors(AZStd::unordered_set& featureProcessors) const = 0; + }; + + using PreviewerFeatureProcessorProviderBus = AZ::EBus; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h index 623d759c9f..22d9dcfc6b 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h @@ -25,7 +25,7 @@ namespace AtomToolsFramework { //! The RenderViewportWidget class is a Qt wrapper around an Atom viewport. - //! RenderViewportWidget renders to an internal window using RPI::ViewportContext + //! RenderViewportWidget renders to an internal window using AZ::RPI::ViewportContext //! and delegates input via its internal ViewportControllerList. //! @see AZ::RPI::ViewportContext for Atom's API for setting up class RenderViewportWidget @@ -39,7 +39,7 @@ namespace AtomToolsFramework public: //! Creates a RenderViewportWidget. //! Requires the Atom RPI to be initialized in order - //! to internally construct an RPI::ViewportContext. + //! to internally construct an AZ::RPI::ViewportContext. //! If initializeViewportContext is set to false, nothing will be displayed on-screen until InitiliazeViewportContext is called. explicit RenderViewportWidget(QWidget* parent = nullptr, bool shouldInitializeViewportContext = true); ~RenderViewportWidget(); diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRenderer.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRenderer.cpp index d21387c925..dfefd0203e 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRenderer.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRenderer.cpp @@ -15,245 +15,238 @@ #include #include #include +#include #include #include #include #include -#include -#include -#include -#include +#include +#include +#include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + PreviewRenderer::PreviewRenderer() { - namespace Thumbnails + PreviewerFeatureProcessorProviderBus::Handler::BusConnect(); + + m_entityContext = AZStd::make_unique(); + m_entityContext->InitContext(); + + // Create and register a scene with all required feature processors + AZStd::unordered_set featureProcessors; + PreviewerFeatureProcessorProviderBus::Broadcast( + &PreviewerFeatureProcessorProviderBus::Handler::GetRequiredFeatureProcessors, featureProcessors); + + AZ::RPI::SceneDescriptor sceneDesc; + sceneDesc.m_featureProcessorNames.assign(featureProcessors.begin(), featureProcessors.end()); + m_scene = AZ::RPI::Scene::CreateScene(sceneDesc); + + // Bind m_frameworkScene to the entity context's AzFramework::Scene + auto sceneSystem = AzFramework::SceneSystemInterface::Get(); + AZ_Assert(sceneSystem, "Failed to get scene system implementation."); + + AZ::Outcome, AZStd::string> createSceneOutcome = sceneSystem->CreateScene(m_sceneName); + AZ_Assert(createSceneOutcome, createSceneOutcome.GetError().c_str()); + + m_frameworkScene = createSceneOutcome.TakeValue(); + m_frameworkScene->SetSubsystem(m_scene); + m_frameworkScene->SetSubsystem(m_entityContext.get()); + + // Create a render pipeline from the specified asset for the window context and add the pipeline to the scene + AZ::RPI::RenderPipelineDescriptor pipelineDesc; + pipelineDesc.m_mainViewTagName = "MainCamera"; + pipelineDesc.m_name = m_pipelineName; + pipelineDesc.m_rootPassTemplate = "MainPipelineRenderToTexture"; + + // We have to set the samples to 4 to match the pipeline passes' setting, otherwise it may lead to device lost issue + // [GFX TODO] [ATOM-13551] Default value sand validation required to prevent pipeline crash and device lost + pipelineDesc.m_renderSettings.m_multisampleState.m_samples = 4; + m_renderPipeline = AZ::RPI::RenderPipeline::CreateRenderPipeline(pipelineDesc); + m_scene->AddRenderPipeline(m_renderPipeline); + m_scene->Activate(); + AZ::RPI::RPISystemInterface::Get()->RegisterScene(m_scene); + m_passHierarchy.push_back(m_pipelineName); + m_passHierarchy.push_back("CopyToSwapChain"); + + // Connect camera to pipeline's default view after camera entity activated + AZ::Matrix4x4 viewToClipMatrix; + AZ::MakePerspectiveFovMatrixRH(viewToClipMatrix, FieldOfView, AspectRatio, NearDist, FarDist, true); + m_view = AZ::RPI::View::CreateView(AZ::Name("MainCamera"), AZ::RPI::View::UsageCamera); + m_view->SetViewToClipMatrix(viewToClipMatrix); + m_renderPipeline->SetDefaultView(m_view); + + m_states[PreviewRenderer::State::IdleState] = AZStd::make_shared(this); + m_states[PreviewRenderer::State::LoadState] = AZStd::make_shared(this); + m_states[PreviewRenderer::State::CaptureState] = AZStd::make_shared(this); + SetState(PreviewRenderer::State::IdleState); + } + + PreviewRenderer::~PreviewRenderer() + { + PreviewerFeatureProcessorProviderBus::Handler::BusDisconnect(); + + SetState(PreviewRenderer::State::None); + m_currentCaptureRequest = {}; + m_captureRequestQueue = {}; + + m_scene->Deactivate(); + m_scene->RemoveRenderPipeline(m_renderPipeline->GetId()); + AZ::RPI::RPISystemInterface::Get()->UnregisterScene(m_scene); + m_frameworkScene->UnsetSubsystem(m_scene); + m_frameworkScene->UnsetSubsystem(m_entityContext.get()); + } + + AZ::RPI::ScenePtr PreviewRenderer::GetScene() const + { + return m_scene; + } + + AZ::RPI::ViewPtr PreviewRenderer::GetView() const + { + return m_view; + } + + AZ::Uuid PreviewRenderer::GetEntityContextId() const + { + return m_entityContext->GetContextId(); + } + + void PreviewRenderer::AddCaptureRequest(const CaptureRequest& captureRequest) + { + m_captureRequestQueue.push(captureRequest); + } + + void PreviewRenderer::SetState(State state) + { + auto stepItr = m_states.find(m_currentState); + if (stepItr != m_states.end()) { - CommonPreviewRenderer::CommonPreviewRenderer() - { - PreviewerFeatureProcessorProviderBus::Handler::BusConnect(); - - m_entityContext = AZStd::make_unique(); - m_entityContext->InitContext(); - - // Create and register a scene with all required feature processors - AZStd::unordered_set featureProcessors; - PreviewerFeatureProcessorProviderBus::Broadcast( - &PreviewerFeatureProcessorProviderBus::Handler::GetRequiredFeatureProcessors, featureProcessors); - - RPI::SceneDescriptor sceneDesc; - sceneDesc.m_featureProcessorNames.assign(featureProcessors.begin(), featureProcessors.end()); - m_scene = RPI::Scene::CreateScene(sceneDesc); - - // Bind m_frameworkScene to the entity context's AzFramework::Scene - auto sceneSystem = AzFramework::SceneSystemInterface::Get(); - AZ_Assert(sceneSystem, "Failed to get scene system implementation."); - - Outcome, AZStd::string> createSceneOutcome = sceneSystem->CreateScene(m_sceneName); - AZ_Assert(createSceneOutcome, createSceneOutcome.GetError().c_str()); - - m_frameworkScene = createSceneOutcome.TakeValue(); - m_frameworkScene->SetSubsystem(m_scene); - m_frameworkScene->SetSubsystem(m_entityContext.get()); - - // Create a render pipeline from the specified asset for the window context and add the pipeline to the scene - RPI::RenderPipelineDescriptor pipelineDesc; - pipelineDesc.m_mainViewTagName = "MainCamera"; - pipelineDesc.m_name = m_pipelineName; - pipelineDesc.m_rootPassTemplate = "MainPipelineRenderToTexture"; - - // We have to set the samples to 4 to match the pipeline passes' setting, otherwise it may lead to device lost issue - // [GFX TODO] [ATOM-13551] Default value sand validation required to prevent pipeline crash and device lost - pipelineDesc.m_renderSettings.m_multisampleState.m_samples = 4; - m_renderPipeline = RPI::RenderPipeline::CreateRenderPipeline(pipelineDesc); - m_scene->AddRenderPipeline(m_renderPipeline); - m_scene->Activate(); - RPI::RPISystemInterface::Get()->RegisterScene(m_scene); - m_passHierarchy.push_back(m_pipelineName); - m_passHierarchy.push_back("CopyToSwapChain"); - - // Connect camera to pipeline's default view after camera entity activated - Matrix4x4 viewToClipMatrix; - MakePerspectiveFovMatrixRH(viewToClipMatrix, FieldOfView, AspectRatio, NearDist, FarDist, true); - m_view = RPI::View::CreateView(Name("MainCamera"), RPI::View::UsageCamera); - m_view->SetViewToClipMatrix(viewToClipMatrix); - m_renderPipeline->SetDefaultView(m_view); - - m_states[CommonPreviewRenderer::State::IdleState] = AZStd::make_shared(this); - m_states[CommonPreviewRenderer::State::LoadState] = AZStd::make_shared(this); - m_states[CommonPreviewRenderer::State::CaptureState] = AZStd::make_shared(this); - SetState(CommonPreviewRenderer::State::IdleState); - } + stepItr->second->Stop(); + } - CommonPreviewRenderer::~CommonPreviewRenderer() - { - PreviewerFeatureProcessorProviderBus::Handler::BusDisconnect(); + m_currentState = state; - SetState(CommonPreviewRenderer::State::None); - m_currentCaptureRequest = {}; - m_captureRequestQueue = {}; + stepItr = m_states.find(m_currentState); + if (stepItr != m_states.end()) + { + stepItr->second->Start(); + } + } - m_scene->Deactivate(); - m_scene->RemoveRenderPipeline(m_renderPipeline->GetId()); - RPI::RPISystemInterface::Get()->UnregisterScene(m_scene); - m_frameworkScene->UnsetSubsystem(m_scene); - m_frameworkScene->UnsetSubsystem(m_entityContext.get()); - } + PreviewRenderer::State PreviewRenderer::GetState() const + { + return m_currentState; + } - RPI::ScenePtr CommonPreviewRenderer::GetScene() const - { - return m_scene; - } + void PreviewRenderer::SelectCaptureRequest() + { + if (!m_captureRequestQueue.empty()) + { + // pop the next request to be rendered from the queue + m_currentCaptureRequest = m_captureRequestQueue.front(); + m_captureRequestQueue.pop(); - RPI::ViewPtr CommonPreviewRenderer::GetView() const - { - return m_view; - } + SetState(PreviewRenderer::State::LoadState); + } + } - AZ::Uuid CommonPreviewRenderer::GetEntityContextId() const - { - return m_entityContext->GetContextId(); - } + void PreviewRenderer::CancelCaptureRequest() + { + m_currentCaptureRequest.m_captureFailedCallback(); + SetState(PreviewRenderer::State::IdleState); + } - void CommonPreviewRenderer::AddCaptureRequest(const CaptureRequest& captureRequest) - { - m_captureRequestQueue.push(captureRequest); - } + void PreviewRenderer::CompleteCaptureRequest() + { + SetState(PreviewRenderer::State::IdleState); + } - void CommonPreviewRenderer::SetState(State state) - { - auto stepItr = m_states.find(m_currentState); - if (stepItr != m_states.end()) - { - stepItr->second->Stop(); - } - - m_currentState = state; - - stepItr = m_states.find(m_currentState); - if (stepItr != m_states.end()) - { - stepItr->second->Start(); - } - } + void PreviewRenderer::LoadAssets() + { + m_currentCaptureRequest.m_content->Load(); + } - CommonPreviewRenderer::State CommonPreviewRenderer::GetState() const - { - return m_currentState; - } + void PreviewRenderer::UpdateLoadAssets() + { + if (m_currentCaptureRequest.m_content->IsReady()) + { + SetState(PreviewRenderer::State::CaptureState); + return; + } - void CommonPreviewRenderer::SelectCaptureRequest() - { - if (!m_captureRequestQueue.empty()) - { - // pop the next request to be rendered from the queue - m_currentCaptureRequest = m_captureRequestQueue.front(); - m_captureRequestQueue.pop(); - - SetState(CommonPreviewRenderer::State::LoadState); - } - } + if (m_currentCaptureRequest.m_content->IsError()) + { + CancelLoadAssets(); + return; + } + } - void CommonPreviewRenderer::CancelCaptureRequest() - { - m_currentCaptureRequest.m_captureFailedCallback(); - SetState(CommonPreviewRenderer::State::IdleState); - } + void PreviewRenderer::CancelLoadAssets() + { + m_currentCaptureRequest.m_content->ReportErrors(); + CancelCaptureRequest(); + } - void CommonPreviewRenderer::CompleteCaptureRequest() - { - SetState(CommonPreviewRenderer::State::IdleState); - } + void PreviewRenderer::UpdateScene() + { + m_currentCaptureRequest.m_content->UpdateScene(); + } - void CommonPreviewRenderer::LoadAssets() + bool PreviewRenderer::StartCapture() + { + auto captureCallback = [currentCaptureRequest = m_currentCaptureRequest](const AZ::RPI::AttachmentReadback::ReadbackResult& result) + { + if (result.m_dataBuffer) { - m_currentCaptureRequest.m_content->Load(); + currentCaptureRequest.m_captureCompleteCallback(QImage( + result.m_dataBuffer.get()->data(), result.m_imageDescriptor.m_size.m_width, result.m_imageDescriptor.m_size.m_height, + QImage::Format_RGBA8888)); } - - void CommonPreviewRenderer::UpdateLoadAssets() + else { - if (m_currentCaptureRequest.m_content->IsReady()) - { - SetState(CommonPreviewRenderer::State::CaptureState); - return; - } - - if (m_currentCaptureRequest.m_content->IsError()) - { - CancelLoadAssets(); - return; - } + currentCaptureRequest.m_captureFailedCallback(); } + }; - void CommonPreviewRenderer::CancelLoadAssets() - { - m_currentCaptureRequest.m_content->ReportErrors(); - CancelCaptureRequest(); - } + if (auto renderToTexturePass = azrtti_cast(m_renderPipeline->GetRootPass().get())) + { + renderToTexturePass->ResizeOutput(m_currentCaptureRequest.m_size, m_currentCaptureRequest.m_size); + } - void CommonPreviewRenderer::UpdateScene() - { - m_currentCaptureRequest.m_content->UpdateScene(); - } + m_renderPipeline->AddToRenderTickOnce(); - bool CommonPreviewRenderer::StartCapture() - { - auto captureCallback = - [currentCaptureRequest = m_currentCaptureRequest](const RPI::AttachmentReadback::ReadbackResult& result) - { - if (result.m_dataBuffer) - { - currentCaptureRequest.m_captureCompleteCallback(QImage( - result.m_dataBuffer.get()->data(), result.m_imageDescriptor.m_size.m_width, - result.m_imageDescriptor.m_size.m_height, QImage::Format_RGBA8888)); - } - else - { - currentCaptureRequest.m_captureFailedCallback(); - } - }; - - if (auto renderToTexturePass = azrtti_cast(m_renderPipeline->GetRootPass().get())) - { - renderToTexturePass->ResizeOutput(m_currentCaptureRequest.m_size, m_currentCaptureRequest.m_size); - } - - m_renderPipeline->AddToRenderTickOnce(); - - bool startedCapture = false; - Render::FrameCaptureRequestBus::BroadcastResult( - startedCapture, &Render::FrameCaptureRequestBus::Events::CapturePassAttachmentWithCallback, m_passHierarchy, - AZStd::string("Output"), captureCallback, RPI::PassAttachmentReadbackOption::Output); - return startedCapture; - } + bool startedCapture = false; + AZ::Render::FrameCaptureRequestBus::BroadcastResult( + startedCapture, &AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachmentWithCallback, m_passHierarchy, + AZStd::string("Output"), captureCallback, AZ::RPI::PassAttachmentReadbackOption::Output); + return startedCapture; + } - void CommonPreviewRenderer::EndCapture() - { - m_renderPipeline->RemoveFromRenderTick(); - } + void PreviewRenderer::EndCapture() + { + m_renderPipeline->RemoveFromRenderTick(); + } - void CommonPreviewRenderer::GetRequiredFeatureProcessors(AZStd::unordered_set& featureProcessors) const - { - featureProcessors.insert({ - "AZ::Render::TransformServiceFeatureProcessor", - "AZ::Render::MeshFeatureProcessor", - "AZ::Render::SimplePointLightFeatureProcessor", - "AZ::Render::SimpleSpotLightFeatureProcessor", - "AZ::Render::PointLightFeatureProcessor", - // There is currently a bug where having multiple DirectionalLightFeatureProcessors active can result in shadow - // flickering [ATOM-13568] - // as well as continually rebuilding MeshDrawPackets [ATOM-13633]. Lets just disable the directional light FP for now. - // Possibly re-enable with [GFX TODO][ATOM-13639] - // "AZ::Render::DirectionalLightFeatureProcessor", - "AZ::Render::DiskLightFeatureProcessor", - "AZ::Render::CapsuleLightFeatureProcessor", - "AZ::Render::QuadLightFeatureProcessor", - "AZ::Render::DecalTextureArrayFeatureProcessor", - "AZ::Render::ImageBasedLightFeatureProcessor", - "AZ::Render::PostProcessFeatureProcessor", - "AZ::Render::SkyBoxFeatureProcessor" }); - } - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + void PreviewRenderer::GetRequiredFeatureProcessors(AZStd::unordered_set& featureProcessors) const + { + featureProcessors.insert({ + "AZ::Render::TransformServiceFeatureProcessor", + "AZ::Render::MeshFeatureProcessor", + "AZ::Render::SimplePointLightFeatureProcessor", + "AZ::Render::SimpleSpotLightFeatureProcessor", + "AZ::Render::PointLightFeatureProcessor", + // There is currently a bug where having multiple DirectionalLightFeatureProcessors active can result in shadow + // flickering [ATOM-13568] + // as well as continually rebuilding MeshDrawPackets [ATOM-13633]. Lets just disable the directional light FP for now. + // Possibly re-enable with [GFX TODO][ATOM-13639] + // "AZ::Render::DirectionalLightFeatureProcessor", + "AZ::Render::DiskLightFeatureProcessor", + "AZ::Render::CapsuleLightFeatureProcessor", + "AZ::Render::QuadLightFeatureProcessor", + "AZ::Render::DecalTextureArrayFeatureProcessor", + "AZ::Render::ImageBasedLightFeatureProcessor", + "AZ::Render::PostProcessFeatureProcessor", + "AZ::Render::SkyBoxFeatureProcessor" }); + } +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.cpp index fc74e9f43b..f3414bc29f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.cpp @@ -6,52 +6,46 @@ * */ -#include -#include +#include +#include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + PreviewRendererCaptureState::PreviewRendererCaptureState(PreviewRenderer* renderer) + : PreviewRendererState(renderer) { - namespace Thumbnails - { - CommonPreviewRendererCaptureState::CommonPreviewRendererCaptureState(CommonPreviewRenderer* renderer) - : CommonPreviewRendererState(renderer) - { - } + } - void CommonPreviewRendererCaptureState::Start() - { - m_ticksToCapture = 1; - m_renderer->UpdateScene(); - TickBus::Handler::BusConnect(); - } + void PreviewRendererCaptureState::Start() + { + m_ticksToCapture = 1; + m_renderer->UpdateScene(); + AZ::TickBus::Handler::BusConnect(); + } - void CommonPreviewRendererCaptureState::Stop() - { - m_renderer->EndCapture(); - TickBus::Handler::BusDisconnect(); - Render::FrameCaptureNotificationBus::Handler::BusDisconnect(); - } + void PreviewRendererCaptureState::Stop() + { + m_renderer->EndCapture(); + AZ::TickBus::Handler::BusDisconnect(); + AZ::Render::FrameCaptureNotificationBus::Handler::BusDisconnect(); + } - void CommonPreviewRendererCaptureState::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] ScriptTimePoint time) + void PreviewRendererCaptureState::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) + { + if (m_ticksToCapture-- <= 0) + { + // Reset the capture flag if the capture request was successful. Otherwise try capture it again next tick. + if (m_renderer->StartCapture()) { - if (m_ticksToCapture-- <= 0) - { - // Reset the capture flag if the capture request was successful. Otherwise try capture it again next tick. - if (m_renderer->StartCapture()) - { - Render::FrameCaptureNotificationBus::Handler::BusConnect(); - TickBus::Handler::BusDisconnect(); - } - } + AZ::Render::FrameCaptureNotificationBus::Handler::BusConnect(); + AZ::TickBus::Handler::BusDisconnect(); } + } + } - void CommonPreviewRendererCaptureState::OnCaptureFinished( - [[maybe_unused]] Render::FrameCaptureResult result, [[maybe_unused]] const AZStd::string& info) - { - m_renderer->CompleteCaptureRequest(); - } - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + void PreviewRendererCaptureState::OnCaptureFinished( + [[maybe_unused]] AZ::Render::FrameCaptureResult result, [[maybe_unused]] const AZStd::string& info) + { + m_renderer->CompleteCaptureRequest(); + } +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.h index c19f12d9bb..190cb919df 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererCaptureState.h @@ -9,38 +9,31 @@ #pragma once #include +#include #include -#include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + //! PreviewRendererCaptureState renders a thumbnail to a pixmap and notifies MaterialOrModelThumbnail once finished + class PreviewRendererCaptureState final + : public PreviewRendererState + , public AZ::TickBus::Handler + , public AZ::Render::FrameCaptureNotificationBus::Handler { - namespace Thumbnails - { - //! CommonPreviewRendererCaptureState renders a thumbnail to a pixmap and notifies MaterialOrModelThumbnail once finished - class CommonPreviewRendererCaptureState - : public CommonPreviewRendererState - , private TickBus::Handler - , private Render::FrameCaptureNotificationBus::Handler - { - public: - CommonPreviewRendererCaptureState(CommonPreviewRenderer* renderer); + public: + PreviewRendererCaptureState(PreviewRenderer* renderer); - void Start() override; - void Stop() override; + void Start() override; + void Stop() override; - private: - //! AZ::TickBus::Handler interface overrides... - void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; + private: + //! AZ::TickBus::Handler interface overrides... + void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; - //! Render::FrameCaptureNotificationBus::Handler overrides... - void OnCaptureFinished(Render::FrameCaptureResult result, const AZStd::string& info) override; - - //! This is necessary to suspend capture to allow a frame for Material and Mesh components to assign materials - int m_ticksToCapture = 0; - }; - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + //! AZ::Render::FrameCaptureNotificationBus::Handler overrides... + void OnCaptureFinished(AZ::Render::FrameCaptureResult result, const AZStd::string& info) override; + //! This is necessary to suspend capture to allow a frame for Material and Mesh components to assign materials + int m_ticksToCapture = 0; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.cpp index 12a38fc93f..db91bedce1 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.cpp @@ -6,34 +6,28 @@ * */ -#include -#include +#include +#include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + PreviewRendererIdleState::PreviewRendererIdleState(PreviewRenderer* renderer) + : PreviewRendererState(renderer) { - namespace Thumbnails - { - CommonPreviewRendererIdleState::CommonPreviewRendererIdleState(CommonPreviewRenderer* renderer) - : CommonPreviewRendererState(renderer) - { - } + } - void CommonPreviewRendererIdleState::Start() - { - TickBus::Handler::BusConnect(); - } + void PreviewRendererIdleState::Start() + { + AZ::TickBus::Handler::BusConnect(); + } - void CommonPreviewRendererIdleState::Stop() - { - TickBus::Handler::BusDisconnect(); - } + void PreviewRendererIdleState::Stop() + { + AZ::TickBus::Handler::BusDisconnect(); + } - void CommonPreviewRendererIdleState::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] ScriptTimePoint time) - { - m_renderer->SelectCaptureRequest(); - } - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + void PreviewRendererIdleState::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) + { + m_renderer->SelectCaptureRequest(); + } +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.h index 3278149b98..9e5380e734 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererIdleState.h @@ -8,31 +8,24 @@ #pragma once -#include +#include +#include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + //! PreviewRendererIdleState checks whether there are any new thumbnails that need to be rendered every tick + class PreviewRendererIdleState final + : public PreviewRendererState + , public AZ::TickBus::Handler { - namespace Thumbnails - { - //! CommonPreviewRendererIdleState checks whether there are any new thumbnails that need to be rendered every tick - class CommonPreviewRendererIdleState - : public CommonPreviewRendererState - , private TickBus::Handler - { - public: - CommonPreviewRendererIdleState(CommonPreviewRenderer* renderer); + public: + PreviewRendererIdleState(PreviewRenderer* renderer); - void Start() override; - void Stop() override; - - private: - - //! AZ::TickBus::Handler interface overrides... - void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; - }; - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + void Start() override; + void Stop() override; + private: + //! AZ::TickBus::Handler interface overrides... + void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.cpp index dcac673de2..b5d219636e 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.cpp @@ -6,44 +6,38 @@ * */ -#include -#include +#include +#include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + PreviewRendererLoadState::PreviewRendererLoadState(PreviewRenderer* renderer) + : PreviewRendererState(renderer) { - namespace Thumbnails - { - CommonPreviewRendererLoadState::CommonPreviewRendererLoadState(CommonPreviewRenderer* renderer) - : CommonPreviewRendererState(renderer) - { - } + } - void CommonPreviewRendererLoadState::Start() - { - m_renderer->LoadAssets(); - m_timeRemainingS = TimeOutS; - TickBus::Handler::BusConnect(); - } + void PreviewRendererLoadState::Start() + { + m_renderer->LoadAssets(); + m_timeRemainingS = TimeOutS; + AZ::TickBus::Handler::BusConnect(); + } - void CommonPreviewRendererLoadState::Stop() - { - TickBus::Handler::BusDisconnect(); - } + void PreviewRendererLoadState::Stop() + { + AZ::TickBus::Handler::BusDisconnect(); + } - void CommonPreviewRendererLoadState::OnTick(float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) - { - m_timeRemainingS -= deltaTime; - if (m_timeRemainingS > 0.0f) - { - m_renderer->UpdateLoadAssets(); - } - else - { - m_renderer->CancelLoadAssets(); - } - } - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + void PreviewRendererLoadState::OnTick(float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) + { + m_timeRemainingS -= deltaTime; + if (m_timeRemainingS > 0.0f) + { + m_renderer->UpdateLoadAssets(); + } + else + { + m_renderer->CancelLoadAssets(); + } + } +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.h index 438fd774ca..623d6cbdfc 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererLoadState.h @@ -9,33 +9,26 @@ #pragma once #include -#include +#include -namespace AZ +namespace AtomToolsFramework { - namespace LyIntegration + //! PreviewRendererLoadState pauses further rendering until all assets used for rendering a thumbnail have been loaded + class PreviewRendererLoadState final + : public PreviewRendererState + , public AZ::TickBus::Handler { - namespace Thumbnails - { - //! CommonPreviewRendererLoadState pauses further rendering until all assets used for rendering a thumbnail have been loaded - class CommonPreviewRendererLoadState - : public CommonPreviewRendererState - , private TickBus::Handler - { - public: - CommonPreviewRendererLoadState(CommonPreviewRenderer* renderer); + public: + PreviewRendererLoadState(PreviewRenderer* renderer); - void Start() override; - void Stop() override; + void Start() override; + void Stop() override; - private: - //! AZ::TickBus::Handler interface overrides... - void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; - - static constexpr float TimeOutS = 5.0f; - float m_timeRemainingS = TimeOutS; - }; - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ + private: + //! AZ::TickBus::Handler interface overrides... + void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; + static constexpr float TimeOutS = 5.0f; + float m_timeRemainingS = TimeOutS; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererState.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererState.h deleted file mode 100644 index 9dbf50ab0e..0000000000 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/PreviewRenderer/PreviewRendererState.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -namespace AZ -{ - namespace LyIntegration - { - namespace Thumbnails - { - class CommonPreviewRenderer; - - //! CommonPreviewRendererState decouples CommonPreviewRenderer logic into easy-to-understand and debug pieces - class CommonPreviewRendererState - { - public: - explicit CommonPreviewRendererState(CommonPreviewRenderer* renderer) : m_renderer(renderer) {} - virtual ~CommonPreviewRendererState() = default; - - //! Start is called when state begins execution - virtual void Start() {} - //! Stop is called when state ends execution - virtual void Stop() {} - - protected: - CommonPreviewRenderer* m_renderer; - }; - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ - diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake index 3d4bb82eec..df0dba2678 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake @@ -58,4 +58,15 @@ set(FILES Source/Window/AtomToolsMainWindow.cpp Source/Window/AtomToolsMainWindowSystemComponent.cpp Source/Window/AtomToolsMainWindowSystemComponent.h + Include/AtomToolsFramework/PreviewRenderer/PreviewContent.h + Include/AtomToolsFramework/PreviewRenderer/PreviewRenderer.h + Include/AtomToolsFramework/PreviewRenderer/PreviewRendererState.h + Include/AtomToolsFramework/PreviewRenderer/PreviewerFeatureProcessorProviderBus.h + Source/PreviewRenderer/PreviewRenderer.cpp + Source/PreviewRenderer/PreviewRendererIdleState.cpp + Source/PreviewRenderer/PreviewRendererIdleState.h + Source/PreviewRenderer/PreviewRendererLoadState.cpp + Source/PreviewRenderer/PreviewRendererLoadState.h + Source/PreviewRenderer/PreviewRendererCaptureState.cpp + Source/PreviewRenderer/PreviewRendererCaptureState.h ) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Thumbnails/PreviewerFeatureProcessorProviderBus.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Thumbnails/PreviewerFeatureProcessorProviderBus.h deleted file mode 100644 index bae49db89d..0000000000 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Thumbnails/PreviewerFeatureProcessorProviderBus.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#include -#include - -namespace AZ -{ - namespace LyIntegration - { - namespace Thumbnails - { - //! PreviewerFeatureProcessorProviderRequests allows registering custom Feature Processors for preview image generation - //! Duplicates will be ignored - //! You can check minimal feature processors that are already registered in CommonPreviewRenderer.cpp - class PreviewerFeatureProcessorProviderRequests - : public AZ::EBusTraits - { - public: - //! Get a list of custom feature processors to register with preview image renderer - virtual void GetRequiredFeatureProcessors(AZStd::unordered_set& featureProcessors) const = 0; - }; - - using PreviewerFeatureProcessorProviderBus = AZ::EBus; - } // namespace Thumbnails - } // namespace LyIntegration -} // namespace AZ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailPreviewContent.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailPreviewContent.h index 59556e03d1..8520d6053a 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailPreviewContent.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailPreviewContent.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace AZ { @@ -23,7 +23,7 @@ namespace AZ { //! Provides custom rendering of material and model previews class CommonThumbnailPreviewContent final - : public CommonPreviewContent + : public AtomToolsFramework::PreviewContent { public: AZ_CLASS_ALLOCATOR(CommonThumbnailPreviewContent, AZ::SystemAllocator, 0); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailRenderer.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailRenderer.h index fb683c1aff..0497521d44 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailRenderer.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/CommonThumbnailRenderer.h @@ -8,10 +8,10 @@ #pragma once +#include #include #include #include -#include #include namespace AZ @@ -39,7 +39,7 @@ namespace AZ //! SystemTickBus::Handler interface overrides... void OnSystemTick() override; - CommonPreviewRenderer m_previewRenderer; + AtomToolsFramework::PreviewRenderer m_previewRenderer; }; } // namespace Thumbnails } // namespace LyIntegration diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/Preview/CommonPreviewer.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/Preview/CommonPreviewer.cpp index 9730c7d4a9..a8692b5eb4 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/Preview/CommonPreviewer.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Thumbnails/Preview/CommonPreviewer.cpp @@ -14,14 +14,14 @@ #include #include -#include -#include +#include +#include // Disables warning messages triggered by the Qt library // 4251: class needs to have dll-interface to be used by clients of class // 4800: forcing value to bool 'true' or 'false' (performance warning) AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") -#include +#include #include #include AZ_POP_DISABLE_WARNING @@ -73,4 +73,4 @@ namespace AZ } // namespace LyIntegration } // namespace AZ -#include +#include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake b/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake index 3b6212e0eb..db42b663c8 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/atomlyintegration_commonfeatures_editor_files.cmake @@ -9,7 +9,6 @@ set(FILES Include/AtomLyIntegration/CommonFeatures/Material/EditorMaterialSystemComponentRequestBus.h Include/AtomLyIntegration/CommonFeatures/ReflectionProbe/EditorReflectionProbeBus.h - Include/AtomLyIntegration/CommonFeatures/Thumbnails/PreviewerFeatureProcessorProviderBus.h Source/Module.cpp Source/Animation/EditorAttachmentComponent.h Source/Animation/EditorAttachmentComponent.cpp @@ -98,16 +97,6 @@ set(FILES Source/Thumbnails/Preview/CommonPreviewer.ui Source/Thumbnails/Preview/CommonPreviewerFactory.cpp Source/Thumbnails/Preview/CommonPreviewerFactory.h - Source/Thumbnails/Rendering/CommonPreviewContent.h - Source/Thumbnails/Rendering/CommonPreviewRenderer.cpp - Source/Thumbnails/Rendering/CommonPreviewRenderer.h - Source/Thumbnails/Rendering/CommonPreviewRendererState.h - Source/Thumbnails/Rendering/CommonPreviewRendererIdleState.cpp - Source/Thumbnails/Rendering/CommonPreviewRendererIdleState.h - Source/Thumbnails/Rendering/CommonPreviewRendererLoadState.cpp - Source/Thumbnails/Rendering/CommonPreviewRendererLoadState.h - Source/Thumbnails/Rendering/CommonPreviewRendererCaptureState.cpp - Source/Thumbnails/Rendering/CommonPreviewRendererCaptureState.h Source/Thumbnails/CommonThumbnailPreviewContent.cpp Source/Thumbnails/CommonThumbnailPreviewContent.h Source/Thumbnails/CommonThumbnailRenderer.cpp