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

@@ -0,0 +1,118 @@
#pragma once
#include <XCEngine/Rendering/RenderPipeline.h>
#include <XCEngine/Rendering/SceneRenderFeaturePass.h>
namespace XCEngine {
namespace Rendering {
namespace Internal {
struct RenderGraphRecordingContextCommon {
RenderGraphBuilder& graphBuilder;
Containers::String passName = {};
const RenderContext& renderContext;
const RenderSceneData& sceneData;
RenderSurface surface = {};
const RenderSurface* sourceSurface = nullptr;
RHI::RHIResourceView* sourceColorView = nullptr;
RHI::ResourceStates sourceColorState = RHI::ResourceStates::Common;
RenderGraphTextureHandle sourceColorTexture = {};
std::vector<RenderGraphTextureHandle> colorTargets = {};
RenderGraphTextureHandle depthTarget = {};
bool* executionSucceeded = nullptr;
RenderGraphBlackboard* blackboard = nullptr;
};
inline RenderPassRenderGraphContext BuildRenderPassRenderGraphContext(
const RenderGraphRecordingContextCommon& common,
RenderPassGraphBeginCallback beginPassCallback = {},
RenderPassGraphEndCallback endPassCallback = {}) {
return {
common.graphBuilder,
common.passName,
common.renderContext,
common.sceneData,
common.surface,
common.sourceSurface,
common.sourceColorView,
common.sourceColorState,
common.sourceColorTexture,
common.colorTargets,
common.depthTarget,
common.executionSucceeded,
beginPassCallback,
endPassCallback,
common.blackboard
};
}
inline SceneRenderFeaturePassRenderGraphContext BuildSceneRenderFeaturePassRenderGraphContext(
const RenderGraphRecordingContextCommon& common,
bool clearAttachments = false,
SceneRenderFeaturePassBeginCallback beginPassCallback = {},
SceneRenderFeaturePassEndCallback endPassCallback = {}) {
return {
common.graphBuilder,
common.passName,
common.renderContext,
common.sceneData,
common.surface,
common.sourceSurface,
common.sourceColorView,
common.sourceColorState,
common.sourceColorTexture,
common.colorTargets,
common.depthTarget,
clearAttachments,
common.executionSucceeded,
beginPassCallback,
endPassCallback,
common.blackboard
};
}
inline RenderPipelineMainSceneRenderGraphContext BuildRenderPipelineMainSceneRenderGraphContext(
const RenderGraphRecordingContextCommon& common) {
return {
common.graphBuilder,
common.passName,
common.renderContext,
common.sceneData,
common.surface,
common.sourceSurface,
common.sourceColorView,
common.sourceColorState,
common.colorTargets,
common.depthTarget,
common.executionSucceeded,
common.blackboard
};
}
inline SceneRenderFeaturePassRenderGraphContext CloneSceneRenderFeaturePassRenderGraphContext(
const SceneRenderFeaturePassRenderGraphContext& context,
const Containers::String& passName,
bool clearAttachments) {
return {
context.graphBuilder,
passName,
context.renderContext,
context.sceneData,
context.surface,
context.sourceSurface,
context.sourceColorView,
context.sourceColorState,
context.sourceColorTexture,
context.colorTargets,
context.depthTarget,
clearAttachments,
context.executionSucceeded,
context.beginPassCallback,
context.endPassCallback,
context.blackboard
};
}
} // namespace Internal
} // namespace Rendering
} // namespace XCEngine