Centralize render-graph recording context builders

This commit is contained in:
2026-04-15 01:18:15 +08:00
parent 65b3078c7f
commit d0ce2d7883
7 changed files with 331 additions and 67 deletions

View File

@@ -8,6 +8,7 @@
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageState.h"
#include "Rendering/Execution/Internal/CameraFrameRenderGraphSurfaceUtils.h"
#include "Rendering/Graph/RenderGraph.h"
#include "Rendering/Internal/RenderGraphRecordingContextBuilders.h"
namespace XCEngine {
namespace Rendering {
@@ -46,7 +47,7 @@ bool TryRecordCameraFrameStageStandaloneRenderGraphPass(
return true;
};
const RenderPassRenderGraphContext standalonePassContext = {
const Internal::RenderGraphRecordingContextCommon commonContext = {
session.graphBuilder,
stageState.stageName,
context.plan.request.context,
@@ -61,10 +62,12 @@ bool TryRecordCameraFrameStageStandaloneRenderGraphPass(
std::vector<RenderGraphTextureHandle>{ stageState.outputColor },
stageState.outputSurface.depthTexture,
&session.stageExecutionSucceeded,
beginStandalonePass,
{},
&session.blackboard
};
const RenderPassRenderGraphContext standalonePassContext =
Internal::BuildRenderPassRenderGraphContext(
commonContext,
beginStandalonePass);
if (!standaloneStagePass->RecordRenderGraph(standalonePassContext)) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
@@ -89,7 +92,7 @@ bool TryRecordCameraFrameMainSceneGraphPass(
}
handled = true;
const RenderPipelineMainSceneRenderGraphContext mainSceneContext = {
const Internal::RenderGraphRecordingContextCommon commonContext = {
session.graphBuilder,
stageState.stageName,
context.plan.request.context,
@@ -100,11 +103,15 @@ bool TryRecordCameraFrameMainSceneGraphPass(
: nullptr,
stageState.sourceColorView,
stageState.sourceColorState,
GetPrimaryColorTexture(stageState.sourceSurface),
std::vector<RenderGraphTextureHandle>{ stageState.outputColor },
stageState.outputSurface.depthTexture,
&session.stageExecutionSucceeded,
&session.blackboard
};
const RenderPipelineMainSceneRenderGraphContext mainSceneContext =
Internal::BuildRenderPipelineMainSceneRenderGraphContext(
commonContext);
if (!session.executionState.pipeline->RecordMainSceneRenderGraph(mainSceneContext)) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,

View File

@@ -7,6 +7,7 @@
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageState.h"
#include "Rendering/Execution/Internal/CameraFrameRenderGraphSurfaceUtils.h"
#include "Rendering/Graph/RenderGraph.h"
#include "Rendering/Internal/RenderGraphRecordingContextBuilders.h"
#include "Rendering/Internal/RenderPassGraphUtils.h"
namespace XCEngine {
@@ -103,7 +104,7 @@ bool RecordRegularPassSequenceStage(
stageSequence->GetPassCount() == 1u
? stageName
: BuildRenderGraphSequencePassName(stageName, passIndex);
const RenderPassRenderGraphContext passContext = {
const Internal::RenderGraphRecordingContextCommon commonContext = {
graphBuilder,
passName,
stagePassContext.renderContext,
@@ -116,10 +117,12 @@ bool RecordRegularPassSequenceStage(
outputSurface.colorTextures,
outputSurface.depthTexture,
&stageExecutionSucceeded,
beginSequencePass,
{},
&blackboard
};
const RenderPassRenderGraphContext passContext =
Internal::BuildRenderPassRenderGraphContext(
commonContext,
beginSequencePass);
if (!RecordSequencePass(
*pass,
passContext,
@@ -206,7 +209,7 @@ bool RecordFullscreenPassSequenceStage(
passIndex == 0u
? binding.sourceColorState
: RHI::ResourceStates::PixelShaderResource;
const RenderPassRenderGraphContext passContext = {
const Internal::RenderGraphRecordingContextCommon commonContext = {
graphBuilder,
passName,
stagePassContext.renderContext,
@@ -219,10 +222,12 @@ bool RecordFullscreenPassSequenceStage(
std::vector<RenderGraphTextureHandle>{ passOutputColor },
{},
&stageExecutionSucceeded,
beginSequencePass,
{},
&blackboard
};
const RenderPassRenderGraphContext passContext =
Internal::BuildRenderPassRenderGraphContext(
commonContext,
beginSequencePass);
if (!RecordSequencePass(
*pass,
passContext,