Unify builtin forward phase render graph recording
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Debug/Logger.h"
|
||||
#include "Rendering/Graph/RenderGraph.h"
|
||||
#include "Rendering/Internal/RenderPassGraphUtils.h"
|
||||
#include "Rendering/Pipelines/Internal/BuiltinForwardSceneSetup.h"
|
||||
#include "RHI/RHICommandList.h"
|
||||
#include "Rendering/Internal/RenderSurfacePipelineUtils.h"
|
||||
@@ -213,81 +214,54 @@ bool BuiltinForwardPipeline::RecordMainSceneRenderGraph(
|
||||
|
||||
const Containers::String phasePassName =
|
||||
BuildForwardScenePhasePassName(passName, step.scenePhase);
|
||||
context.graphBuilder.AddRasterPass(
|
||||
const RenderPassGraphBeginCallback beginPhasePass =
|
||||
[beginRecordedPass, clearAttachments](const RenderPassContext& passContext) {
|
||||
return beginRecordedPass(passContext, clearAttachments);
|
||||
};
|
||||
const std::vector<RenderGraphTextureHandle> additionalReadTextures =
|
||||
ScenePhaseSamplesMainDirectionalShadow(step.scenePhase) &&
|
||||
mainDirectionalShadowTexture.IsValid()
|
||||
? std::vector<RenderGraphTextureHandle>{ mainDirectionalShadowTexture }
|
||||
: std::vector<RenderGraphTextureHandle>{};
|
||||
const RenderPassRenderGraphContext phaseContext = {
|
||||
context.graphBuilder,
|
||||
phasePassName,
|
||||
[this,
|
||||
surfaceTemplate,
|
||||
renderContext,
|
||||
sceneData,
|
||||
hasSourceSurface,
|
||||
sourceSurface,
|
||||
sourceColorView,
|
||||
sourceColorState,
|
||||
colorTargets,
|
||||
depthTarget,
|
||||
mainDirectionalShadowTexture,
|
||||
executionSucceeded,
|
||||
beginRecordedPass,
|
||||
endRecordedPass,
|
||||
clearAttachments,
|
||||
scenePhase = step.scenePhase](
|
||||
RenderGraphPassBuilder& passBuilder) {
|
||||
for (RenderGraphTextureHandle colorTarget : colorTargets) {
|
||||
if (colorTarget.IsValid()) {
|
||||
passBuilder.WriteTexture(colorTarget);
|
||||
}
|
||||
}
|
||||
|
||||
if (depthTarget.IsValid()) {
|
||||
passBuilder.WriteDepthTexture(depthTarget);
|
||||
}
|
||||
if (ScenePhaseSamplesMainDirectionalShadow(scenePhase) &&
|
||||
mainDirectionalShadowTexture.IsValid()) {
|
||||
passBuilder.ReadTexture(mainDirectionalShadowTexture);
|
||||
}
|
||||
|
||||
passBuilder.SetExecuteCallback(
|
||||
[this,
|
||||
surfaceTemplate,
|
||||
renderContext,
|
||||
sceneData,
|
||||
hasSourceSurface,
|
||||
sourceSurface,
|
||||
sourceColorView,
|
||||
sourceColorState,
|
||||
executionSucceeded,
|
||||
beginRecordedPass,
|
||||
endRecordedPass,
|
||||
clearAttachments,
|
||||
scenePhase](
|
||||
const RenderGraphExecutionContext&) {
|
||||
if (executionSucceeded != nullptr && !(*executionSucceeded)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const FrameExecutionContext executionContext(
|
||||
renderContext,
|
||||
surfaceTemplate,
|
||||
*sceneData,
|
||||
hasSourceSurface ? &sourceSurface : nullptr,
|
||||
sourceColorView,
|
||||
sourceColorState);
|
||||
const RenderPassContext passContext =
|
||||
BuildRenderPassContext(executionContext);
|
||||
if (!beginRecordedPass(passContext, clearAttachments)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ScenePhaseExecutionContext scenePhaseExecutionContext =
|
||||
BuildScenePhaseExecutionContext(executionContext, scenePhase);
|
||||
const bool renderResult =
|
||||
ExecuteBuiltinScenePhase(scenePhaseExecutionContext);
|
||||
endRecordedPass(passContext);
|
||||
if (executionSucceeded != nullptr) {
|
||||
*executionSucceeded = renderResult;
|
||||
}
|
||||
});
|
||||
});
|
||||
renderContext,
|
||||
*sceneData,
|
||||
surfaceTemplate,
|
||||
hasSourceSurface ? &sourceSurface : nullptr,
|
||||
sourceColorView,
|
||||
sourceColorState,
|
||||
{},
|
||||
colorTargets,
|
||||
depthTarget,
|
||||
executionSucceeded,
|
||||
beginPhasePass,
|
||||
endRecordedPass,
|
||||
context.blackboard
|
||||
};
|
||||
if (!::XCEngine::Rendering::Internal::RecordCallbackRasterRenderPass(
|
||||
phaseContext,
|
||||
{
|
||||
false,
|
||||
true,
|
||||
depthTarget.IsValid()
|
||||
},
|
||||
[this, scenePhase = step.scenePhase](const RenderPassContext& passContext) {
|
||||
const FrameExecutionContext executionContext(
|
||||
passContext.renderContext,
|
||||
passContext.surface,
|
||||
passContext.sceneData,
|
||||
passContext.sourceSurface,
|
||||
passContext.sourceColorView,
|
||||
passContext.sourceColorState);
|
||||
const ScenePhaseExecutionContext scenePhaseExecutionContext =
|
||||
BuildScenePhaseExecutionContext(executionContext, scenePhase);
|
||||
return ExecuteBuiltinScenePhase(scenePhaseExecutionContext);
|
||||
},
|
||||
additionalReadTextures)) {
|
||||
return false;
|
||||
}
|
||||
clearAttachments = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user