Extract camera frame stage surface resolver
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <XCEngine/Resources/Shader/ShaderKeywordTypes.h>
|
||||
#include <XCEngine/Scene/Scene.h>
|
||||
|
||||
#include "Rendering/Execution/Internal/CameraFrameStageSurfaceResolver.h"
|
||||
#include "Rendering/Internal/RenderPassGraphUtils.h"
|
||||
|
||||
#include <memory>
|
||||
@@ -27,6 +28,21 @@ using namespace XCEngine::Rendering;
|
||||
|
||||
namespace {
|
||||
|
||||
const RenderSurface* ResolveStageOutputSurface(
|
||||
CameraFrameStage stage,
|
||||
const CameraFramePlan& plan) {
|
||||
return ResolveCameraFrameStageOutputSurface(
|
||||
stage,
|
||||
plan,
|
||||
DirectionalShadowExecutionState{});
|
||||
}
|
||||
|
||||
CameraFrameStageSourceBinding ResolveStageSourceBinding(
|
||||
CameraFrameStage stage,
|
||||
const CameraFramePlan& plan) {
|
||||
return ResolveCameraFrameStageSourceBinding(stage, plan);
|
||||
}
|
||||
|
||||
struct MockPipelineState {
|
||||
int initializeCalls = 0;
|
||||
int shutdownCalls = 0;
|
||||
@@ -928,23 +944,29 @@ TEST(CameraRenderRequest_Test, ReportsFormalFrameStageContract) {
|
||||
EXPECT_EQ(plan.GetMainSceneSurface().GetRenderAreaHeight(), 128u);
|
||||
EXPECT_EQ(plan.GetFinalCompositedSurface().GetRenderAreaWidth(), 640u);
|
||||
EXPECT_EQ(plan.GetFinalCompositedSurface().GetRenderAreaHeight(), 360u);
|
||||
ASSERT_NE(plan.GetOutputSurface(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(plan.GetOutputSurface(CameraFrameStage::PostProcess)->GetRenderAreaWidth(), 512u);
|
||||
ASSERT_NE(plan.GetSourceSurface(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(plan.GetSourceSurface(CameraFrameStage::PostProcess)->GetRenderAreaWidth(), 256u);
|
||||
const RenderSurface* const postProcessOutput =
|
||||
ResolveStageOutputSurface(CameraFrameStage::PostProcess, plan);
|
||||
const CameraFrameStageSourceBinding postProcessSource =
|
||||
ResolveStageSourceBinding(CameraFrameStage::PostProcess, plan);
|
||||
ASSERT_NE(postProcessOutput, nullptr);
|
||||
EXPECT_EQ(postProcessOutput->GetRenderAreaWidth(), 512u);
|
||||
ASSERT_NE(postProcessSource.sourceSurface, nullptr);
|
||||
EXPECT_EQ(postProcessSource.sourceSurface->GetRenderAreaWidth(), 256u);
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorView(CameraFrameStage::PostProcess),
|
||||
postProcessSource.sourceColorView,
|
||||
reinterpret_cast<XCEngine::RHI::RHIResourceView*>(20));
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorState(CameraFrameStage::PostProcess),
|
||||
postProcessSource.sourceColorState,
|
||||
XCEngine::RHI::ResourceStates::PixelShaderResource);
|
||||
ASSERT_NE(plan.GetSourceSurface(CameraFrameStage::FinalOutput), nullptr);
|
||||
EXPECT_EQ(plan.GetSourceSurface(CameraFrameStage::FinalOutput)->GetRenderAreaWidth(), 512u);
|
||||
const CameraFrameStageSourceBinding finalOutputSource =
|
||||
ResolveStageSourceBinding(CameraFrameStage::FinalOutput, plan);
|
||||
ASSERT_NE(finalOutputSource.sourceSurface, nullptr);
|
||||
EXPECT_EQ(finalOutputSource.sourceSurface->GetRenderAreaWidth(), 512u);
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorView(CameraFrameStage::FinalOutput),
|
||||
finalOutputSource.sourceColorView,
|
||||
reinterpret_cast<XCEngine::RHI::RHIResourceView*>(40));
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorState(CameraFrameStage::FinalOutput),
|
||||
finalOutputSource.sourceColorState,
|
||||
XCEngine::RHI::ResourceStates::PixelShaderResource);
|
||||
}
|
||||
|
||||
@@ -2880,10 +2902,12 @@ TEST(SceneRenderer_Test, BuildsCameraColorScalePostProcessRequestFromCameraPassS
|
||||
EXPECT_EQ(sourceRenderArea.y, 75);
|
||||
EXPECT_EQ(sourceRenderArea.width, 400);
|
||||
EXPECT_EQ(sourceRenderArea.height, 375);
|
||||
EXPECT_EQ(plan.GetSourceSurface(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(plan.GetSourceColorView(CameraFrameStage::PostProcess), nullptr);
|
||||
const CameraFrameStageSourceBinding postProcessSource =
|
||||
ResolveStageSourceBinding(CameraFrameStage::PostProcess, plan);
|
||||
EXPECT_EQ(postProcessSource.sourceSurface, nullptr);
|
||||
EXPECT_EQ(postProcessSource.sourceColorView, nullptr);
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorState(CameraFrameStage::PostProcess),
|
||||
postProcessSource.sourceColorState,
|
||||
XCEngine::RHI::ResourceStates::Common);
|
||||
EXPECT_EQ(allocationState->createTextureCalls, 0);
|
||||
EXPECT_EQ(allocationState->createRenderTargetViewCalls, 0);
|
||||
@@ -3010,10 +3034,12 @@ TEST(SceneRenderer_Test, BuildsFinalOutputRequestFromResolvedFinalColorPolicy) {
|
||||
XCEngine::RHI::ResourceStates::PixelShaderResource);
|
||||
EXPECT_EQ(plan.GetMainSceneSurface().GetWidth(), 800u);
|
||||
EXPECT_EQ(plan.GetMainSceneSurface().GetHeight(), 600u);
|
||||
EXPECT_EQ(plan.GetSourceSurface(CameraFrameStage::FinalOutput), nullptr);
|
||||
EXPECT_EQ(plan.GetSourceColorView(CameraFrameStage::FinalOutput), nullptr);
|
||||
const CameraFrameStageSourceBinding finalOutputSource =
|
||||
ResolveStageSourceBinding(CameraFrameStage::FinalOutput, plan);
|
||||
EXPECT_EQ(finalOutputSource.sourceSurface, nullptr);
|
||||
EXPECT_EQ(finalOutputSource.sourceColorView, nullptr);
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorState(CameraFrameStage::FinalOutput),
|
||||
finalOutputSource.sourceColorState,
|
||||
XCEngine::RHI::ResourceStates::Common);
|
||||
EXPECT_EQ(allocationState->createTextureCalls, 0);
|
||||
EXPECT_EQ(allocationState->createRenderTargetViewCalls, 0);
|
||||
@@ -3085,9 +3111,15 @@ TEST(SceneRenderer_Test, RoutesPostProcessIntoIntermediateSurfaceBeforeFinalOutp
|
||||
EXPECT_EQ(plan.postProcessSource, CameraFrameColorSource::MainSceneColor);
|
||||
EXPECT_EQ(plan.finalOutputSource, CameraFrameColorSource::PostProcessColor);
|
||||
|
||||
EXPECT_EQ(plan.GetSourceSurface(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(plan.GetOutputSurface(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(plan.GetSourceSurface(CameraFrameStage::FinalOutput), nullptr);
|
||||
const CameraFrameStageSourceBinding postProcessSource =
|
||||
ResolveStageSourceBinding(CameraFrameStage::PostProcess, plan);
|
||||
const RenderSurface* const postProcessOutput =
|
||||
ResolveStageOutputSurface(CameraFrameStage::PostProcess, plan);
|
||||
const CameraFrameStageSourceBinding finalOutputSource =
|
||||
ResolveStageSourceBinding(CameraFrameStage::FinalOutput, plan);
|
||||
EXPECT_EQ(postProcessSource.sourceSurface, nullptr);
|
||||
EXPECT_EQ(postProcessOutput, nullptr);
|
||||
EXPECT_EQ(finalOutputSource.sourceSurface, nullptr);
|
||||
EXPECT_EQ(plan.finalOutput.destinationSurface.GetColorAttachments()[0], backBufferColorView);
|
||||
EXPECT_EQ(plan.finalOutput.destinationSurface.GetDepthAttachment(), depthView);
|
||||
EXPECT_EQ(
|
||||
@@ -3106,13 +3138,13 @@ TEST(SceneRenderer_Test, RoutesPostProcessIntoIntermediateSurfaceBeforeFinalOutp
|
||||
EXPECT_EQ(finalOutputSourceArea.y, 75);
|
||||
EXPECT_EQ(finalOutputSourceArea.width, 400);
|
||||
EXPECT_EQ(finalOutputSourceArea.height, 375);
|
||||
EXPECT_EQ(plan.GetSourceColorView(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(plan.GetSourceColorView(CameraFrameStage::FinalOutput), nullptr);
|
||||
EXPECT_EQ(postProcessSource.sourceColorView, nullptr);
|
||||
EXPECT_EQ(finalOutputSource.sourceColorView, nullptr);
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorState(CameraFrameStage::PostProcess),
|
||||
postProcessSource.sourceColorState,
|
||||
XCEngine::RHI::ResourceStates::Common);
|
||||
EXPECT_EQ(
|
||||
plan.GetSourceColorState(CameraFrameStage::FinalOutput),
|
||||
finalOutputSource.sourceColorState,
|
||||
XCEngine::RHI::ResourceStates::Common);
|
||||
EXPECT_EQ(allocationState->createTextureCalls, 0);
|
||||
EXPECT_EQ(allocationState->createRenderTargetViewCalls, 0);
|
||||
@@ -3309,7 +3341,9 @@ TEST(SceneRenderer_Test, KeepsPostProcessOutputGraphManagedWhenFinalOutputIsEnab
|
||||
EXPECT_EQ(
|
||||
firstFramePlan.GetMainSceneSurface().GetColorStateBefore(),
|
||||
XCEngine::RHI::ResourceStates::Common);
|
||||
EXPECT_EQ(firstFramePlan.GetOutputSurface(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(
|
||||
ResolveStageOutputSurface(CameraFrameStage::PostProcess, firstFramePlan),
|
||||
nullptr);
|
||||
|
||||
RenderPassSequence postProcessPasses;
|
||||
postProcessPasses.AddPass(std::make_unique<MockScenePass>(pipelineState, "postProcess"));
|
||||
@@ -3335,8 +3369,12 @@ TEST(SceneRenderer_Test, KeepsPostProcessOutputGraphManagedWhenFinalOutputIsEnab
|
||||
EXPECT_EQ(
|
||||
secondFramePlan.GetMainSceneSurface().GetColorStateBefore(),
|
||||
XCEngine::RHI::ResourceStates::Common);
|
||||
EXPECT_EQ(secondFramePlan.GetOutputSurface(CameraFrameStage::PostProcess), nullptr);
|
||||
EXPECT_EQ(secondFramePlan.GetSourceSurface(CameraFrameStage::FinalOutput), nullptr);
|
||||
EXPECT_EQ(
|
||||
ResolveStageOutputSurface(CameraFrameStage::PostProcess, secondFramePlan),
|
||||
nullptr);
|
||||
EXPECT_EQ(
|
||||
ResolveStageSourceBinding(CameraFrameStage::FinalOutput, secondFramePlan).sourceSurface,
|
||||
nullptr);
|
||||
EXPECT_EQ(allocationState->createTextureCalls, createTextureCallsAfterFirstRender);
|
||||
EXPECT_EQ(
|
||||
allocationState->createRenderTargetViewCalls,
|
||||
|
||||
Reference in New Issue
Block a user