From 289b216bc57bfce5f43705330a5c315d7eafeb9c Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Tue, 21 Apr 2026 14:05:17 +0800 Subject: [PATCH] refactor(srp): narrow generic pipeline renderer key seam --- ...eySeamNarrowingPlan_完成归档_2026-04-21.md | 58 +++++++++++++++++++ .../RendererBackedRenderPipelineAsset.cs | 4 +- .../Core/ScriptableRenderPipelineAsset.cs | 11 ---- 3 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 docs/used/SRP_GenericPipelineRendererKeySeamNarrowingPlan_完成归档_2026-04-21.md diff --git a/docs/used/SRP_GenericPipelineRendererKeySeamNarrowingPlan_完成归档_2026-04-21.md b/docs/used/SRP_GenericPipelineRendererKeySeamNarrowingPlan_完成归档_2026-04-21.md new file mode 100644 index 00000000..fcab0cff --- /dev/null +++ b/docs/used/SRP_GenericPipelineRendererKeySeamNarrowingPlan_完成归档_2026-04-21.md @@ -0,0 +1,58 @@ +# SRP Generic Pipeline Renderer Key Seam Narrowing Plan 2026-04-21 + +## Goal + +Remove native scene renderer key selection from the generic `ScriptableRenderPipelineAsset` public surface and narrow that seam to renderer-backed pipelines only. + +## Why This Stage + +The current managed SRP API still exposes `GetPipelineRendererAssetKey*` on the generic pipeline asset base class. That is not a Unity-style SRP-facing concept. It is an internal native binding seam used to resolve a native scene renderer backend for renderer-backed pipelines. + +Keeping it on the generic SRP asset base has two problems: + +1. it leaks native backend selection into the public API shape of all managed pipelines; +2. it makes custom SRP assets look like they are supposed to choose native renderer assets directly, which is not the long-term ownership model. + +At the same time, the repo scan shows the active usage is renderer-backed only: + +1. `RendererBackedRenderPipelineAsset` provides the asset-level contextual key resolution; +2. `ScriptableRendererData` provides the renderer-data-level backend key; +3. no plain `ScriptableRenderPipelineAsset` subclass currently overrides this seam. + +## Scope + +Included: + +1. remove `GetPipelineRendererAssetKey*` from generic managed `ScriptableRenderPipelineAsset`; +2. keep the optional native bridge support so renderer-backed assets can still expose the method by name; +3. define the pipeline-renderer-key seam directly on `RendererBackedRenderPipelineAsset`; +4. rebuild `XCEditor` and run old editor smoke. + +Not included: + +1. deleting native pipeline renderer asset resolution from the runtime bridge; +2. renaming renderer-data backend key APIs; +3. removing other native key seams such as scene setup / shadow execution; +4. deferred renderer work. + +## Acceptance + +This stage is complete when: + +1. generic `ScriptableRenderPipelineAsset` no longer exposes `GetPipelineRendererAssetKey*`; +2. renderer-backed assets still resolve native scene renderer binding correctly; +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:04:19] [INFO] [General] [SceneLoadTrace] SceneReady elapsed_ms=5688 first_frame_ms=600 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 2c5af238..dcafcf0e 100644 --- a/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/RendererBackedRenderPipelineAsset.cs +++ b/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/RendererBackedRenderPipelineAsset.cs @@ -71,13 +71,13 @@ namespace XCEngine.Rendering.Universal } } - protected override string GetPipelineRendererAssetKey() + protected string GetPipelineRendererAssetKey() { return GetPipelineRendererAssetKeyContextual( -1); } - protected override string GetPipelineRendererAssetKeyContextual( + protected virtual string GetPipelineRendererAssetKeyContextual( int rendererIndex) { ScriptableRendererData resolvedRendererData = diff --git a/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs b/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs index 44f909e6..b5712979 100644 --- a/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs +++ b/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderPipelineAsset.cs @@ -47,17 +47,6 @@ namespace XCEngine.Rendering return FinalColorSettings.CreateDefault(); } - protected virtual string GetPipelineRendererAssetKey() - { - return string.Empty; - } - - protected virtual string GetPipelineRendererAssetKeyContextual( - int rendererIndex) - { - return GetPipelineRendererAssetKey(); - } - protected virtual bool UsesNativeCameraFramePlanBaseline() { return false;