From 2d4ff384fd2012cf12b131b033e36a0a6f1b99a1 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Tue, 21 Apr 2026 13:07:24 +0800 Subject: [PATCH] refactor(srp): remove renderer fullscreen stage heuristics --- ...enStagePlanningPlan_完成归档_2026-04-21.md | 52 +++++++++++++++++ .../ColorScalePostProcessRendererFeature.cs | 32 ++++++++--- .../Rendering/Universal/ScriptableRenderer.cs | 56 ------------------- 3 files changed, 75 insertions(+), 65 deletions(-) create mode 100644 docs/used/SRP_UniversalExplicitFullscreenStagePlanningPlan_完成归档_2026-04-21.md diff --git a/docs/used/SRP_UniversalExplicitFullscreenStagePlanningPlan_完成归档_2026-04-21.md b/docs/used/SRP_UniversalExplicitFullscreenStagePlanningPlan_完成归档_2026-04-21.md new file mode 100644 index 00000000..b6dbd4b8 --- /dev/null +++ b/docs/used/SRP_UniversalExplicitFullscreenStagePlanningPlan_完成归档_2026-04-21.md @@ -0,0 +1,52 @@ +# SRP Universal Explicit Fullscreen Stage Planning Plan 2026-04-21 + +## Goal + +Remove renderer-level fullscreen stage request heuristics and make managed URP fullscreen stage ownership explicit through renderer features. + +## Why This Stage + +Current managed URP already owns more of the camera-frame plan, but one important seam is still implicit: + +1. `ScriptableRenderer.ConfigureCameraFramePlan(...)` scans queued render passes; +2. it infers whether `PostProcess` or `FinalOutput` should exist from `RenderPassEvent`; +3. fullscreen stage planning therefore still depends on hidden pass-event heuristics instead of explicit managed planning code. + +That is weak architecture for a Unity-style SRP/URP direction. A renderer feature that needs a fullscreen stage should explicitly request it. + +## Scope + +Included: + +1. remove fullscreen-stage inference from `ScriptableRenderer`; +2. make first-party post-process-style feature planning explicit; +3. keep builtin final-color feature on explicit planning path; +4. rebuild `XCEditor` and run old editor smoke. + +Not included: + +1. moving all native fullscreen request legacy paths out of the engine; +2. deleting native final-color or vector fullscreen pass implementations; +3. deferred renderer work; +4. editor UI work. + +## Acceptance + +This stage is complete when: + +1. `ScriptableRenderer` no longer auto-requests fullscreen stages from queued pass events; +2. first-party managed fullscreen features explicitly request the stages they need; +3. `XCEditor` build passes; +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` for about 12 seconds; +3. verified fresh `editor/bin/Debug/editor.log` contains `SceneReady`. + +Observed log line: + +`[2026-04-21 13:06:17] [INFO] [General] [SceneLoadTrace] SceneReady elapsed_ms=5372 first_frame_ms=536 peak_pending_async=9` diff --git a/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ColorScalePostProcessRendererFeature.cs b/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ColorScalePostProcessRendererFeature.cs index 594a952d..ad02796c 100644 --- a/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ColorScalePostProcessRendererFeature.cs +++ b/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ColorScalePostProcessRendererFeature.cs @@ -23,19 +23,17 @@ namespace XCEngine.Rendering.Universal if (context == null || renderingData == null || !renderingData.isPostProcessStage || - m_feature == null || - !context.sourceColorTexture.isValid || - !context.primaryColorTarget.isValid) + m_feature == null) { return false; } - return context - .AddRasterPass("Universal.ColorScalePostProcess") - .UseColorSource(context.sourceColorTexture) - .SetColorAttachment(context.primaryColorTarget) - .SetColorScaleFullscreenExecution(m_feature.colorScale) - .Commit(); + return RecordColorScaleFullscreenPass( + context, + context.sourceColorTexture, + context.primaryColorTarget, + m_feature.colorScale, + "Universal.ColorScalePostProcess"); } } @@ -56,6 +54,22 @@ namespace XCEngine.Rendering.Universal new ColorScalePostProcessPass(this); } + public override void ConfigureCameraFramePlan( + ScriptableRenderPipelinePlanningContext context) + { + if (context == null || + context.IsStageRequested( + CameraFrameStage.PostProcess)) + { + return; + } + + context.RequestFullscreenStage( + CameraFrameStage.PostProcess, + CameraFrameColorSource.MainSceneColor, + context.HasFinalColorProcessing()); + } + public override void AddRenderPasses( ScriptableRenderer renderer, RenderingData renderingData) diff --git a/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ScriptableRenderer.cs b/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ScriptableRenderer.cs index 9e6cccdb..32ce58c9 100644 --- a/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ScriptableRenderer.cs +++ b/managed/XCEngine.RenderPipelines.Universal/Rendering/Universal/ScriptableRenderer.cs @@ -179,62 +179,6 @@ namespace XCEngine.Rendering.Universal protected virtual void ConfigureCameraFramePlan( ScriptableRenderPipelinePlanningContext context) { - if (context == null) - { - return; - } - - BuildPassQueue(new RenderingData(CameraFrameStage.MainScene)); - - bool hasPostProcessPass = false; - bool hasFinalOutputPass = false; - for (int i = 0; i < m_activePassQueue.Count; ++i) - { - ScriptableRenderPass renderPass = m_activePassQueue[i]; - if (renderPass == null) - { - continue; - } - - CameraFrameStage passStage; - if (!ScriptableRenderPass.TryResolveStage( - renderPass.renderPassEvent, - out passStage)) - { - continue; - } - - if (passStage == CameraFrameStage.PostProcess) - { - hasPostProcessPass = true; - } - else if (passStage == - CameraFrameStage.FinalOutput) - { - hasFinalOutputPass = true; - } - } - - if (hasPostProcessPass && - !context.IsStageRequested( - CameraFrameStage.PostProcess)) - { - context.RequestFullscreenStage( - CameraFrameStage.PostProcess, - CameraFrameColorSource.MainSceneColor, - hasFinalOutputPass); - } - - if (hasFinalOutputPass && - !context.IsStageRequested( - CameraFrameStage.FinalOutput)) - { - context.RequestFullscreenStage( - CameraFrameStage.FinalOutput, - hasPostProcessPass - ? CameraFrameColorSource.PostProcessColor - : CameraFrameColorSource.MainSceneColor); - } } private void BuildPassQueue(