Unify camera frame graph resource binding helpers
This commit is contained in:
@@ -608,8 +608,7 @@ RenderGraphTextureHandle ResolveStageOutputColorHandle(
|
||||
const Containers::String& stageName,
|
||||
const RenderPassContext& stagePassContext,
|
||||
const RenderGraphImportedSurface& outputSurface,
|
||||
RenderGraphBuilder& graphBuilder,
|
||||
CameraFrameRenderGraphResources& frameResources) {
|
||||
RenderGraphBuilder& graphBuilder) {
|
||||
if (stage == CameraFrameStage::MainScene &&
|
||||
plan.usesGraphManagedMainSceneColor) {
|
||||
return graphBuilder.CreateTransientTexture(
|
||||
@@ -621,37 +620,21 @@ RenderGraphTextureHandle ResolveStageOutputColorHandle(
|
||||
|
||||
if (stage == CameraFrameStage::PostProcess &&
|
||||
plan.usesGraphManagedPostProcessColor) {
|
||||
frameResources.postProcess.color =
|
||||
graphBuilder.CreateTransientTexture(
|
||||
stageName + ".Color",
|
||||
BuildFullscreenTransientTextureDesc(stagePassContext.surface));
|
||||
return frameResources.postProcess.color;
|
||||
return graphBuilder.CreateTransientTexture(
|
||||
stageName + ".Color",
|
||||
BuildFullscreenTransientTextureDesc(stagePassContext.surface));
|
||||
}
|
||||
|
||||
return GetPrimaryColorTexture(outputSurface);
|
||||
}
|
||||
|
||||
RenderGraphTextureHandle ResolveFrameResourceColorSource(
|
||||
const CameraFrameRenderGraphResources& frameResources,
|
||||
CameraFrameColorSource source) {
|
||||
switch (source) {
|
||||
case CameraFrameColorSource::MainSceneColor:
|
||||
return frameResources.mainScene.color;
|
||||
case CameraFrameColorSource::PostProcessColor:
|
||||
return frameResources.postProcess.color;
|
||||
case CameraFrameColorSource::ExplicitSurface:
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
FullscreenStageGraphBinding ResolveFullscreenStageGraphBinding(
|
||||
CameraFrameStage stage,
|
||||
const CameraFramePlan& plan,
|
||||
const RenderPassContext& stagePassContext,
|
||||
const RenderGraphImportedSurface& sourceSurface,
|
||||
RenderGraphTextureHandle outputColor,
|
||||
CameraFrameRenderGraphResources& frameResources) {
|
||||
const RenderGraphBlackboard* blackboard) {
|
||||
FullscreenStageGraphBinding binding = {};
|
||||
binding.sourceSurfaceTemplate = stagePassContext.sourceSurface;
|
||||
binding.sourceColorView = stagePassContext.sourceColorView;
|
||||
@@ -665,8 +648,8 @@ FullscreenStageGraphBinding ResolveFullscreenStageGraphBinding(
|
||||
binding.sourceColorView = nullptr;
|
||||
binding.sourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
binding.sourceColor =
|
||||
ResolveFrameResourceColorSource(
|
||||
frameResources,
|
||||
ResolveCameraFrameRenderGraphColorSource(
|
||||
blackboard,
|
||||
plan.postProcessSource);
|
||||
}
|
||||
|
||||
@@ -677,8 +660,8 @@ FullscreenStageGraphBinding ResolveFullscreenStageGraphBinding(
|
||||
binding.sourceColorView = nullptr;
|
||||
binding.sourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
binding.sourceColor =
|
||||
ResolveFrameResourceColorSource(
|
||||
frameResources,
|
||||
ResolveCameraFrameRenderGraphColorSource(
|
||||
blackboard,
|
||||
plan.finalOutputSource);
|
||||
}
|
||||
}
|
||||
@@ -979,25 +962,17 @@ bool ExecuteRenderGraphPlan(
|
||||
stageName,
|
||||
stagePassContext,
|
||||
outputSurface,
|
||||
graphBuilder,
|
||||
frameResources);
|
||||
graphBuilder);
|
||||
if (stage == CameraFrameStage::ShadowCaster &&
|
||||
shadowState.HasShadowSampling() &&
|
||||
outputSurface.depthTexture.IsValid()) {
|
||||
frameResources.mainDirectionalShadow = outputSurface.depthTexture;
|
||||
}
|
||||
if (stage == CameraFrameStage::MainScene) {
|
||||
frameResources.mainScene.color = stageOutputColor;
|
||||
frameResources.mainScene.depth = outputSurface.depthTexture;
|
||||
}
|
||||
if (stage == CameraFrameStage::PostProcess) {
|
||||
frameResources.postProcess.color = stageOutputColor;
|
||||
frameResources.postProcess.depth = outputSurface.depthTexture;
|
||||
}
|
||||
if (stage == CameraFrameStage::ObjectId) {
|
||||
frameResources.objectId.color = stageOutputColor;
|
||||
frameResources.objectId.depth = outputSurface.depthTexture;
|
||||
}
|
||||
WriteCameraFrameRenderGraphStageSurfaceResources(
|
||||
frameResources,
|
||||
stage,
|
||||
stageOutputColor,
|
||||
outputSurface.depthTexture);
|
||||
const RenderSurface stageSurfaceTemplate = stagePassContext.surface;
|
||||
const bool hasStageSourceSurface = stagePassContext.sourceSurface != nullptr;
|
||||
const RenderSurface stageSourceSurfaceTemplate =
|
||||
@@ -1020,7 +995,7 @@ bool ExecuteRenderGraphPlan(
|
||||
stagePassContext,
|
||||
sourceSurface,
|
||||
stageOutputColor,
|
||||
frameResources),
|
||||
&blackboard),
|
||||
sceneData,
|
||||
stageSequence,
|
||||
executionState,
|
||||
|
||||
Reference in New Issue
Block a user