瀏覽代碼

Added setreg for UI viewport and animation viewport to limit feature … (#11034)

* Added setreg for UI viewport and animation viewport to limit feature processors enabled for their scenes.
https://github.com/o3de/o3de/issues/10931

Signed-off-by: Qing Tao <[email protected]>
Qing Tao 3 年之前
父節點
當前提交
67c3f85ea5

+ 9 - 6
Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp

@@ -56,16 +56,19 @@ namespace EMStudio
         m_frameworkScene = createSceneOutcome.TakeValue();
         m_frameworkScene->SetSubsystem<AzFramework::EntityContext::SceneStorageType>(m_entityContext.get());
 
-        // Create and register a scene with all available feature processors
+        // Create and register a scene with feature processors defined in the viewport settings
         AZ::RPI::SceneDescriptor sceneDesc;
         sceneDesc.m_nameId = AZ::Name("AnimViewport");
+        auto settingsRegistry = AZ::SettingsRegistry::Get();
+        const char* viewportSettingPath = "/O3DE/Editor/Viewport/Animation/Scene";
+        bool sceneDescLoaded = settingsRegistry->GetObject(sceneDesc, viewportSettingPath);
         m_scene = AZ::RPI::Scene::CreateScene(sceneDesc);
-        m_scene->EnableAllFeatureProcessors();
-        // Disable the terrain feature processor as we don't need terrian in anim editor.
-        const AZ::Name terrainFeatureProcessor("TerrainFeatureProcessor");
-        if (m_scene->GetFeatureProcessor(terrainFeatureProcessor))
+
+        if (!sceneDescLoaded)
         {
-            m_scene->DisableFeatureProcessor(terrainFeatureProcessor);
+            AZ_Warning("AnimViewportRenderer", false, "Settings registry is missing the scene settings for this viewport, so all feature processors will be enabled. "
+                        "To enable only a minimal set, add the specific list of feature processors with a registry path of '%s'.", viewportSettingPath);
+            m_scene->EnableAllFeatureProcessors();
         }
 
         // Link our RPI::Scene to the AzFramework::Scene

+ 31 - 0
Gems/AtomLyIntegration/EMotionFXAtom/Registry/AnimViewport.setreg

@@ -0,0 +1,31 @@
+{
+    "O3DE": {
+        "Editor": {
+            "Viewport": {
+                "Animation": {
+                    "Scene": {
+                        "FeatureProcessors": [
+                            "AZ::Render::AcesDisplayMapperFeatureProcessor",
+                            "AZ::Render::DirectionalLightFeatureProcessor",
+                            "AZ::Render::MeshFeatureProcessor",
+                            "AZ::Render::ImageBasedLightFeatureProcessor",
+                            "AZ::Render::PostProcessFeatureProcessor",
+                            "AZ::Render::SkinnedMeshFeatureProcessor",
+                            "AZ::Render::SkyBoxFeatureProcessor",
+                            "AZ::Render::TransformServiceFeatureProcessor",
+
+                            // These FPs can be removed once the LightCullingPass issue [ATOM-17812] is addressed 
+                            "AZ::Render::SimplePointLightFeatureProcessor",
+                            "AZ::Render::SimpleSpotLightFeatureProcessor",
+                            "AZ::Render::PointLightFeatureProcessor",
+                            "AZ::Render::DiskLightFeatureProcessor",
+                            "AZ::Render::CapsuleLightFeatureProcessor",
+                            "AZ::Render::QuadLightFeatureProcessor",
+                            "AZ::Render::DecalTextureArrayFeatureProcessor"
+                        ]
+                    }
+                }
+            }
+        }
+    }
+}

+ 13 - 3
Gems/LyShine/Code/Source/UiRenderer.cpp

@@ -18,8 +18,9 @@
 #include <Atom/RPI.Public/RenderPipeline.h>
 #include <Atom/RPI.Public/Pass/RasterPass.h>
 
-#include <AzCore/Math/MatrixUtils.h>
 #include <AzCore/Debug/Trace.h>
+#include <AzCore/Math/MatrixUtils.h>
+#include <AzCore/Settings/SettingsRegistry.h>
 
 #include <LyShine/IDraw2d.h>
 
@@ -93,11 +94,20 @@ void UiRenderer::OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene)
 
 AZ::RPI::ScenePtr UiRenderer::CreateScene(AZStd::shared_ptr<AZ::RPI::ViewportContext> viewportContext)
 {
-    // Create a scene with the necessary feature processors
+    // Create and register a scene with feature processors defined in the viewport settings
     AZ::RPI::SceneDescriptor sceneDesc;
     sceneDesc.m_nameId = AZ::Name("UiRenderer");
+    auto settingsRegistry = AZ::SettingsRegistry::Get();
+    const char* viewportSettingPath = "/O3DE/Editor/Viewport/UI/Scene";
+    bool sceneDescLoaded = settingsRegistry->GetObject(sceneDesc, viewportSettingPath);
     AZ::RPI::ScenePtr atomScene = AZ::RPI::Scene::CreateScene(sceneDesc);
-    atomScene->EnableAllFeatureProcessors(); // [LYSHINE_ATOM_TODO][GHI #6272] Enable minimal feature processors
+
+    if (!sceneDescLoaded)
+    {
+        AZ_Warning("UiRenderer", false, "Settings registry is missing the scene settings for this viewport, so all feature processors will be enabled. "
+                    "To enable only a minimal set, add the specific list of feature processors with a registry path of '%s'.", viewportSettingPath);
+        atomScene->EnableAllFeatureProcessors();
+    }
 
     // Assign the new scene to the specified viewport context
     viewportContext->SetRenderScene(atomScene);

+ 23 - 0
Gems/LyShine/Registry/UiViewport.setreg

@@ -0,0 +1,23 @@
+{
+    "O3DE": {
+        "Editor": {
+            "Viewport": {
+                "UI": {
+                    "Scene": {
+                        "FeatureProcessors": [
+                            "LyShineFeatureProcessor",
+                            // These FPs can be removed once the LightCullingPass issue [ATOM-17812] is addressed 
+                            "AZ::Render::SimplePointLightFeatureProcessor",
+                            "AZ::Render::SimpleSpotLightFeatureProcessor",
+                            "AZ::Render::PointLightFeatureProcessor",
+                            "AZ::Render::DiskLightFeatureProcessor",
+                            "AZ::Render::CapsuleLightFeatureProcessor",
+                            "AZ::Render::QuadLightFeatureProcessor",
+                            "AZ::Render::DecalTextureArrayFeatureProcessor"
+                        ]
+                    }
+                }
+            }
+        }
+    }
+}