refactor(rendering): add override helpers for shared recording contexts
This commit is contained in:
@@ -384,17 +384,19 @@ RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
const CameraFrameRenderGraphSourceBinding& sourceBinding,
|
||||
std::vector<RenderGraphTextureHandle> colorTargets,
|
||||
RenderGraphTextureHandle depthTarget) {
|
||||
RenderGraphRecordingContext recordingContext =
|
||||
CloneRenderGraphRecordingContext(
|
||||
BuildCameraFrameStageGraphRecordingContext(
|
||||
context,
|
||||
stageState,
|
||||
sceneData,
|
||||
sourceBinding),
|
||||
passName);
|
||||
recordingContext.colorTargets = std::move(colorTargets);
|
||||
recordingContext.depthTarget = depthTarget;
|
||||
return recordingContext;
|
||||
RenderGraphRecordingContextOverrides overrides = {};
|
||||
overrides.passName = &passName;
|
||||
overrides.overrideColorTargets = true;
|
||||
overrides.colorTargets = std::move(colorTargets);
|
||||
overrides.overrideDepthTarget = true;
|
||||
overrides.depthTarget = depthTarget;
|
||||
return CloneRenderGraphRecordingContext(
|
||||
BuildCameraFrameStageGraphRecordingContext(
|
||||
context,
|
||||
stageState,
|
||||
sceneData,
|
||||
sourceBinding),
|
||||
overrides);
|
||||
}
|
||||
|
||||
RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
|
||||
@@ -37,15 +37,19 @@ bool ScenePhaseSamplesMainDirectionalShadow(ScenePhase scenePhase) {
|
||||
bool BuiltinForwardMainSceneGraphBuilder::Record(
|
||||
BuiltinForwardPipeline& pipeline,
|
||||
const RenderPipelineMainSceneRenderGraphContext& context) {
|
||||
RenderGraphRecordingContext recordingContext =
|
||||
BuildRenderGraphRecordingContext(context);
|
||||
recordingContext.surface =
|
||||
const RenderSurface graphManagedSurface =
|
||||
BuildGraphManagedForwardSceneSurface(context.surfaceTemplate);
|
||||
|
||||
const bool hasSourceSurface = recordingContext.sourceSurface != nullptr;
|
||||
const bool hasSourceSurface = context.sourceSurface != nullptr;
|
||||
const RenderSurface sourceSurface =
|
||||
hasSourceSurface ? *recordingContext.sourceSurface : RenderSurface();
|
||||
recordingContext.sourceSurface = hasSourceSurface ? &sourceSurface : nullptr;
|
||||
hasSourceSurface ? *context.sourceSurface : RenderSurface();
|
||||
RenderGraphRecordingContextOverrides overrides = {};
|
||||
overrides.surface = &graphManagedSurface;
|
||||
overrides.overrideSourceSurface = true;
|
||||
overrides.sourceSurface = hasSourceSurface ? &sourceSurface : nullptr;
|
||||
RenderGraphRecordingContext recordingContext =
|
||||
CloneRenderGraphRecordingContext(
|
||||
BuildRenderGraphRecordingContext(context),
|
||||
overrides);
|
||||
|
||||
const CameraFrameRenderGraphResources* const frameResources =
|
||||
TryGetCameraFrameRenderGraphResources(recordingContext.blackboard);
|
||||
|
||||
@@ -18,15 +18,21 @@ bool SceneRenderFeaturePass::RecordRenderGraph(
|
||||
[](RenderGraphTextureHandle handle) {
|
||||
return handle.IsValid();
|
||||
});
|
||||
RenderGraphRecordingContext recordingContext =
|
||||
const RenderGraphRecordingContext baseRecordingContext =
|
||||
BuildRenderGraphRecordingContext(context);
|
||||
const RenderSurface sourceSurfaceTemplate =
|
||||
recordingContext.sourceSurface != nullptr
|
||||
? *recordingContext.sourceSurface
|
||||
baseRecordingContext.sourceSurface != nullptr
|
||||
? *baseRecordingContext.sourceSurface
|
||||
: (usesSourceColor ? context.surface : RenderSurface());
|
||||
if (recordingContext.sourceSurface == nullptr && usesSourceColor) {
|
||||
recordingContext.sourceSurface = &sourceSurfaceTemplate;
|
||||
}
|
||||
RenderGraphRecordingContextOverrides overrides = {};
|
||||
overrides.overrideSourceSurface =
|
||||
baseRecordingContext.sourceSurface == nullptr && usesSourceColor;
|
||||
overrides.sourceSurface =
|
||||
overrides.overrideSourceSurface ? &sourceSurfaceTemplate : nullptr;
|
||||
const RenderGraphRecordingContext recordingContext =
|
||||
CloneRenderGraphRecordingContext(
|
||||
baseRecordingContext,
|
||||
overrides);
|
||||
|
||||
const RenderPassGraphBeginCallback beginPassCallback =
|
||||
context.beginPassCallback
|
||||
|
||||
Reference in New Issue
Block a user