Formalize camera frame render-graph blackboard resources
This commit is contained in:
@@ -621,16 +621,30 @@ RenderGraphTextureHandle ResolveStageOutputColorHandle(
|
||||
|
||||
if (stage == CameraFrameStage::PostProcess &&
|
||||
plan.usesGraphManagedPostProcessColor) {
|
||||
frameResources.postProcessColor =
|
||||
frameResources.postProcess.color =
|
||||
graphBuilder.CreateTransientTexture(
|
||||
stageName + ".Color",
|
||||
BuildFullscreenTransientTextureDesc(stagePassContext.surface));
|
||||
return frameResources.postProcessColor;
|
||||
return frameResources.postProcess.color;
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -650,20 +664,22 @@ FullscreenStageGraphBinding ResolveFullscreenStageGraphBinding(
|
||||
binding.sourceSurfaceTemplate = &stagePassContext.surface;
|
||||
binding.sourceColorView = nullptr;
|
||||
binding.sourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
binding.sourceColor = frameResources.mainSceneColor;
|
||||
binding.sourceColor =
|
||||
ResolveFrameResourceColorSource(
|
||||
frameResources,
|
||||
plan.postProcessSource);
|
||||
}
|
||||
|
||||
if (stage == CameraFrameStage::FinalOutput) {
|
||||
if (plan.finalOutputSource == CameraFrameColorSource::MainSceneColor) {
|
||||
if (plan.finalOutputSource == CameraFrameColorSource::MainSceneColor ||
|
||||
plan.finalOutputSource == CameraFrameColorSource::PostProcessColor) {
|
||||
binding.sourceSurfaceTemplate = &stagePassContext.surface;
|
||||
binding.sourceColorView = nullptr;
|
||||
binding.sourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
binding.sourceColor = frameResources.mainSceneColor;
|
||||
} else if (plan.finalOutputSource == CameraFrameColorSource::PostProcessColor) {
|
||||
binding.sourceSurfaceTemplate = &stagePassContext.surface;
|
||||
binding.sourceColorView = nullptr;
|
||||
binding.sourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
binding.sourceColor = frameResources.postProcessColor;
|
||||
binding.sourceColor =
|
||||
ResolveFrameResourceColorSource(
|
||||
frameResources,
|
||||
plan.finalOutputSource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,7 +943,6 @@ bool ExecuteRenderGraphPlan(
|
||||
blackboard.Emplace<CameraFrameRenderGraphResources>();
|
||||
|
||||
bool stageExecutionSucceeded = true;
|
||||
RenderGraphTextureHandle mainDirectionalShadowTexture = {};
|
||||
for (const CameraFrameStageInfo& stageInfo : kOrderedCameraFrameStages) {
|
||||
if (!plan.HasFrameStage(stageInfo.stage) &&
|
||||
stageInfo.stage != CameraFrameStage::MainScene) {
|
||||
@@ -969,15 +984,19 @@ bool ExecuteRenderGraphPlan(
|
||||
if (stage == CameraFrameStage::ShadowCaster &&
|
||||
shadowState.HasShadowSampling() &&
|
||||
outputSurface.depthTexture.IsValid()) {
|
||||
mainDirectionalShadowTexture = outputSurface.depthTexture;
|
||||
frameResources.mainDirectionalShadow = outputSurface.depthTexture;
|
||||
}
|
||||
if (stage == CameraFrameStage::MainScene) {
|
||||
frameResources.mainSceneColor = stageOutputColor;
|
||||
frameResources.mainSceneDepth = outputSurface.depthTexture;
|
||||
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.objectIdColor = stageOutputColor;
|
||||
frameResources.objectId.color = stageOutputColor;
|
||||
frameResources.objectId.depth = outputSurface.depthTexture;
|
||||
}
|
||||
const RenderSurface stageSurfaceTemplate = stagePassContext.surface;
|
||||
const bool hasStageSourceSurface = stagePassContext.sourceSurface != nullptr;
|
||||
@@ -1093,7 +1112,6 @@ bool ExecuteRenderGraphPlan(
|
||||
stageSourceColorState,
|
||||
std::vector<RenderGraphTextureHandle>{ stageOutputColor },
|
||||
outputSurface.depthTexture,
|
||||
mainDirectionalShadowTexture,
|
||||
&stageExecutionSucceeded,
|
||||
&blackboard
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user