Add render-graph main-scene pipeline recording

This commit is contained in:
2026-04-14 16:22:58 +08:00
parent 307259091e
commit c495581878
6 changed files with 1181 additions and 20 deletions

View File

@@ -774,6 +774,7 @@ bool ExecuteRenderGraphPlan(
RenderGraphImportedTextureRegistry importedTextures = {};
bool stageExecutionSucceeded = true;
RenderGraphTextureHandle mainDirectionalShadowTexture = {};
for (const CameraFrameStageInfo& stageInfo : kOrderedCameraFrameStages) {
if (!plan.HasFrameStage(stageInfo.stage) &&
stageInfo.stage != CameraFrameStage::MainScene) {
@@ -891,6 +892,11 @@ bool ExecuteRenderGraphPlan(
RenderGraphSurfaceImportUsage::Output,
ShouldGraphOwnStageColorTransitions(stage),
ShouldGraphOwnStageDepthTransitions(stage));
if (stage == CameraFrameStage::ShadowCaster &&
shadowState.HasShadowSampling() &&
outputSurface.depthTexture.IsValid()) {
mainDirectionalShadowTexture = outputSurface.depthTexture;
}
const RenderSurface stageSurfaceTemplate = stagePassContext.surface;
const bool hasStageSourceSurface = stagePassContext.sourceSurface != nullptr;
const RenderSurface stageSourceSurfaceTemplate =
@@ -900,6 +906,32 @@ bool ExecuteRenderGraphPlan(
const RHI::RHIResourceView* const stageSourceColorView = stagePassContext.sourceColorView;
const RHI::ResourceStates stageSourceColorState = stagePassContext.sourceColorState;
if (stage == CameraFrameStage::MainScene &&
executionState.pipeline != nullptr &&
executionState.pipeline->SupportsMainSceneRenderGraph()) {
const RenderPipelineMainSceneRenderGraphContext mainSceneContext = {
graphBuilder,
stageName,
plan.request.context,
sceneData,
stageSurfaceTemplate,
hasStageSourceSurface ? &stageSourceSurfaceTemplate : nullptr,
const_cast<RHI::RHIResourceView*>(stageSourceColorView),
stageSourceColorState,
outputSurface.colorTextures,
outputSurface.depthTexture,
mainDirectionalShadowTexture,
&stageExecutionSucceeded
};
if (!executionState.pipeline->RecordMainSceneRenderGraph(mainSceneContext)) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"CameraRenderer::Render failed: RenderPipeline::RecordMainSceneRenderGraph returned false");
return false;
}
continue;
}
graphBuilder.AddRasterPass(
stageName,
[&, sourceSurface, outputSurface, stage, stageSurfaceTemplate, hasStageSourceSurface, stageSourceSurfaceTemplate, stageSourceColorView, stageSourceColorState](