Extract camera frame fullscreen stage planner

This commit is contained in:
2026-04-15 00:53:51 +08:00
parent 0afcaa0b3b
commit f064d6ed68
10 changed files with 284 additions and 54 deletions

View File

@@ -1,9 +1,7 @@
#include "Rendering/Planning/CameraFramePlanBuilder.h"
#include "Components/CameraComponent.h"
#include "Debug/Logger.h"
#include "Rendering/Planning/CameraPostProcessPassFactory.h"
#include "Rendering/Planning/FinalColorPassFactory.h"
#include "Rendering/Planning/Internal/CameraFrameFullscreenStagePlanner.h"
#include "Rendering/RenderPipelineAsset.h"
namespace XCEngine {
@@ -55,57 +53,10 @@ void CameraFramePlanBuilder::AttachFullscreenStageRequests(
for (size_t index = 0; index < plans.size(); ++index) {
CameraFramePlan& plan = plans[index];
if (plan.request.camera == nullptr ||
plan.request.context.device == nullptr ||
!HasValidColorTarget(plan.request.surface)) {
continue;
}
std::unique_ptr<RenderPassSequence> postProcessSequence =
BuildCameraPostProcessPassSequence(plan.request.camera->GetPostProcessPasses());
std::unique_ptr<RenderPassSequence> finalOutputSequence =
BuildFinalColorPassSequence(plan.finalColorPolicy);
const bool hasPostProcess =
postProcessSequence != nullptr && postProcessSequence->GetPassCount() > 0u;
const bool hasFinalOutput =
finalOutputSequence != nullptr && finalOutputSequence->GetPassCount() > 0u;
if (!hasPostProcess && !hasFinalOutput) {
continue;
}
if (plan.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;
}
if (hasPostProcess) {
m_ownedPostProcessSequences[index] = std::move(postProcessSequence);
plan.postProcess.passes = m_ownedPostProcessSequences[index].get();
plan.colorChain.usesGraphManagedMainSceneColor = true;
plan.colorChain.postProcess.source = CameraFrameColorSource::MainSceneColor;
plan.colorChain.postProcess.usesGraphManagedOutputColor = hasFinalOutput;
if (!hasFinalOutput) {
plan.postProcess.destinationSurface = plan.request.surface;
}
}
if (hasFinalOutput) {
m_ownedFinalOutputSequences[index] = std::move(finalOutputSequence);
plan.finalOutput.passes = m_ownedFinalOutputSequences[index].get();
plan.colorChain.usesGraphManagedMainSceneColor = true;
plan.colorChain.finalOutput.source =
hasPostProcess
? CameraFrameColorSource::PostProcessColor
: CameraFrameColorSource::MainSceneColor;
plan.finalOutput.destinationSurface = plan.request.surface;
}
if (plan.UsesGraphManagedMainSceneColor()) {
plan.ConfigureGraphManagedMainSceneSurface();
}
Internal::PlanCameraFrameFullscreenStages(
plan,
m_ownedPostProcessSequences[index],
m_ownedFinalOutputSequences[index]);
}
}

View File

@@ -0,0 +1,76 @@
#include "Rendering/Planning/Internal/CameraFrameFullscreenStagePlanner.h"
#include "Components/CameraComponent.h"
#include "Debug/Logger.h"
#include <XCEngine/Rendering/Execution/CameraFramePlan.h>
#include <XCEngine/Rendering/Planning/CameraPostProcessPassFactory.h>
#include <XCEngine/Rendering/Planning/FinalColorPassFactory.h>
namespace XCEngine {
namespace Rendering {
namespace Internal {
void PlanCameraFrameFullscreenStages(
CameraFramePlan& plan,
std::unique_ptr<RenderPassSequence>& ownedPostProcessSequence,
std::unique_ptr<RenderPassSequence>& ownedFinalOutputSequence) {
ownedPostProcessSequence.reset();
ownedFinalOutputSequence.reset();
if (plan.request.camera == nullptr ||
plan.request.context.device == nullptr ||
!HasValidColorTarget(plan.request.surface)) {
return;
}
std::unique_ptr<RenderPassSequence> postProcessSequence =
BuildCameraPostProcessPassSequence(plan.request.camera->GetPostProcessPasses());
std::unique_ptr<RenderPassSequence> finalOutputSequence =
BuildFinalColorPassSequence(plan.finalColorPolicy);
const bool hasPostProcess =
postProcessSequence != nullptr && postProcessSequence->GetPassCount() > 0u;
const bool hasFinalOutput =
finalOutputSequence != nullptr && finalOutputSequence->GetPassCount() > 0u;
if (!hasPostProcess && !hasFinalOutput) {
return;
}
if (plan.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");
return;
}
if (hasPostProcess) {
ownedPostProcessSequence = std::move(postProcessSequence);
plan.postProcess.passes = ownedPostProcessSequence.get();
plan.colorChain.usesGraphManagedMainSceneColor = true;
plan.colorChain.postProcess.source = CameraFrameColorSource::MainSceneColor;
plan.colorChain.postProcess.usesGraphManagedOutputColor = hasFinalOutput;
if (!hasFinalOutput) {
plan.postProcess.destinationSurface = plan.request.surface;
}
}
if (hasFinalOutput) {
ownedFinalOutputSequence = std::move(finalOutputSequence);
plan.finalOutput.passes = ownedFinalOutputSequence.get();
plan.colorChain.usesGraphManagedMainSceneColor = true;
plan.colorChain.finalOutput.source =
hasPostProcess
? CameraFrameColorSource::PostProcessColor
: CameraFrameColorSource::MainSceneColor;
plan.finalOutput.destinationSurface = plan.request.surface;
}
if (plan.UsesGraphManagedMainSceneColor()) {
plan.ConfigureGraphManagedMainSceneSurface();
}
}
} // namespace Internal
} // namespace Rendering
} // namespace XCEngine

View File

@@ -0,0 +1,21 @@
#pragma once
#include <XCEngine/Rendering/RenderPass.h>
#include <memory>
namespace XCEngine {
namespace Rendering {
struct CameraFramePlan;
namespace Internal {
void PlanCameraFrameFullscreenStages(
CameraFramePlan& plan,
std::unique_ptr<RenderPassSequence>& ownedPostProcessSequence,
std::unique_ptr<RenderPassSequence>& ownedFinalOutputSequence);
} // namespace Internal
} // namespace Rendering
} // namespace XCEngine