refactor(rendering): generalize pipeline stage render graph boundary

This commit is contained in:
2026-04-15 19:31:52 +08:00
parent df8f433fbb
commit 7671663b12
20 changed files with 108 additions and 84 deletions

View File

@@ -36,7 +36,7 @@ bool ScenePhaseSamplesMainDirectionalShadow(ScenePhase scenePhase) {
bool BuiltinForwardMainSceneGraphBuilder::Record(
BuiltinForwardPipeline& pipeline,
const RenderPipelineMainSceneRenderGraphContext& context) {
const RenderPipelineStageRenderGraphContext& context) {
const RenderSurface graphManagedSurface =
BuildGraphManagedForwardSceneSurface(context.surfaceTemplate);
const bool hasSourceSurface = context.sourceSurface != nullptr;
@@ -58,8 +58,10 @@ bool BuiltinForwardMainSceneGraphBuilder::Record(
? frameResources->mainDirectionalShadow
: RenderGraphTextureHandle{};
bool* const executionSucceeded = recordingContext.executionSucceeded;
const RenderPipelineMainSceneRenderGraphContext graphContext =
BuildRenderPipelineMainSceneRenderGraphContext(recordingContext);
const RenderPipelineStageRenderGraphContext graphContext =
BuildRenderPipelineStageRenderGraphContext(
recordingContext,
CameraFrameStage::MainScene);
const std::shared_ptr<ForwardSceneGraphExecutionState> graphExecutionState =
std::make_shared<ForwardSceneGraphExecutionState>();
const SceneRenderFeaturePassBeginCallback beginRecordedPass =
@@ -76,7 +78,7 @@ bool BuiltinForwardMainSceneGraphBuilder::Record(
if (!pipeline.Initialize(passContext.renderContext)) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"BuiltinForwardPipeline::RecordMainSceneRenderGraph failed during execution: Initialize returned false");
"BuiltinForwardPipeline::RecordStageRenderGraph failed during execution: Initialize returned false");
if (executionSucceeded != nullptr) {
*executionSucceeded = false;
}
@@ -93,7 +95,7 @@ bool BuiltinForwardMainSceneGraphBuilder::Record(
if (!pipeline.m_forwardSceneFeatureHost.Prepare(executionContext)) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"BuiltinForwardPipeline::RecordMainSceneRenderGraph failed during execution: SceneRenderFeatureHost::Prepare returned false");
"BuiltinForwardPipeline::RecordStageRenderGraph failed during execution: SceneRenderFeatureHost::Prepare returned false");
if (executionSucceeded != nullptr) {
*executionSucceeded = false;
}
@@ -106,7 +108,7 @@ bool BuiltinForwardMainSceneGraphBuilder::Record(
if (!pipeline.BeginForwardScenePass(passContext, clearAttachments)) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"BuiltinForwardPipeline::RecordMainSceneRenderGraph failed during execution: BeginForwardScenePass returned false");
"BuiltinForwardPipeline::RecordStageRenderGraph failed during execution: BeginForwardScenePass returned false");
if (executionSucceeded != nullptr) {
*executionSucceeded = false;
}
@@ -124,7 +126,7 @@ bool BuiltinForwardMainSceneGraphBuilder::Record(
for (const ForwardSceneStep& step : GetBuiltinForwardSceneSteps()) {
if (step.type == ForwardSceneStepType::InjectionPoint) {
bool recordedAnyPass = false;
if (!::XCEngine::Rendering::RecordRenderPipelineMainSceneFeaturePasses(
if (!::XCEngine::Rendering::RecordRenderPipelineStageFeaturePasses(
graphContext,
pipeline.m_forwardSceneFeatureHost,
step.injectionPoint,
@@ -150,7 +152,7 @@ bool BuiltinForwardMainSceneGraphBuilder::Record(
mainDirectionalShadowTexture.IsValid()
? std::vector<RenderGraphTextureHandle>{ mainDirectionalShadowTexture }
: std::vector<RenderGraphTextureHandle>{};
if (!::XCEngine::Rendering::RecordRenderPipelineMainScenePhasePass(
if (!::XCEngine::Rendering::RecordRenderPipelineStagePhasePass(
graphContext,
step.scenePhase,
[&pipeline, scenePhase = step.scenePhase](const RenderPassContext& passContext) {

View File

@@ -3,7 +3,7 @@
namespace XCEngine {
namespace Rendering {
struct RenderPipelineMainSceneRenderGraphContext;
struct RenderPipelineStageRenderGraphContext;
namespace Pipelines {
@@ -14,7 +14,7 @@ namespace Internal {
struct BuiltinForwardMainSceneGraphBuilder {
static bool Record(
BuiltinForwardPipeline& pipeline,
const RenderPipelineMainSceneRenderGraphContext& context);
const RenderPipelineStageRenderGraphContext& context);
};
} // namespace Internal

View File

@@ -59,13 +59,15 @@ bool BuiltinForwardPipeline::ShouldSampleMainDirectionalShadowMap(const RenderSc
IsDepthFormat(sceneData.lighting.mainDirectionalShadow.shadowMap->GetFormat());
}
bool BuiltinForwardPipeline::SupportsMainSceneRenderGraph() const {
return true;
bool BuiltinForwardPipeline::SupportsStageRenderGraph(
CameraFrameStage stage) const {
return SupportsCameraFramePipelineGraphRecording(stage);
}
bool BuiltinForwardPipeline::RecordMainSceneRenderGraph(
const RenderPipelineMainSceneRenderGraphContext& context) {
return Internal::BuiltinForwardMainSceneGraphBuilder::Record(*this, context);
bool BuiltinForwardPipeline::RecordStageRenderGraph(
const RenderPipelineStageRenderGraphContext& context) {
return context.stage == CameraFrameStage::MainScene &&
Internal::BuiltinForwardMainSceneGraphBuilder::Record(*this, context);
}
bool BuiltinForwardPipeline::Render(