refactor(rendering): route feature pass recording through shared context

This commit is contained in:
2026-04-15 12:40:31 +08:00
parent d501e895eb
commit f90f449745

View File

@@ -1,5 +1,6 @@
#include "Rendering/SceneRenderFeaturePass.h"
#include <XCEngine/Rendering/Graph/RenderGraphRecordingContext.h>
#include <XCEngine/Rendering/RenderPassGraphContract.h>
#include <algorithm>
@@ -10,12 +11,6 @@ namespace Rendering {
bool SceneRenderFeaturePass::RecordRenderGraph(
const SceneRenderFeaturePassRenderGraphContext& context) {
const bool usesSourceColor = context.sourceColorTexture.IsValid();
const bool hasSourceSurfaceTemplate =
context.sourceSurface != nullptr || usesSourceColor;
const RenderSurface sourceSurfaceTemplate =
context.sourceSurface != nullptr
? *context.sourceSurface
: (usesSourceColor ? context.surface : RenderSurface());
const bool writesColor =
std::any_of(
context.colorTargets.begin(),
@@ -23,6 +18,16 @@ bool SceneRenderFeaturePass::RecordRenderGraph(
[](RenderGraphTextureHandle handle) {
return handle.IsValid();
});
RenderGraphRecordingContext recordingContext =
BuildRenderGraphRecordingContext(context);
const RenderSurface sourceSurfaceTemplate =
recordingContext.sourceSurface != nullptr
? *recordingContext.sourceSurface
: (usesSourceColor ? context.surface : RenderSurface());
if (recordingContext.sourceSurface == nullptr && usesSourceColor) {
recordingContext.sourceSurface = &sourceSurfaceTemplate;
}
const RenderPassGraphBeginCallback beginPassCallback =
context.beginPassCallback
? RenderPassGraphBeginCallback(
@@ -32,23 +37,11 @@ bool SceneRenderFeaturePass::RecordRenderGraph(
return beginPass(passContext, clearAttachments);
})
: RenderPassGraphBeginCallback();
const RenderPassRenderGraphContext passContext = {
context.graphBuilder,
context.passName,
context.renderContext,
context.sceneData,
context.surface,
hasSourceSurfaceTemplate ? &sourceSurfaceTemplate : nullptr,
context.sourceColorView,
context.sourceColorState,
context.sourceColorTexture,
context.colorTargets,
context.depthTarget,
context.executionSucceeded,
beginPassCallback,
context.endPassCallback,
context.blackboard
};
const RenderPassRenderGraphContext passContext =
BuildRenderPassRenderGraphContext(
recordingContext,
beginPassCallback,
context.endPassCallback);
return RecordRasterRenderPass(
*this,
passContext,