refactor(rendering): route camera-stage recording through shared graph contract
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageContract.h"
|
||||
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphBuilderContext.h"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
|
||||
CameraFrameRenderGraphSourceBinding BuildCameraFrameStageGraphSourceBinding(
|
||||
const CameraFrameStageGraphBuildState& stageState) {
|
||||
return {
|
||||
stageState.hasSourceSurface
|
||||
? &stageState.sourceSurfaceTemplate
|
||||
: nullptr,
|
||||
stageState.sourceColorView,
|
||||
stageState.sourceColorState,
|
||||
GetPrimaryColorTexture(stageState.sourceSurface)
|
||||
};
|
||||
}
|
||||
|
||||
RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
const CameraFrameRenderGraphStageContext& context,
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
const Containers::String& passName,
|
||||
const RenderSceneData& sceneData,
|
||||
const CameraFrameRenderGraphSourceBinding& sourceBinding,
|
||||
std::vector<RenderGraphTextureHandle> colorTargets,
|
||||
RenderGraphTextureHandle depthTarget) {
|
||||
return {
|
||||
context.builder.graphBuilder,
|
||||
passName,
|
||||
context.plan.request.context,
|
||||
sceneData,
|
||||
stageState.surfaceTemplate,
|
||||
sourceBinding.sourceSurfaceTemplate,
|
||||
sourceBinding.sourceColorView,
|
||||
sourceBinding.sourceColorState,
|
||||
sourceBinding.sourceColor,
|
||||
std::move(colorTargets),
|
||||
depthTarget,
|
||||
&context.builder.stageExecutionSucceeded,
|
||||
&context.builder.blackboard
|
||||
};
|
||||
}
|
||||
|
||||
RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
const CameraFrameRenderGraphStageContext& context,
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
const Containers::String& passName,
|
||||
const RenderSceneData& sceneData,
|
||||
std::vector<RenderGraphTextureHandle> colorTargets,
|
||||
RenderGraphTextureHandle depthTarget) {
|
||||
return BuildCameraFrameStageGraphRecordingContext(
|
||||
context,
|
||||
stageState,
|
||||
passName,
|
||||
sceneData,
|
||||
BuildCameraFrameStageGraphSourceBinding(stageState),
|
||||
std::move(colorTargets),
|
||||
depthTarget);
|
||||
}
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Rendering/Graph/RenderGraphRecordingContext.h>
|
||||
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStagePolicy.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageState.h"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
|
||||
CameraFrameRenderGraphSourceBinding BuildCameraFrameStageGraphSourceBinding(
|
||||
const CameraFrameStageGraphBuildState& stageState);
|
||||
|
||||
RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
const CameraFrameRenderGraphStageContext& context,
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
const Containers::String& passName,
|
||||
const RenderSceneData& sceneData,
|
||||
const CameraFrameRenderGraphSourceBinding& sourceBinding,
|
||||
std::vector<RenderGraphTextureHandle> colorTargets,
|
||||
RenderGraphTextureHandle depthTarget);
|
||||
|
||||
RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
const CameraFrameRenderGraphStageContext& context,
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
const Containers::String& passName,
|
||||
const RenderSceneData& sceneData,
|
||||
std::vector<RenderGraphTextureHandle> colorTargets,
|
||||
RenderGraphTextureHandle depthTarget);
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#include "Debug/Logger.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphBuilderContext.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageContract.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStagePolicy.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStagePassRuntime.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageState.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphSurfaceUtils.h"
|
||||
#include "Rendering/Graph/RenderGraph.h"
|
||||
#include <XCEngine/Rendering/Graph/RenderGraphRecordingContext.h>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
@@ -46,26 +46,15 @@ bool TryRecordCameraFrameStageStandaloneRenderGraphPass(
|
||||
|
||||
return true;
|
||||
};
|
||||
const RenderGraphRecordingContext commonContext = {
|
||||
builder.graphBuilder,
|
||||
stageState.stageName,
|
||||
context.plan.request.context,
|
||||
stageSceneData,
|
||||
stageState.surfaceTemplate,
|
||||
stageState.hasSourceSurface
|
||||
? &stageState.sourceSurfaceTemplate
|
||||
: nullptr,
|
||||
stageState.sourceColorView,
|
||||
stageState.sourceColorState,
|
||||
GetPrimaryColorTexture(stageState.sourceSurface),
|
||||
std::vector<RenderGraphTextureHandle>{ stageState.outputColor },
|
||||
stageState.outputSurface.depthTexture,
|
||||
&builder.stageExecutionSucceeded,
|
||||
&builder.blackboard
|
||||
};
|
||||
const RenderPassRenderGraphContext standalonePassContext =
|
||||
BuildRenderPassRenderGraphContext(
|
||||
commonContext,
|
||||
BuildCameraFrameStageGraphRecordingContext(
|
||||
context,
|
||||
stageState,
|
||||
stageState.stageName,
|
||||
stageSceneData,
|
||||
std::vector<RenderGraphTextureHandle>{ stageState.outputColor },
|
||||
stageState.outputSurface.depthTexture),
|
||||
beginStandalonePass);
|
||||
if (!standaloneStagePass->RecordRenderGraph(standalonePassContext)) {
|
||||
Debug::Logger::Get().Error(
|
||||
@@ -91,26 +80,15 @@ bool TryRecordCameraFrameMainSceneGraphPass(
|
||||
}
|
||||
|
||||
handled = true;
|
||||
const RenderGraphRecordingContext commonContext = {
|
||||
builder.graphBuilder,
|
||||
stageState.stageName,
|
||||
context.plan.request.context,
|
||||
context.sceneData,
|
||||
stageState.surfaceTemplate,
|
||||
stageState.hasSourceSurface
|
||||
? &stageState.sourceSurfaceTemplate
|
||||
: nullptr,
|
||||
stageState.sourceColorView,
|
||||
stageState.sourceColorState,
|
||||
GetPrimaryColorTexture(stageState.sourceSurface),
|
||||
std::vector<RenderGraphTextureHandle>{ stageState.outputColor },
|
||||
stageState.outputSurface.depthTexture,
|
||||
&builder.stageExecutionSucceeded,
|
||||
&builder.blackboard
|
||||
};
|
||||
const RenderPipelineMainSceneRenderGraphContext mainSceneContext =
|
||||
BuildRenderPipelineMainSceneRenderGraphContext(
|
||||
commonContext);
|
||||
BuildCameraFrameStageGraphRecordingContext(
|
||||
context,
|
||||
stageState,
|
||||
stageState.stageName,
|
||||
context.sceneData,
|
||||
std::vector<RenderGraphTextureHandle>{ stageState.outputColor },
|
||||
stageState.outputSurface.depthTexture));
|
||||
if (!builder.executionState.pipeline->RecordMainSceneRenderGraph(mainSceneContext)) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include "Debug/Logger.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphBuilderContext.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageContract.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStagePolicy.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphStageState.h"
|
||||
#include "Rendering/Execution/Internal/CameraFrameRenderGraphSurfaceUtils.h"
|
||||
#include "Rendering/Graph/RenderGraph.h"
|
||||
#include <XCEngine/Rendering/Graph/RenderGraphRecordingContext.h>
|
||||
#include <XCEngine/Rendering/RenderPassGraphContract.h>
|
||||
|
||||
namespace XCEngine {
|
||||
@@ -57,13 +57,13 @@ bool RecordSequencePass(
|
||||
bool RecordRegularPassSequenceStage(
|
||||
CameraFrameStage stage,
|
||||
const Containers::String& stageName,
|
||||
const CameraFrameRenderGraphStageContext& stageContext,
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
const RenderPassContext& stagePassContext,
|
||||
const RenderGraphImportedSurface& outputSurface,
|
||||
const RenderSceneData& sceneData,
|
||||
RenderPassSequence* stageSequence,
|
||||
CameraFrameExecutionState& executionState,
|
||||
RenderGraphBuilder& graphBuilder,
|
||||
RenderGraphBlackboard& blackboard,
|
||||
bool& stageExecutionSucceeded) {
|
||||
if (stageSequence == nullptr || stageSequence->GetPassCount() == 0u) {
|
||||
return true;
|
||||
@@ -103,24 +103,16 @@ bool RecordRegularPassSequenceStage(
|
||||
stageSequence->GetPassCount() == 1u
|
||||
? stageName
|
||||
: BuildRenderGraphSequencePassName(stageName, passIndex);
|
||||
const RenderGraphRecordingContext commonContext = {
|
||||
graphBuilder,
|
||||
passName,
|
||||
stagePassContext.renderContext,
|
||||
sceneData,
|
||||
stagePassContext.surface,
|
||||
stagePassContext.sourceSurface,
|
||||
stagePassContext.sourceColorView,
|
||||
stagePassContext.sourceColorState,
|
||||
{},
|
||||
outputSurface.colorTextures,
|
||||
outputSurface.depthTexture,
|
||||
&stageExecutionSucceeded,
|
||||
&blackboard
|
||||
};
|
||||
const RenderPassRenderGraphContext passContext =
|
||||
BuildRenderPassRenderGraphContext(
|
||||
commonContext,
|
||||
BuildCameraFrameStageGraphRecordingContext(
|
||||
stageContext,
|
||||
stageState,
|
||||
passName,
|
||||
sceneData,
|
||||
BuildCameraFrameStageGraphSourceBinding(stageState),
|
||||
outputSurface.colorTextures,
|
||||
outputSurface.depthTexture),
|
||||
beginSequencePass);
|
||||
if (!RecordSequencePass(
|
||||
*pass,
|
||||
@@ -140,6 +132,8 @@ bool RecordRegularPassSequenceStage(
|
||||
bool RecordFullscreenPassSequenceStage(
|
||||
CameraFrameStage stage,
|
||||
const Containers::String& stageName,
|
||||
const CameraFrameRenderGraphStageContext& stageContext,
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
const RenderPassContext& stagePassContext,
|
||||
const CameraFrameRenderGraphSourceBinding& binding,
|
||||
RenderGraphTextureHandle finalOutputColor,
|
||||
@@ -147,7 +141,6 @@ bool RecordFullscreenPassSequenceStage(
|
||||
RenderPassSequence* stageSequence,
|
||||
CameraFrameExecutionState& executionState,
|
||||
RenderGraphBuilder& graphBuilder,
|
||||
RenderGraphBlackboard& blackboard,
|
||||
bool& stageExecutionSucceeded) {
|
||||
if (stageSequence == nullptr || stageSequence->GetPassCount() == 0u) {
|
||||
return true;
|
||||
@@ -208,24 +201,21 @@ bool RecordFullscreenPassSequenceStage(
|
||||
passIndex == 0u
|
||||
? binding.sourceColorState
|
||||
: RHI::ResourceStates::PixelShaderResource;
|
||||
const RenderGraphRecordingContext commonContext = {
|
||||
graphBuilder,
|
||||
passName,
|
||||
stagePassContext.renderContext,
|
||||
sceneData,
|
||||
stagePassContext.surface,
|
||||
sourceSurfaceTemplate,
|
||||
sourceColorView,
|
||||
sourceColorState,
|
||||
currentSourceColor,
|
||||
std::vector<RenderGraphTextureHandle>{ passOutputColor },
|
||||
{},
|
||||
&stageExecutionSucceeded,
|
||||
&blackboard
|
||||
};
|
||||
const RenderPassRenderGraphContext passContext =
|
||||
BuildRenderPassRenderGraphContext(
|
||||
commonContext,
|
||||
BuildCameraFrameStageGraphRecordingContext(
|
||||
stageContext,
|
||||
stageState,
|
||||
passName,
|
||||
sceneData,
|
||||
{
|
||||
sourceSurfaceTemplate,
|
||||
sourceColorView,
|
||||
sourceColorState,
|
||||
currentSourceColor
|
||||
},
|
||||
std::vector<RenderGraphTextureHandle>{ passOutputColor },
|
||||
{}),
|
||||
beginSequencePass);
|
||||
if (!RecordSequencePass(
|
||||
*pass,
|
||||
@@ -267,6 +257,8 @@ bool TryRecordCameraFrameStageSequence(
|
||||
? RecordFullscreenPassSequenceStage(
|
||||
stageState.stage,
|
||||
stageState.stageName,
|
||||
context,
|
||||
stageState,
|
||||
stagePassContext,
|
||||
ResolveCameraFrameFullscreenStageGraphSourceBinding(
|
||||
context.plan,
|
||||
@@ -282,18 +274,17 @@ bool TryRecordCameraFrameStageSequence(
|
||||
stageState.stageSequence,
|
||||
builder.executionState,
|
||||
builder.graphBuilder,
|
||||
builder.blackboard,
|
||||
builder.stageExecutionSucceeded)
|
||||
: RecordRegularPassSequenceStage(
|
||||
stageState.stage,
|
||||
stageState.stageName,
|
||||
context,
|
||||
stageState,
|
||||
stagePassContext,
|
||||
stageState.outputSurface,
|
||||
context.sceneData,
|
||||
stageState.stageSequence,
|
||||
builder.executionState,
|
||||
builder.graphBuilder,
|
||||
builder.blackboard,
|
||||
builder.stageExecutionSucceeded);
|
||||
if (!recordResult) {
|
||||
Debug::Logger::Get().Error(
|
||||
|
||||
Reference in New Issue
Block a user