From 32d725844f977e98c42d2dceb6c861b268424366 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Tue, 21 Apr 2026 14:09:23 +0800 Subject: [PATCH] refactor(srp): narrow generic native policy key seams --- ...eySeamNarrowingPlan_完成归档_2026-04-21.md | 60 +++++++++++++++++++ .../RendererBackedRenderPipelineAsset.cs | 43 +++++++++---- .../Core/ScriptableRenderPipelineAsset.cs | 46 -------------- 3 files changed, 90 insertions(+), 59 deletions(-) create mode 100644 docs/used/SRP_GenericNativePolicyKeySeamNarrowingPlan_完成归档_2026-04-21.md diff --git a/docs/used/SRP_GenericNativePolicyKeySeamNarrowingPlan_完成归档_2026-04-21.md b/docs/used/SRP_GenericNativePolicyKeySeamNarrowingPlan_完成归档_2026-04-21.md new file mode 100644 index 00000000..5055c178 --- /dev/null +++ b/docs/used/SRP_GenericNativePolicyKeySeamNarrowingPlan_完成归档_2026-04-21.md @@ -0,0 +1,60 @@ +# SRP Generic Native Policy Key Seam Narrowing Plan 2026-04-21 + +## Goal + +Remove the remaining native policy-key seams from the generic `ScriptableRenderPipelineAsset` API surface and narrow them to renderer-backed pipelines. + +## Why This Stage + +After the previous cleanup stages, the generic managed SRP base still exposes several string-key seams that are not Unity-style SRP-facing concepts: + +1. `GetRenderSceneSetupPolicyAssetKey*` +2. `GetCameraFrameStandalonePassAssetKey*` +3. `GetDirectionalShadowPlanningPolicyAssetKey` +4. `GetDirectionalShadowExecutionPolicyAssetKey*` + +Repo usage shows these seams are effectively renderer-backed only: + +1. renderer-data-level overrides live in `ScriptableRendererData` / `UniversalRendererData`; +2. asset-level directional-shadow planning override lives in `UniversalRenderPipelineAsset`; +3. no plain `ScriptableRenderPipelineAsset` subclass currently overrides these methods. + +So the generic base is still carrying URP/native binding details that should sit lower in the stack. + +## Scope + +Included: + +1. remove the remaining native policy-key methods from generic `ScriptableRenderPipelineAsset`; +2. re-home asset-level fallback hooks onto `RendererBackedRenderPipelineAsset`; +3. keep optional native Mono bridge resolution so renderer-backed/URP behavior still works; +4. rebuild `XCEditor` and run old editor smoke. + +Not included: + +1. removing policy-key based native resolution entirely; +2. changing renderer-data-level native key APIs; +3. redesigning native scene renderer binding itself; +4. deferred renderer work. + +## Acceptance + +This stage is complete when: + +1. generic `ScriptableRenderPipelineAsset` no longer exposes render-scene / standalone-pass / directional-shadow native key seams; +2. `RendererBackedRenderPipelineAsset` still provides the required fallback hooks for URP/native binding; +3. `XCEditor` builds successfully; +4. old editor smoke passes and `editor.log` contains a fresh `SceneReady`. + +## Validation + +Validated on 2026-04-21: + +1. built old editor target with `cmake --build . --config Debug --target XCEditor` from `build/`; +2. launched `editor/bin/Debug/XCEngine.exe`; +3. let it run for about 12 seconds; +4. verified a fresh `SceneReady` entry in `editor/bin/Debug/editor.log`. + +Observed log line: + +`[2026-04-21 14:08:38] [INFO] [General] [SceneLoadTrace] SceneReady elapsed_ms=6527 first_frame_ms=806 peak_pending_async=9` diff --git a/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/RendererBackedRenderPipelineAsset.cs b/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/RendererBackedRenderPipelineAsset.cs index dcafcf0e..9f75057f 100644 --- a/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/RendererBackedRenderPipelineAsset.cs +++ b/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/RendererBackedRenderPipelineAsset.cs @@ -88,7 +88,12 @@ namespace XCEngine.Rendering.Universal : string.Empty; } - protected override string + protected virtual string GetRenderSceneSetupPolicyAssetKey() + { + return string.Empty; + } + + protected virtual string GetRenderSceneSetupPolicyAssetKeyContextual( int rendererIndex) { @@ -105,12 +110,16 @@ namespace XCEngine.Rendering.Universal } } - return base - .GetRenderSceneSetupPolicyAssetKeyContextual( - rendererIndex); + return GetRenderSceneSetupPolicyAssetKey(); } - protected override string + protected virtual string GetCameraFrameStandalonePassAssetKey( + CameraFrameStage stage) + { + return string.Empty; + } + + protected virtual string GetCameraFrameStandalonePassAssetKeyContextual( CameraFrameStage stage, int rendererIndex) @@ -130,13 +139,23 @@ namespace XCEngine.Rendering.Universal } } - return base - .GetCameraFrameStandalonePassAssetKeyContextual( - stage, - rendererIndex); + return GetCameraFrameStandalonePassAssetKey( + stage); } - protected override string + protected virtual string + GetDirectionalShadowPlanningPolicyAssetKey() + { + return string.Empty; + } + + protected virtual string + GetDirectionalShadowExecutionPolicyAssetKey() + { + return string.Empty; + } + + protected virtual string GetDirectionalShadowExecutionPolicyAssetKeyContextual( int rendererIndex) { @@ -154,9 +173,7 @@ namespace XCEngine.Rendering.Universal } } - return base - .GetDirectionalShadowExecutionPolicyAssetKeyContextual( - rendererIndex); + return GetDirectionalShadowExecutionPolicyAssetKey(); } protected override void ReleaseRuntimeResources() diff --git a/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs b/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs index b5712979..44491591 100644 --- a/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs +++ b/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs @@ -58,52 +58,6 @@ namespace XCEngine.Rendering return UsesNativeCameraFramePlanBaseline(); } - protected virtual string GetRenderSceneSetupPolicyAssetKey() - { - return string.Empty; - } - - protected virtual string - GetRenderSceneSetupPolicyAssetKeyContextual( - int rendererIndex) - { - return GetRenderSceneSetupPolicyAssetKey(); - } - - protected virtual string GetCameraFrameStandalonePassAssetKey( - CameraFrameStage stage) - { - return string.Empty; - } - - protected virtual string - GetCameraFrameStandalonePassAssetKeyContextual( - CameraFrameStage stage, - int rendererIndex) - { - return GetCameraFrameStandalonePassAssetKey( - stage); - } - - protected virtual string - GetDirectionalShadowPlanningPolicyAssetKey() - { - return string.Empty; - } - - protected virtual string - GetDirectionalShadowExecutionPolicyAssetKey() - { - return string.Empty; - } - - protected virtual string - GetDirectionalShadowExecutionPolicyAssetKeyContextual( - int rendererIndex) - { - return GetDirectionalShadowExecutionPolicyAssetKey(); - } - protected virtual void ReleaseRuntimeResources() { }