Tighten final color contract

This commit is contained in:
2026-04-10 01:21:00 +08:00
parent 4111f841d4
commit 4debbbea1f
4 changed files with 19 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
#include "Rendering/Execution/SceneRenderer.h"
#include "Components/CameraComponent.h"
#include "Debug/Logger.h"
#include "Rendering/Caches/FullscreenPassSurfaceCache.h"
#include "Rendering/Planning/CameraPostProcessPassFactory.h"
#include "Rendering/Planning/FinalColorPassFactory.h"
@@ -19,6 +20,8 @@ RenderSurface ConfigureFullscreenStageSurface(
RenderSurface surface = entry.surface;
if (copyDepthAttachment) {
surface.SetDepthAttachment(templateSurface.GetDepthAttachment());
surface.SetDepthStateBefore(templateSurface.GetDepthStateBefore());
surface.SetDepthStateAfter(templateSurface.GetDepthStateAfter());
if (templateSurface.HasClearColorOverride()) {
surface.SetClearColorOverride(templateSurface.GetClearColorOverride());
}
@@ -175,8 +178,7 @@ void SceneRenderer::ResolveCameraFinalColorPolicies(
request.finalColorPolicy = ResolveFinalColorPolicy(
pipelineDefaults,
&request.camera->GetFinalColorOverrides(),
nullptr);
&request.camera->GetFinalColorOverrides());
}
}
@@ -206,6 +208,13 @@ void SceneRenderer::AttachFullscreenStageRequests(
continue;
}
if (request.surface.GetSampleCount() > 1u) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"SceneRenderer fullscreen post-process/final-output chain currently requires a single-sample main scene surface");
continue;
}
const std::vector<RHI::RHIResourceView*>& colorAttachments = request.surface.GetColorAttachments();
const RHI::Format colorFormat = colorAttachments[0]->GetFormat();
if (colorFormat == RHI::Format::Unknown) {
@@ -240,6 +249,7 @@ void SceneRenderer::AttachFullscreenStageRequests(
request.postProcess.sourceSurface =
ConfigureFullscreenStageSurface(*sceneColorEntry, request.surface, true);
request.postProcess.sourceColorView = sceneColorEntry->shaderResourceView;
request.postProcess.sourceColorState = request.postProcess.sourceSurface.GetColorStateAfter();
request.postProcess.destinationSurface =
hasFinalOutput
? ConfigureFullscreenStageSurface(*postProcessOutputEntry, request.surface, false)
@@ -256,6 +266,7 @@ void SceneRenderer::AttachFullscreenStageRequests(
? request.postProcess.destinationSurface
: ConfigureFullscreenStageSurface(*sceneColorEntry, request.surface, true);
request.finalOutput.sourceColorView = finalOutputSourceEntry->shaderResourceView;
request.finalOutput.sourceColorState = request.finalOutput.sourceSurface.GetColorStateAfter();
request.finalOutput.destinationSurface = request.surface;
m_ownedFinalOutputSequences[index] = std::move(finalOutputSequence);
request.finalOutput.passes = m_ownedFinalOutputSequences[index].get();