refactor(srp): move urp final color defaults into managed asset

This commit is contained in:
2026-04-21 12:44:42 +08:00
parent d3db6b21ea
commit 0063acadc9
4 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
# SRP Universal Final Color Defaults Managed Ownership Plan 2026-04-21
## Goal
Move default final-color settings ownership into managed URP asset data so `UniversalRenderPipelineAsset` explicitly supplies the pipeline-level `FinalColorSettings` used by native frame-plan policy resolution.
## Why This Stage
The native side already asks managed pipeline assets for `GetDefaultFinalColorSettings()`.
But current URP package still leaves that path at the base default, which means:
1. URP asset does not explicitly own pipeline-level final-color defaults yet;
2. final-color runtime data is visible to managed renderer code, but its asset authoring surface is missing;
3. later migration of final-output behavior into managed URP would still lack a proper asset-owned source of truth.
## Scope
Included:
1. add managed URP data container for default final-color settings;
2. make `UniversalRenderPipelineAsset` own and return those settings;
3. keep the native final-color execution path unchanged;
4. rebuild `XCEditor` and run old editor smoke.
Not included:
1. moving final-output pass execution into managed URP;
2. exposing raw `ResolvedFinalColorPolicy` mutation to C#;
3. editor inspector authoring UI;
4. post-process stack migration.
## Acceptance
This stage is complete when:
1. `UniversalRenderPipelineAsset` explicitly owns default `FinalColorSettings`;
2. managed URP no longer relies on base-class implicit defaults for pipeline final-color settings;
3. existing editor build and smoke still pass.
## Result
Completed.
Managed URP now has an explicit `UniversalFinalColorSettings` asset data container, and `UniversalRenderPipelineAsset` returns that data through `GetDefaultFinalColorSettings()`.
The native execution path for final-color resolution remains unchanged in this stage.
Only the pipeline-level data ownership moved into the managed URP package.
## Validation
1. `cmake --build . --config Debug --target XCEditor`
2. launched `editor/bin/Debug/XCEngine.exe` for about 12 seconds
3. verified `editor/bin/Debug/editor.log` contains new `SceneReady` at `2026-04-21 12:42:26`

View File

@@ -239,6 +239,7 @@ set(XCENGINE_RENDER_PIPELINES_UNIVERSAL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.RenderPipelines.Universal/Rendering/Universal/ScriptableRendererFeature.cs
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.RenderPipelines.Universal/Rendering/Universal/StageColorData.cs
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.RenderPipelines.Universal/Rendering/Universal/UniversalAdditionalCameraData.cs
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.RenderPipelines.Universal/Rendering/Universal/UniversalFinalColorSettings.cs
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.RenderPipelines.Universal/Rendering/Universal/UniversalMainSceneData.cs
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.RenderPipelines.Universal/Rendering/Universal/UniversalRenderPipeline.cs
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.RenderPipelines.Universal/Rendering/Universal/UniversalRenderer.cs

View File

@@ -0,0 +1,15 @@
using XCEngine.Rendering;
namespace XCEngine.Rendering.Universal
{
public sealed class UniversalFinalColorSettings
{
public FinalColorSettings settings =
FinalColorSettings.CreateDefault();
public static UniversalFinalColorSettings CreateDefault()
{
return new UniversalFinalColorSettings();
}
}
}

View File

@@ -7,11 +7,14 @@ namespace XCEngine.Rendering.Universal
: RendererBackedRenderPipelineAsset
{
public UniversalShadowSettings shadows;
public UniversalFinalColorSettings finalColor;
public UniversalRenderPipelineAsset()
{
shadows =
UniversalShadowSettings.CreateDefault();
finalColor =
UniversalFinalColorSettings.CreateDefault();
}
protected override ScriptableRenderPipeline
@@ -26,6 +29,12 @@ namespace XCEngine.Rendering.Universal
return "BuiltinDirectionalShadowPlanning";
}
protected override FinalColorSettings
GetDefaultFinalColorSettings()
{
return GetFinalColorSettingsInstance().settings;
}
protected override void ConfigureRendererCameraRequest(
RendererCameraRequestContext context)
{
@@ -92,6 +101,18 @@ namespace XCEngine.Rendering.Universal
return shadows;
}
private UniversalFinalColorSettings
GetFinalColorSettingsInstance()
{
if (finalColor == null)
{
finalColor =
UniversalFinalColorSettings.CreateDefault();
}
return finalColor;
}
}
}