refactor(rendering): centralize stage graph output policies

This commit is contained in:
2026-04-15 16:42:36 +08:00
parent c853f67c56
commit bf0b81d034
5 changed files with 48 additions and 12 deletions

View File

@@ -41,6 +41,10 @@ bool CameraFramePlan::UsesGraphManagedMainSceneColor() const {
}
bool CameraFramePlan::UsesGraphManagedOutputColor(CameraFrameStage stage) const {
if (stage == CameraFrameStage::MainScene) {
return UsesGraphManagedMainSceneColor();
}
if (const CameraFrameFullscreenStagePlan* fullscreenStagePlan =
GetFullscreenStagePlan(stage);
fullscreenStagePlan != nullptr) {

View File

@@ -108,6 +108,23 @@ RenderGraphSurfaceAccessMode BuildCameraFrameStageFallbackSurfaceAccessMode(
: RenderGraphSurfaceAccessMode::ColorDepth;
}
void PublishCameraFrameStageGraphDepthAliasResource(
CameraFrameRenderGraphResources& frameResources,
const CameraFrameStageGraphBuildState& stageState,
const DirectionalShadowExecutionState& shadowState) {
switch (GetCameraFrameStagePublishedDepthAliasRole(stageState.stage)) {
case CameraFrameStagePublishedDepthAliasRole::MainDirectionalShadow:
if (shadowState.HasShadowSampling() &&
stageState.outputSurface.depthTexture.IsValid()) {
frameResources.mainDirectionalShadow =
stageState.outputSurface.depthTexture;
}
break;
default:
break;
}
}
} // namespace
CameraFrameRenderGraphSourceBinding BuildCameraFrameStageGraphSourceBinding(
@@ -168,12 +185,10 @@ void PublishCameraFrameStageGraphResources(
stageState.stage,
stageState.outputColor,
stageState.outputSurface.depthTexture);
if (stageState.stage == CameraFrameStage::ShadowCaster &&
context.shadowState.HasShadowSampling() &&
stageState.outputSurface.depthTexture.IsValid()) {
frameResources.mainDirectionalShadow = stageState.outputSurface.depthTexture;
}
PublishCameraFrameStageGraphDepthAliasResource(
frameResources,
stageState,
context.shadowState);
}
RenderSceneData BuildCameraFrameStandaloneStageSceneData(

View File

@@ -16,12 +16,7 @@ struct CameraFrameRenderGraphSourceBinding {
inline bool UsesCameraFrameStageGraphManagedOutputColor(
const CameraFramePlan& plan,
CameraFrameStage stage) {
switch (stage) {
case CameraFrameStage::MainScene:
return plan.UsesGraphManagedMainSceneColor();
default:
return plan.UsesGraphManagedOutputColor(stage);
}
return plan.UsesGraphManagedOutputColor(stage);
}
inline CameraFrameColorSource ResolveCameraFrameStageGraphManagedColorSource(