ATOM-16747 RPISystemInterface::GetDefaultScene returns the scene crea… (#5153) (#5389)

* ATOM-16747 RPISystemInterface::GetDefaultScene returns the scene created by PreviewRenderer but not the Main Scene
Deprecate GetDefaultScene() function.
Update all the places which use GetDefaultScene to use Scene::GetFeatureProcessorFromEntityId or GetMainScene.
Tested with Editor, UI Editor, Material Editor, game launcher.

Signed-off-by: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com>
(cherry picked from commit 8da6bea073)
monroegm-disable-blank-issue-2
Qing Tao 4 years ago committed by GitHub
parent c0d36399db
commit 5a39361f77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -272,6 +272,7 @@ namespace AZ
// Create and register a scene with all available feature processors // Create and register a scene with all available feature processors
RPI::SceneDescriptor sceneDesc; RPI::SceneDescriptor sceneDesc;
sceneDesc.m_nameId = AZ::Name("Main");
AZ::RPI::ScenePtr atomScene = RPI::Scene::CreateScene(sceneDesc); AZ::RPI::ScenePtr atomScene = RPI::Scene::CreateScene(sceneDesc);
atomScene->EnableAllFeatureProcessors(); atomScene->EnableAllFeatureProcessors();
atomScene->Activate(); atomScene->Activate();

@ -32,7 +32,7 @@ namespace AZ
{ {
if (m_rtPipeline) if (m_rtPipeline)
{ {
AZ::RPI::RPISystemInterface::Get()->GetDefaultScene()->RemoveRenderPipeline(m_rtPipeline->GetId()); m_rtPipeline->RemoveFromScene();
m_rtPipeline = nullptr; m_rtPipeline = nullptr;
} }
@ -111,8 +111,12 @@ namespace AZ
parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM); parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM);
break; break;
} }
AZ::RPI::RPISystemInterface::Get()->GetDefaultScene()->AddRenderPipeline(m_rtPipeline); const auto mainScene = AZ::RPI::RPISystemInterface::Get()->GetSceneByName(AZ::Name("RPI"));
if (mainScene)
{
mainScene->AddRenderPipeline(m_rtPipeline);
}
} }
bool LuxCoreTexture::IsIBLTexture() bool LuxCoreTexture::IsIBLTexture()

@ -70,7 +70,8 @@ namespace AZ
void InitializeSystemAssets() override; void InitializeSystemAssets() override;
void RegisterScene(ScenePtr scene) override; void RegisterScene(ScenePtr scene) override;
void UnregisterScene(ScenePtr scene) override; void UnregisterScene(ScenePtr scene) override;
ScenePtr GetScene(const SceneId& sceneId) const override; Scene* GetScene(const SceneId& sceneId) const override;
Scene* GetSceneByName(const AZ::Name& name) const override;
ScenePtr GetDefaultScene() const override; ScenePtr GetDefaultScene() const override;
RenderPipelinePtr GetRenderPipelineForWindow(AzFramework::NativeWindowHandle windowHandle) override; RenderPipelinePtr GetRenderPipelineForWindow(AzFramework::NativeWindowHandle windowHandle) override;
Data::Asset<ShaderAsset> GetCommonShaderAssetForSrgs() const override; Data::Asset<ShaderAsset> GetCommonShaderAssetForSrgs() const override;

@ -13,6 +13,7 @@
#include <Atom/RPI.Public/Base.h> #include <Atom/RPI.Public/Base.h>
#include <AzCore/Name/Name.h>
#include <AzFramework/Windowing/WindowBus.h> #include <AzFramework/Windowing/WindowBus.h>
namespace AZ namespace AZ
@ -46,11 +47,14 @@ namespace AZ
//! Unregister a scene from RPISystem. The scene won't be simulated or rendered. //! Unregister a scene from RPISystem. The scene won't be simulated or rendered.
virtual void UnregisterScene(ScenePtr scene) = 0; virtual void UnregisterScene(ScenePtr scene) = 0;
// [GFX TODO] to be removed when we have scene setup in AZ Core //! Deprecated. Use GetSceneByName(name), GetSceneForEntityContextId(entityContextId) or Scene::GetSceneForEntityId(AZ::EntityId entityId) instead
virtual ScenePtr GetDefaultScene() const = 0; AZ_DEPRECATED(virtual ScenePtr GetDefaultScene() const = 0;, "This method has been deprecated. Please use GetSceneByName(name), GetSceneForEntityContextId(entityContextId) or Scene::GetSceneForEntityId(AZ::EntityId entityId) instead.");
//! Get scene by using scene id. //! Get scene by using scene id.
virtual ScenePtr GetScene(const SceneId& sceneId) const = 0; virtual Scene* GetScene(const SceneId& sceneId) const = 0;
//! Get scene by using scene name.
virtual Scene* GetSceneByName(const AZ::Name& name) const = 0;
//! Get the render pipeline created for a window //! Get the render pipeline created for a window
virtual RenderPipelinePtr GetRenderPipelineForWindow(AzFramework::NativeWindowHandle windowHandle) = 0; virtual RenderPipelinePtr GetRenderPipelineForWindow(AzFramework::NativeWindowHandle windowHandle) = 0;

@ -80,6 +80,9 @@ namespace AZ
//! Gets the RPI::Scene for a given entityContextId. //! Gets the RPI::Scene for a given entityContextId.
//! May return nullptr if there is no RPI::Scene created for that entityContext. //! May return nullptr if there is no RPI::Scene created for that entityContext.
static Scene* GetSceneForEntityContextId(AzFramework::EntityContextId entityContextId); static Scene* GetSceneForEntityContextId(AzFramework::EntityContextId entityContextId);
//! Gets the RPI::Scene for a given entityId.
static Scene* GetSceneForEntityId(AZ::EntityId entityId);
~Scene(); ~Scene();
@ -135,6 +138,8 @@ namespace AZ
const SceneId& GetId() const; const SceneId& GetId() const;
AZ::Name GetName() const;
//! Set default pipeline by render pipeline ID. //! Set default pipeline by render pipeline ID.
//! It returns true if the default render pipeline was set from the input ID. //! It returns true if the default render pipeline was set from the input ID.
//! If the specified render pipeline doesn't exist in this scene then it won't do anything and returns false. //! If the specified render pipeline doesn't exist in this scene then it won't do anything and returns false.
@ -245,6 +250,9 @@ namespace AZ
// The uuid to identify this scene. // The uuid to identify this scene.
SceneId m_id; SceneId m_id;
// Scene's name which is set at initialization. Can be empty
AZ::Name m_name;
bool m_activated = false; bool m_activated = false;
bool m_taskGraphActive = false; // update during tick, to ensure it only changes on frame boundaries bool m_taskGraphActive = false; // update during tick, to ensure it only changes on frame boundaries
@ -286,13 +294,10 @@ namespace AZ
template<typename FeatureProcessorType> template<typename FeatureProcessorType>
FeatureProcessorType* Scene::GetFeatureProcessorForEntity(AZ::EntityId entityId) FeatureProcessorType* Scene::GetFeatureProcessorForEntity(AZ::EntityId entityId)
{ {
// Find the entity context for the entity ID. RPI::Scene* renderScene = GetSceneForEntityId(entityId);
AzFramework::EntityContextId entityContextId = AzFramework::EntityContextId::CreateNull(); if (renderScene)
AzFramework::EntityIdContextQueryBus::EventResult(entityContextId, entityId, &AzFramework::EntityIdContextQueryBus::Events::GetOwningContextId);
if (!entityContextId.IsNull())
{ {
return GetFeatureProcessorForEntityContextId<FeatureProcessorType>(entityContextId); return renderScene->GetFeatureProcessor<FeatureProcessorType>();
} }
return nullptr; return nullptr;
}; };

@ -9,6 +9,7 @@
#pragma once #pragma once
#include <AzCore/Asset/AssetCommon.h> #include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Name/Name.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h> #include <AzCore/std/string/string.h>
@ -25,6 +26,9 @@ namespace AZ
//! List of feature processors which the scene will initially enable. //! List of feature processors which the scene will initially enable.
AZStd::vector<AZStd::string> m_featureProcessorNames; AZStd::vector<AZStd::string> m_featureProcessorNames;
//! A name used as scene id. It can be used to search a registered scene via RPISystemInterface::GetScene()
AZ::Name m_nameId;
}; };
} // namespace RPI } // namespace RPI
} // namespace AZ } // namespace AZ

@ -699,9 +699,7 @@ namespace AZ
m_parentScene = parentScene; m_parentScene = parentScene;
AZ_Assert(m_visScene == nullptr, "IVisibilityScene already created for this RPI::Scene"); AZ_Assert(m_visScene == nullptr, "IVisibilityScene already created for this RPI::Scene");
char sceneIdBuf[40] = ""; AZ::Name visSceneName(AZStd::string::format("RenderCullScene[%s]", m_parentScene->GetName().GetCStr()));
m_parentScene->GetId().ToString(sceneIdBuf);
AZ::Name visSceneName(AZStd::string::format("RenderCullScene[%s]", sceneIdBuf));
m_visScene = AZ::Interface<AzFramework::IVisibilitySystem>::Get()->CreateVisibilityScene(visSceneName); m_visScene = AZ::Interface<AzFramework::IVisibilitySystem>::Get()->CreateVisibilityScene(visSceneName);
#ifdef AZ_CULL_DEBUG_ENABLED #ifdef AZ_CULL_DEBUG_ENABLED

@ -159,6 +159,11 @@ namespace AZ
AZ_Assert(false, "Scene was already registered"); AZ_Assert(false, "Scene was already registered");
return; return;
} }
else if (!scene->GetName().IsEmpty() && scene->GetName() == sceneItem->GetName())
{
// only report a warning if there is a scene with duplicated name
AZ_Warning("RPISystem", false, "There is a registered scene with same name [%s]", scene->GetName().GetCStr());
}
} }
m_scenes.push_back(scene); m_scenes.push_back(scene);
@ -177,28 +182,42 @@ namespace AZ
AZ_Assert(false, "Can't unregister scene which wasn't registered"); AZ_Assert(false, "Can't unregister scene which wasn't registered");
} }
ScenePtr RPISystem::GetScene(const SceneId& sceneId) const Scene* RPISystem::GetScene(const SceneId& sceneId) const
{ {
for (const auto& scene : m_scenes) for (const auto& scene : m_scenes)
{ {
if (scene->GetId() == sceneId) if (scene->GetId() == sceneId)
{ {
return scene; return scene.get();
} }
} }
return nullptr; return nullptr;
} }
Scene* RPISystem::GetSceneByName(const AZ::Name& name) const
{
for (const auto& scene : m_scenes)
{
if (scene->GetName() == name)
{
return scene.get();
}
}
return nullptr;
}
ScenePtr RPISystem::GetDefaultScene() const ScenePtr RPISystem::GetDefaultScene() const
{ {
if (m_scenes.size() > 0) for (const auto& scene : m_scenes)
{ {
return m_scenes[0]; if (scene->GetName() == AZ::Name("Main"))
{
return scene;
}
} }
return nullptr; return nullptr;
} }
RenderPipelinePtr RPISystem::GetRenderPipelineForWindow(AzFramework::NativeWindowHandle windowHandle) RenderPipelinePtr RPISystem::GetRenderPipelineForWindow(AzFramework::NativeWindowHandle windowHandle)
{ {
RenderPipelinePtr renderPipeline; RenderPipelinePtr renderPipeline;

@ -45,7 +45,9 @@ namespace AZ
auto shaderAsset = RPISystemInterface::Get()->GetCommonShaderAssetForSrgs(); auto shaderAsset = RPISystemInterface::Get()->GetCommonShaderAssetForSrgs();
scene->m_srg = ShaderResourceGroup::Create(shaderAsset, sceneSrgLayout->GetName()); scene->m_srg = ShaderResourceGroup::Create(shaderAsset, sceneSrgLayout->GetName());
} }
scene->m_name = sceneDescriptor.m_nameId;
return ScenePtr(scene); return ScenePtr(scene);
} }
@ -83,10 +85,23 @@ namespace AZ
return nullptr; return nullptr;
} }
Scene* Scene::GetSceneForEntityId(AZ::EntityId entityId)
{
// Find the entity context for the entity ID.
AzFramework::EntityContextId entityContextId = AzFramework::EntityContextId::CreateNull();
AzFramework::EntityIdContextQueryBus::EventResult(entityContextId, entityId, &AzFramework::EntityIdContextQueryBus::Events::GetOwningContextId);
if (!entityContextId.IsNull())
{
return GetSceneForEntityContextId(entityContextId);
}
return nullptr;
}
Scene::Scene() Scene::Scene()
{ {
m_id = Uuid::CreateRandom(); m_id = AZ::Uuid::CreateRandom();
m_cullingScene = aznew CullingScene(); m_cullingScene = aznew CullingScene();
SceneRequestBus::Handler::BusConnect(m_id); SceneRequestBus::Handler::BusConnect(m_id);
m_drawFilterTagRegistry = RHI::DrawFilterTagRegistry::Create(); m_drawFilterTagRegistry = RHI::DrawFilterTagRegistry::Create();
@ -299,7 +314,6 @@ namespace AZ
// Force to update the lookup table since adding render pipeline would effect any pipeline states created before pass system tick // Force to update the lookup table since adding render pipeline would effect any pipeline states created before pass system tick
RebuildPipelineStatesLookup(); RebuildPipelineStatesLookup();
AZ_Assert(!m_id.IsNull(), "RPI::Scene needs to have a valid uuid.");
SceneNotificationBus::Event(m_id, &SceneNotification::OnRenderPipelineAdded, pipeline); SceneNotificationBus::Event(m_id, &SceneNotification::OnRenderPipelineAdded, pipeline);
} }
@ -785,6 +799,11 @@ namespace AZ
{ {
return m_id; return m_id;
} }
AZ::Name Scene::GetName() const
{
return m_name;
}
bool Scene::SetDefaultRenderPipeline(const RenderPipelineId& pipelineId) bool Scene::SetDefaultRenderPipeline(const RenderPipelineId& pipelineId)
{ {

@ -43,6 +43,7 @@ namespace AtomToolsFramework
&PreviewerFeatureProcessorProviderBus::Handler::GetRequiredFeatureProcessors, featureProcessors); &PreviewerFeatureProcessorProviderBus::Handler::GetRequiredFeatureProcessors, featureProcessors);
AZ::RPI::SceneDescriptor sceneDesc; AZ::RPI::SceneDescriptor sceneDesc;
sceneDesc.m_nameId = AZ::Name("PreviewRenderer");
sceneDesc.m_featureProcessorNames.assign(featureProcessors.begin(), featureProcessors.end()); sceneDesc.m_featureProcessorNames.assign(featureProcessors.begin(), featureProcessors.end());
m_scene = AZ::RPI::Scene::CreateScene(sceneDesc); m_scene = AZ::RPI::Scene::CreateScene(sceneDesc);

@ -279,9 +279,9 @@ namespace MaterialEditor
// reset environment // reset environment
AZ::Transform iblTransform = AZ::Transform::CreateIdentity(); AZ::Transform iblTransform = AZ::Transform::CreateIdentity();
AZ::TransformBus::Event(m_iblEntityId, &AZ::TransformBus::Events::SetLocalTM, iblTransform); AZ::TransformBus::Event(m_iblEntityId, &AZ::TransformBus::Events::SetLocalTM, iblTransform);
const AZ::Matrix4x4 rotationMatrix = AZ::Matrix4x4::CreateIdentity(); const AZ::Matrix4x4 rotationMatrix = AZ::Matrix4x4::CreateIdentity();
AZ::RPI::ScenePtr scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); auto skyBoxFeatureProcessorInterface = AZ::RPI::Scene::GetFeatureProcessorForEntity<AZ::Render::SkyBoxFeatureProcessorInterface>(m_iblEntityId);
auto skyBoxFeatureProcessorInterface = scene->GetFeatureProcessor<AZ::Render::SkyBoxFeatureProcessorInterface>();
skyBoxFeatureProcessorInterface->SetCubemapRotationMatrix(rotationMatrix); skyBoxFeatureProcessorInterface->SetCubemapRotationMatrix(rotationMatrix);
if (m_behavior) if (m_behavior)

@ -25,8 +25,7 @@ namespace MaterialEditor
m_iblEntityId, m_iblEntityId,
&MaterialEditorViewportInputControllerRequestBus::Handler::GetIblEntityId); &MaterialEditorViewportInputControllerRequestBus::Handler::GetIblEntityId);
AZ_Assert(m_iblEntityId.IsValid(), "Failed to find m_iblEntityId"); AZ_Assert(m_iblEntityId.IsValid(), "Failed to find m_iblEntityId");
AZ::RPI::ScenePtr scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); m_skyBoxFeatureProcessorInterface = AZ::RPI::Scene::GetFeatureProcessorForEntity<AZ::Render::SkyBoxFeatureProcessorInterface>(m_iblEntityId);
m_skyBoxFeatureProcessorInterface = scene->GetFeatureProcessor<AZ::Render::SkyBoxFeatureProcessorInterface>();
} }
void RotateEnvironmentBehavior::TickInternal(float x, float y, float z) void RotateEnvironmentBehavior::TickInternal(float x, float y, float z)

@ -67,6 +67,7 @@ namespace MaterialEditor
// Create and register a scene with all available feature processors // Create and register a scene with all available feature processors
AZ::RPI::SceneDescriptor sceneDesc; AZ::RPI::SceneDescriptor sceneDesc;
sceneDesc.m_nameId = AZ::Name("MaterialViewport");
m_scene = AZ::RPI::Scene::CreateScene(sceneDesc); m_scene = AZ::RPI::Scene::CreateScene(sceneDesc);
m_scene->EnableAllFeatureProcessors(); m_scene->EnableAllFeatureProcessors();

@ -108,7 +108,7 @@ namespace AZ
{ {
m_dynamicDrawManager.reset(); m_dynamicDrawManager.reset();
AZ::RPI::ViewportContextManagerNotificationsBus::Handler::BusDisconnect(); AZ::RPI::ViewportContextManagerNotificationsBus::Handler::BusDisconnect();
RPI::Scene* scene = RPI::RPISystemInterface::Get()->GetDefaultScene().get(); RPI::Scene* scene = AZ::RPI::Scene::GetSceneForEntityContextId(m_entityContextId);
// Check if scene is emptry since scene might be released already when running AtomSampleViewer // Check if scene is emptry since scene might be released already when running AtomSampleViewer
if (scene) if (scene)
{ {
@ -157,9 +157,9 @@ namespace AZ
void AtomBridgeSystemComponent::OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene) void AtomBridgeSystemComponent::OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene)
{ {
AZ_UNUSED(bootstrapScene);
// Make default AtomDebugDisplayViewportInterface // Make default AtomDebugDisplayViewportInterface
AZStd::shared_ptr<AtomDebugDisplayViewportInterface> mainEntityDebugDisplay = AZStd::make_shared<AtomDebugDisplayViewportInterface>(AzFramework::g_defaultSceneEntityDebugDisplayId); AZStd::shared_ptr<AtomDebugDisplayViewportInterface> mainEntityDebugDisplay =
AZStd::make_shared<AtomDebugDisplayViewportInterface>(AzFramework::g_defaultSceneEntityDebugDisplayId, bootstrapScene);
m_activeViewportsList[AzFramework::g_defaultSceneEntityDebugDisplayId] = mainEntityDebugDisplay; m_activeViewportsList[AzFramework::g_defaultSceneEntityDebugDisplayId] = mainEntityDebugDisplay;
} }

@ -256,12 +256,11 @@ namespace AZ::AtomBridge
viewportContextPtr->ConnectSceneChangedHandler(m_sceneChangeHandler); viewportContextPtr->ConnectSceneChangedHandler(m_sceneChangeHandler);
} }
AtomDebugDisplayViewportInterface::AtomDebugDisplayViewportInterface(uint32_t defaultInstanceAddress) AtomDebugDisplayViewportInterface::AtomDebugDisplayViewportInterface(uint32_t defaultInstanceAddress, RPI::Scene* scene)
{ {
ResetRenderState(); ResetRenderState();
m_viewportId = defaultInstanceAddress; m_viewportId = defaultInstanceAddress;
m_defaultInstance = true; m_defaultInstance = true;
RPI::Scene* scene = RPI::RPISystemInterface::Get()->GetDefaultScene().get();
InitInternal(scene, nullptr); InitInternal(scene, nullptr);
} }

@ -124,7 +124,7 @@ namespace AZ::AtomBridge
AZ_RTTI(AtomDebugDisplayViewportInterface, "{09AF6A46-0100-4FBF-8F94-E6B221322D14}", AzFramework::DebugDisplayRequestBus::Handler); AZ_RTTI(AtomDebugDisplayViewportInterface, "{09AF6A46-0100-4FBF-8F94-E6B221322D14}", AzFramework::DebugDisplayRequestBus::Handler);
explicit AtomDebugDisplayViewportInterface(AZ::RPI::ViewportContextPtr viewportContextPtr); explicit AtomDebugDisplayViewportInterface(AZ::RPI::ViewportContextPtr viewportContextPtr);
explicit AtomDebugDisplayViewportInterface(uint32_t defaultInstanceAddress); explicit AtomDebugDisplayViewportInterface(uint32_t defaultInstanceAddress, RPI::Scene* scene);
~AtomDebugDisplayViewportInterface(); ~AtomDebugDisplayViewportInterface();
void ResetRenderState(); void ResetRenderState();

@ -133,18 +133,6 @@ namespace AZ
typedef std::vector<FontEffect> FontEffects; typedef std::vector<FontEffect> FontEffects;
typedef FontEffects::iterator FontEffectsIterator; typedef FontEffects::iterator FontEffectsIterator;
struct FontPipelineStateMapKey
{
AZ::RPI::SceneId m_sceneId; // which scene pipeline state is attached to (via Render Pipeline)
AZ::RHI::DrawListTag m_drawListTag; // which render pass this pipeline draws in by default
bool operator<(const FontPipelineStateMapKey& other) const
{
return m_sceneId < other.m_sceneId
|| (m_sceneId == other.m_sceneId && m_drawListTag < other.m_drawListTag);
}
};
struct FontShaderData struct FontShaderData
{ {
AZ::RHI::ShaderInputNameIndex m_imageInputIndex = "m_texture"; AZ::RHI::ShaderInputNameIndex m_imageInputIndex = "m_texture";

@ -48,11 +48,7 @@ namespace AZ
void DiffuseGlobalIlluminationComponentController::Activate(EntityId entityId) void DiffuseGlobalIlluminationComponentController::Activate(EntityId entityId)
{ {
AZ_UNUSED(entityId); m_featureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntity<DiffuseGlobalIlluminationFeatureProcessorInterface>(entityId);
const RPI::Scene* scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene().get();
m_featureProcessor = scene->GetFeatureProcessor<DiffuseGlobalIlluminationFeatureProcessorInterface>();
OnConfigChanged(); OnConfigChanged();
} }

@ -79,7 +79,7 @@ namespace AZ
m_entityId = entityId; m_entityId = entityId;
m_dirty = true; m_dirty = true;
RPI::ScenePtr scene = RPI::RPISystemInterface::Get()->GetDefaultScene(); RPI::Scene* scene = RPI::Scene::GetSceneForEntityId(m_entityId);
if (scene) if (scene)
{ {
AZ::RPI::SceneNotificationBus::Handler::BusConnect(scene->GetId()); AZ::RPI::SceneNotificationBus::Handler::BusConnect(scene->GetId());

@ -357,8 +357,7 @@ namespace AZ
void DisplayMapperComponentController::OnConfigChanged() void DisplayMapperComponentController::OnConfigChanged()
{ {
// Register the configuration with the AcesDisplayMapperFeatureProcessor for this scene. // Register the configuration with the AcesDisplayMapperFeatureProcessor for this scene.
const AZ::RPI::Scene* scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene().get(); DisplayMapperFeatureProcessorInterface* fp = AZ::RPI::Scene::GetFeatureProcessorForEntity<DisplayMapperFeatureProcessorInterface>(m_entityId);
DisplayMapperFeatureProcessorInterface* fp = scene->GetFeatureProcessor<DisplayMapperFeatureProcessorInterface>();
DisplayMapperConfigurationDescriptor desc; DisplayMapperConfigurationDescriptor desc;
desc.m_operationType = m_configuration.m_displayMapperOperation; desc.m_operationType = m_configuration.m_displayMapperOperation;
desc.m_ldrGradingLutEnabled = m_configuration.m_ldrColorGradingLutEnabled; desc.m_ldrGradingLutEnabled = m_configuration.m_ldrColorGradingLutEnabled;

@ -48,7 +48,7 @@ namespace AZ
// CVar for toggling the display of the scene stats // CVar for toggling the display of the scene stats
int r_skinnedMeshDisplaySceneStats = 0; int r_skinnedMeshDisplaySceneStats = 0;
// SceneId to query for the stats // SceneId to query for the stats
RPI::SceneId m_sceneId = RPI::SceneId::CreateNull(); RPI::SceneId m_sceneId;
}; };
}// namespace Render }// namespace Render
}// namespace AZ }// namespace AZ

@ -60,6 +60,7 @@ namespace EMStudio
// Create and register a scene with all available feature processors // Create and register a scene with all available feature processors
AZ::RPI::SceneDescriptor sceneDesc; AZ::RPI::SceneDescriptor sceneDesc;
sceneDesc.m_nameId = AZ::Name("AnimViewport");
m_scene = AZ::RPI::Scene::CreateScene(sceneDesc); m_scene = AZ::RPI::Scene::CreateScene(sceneDesc);
m_scene->EnableAllFeatureProcessors(); m_scene->EnableAllFeatureProcessors();
@ -213,8 +214,7 @@ namespace EMStudio
AZ::TransformBus::Event(m_iblEntity->GetId(), &AZ::TransformBus::Events::SetLocalTM, iblTransform); AZ::TransformBus::Event(m_iblEntity->GetId(), &AZ::TransformBus::Events::SetLocalTM, iblTransform);
const AZ::Matrix4x4 rotationMatrix = AZ::Matrix4x4::CreateIdentity(); const AZ::Matrix4x4 rotationMatrix = AZ::Matrix4x4::CreateIdentity();
AZ::RPI::ScenePtr scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); auto skyBoxFeatureProcessorInterface = m_scene->GetFeatureProcessor<AZ::Render::SkyBoxFeatureProcessorInterface>();
auto skyBoxFeatureProcessorInterface = scene->GetFeatureProcessor<AZ::Render::SkyBoxFeatureProcessorInterface>();
skyBoxFeatureProcessorInterface->SetCubemapRotationMatrix(rotationMatrix); skyBoxFeatureProcessorInterface->SetCubemapRotationMatrix(rotationMatrix);
} }

@ -255,19 +255,22 @@ namespace Blast
BlastFamilyComponentRequestBus::Broadcast( BlastFamilyComponentRequestBus::Broadcast(
&BlastFamilyComponentRequests::FillDebugRenderBuffer, buffer, m_debugRenderMode); &BlastFamilyComponentRequests::FillDebugRenderBuffer, buffer, m_debugRenderMode);
// This is a system component, and thus is not associated with a specific scene, so use the default scene // This is a system component, and thus is not associated with a specific scene, so use the bootstrap scene
// for the debug drawing // for the debug drawing
const auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); const auto mainScene = AZ::RPI::RPISystemInterface::Get()->GetSceneByName(AZ::Name("Main"));
auto drawQueue = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene); if (mainScene)
for (DebugLine& line : buffer.m_lines)
{ {
AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArguments; auto drawQueue = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(mainScene);
drawArguments.m_verts = &line.m_p0;
drawArguments.m_vertCount = 2; for (DebugLine& line : buffer.m_lines)
drawArguments.m_colors = &line.m_color; {
drawArguments.m_colorCount = 1; AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArguments;
drawQueue->DrawLines(drawArguments); drawArguments.m_verts = &line.m_p0;
drawArguments.m_vertCount = 2;
drawArguments.m_colors = &line.m_color;
drawArguments.m_colorCount = 1;
drawQueue->DrawLines(drawArguments);
}
} }
} }
} }

@ -65,7 +65,7 @@ CDraw2d::~CDraw2d()
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapScene) void CDraw2d::OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene)
{ {
// At this point the RPI is ready for use // At this point the RPI is ready for use
@ -74,16 +74,16 @@ void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapSc
AZ::Data::Instance<AZ::RPI::Shader> shader = AZ::RPI::LoadCriticalShader(shaderFilepath); AZ::Data::Instance<AZ::RPI::Shader> shader = AZ::RPI::LoadCriticalShader(shaderFilepath);
// Set scene to be associated with the dynamic draw context // Set scene to be associated with the dynamic draw context
AZ::RPI::ScenePtr scene; AZ::RPI::Scene* scene = nullptr;
if (m_viewportContext) if (m_viewportContext)
{ {
// Use scene associated with the specified viewport context // Use scene associated with the specified viewport context
scene = m_viewportContext->GetRenderScene(); scene = m_viewportContext->GetRenderScene().get();
} }
else else
{ {
// No viewport context specified, use default scene // No viewport context specified, use main scene
scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); scene = bootstrapScene;
} }
AZ_Assert(scene != nullptr, "Attempting to create a DynamicDrawContext for a viewport context that has not been associated with a scene yet."); AZ_Assert(scene != nullptr, "Attempting to create a DynamicDrawContext for a viewport context that has not been associated with a scene yet.");
@ -113,7 +113,7 @@ void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapSc
else else
{ {
// Render target support is disabled // Render target support is disabled
m_dynamicDraw->SetOutputScope(scene.get()); m_dynamicDraw->SetOutputScope(scene);
} }
m_dynamicDraw->EndInit(); m_dynamicDraw->EndInit();

@ -653,12 +653,12 @@ void CLyShine::OnRenderTick()
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void CLyShine::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapScene) void CLyShine::OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene)
{ {
// Load cursor if its path was set before RPI was initialized // Load cursor if its path was set before RPI was initialized
LoadUiCursor(); LoadUiCursor();
LyShinePassDataRequestBus::Handler::BusConnect(AZ::RPI::RPISystemInterface::Get()->GetDefaultScene()->GetId()); LyShinePassDataRequestBus::Handler::BusConnect(bootstrapScene->GetId());
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

@ -52,7 +52,7 @@ bool UiRenderer::IsReady()
return m_isRPIReady; return m_isRPIReady;
} }
void UiRenderer::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapScene) void UiRenderer::OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene)
{ {
// At this point the RPI is ready for use // At this point the RPI is ready for use
@ -64,16 +64,17 @@ void UiRenderer::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstra
if (m_viewportContext) if (m_viewportContext)
{ {
// Create a new scene based on the user specified viewport context // Create a new scene based on the user specified viewport context
m_scene = CreateScene(m_viewportContext); m_ownedScene = CreateScene(m_viewportContext);
m_scene = m_ownedScene.get();
} }
else else
{ {
// No viewport context specified, use default scene // No viewport context specified, use default scene
m_scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); m_scene = bootstrapScene;
} }
// Create a dynamic draw context for UI Canvas drawing for the scene // Create a dynamic draw context for UI Canvas drawing for the scene
m_dynamicDraw = CreateDynamicDrawContext(m_scene, uiShader); m_dynamicDraw = CreateDynamicDrawContext(uiShader);
if (m_dynamicDraw) if (m_dynamicDraw)
{ {
@ -93,6 +94,7 @@ AZ::RPI::ScenePtr UiRenderer::CreateScene(AZStd::shared_ptr<AZ::RPI::ViewportCon
{ {
// Create a scene with the necessary feature processors // Create a scene with the necessary feature processors
AZ::RPI::SceneDescriptor sceneDesc; AZ::RPI::SceneDescriptor sceneDesc;
sceneDesc.m_nameId = AZ::Name("UiRenderer");
AZ::RPI::ScenePtr atomScene = AZ::RPI::Scene::CreateScene(sceneDesc); AZ::RPI::ScenePtr atomScene = AZ::RPI::Scene::CreateScene(sceneDesc);
atomScene->EnableAllFeatureProcessors(); // LYSHINE_ATOM_TODO - have a UI pipeline and enable only needed fps atomScene->EnableAllFeatureProcessors(); // LYSHINE_ATOM_TODO - have a UI pipeline and enable only needed fps
@ -116,7 +118,6 @@ AZ::RPI::ScenePtr UiRenderer::CreateScene(AZStd::shared_ptr<AZ::RPI::ViewportCon
} }
AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> UiRenderer::CreateDynamicDrawContext( AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> UiRenderer::CreateDynamicDrawContext(
AZ::RPI::ScenePtr scene,
AZ::Data::Instance<AZ::RPI::Shader> uiShader) AZ::Data::Instance<AZ::RPI::Shader> uiShader)
{ {
// Find the pass that renders the UI canvases after the rtt passes // Find the pass that renders the UI canvases after the rtt passes
@ -144,7 +145,7 @@ AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> UiRenderer::CreateDynamicDrawContext(
else else
{ {
// Render target support is disabled // Render target support is disabled
dynamicDraw->SetOutputScope(m_scene.get()); dynamicDraw->SetOutputScope(m_scene);
} }
dynamicDraw->EndInit(); dynamicDraw->EndInit();

@ -152,7 +152,6 @@ private: // member functions
//! Create a dynamic draw context for this renderer //! Create a dynamic draw context for this renderer
AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> CreateDynamicDrawContext( AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> CreateDynamicDrawContext(
AZ::RPI::ScenePtr scene,
AZ::Data::Instance<AZ::RPI::Shader> uiShader); AZ::Data::Instance<AZ::RPI::Shader> uiShader);
//! Bind the global white texture for all the texture units we use //! Bind the global white texture for all the texture units we use
@ -175,7 +174,8 @@ protected: // attributes
// Set by user when viewport context is not the main/default viewport // Set by user when viewport context is not the main/default viewport
AZStd::shared_ptr<AZ::RPI::ViewportContext> m_viewportContext; AZStd::shared_ptr<AZ::RPI::ViewportContext> m_viewportContext;
AZ::RPI::ScenePtr m_scene; AZ::RPI::ScenePtr m_ownedScene;
AZ::RPI::Scene* m_scene = nullptr;
#ifndef _RELEASE #ifndef _RELEASE
int m_debugTextureDataRecordLevel = 0; int m_debugTextureDataRecordLevel = 0;

Loading…
Cancel
Save