Everything compiling again after moving preview renderer to atom tools framework
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
|
||||
+14
-20
@@ -10,26 +10,20 @@
|
||||
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
|
||||
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
|
||||
|
||||
+62
-69
@@ -10,10 +10,10 @@
|
||||
|
||||
#include <Atom/RPI.Public/Base.h>
|
||||
#include <Atom/RPI.Public/Pass/AttachmentReadback.h>
|
||||
#include <AtomLyIntegration/CommonFeatures/Thumbnails/PreviewerFeatureProcessorProviderBus.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewContent.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRendererState.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewerFeatureProcessorProviderBus.h>
|
||||
#include <AzFramework/Entity/GameEntityContextComponent.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewContent.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererState.h>
|
||||
|
||||
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
|
||||
{
|
||||
//! Provides custom rendering of material and model thumbnails
|
||||
class CommonPreviewRenderer final
|
||||
: public PreviewerFeatureProcessorProviderBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CommonPreviewRenderer, AZ::SystemAllocator, 0);
|
||||
int m_size = 512;
|
||||
AZStd::shared_ptr<PreviewContent> m_content;
|
||||
AZStd::function<void()> m_captureFailedCallback;
|
||||
AZStd::function<void(const QImage&)> m_captureCompleteCallback;
|
||||
};
|
||||
|
||||
CommonPreviewRenderer();
|
||||
~CommonPreviewRenderer();
|
||||
AZ::RPI::ScenePtr GetScene() const;
|
||||
AZ::RPI::ViewPtr GetView() const;
|
||||
AZ::Uuid GetEntityContextId() const;
|
||||
|
||||
struct CaptureRequest final
|
||||
{
|
||||
int m_size = 512;
|
||||
AZStd::shared_ptr<CommonPreviewContent> m_content;
|
||||
AZStd::function<void()> m_captureFailedCallback;
|
||||
AZStd::function<void(const QImage&)> m_captureCompleteCallback;
|
||||
};
|
||||
void AddCaptureRequest(const CaptureRequest& captureRequest);
|
||||
|
||||
RPI::ScenePtr GetScene() const;
|
||||
RPI::ViewPtr GetView() const;
|
||||
AZ::Uuid GetEntityContextId() const;
|
||||
enum class State : AZ::s8
|
||||
{
|
||||
None,
|
||||
IdleState,
|
||||
LoadState,
|
||||
CaptureState
|
||||
};
|
||||
|
||||
void AddCaptureRequest(const CaptureRequest& captureRequest);
|
||||
void SetState(State state);
|
||||
State GetState() const;
|
||||
|
||||
enum class State : AZ::s8
|
||||
{
|
||||
None,
|
||||
IdleState,
|
||||
LoadState,
|
||||
CaptureState
|
||||
};
|
||||
void SelectCaptureRequest();
|
||||
void CancelCaptureRequest();
|
||||
void CompleteCaptureRequest();
|
||||
|
||||
void SetState(State state);
|
||||
State GetState() const;
|
||||
void LoadAssets();
|
||||
void UpdateLoadAssets();
|
||||
void CancelLoadAssets();
|
||||
|
||||
void SelectCaptureRequest();
|
||||
void CancelCaptureRequest();
|
||||
void CompleteCaptureRequest();
|
||||
void UpdateScene();
|
||||
|
||||
void LoadAssets();
|
||||
void UpdateLoadAssets();
|
||||
void CancelLoadAssets();
|
||||
bool StartCapture();
|
||||
void EndCapture();
|
||||
|
||||
void UpdateScene();
|
||||
private:
|
||||
//! AZ::Render::PreviewerFeatureProcessorProviderBus::Handler interface overrides...
|
||||
void GetRequiredFeatureProcessors(AZStd::unordered_set<AZStd::string>& featureProcessors) const override;
|
||||
|
||||
bool StartCapture();
|
||||
void EndCapture();
|
||||
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;
|
||||
|
||||
private:
|
||||
//! Render::PreviewerFeatureProcessorProviderBus::Handler interface overrides...
|
||||
void GetRequiredFeatureProcessors(AZStd::unordered_set<AZStd::string>& featureProcessors) const override;
|
||||
AZ::RPI::ScenePtr m_scene;
|
||||
AZStd::string m_sceneName = "Preview Renderer Scene";
|
||||
AZStd::string m_pipelineName = "Preview Renderer Pipeline";
|
||||
AZStd::shared_ptr<AzFramework::Scene> m_frameworkScene;
|
||||
AZ::RPI::RenderPipelinePtr m_renderPipeline;
|
||||
AZ::RPI::ViewPtr m_view;
|
||||
AZStd::vector<AZStd::string> m_passHierarchy;
|
||||
AZStd::unique_ptr<AzFramework::EntityContext> m_entityContext;
|
||||
|
||||
static constexpr float AspectRatio = 1.0f;
|
||||
static constexpr float NearDist = 0.001f;
|
||||
static constexpr float FarDist = 100.0f;
|
||||
static constexpr float FieldOfView = Constants::HalfPi;
|
||||
//! Incoming requests are appended to this queue and processed one at a time in OnTick function.
|
||||
AZStd::queue<CaptureRequest> m_captureRequestQueue;
|
||||
CaptureRequest m_currentCaptureRequest;
|
||||
|
||||
RPI::ScenePtr m_scene;
|
||||
AZStd::string m_sceneName = "Material Thumbnail Scene";
|
||||
AZStd::string m_pipelineName = "Material Thumbnail Pipeline";
|
||||
AZStd::shared_ptr<AzFramework::Scene> m_frameworkScene;
|
||||
RPI::RenderPipelinePtr m_renderPipeline;
|
||||
RPI::ViewPtr m_view;
|
||||
AZStd::vector<AZStd::string> m_passHierarchy;
|
||||
AZStd::unique_ptr<AzFramework::EntityContext> m_entityContext;
|
||||
|
||||
//! Incoming requests are appended to this queue and processed one at a time in OnTick function.
|
||||
AZStd::queue<CaptureRequest> m_captureRequestQueue;
|
||||
CaptureRequest m_currentCaptureRequest;
|
||||
|
||||
AZStd::unordered_map<State, AZStd::shared_ptr<CommonPreviewRendererState>> m_states;
|
||||
State m_currentState = CommonPreviewRenderer::State::None;
|
||||
};
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
AZStd::unordered_map<State, AZStd::shared_ptr<PreviewRendererState>> m_states;
|
||||
State m_currentState = PreviewRenderer::State::None;
|
||||
};
|
||||
} // namespace AtomToolsFramework
|
||||
|
||||
+35
@@ -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
|
||||
+25
@@ -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 <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/std/containers/unordered_set.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
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<AZStd::string>& featureProcessors) const = 0;
|
||||
};
|
||||
|
||||
using PreviewerFeatureProcessorProviderBus = AZ::EBus<PreviewerFeatureProcessorProviderRequests>;
|
||||
} // namespace AtomToolsFramework
|
||||
+2
-2
@@ -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();
|
||||
|
||||
+218
-225
@@ -15,245 +15,238 @@
|
||||
#include <Atom/RPI.Public/View.h>
|
||||
#include <Atom/RPI.Reflect/System/RenderPipelineDescriptor.h>
|
||||
#include <Atom/RPI.Reflect/System/SceneDescriptor.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRenderer.h>
|
||||
#include <AzCore/Math/MatrixUtils.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererCaptureState.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererIdleState.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererLoadState.h>
|
||||
#include <PreviewRenderer/PreviewRendererCaptureState.h>
|
||||
#include <PreviewRenderer/PreviewRendererIdleState.h>
|
||||
#include <PreviewRenderer/PreviewRendererLoadState.h>
|
||||
|
||||
namespace AZ
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
namespace LyIntegration
|
||||
PreviewRenderer::PreviewRenderer()
|
||||
{
|
||||
namespace Thumbnails
|
||||
PreviewerFeatureProcessorProviderBus::Handler::BusConnect();
|
||||
|
||||
m_entityContext = AZStd::make_unique<AzFramework::EntityContext>();
|
||||
m_entityContext->InitContext();
|
||||
|
||||
// Create and register a scene with all required feature processors
|
||||
AZStd::unordered_set<AZStd::string> 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::shared_ptr<AzFramework::Scene>, 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<PreviewRendererIdleState>(this);
|
||||
m_states[PreviewRenderer::State::LoadState] = AZStd::make_shared<PreviewRendererLoadState>(this);
|
||||
m_states[PreviewRenderer::State::CaptureState] = AZStd::make_shared<PreviewRendererCaptureState>(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()
|
||||
stepItr->second->Stop();
|
||||
}
|
||||
|
||||
m_currentState = state;
|
||||
|
||||
stepItr = m_states.find(m_currentState);
|
||||
if (stepItr != m_states.end())
|
||||
{
|
||||
stepItr->second->Start();
|
||||
}
|
||||
}
|
||||
|
||||
PreviewRenderer::State PreviewRenderer::GetState() const
|
||||
{
|
||||
return m_currentState;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
SetState(PreviewRenderer::State::LoadState);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewRenderer::CancelCaptureRequest()
|
||||
{
|
||||
m_currentCaptureRequest.m_captureFailedCallback();
|
||||
SetState(PreviewRenderer::State::IdleState);
|
||||
}
|
||||
|
||||
void PreviewRenderer::CompleteCaptureRequest()
|
||||
{
|
||||
SetState(PreviewRenderer::State::IdleState);
|
||||
}
|
||||
|
||||
void PreviewRenderer::LoadAssets()
|
||||
{
|
||||
m_currentCaptureRequest.m_content->Load();
|
||||
}
|
||||
|
||||
void PreviewRenderer::UpdateLoadAssets()
|
||||
{
|
||||
if (m_currentCaptureRequest.m_content->IsReady())
|
||||
{
|
||||
SetState(PreviewRenderer::State::CaptureState);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_currentCaptureRequest.m_content->IsError())
|
||||
{
|
||||
CancelLoadAssets();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewRenderer::CancelLoadAssets()
|
||||
{
|
||||
m_currentCaptureRequest.m_content->ReportErrors();
|
||||
CancelCaptureRequest();
|
||||
}
|
||||
|
||||
void PreviewRenderer::UpdateScene()
|
||||
{
|
||||
m_currentCaptureRequest.m_content->UpdateScene();
|
||||
}
|
||||
|
||||
bool PreviewRenderer::StartCapture()
|
||||
{
|
||||
auto captureCallback = [currentCaptureRequest = m_currentCaptureRequest](const AZ::RPI::AttachmentReadback::ReadbackResult& result)
|
||||
{
|
||||
if (result.m_dataBuffer)
|
||||
{
|
||||
PreviewerFeatureProcessorProviderBus::Handler::BusConnect();
|
||||
|
||||
m_entityContext = AZStd::make_unique<AzFramework::EntityContext>();
|
||||
m_entityContext->InitContext();
|
||||
|
||||
// Create and register a scene with all required feature processors
|
||||
AZStd::unordered_set<AZStd::string> 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::shared_ptr<AzFramework::Scene>, 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<CommonPreviewRendererIdleState>(this);
|
||||
m_states[CommonPreviewRenderer::State::LoadState] = AZStd::make_shared<CommonPreviewRendererLoadState>(this);
|
||||
m_states[CommonPreviewRenderer::State::CaptureState] = AZStd::make_shared<CommonPreviewRendererCaptureState>(this);
|
||||
SetState(CommonPreviewRenderer::State::IdleState);
|
||||
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));
|
||||
}
|
||||
|
||||
CommonPreviewRenderer::~CommonPreviewRenderer()
|
||||
else
|
||||
{
|
||||
PreviewerFeatureProcessorProviderBus::Handler::BusDisconnect();
|
||||
|
||||
SetState(CommonPreviewRenderer::State::None);
|
||||
m_currentCaptureRequest = {};
|
||||
m_captureRequestQueue = {};
|
||||
|
||||
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());
|
||||
currentCaptureRequest.m_captureFailedCallback();
|
||||
}
|
||||
};
|
||||
|
||||
RPI::ScenePtr CommonPreviewRenderer::GetScene() const
|
||||
{
|
||||
return m_scene;
|
||||
}
|
||||
if (auto renderToTexturePass = azrtti_cast<AZ::RPI::RenderToTexturePass*>(m_renderPipeline->GetRootPass().get()))
|
||||
{
|
||||
renderToTexturePass->ResizeOutput(m_currentCaptureRequest.m_size, m_currentCaptureRequest.m_size);
|
||||
}
|
||||
|
||||
RPI::ViewPtr CommonPreviewRenderer::GetView() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
m_renderPipeline->AddToRenderTickOnce();
|
||||
|
||||
AZ::Uuid CommonPreviewRenderer::GetEntityContextId() const
|
||||
{
|
||||
return m_entityContext->GetContextId();
|
||||
}
|
||||
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::AddCaptureRequest(const CaptureRequest& captureRequest)
|
||||
{
|
||||
m_captureRequestQueue.push(captureRequest);
|
||||
}
|
||||
void PreviewRenderer::EndCapture()
|
||||
{
|
||||
m_renderPipeline->RemoveFromRenderTick();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
CommonPreviewRenderer::State CommonPreviewRenderer::GetState() const
|
||||
{
|
||||
return m_currentState;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::CancelCaptureRequest()
|
||||
{
|
||||
m_currentCaptureRequest.m_captureFailedCallback();
|
||||
SetState(CommonPreviewRenderer::State::IdleState);
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::CompleteCaptureRequest()
|
||||
{
|
||||
SetState(CommonPreviewRenderer::State::IdleState);
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::LoadAssets()
|
||||
{
|
||||
m_currentCaptureRequest.m_content->Load();
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::UpdateLoadAssets()
|
||||
{
|
||||
if (m_currentCaptureRequest.m_content->IsReady())
|
||||
{
|
||||
SetState(CommonPreviewRenderer::State::CaptureState);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_currentCaptureRequest.m_content->IsError())
|
||||
{
|
||||
CancelLoadAssets();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::CancelLoadAssets()
|
||||
{
|
||||
m_currentCaptureRequest.m_content->ReportErrors();
|
||||
CancelCaptureRequest();
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::UpdateScene()
|
||||
{
|
||||
m_currentCaptureRequest.m_content->UpdateScene();
|
||||
}
|
||||
|
||||
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<AZ::RPI::RenderToTexturePass*>(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;
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::EndCapture()
|
||||
{
|
||||
m_renderPipeline->RemoveFromRenderTick();
|
||||
}
|
||||
|
||||
void CommonPreviewRenderer::GetRequiredFeatureProcessors(AZStd::unordered_set<AZStd::string>& 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<AZStd::string>& 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
|
||||
|
||||
+36
-42
@@ -6,52 +6,46 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererCaptureState.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRenderer.h>
|
||||
#include <PreviewRenderer/PreviewRendererCaptureState.h>
|
||||
|
||||
namespace AZ
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
namespace LyIntegration
|
||||
PreviewRendererCaptureState::PreviewRendererCaptureState(PreviewRenderer* renderer)
|
||||
: PreviewRendererState(renderer)
|
||||
{
|
||||
namespace Thumbnails
|
||||
}
|
||||
|
||||
void PreviewRendererCaptureState::Start()
|
||||
{
|
||||
m_ticksToCapture = 1;
|
||||
m_renderer->UpdateScene();
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void PreviewRendererCaptureState::Stop()
|
||||
{
|
||||
m_renderer->EndCapture();
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
AZ::Render::FrameCaptureNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void PreviewRendererCaptureState::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
|
||||
{
|
||||
if (m_ticksToCapture-- <= 0)
|
||||
{
|
||||
CommonPreviewRendererCaptureState::CommonPreviewRendererCaptureState(CommonPreviewRenderer* renderer)
|
||||
: CommonPreviewRendererState(renderer)
|
||||
// Reset the capture flag if the capture request was successful. Otherwise try capture it again next tick.
|
||||
if (m_renderer->StartCapture())
|
||||
{
|
||||
AZ::Render::FrameCaptureNotificationBus::Handler::BusConnect();
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommonPreviewRendererCaptureState::Start()
|
||||
{
|
||||
m_ticksToCapture = 1;
|
||||
m_renderer->UpdateScene();
|
||||
TickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void CommonPreviewRendererCaptureState::Stop()
|
||||
{
|
||||
m_renderer->EndCapture();
|
||||
TickBus::Handler::BusDisconnect();
|
||||
Render::FrameCaptureNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void CommonPreviewRendererCaptureState::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] 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())
|
||||
{
|
||||
Render::FrameCaptureNotificationBus::Handler::BusConnect();
|
||||
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
|
||||
|
||||
+20
-27
@@ -9,38 +9,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <Atom/Feature/Utils/FrameCaptureBus.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRendererState.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererState.h>
|
||||
|
||||
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
|
||||
|
||||
+19
-25
@@ -6,34 +6,28 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererIdleState.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRenderer.h>
|
||||
#include <PreviewRenderer/PreviewRendererIdleState.h>
|
||||
|
||||
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
|
||||
|
||||
+16
-23
@@ -8,31 +8,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererState.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRendererState.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
|
||||
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
|
||||
|
||||
+31
-37
@@ -6,44 +6,38 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererLoadState.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRenderer.h>
|
||||
#include <PreviewRenderer/PreviewRendererLoadState.h>
|
||||
|
||||
namespace AZ
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
namespace LyIntegration
|
||||
PreviewRendererLoadState::PreviewRendererLoadState(PreviewRenderer* renderer)
|
||||
: PreviewRendererState(renderer)
|
||||
{
|
||||
namespace Thumbnails
|
||||
}
|
||||
|
||||
void PreviewRendererLoadState::Start()
|
||||
{
|
||||
m_renderer->LoadAssets();
|
||||
m_timeRemainingS = TimeOutS;
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void PreviewRendererLoadState::Stop()
|
||||
{
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void PreviewRendererLoadState::OnTick(float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
|
||||
{
|
||||
m_timeRemainingS -= deltaTime;
|
||||
if (m_timeRemainingS > 0.0f)
|
||||
{
|
||||
CommonPreviewRendererLoadState::CommonPreviewRendererLoadState(CommonPreviewRenderer* renderer)
|
||||
: CommonPreviewRendererState(renderer)
|
||||
{
|
||||
}
|
||||
|
||||
void CommonPreviewRendererLoadState::Start()
|
||||
{
|
||||
m_renderer->LoadAssets();
|
||||
m_timeRemainingS = TimeOutS;
|
||||
TickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void CommonPreviewRendererLoadState::Stop()
|
||||
{
|
||||
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
|
||||
m_renderer->UpdateLoadAssets();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_renderer->CancelLoadAssets();
|
||||
}
|
||||
}
|
||||
} // namespace AtomToolsFramework
|
||||
|
||||
+17
-24
@@ -9,33 +9,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRendererState.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRendererState.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
-33
@@ -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 <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
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<AZStd::string>& featureProcessors) const = 0;
|
||||
};
|
||||
|
||||
using PreviewerFeatureProcessorProviderBus = AZ::EBus<PreviewerFeatureProcessorProviderRequests>;
|
||||
} // namespace Thumbnails
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
+2
-2
@@ -13,7 +13,7 @@
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewContent.h>
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewContent.h>
|
||||
|
||||
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);
|
||||
|
||||
+2
-2
@@ -8,10 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AtomToolsFramework/PreviewRenderer/PreviewRenderer.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <Thumbnails/Rendering/CommonPreviewRenderer.h>
|
||||
#include <Thumbnails/Thumbnail.h>
|
||||
|
||||
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
|
||||
|
||||
+4
-4
@@ -14,14 +14,14 @@
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
|
||||
#include <Source/Thumbnails/Preview/CommonPreviewer.h>
|
||||
#include <Source/Thumbnails/ThumbnailUtils.h>
|
||||
#include <Thumbnails/Preview/CommonPreviewer.h>
|
||||
#include <Thumbnails/ThumbnailUtils.h>
|
||||
|
||||
// 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 <Source/Thumbnails/Preview/ui_CommonPreviewer.h>
|
||||
#include <Thumbnails/Preview/ui_CommonPreviewer.h>
|
||||
#include <QString>
|
||||
#include <QResizeEvent>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
@@ -73,4 +73,4 @@ namespace AZ
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Source/Thumbnails/Preview/moc_CommonPreviewer.cpp>
|
||||
#include <Thumbnails/Preview/moc_CommonPreviewer.cpp>
|
||||
|
||||
-11
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user