Remove legacy camera sequence execution path
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "Rendering/Execution/CameraRenderer.h"
|
||||
|
||||
#include "Components/CameraComponent.h"
|
||||
#include "Rendering/Caches/FullscreenPassSurfaceCache.h"
|
||||
#include "Rendering/Execution/DirectionalShadowExecutionState.h"
|
||||
#include "Rendering/Graph/RenderGraph.h"
|
||||
#include "Rendering/Graph/RenderGraphCompiler.h"
|
||||
@@ -421,8 +420,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
m_initialized = m_sequence->Initialize(context);
|
||||
if (!m_initialized) {
|
||||
if (!m_sequence->Initialize(context)) {
|
||||
m_failed = true;
|
||||
m_sequence->Shutdown();
|
||||
m_sequence = nullptr;
|
||||
@@ -443,13 +441,8 @@ public:
|
||||
return !m_failed;
|
||||
}
|
||||
|
||||
bool Execute(const RenderPassContext& context) const {
|
||||
return m_sequence == nullptr || m_sequence->Execute(context);
|
||||
}
|
||||
|
||||
private:
|
||||
RenderPassSequence* m_sequence = nullptr;
|
||||
bool m_initialized = false;
|
||||
bool m_failed = false;
|
||||
};
|
||||
|
||||
@@ -469,8 +462,6 @@ struct CameraFrameExecutionState {
|
||||
RenderPass* objectIdPass = nullptr;
|
||||
RenderPass* depthOnlyPass = nullptr;
|
||||
RenderPass* shadowCasterPass = nullptr;
|
||||
FullscreenPassSurfaceCache* postProcessSurfaceCache = nullptr;
|
||||
FullscreenPassSurfaceCache* finalOutputSurfaceCache = nullptr;
|
||||
std::unique_ptr<ScopedInitializedPassSequence> preScenePasses;
|
||||
std::unique_ptr<ScopedInitializedPassSequence> postProcessPasses;
|
||||
std::unique_ptr<ScopedInitializedPassSequence> finalOutputPasses;
|
||||
@@ -521,141 +512,6 @@ bool RecordSequencePass(
|
||||
: Internal::RecordRasterRenderPass(pass, context, io);
|
||||
}
|
||||
|
||||
bool ExecutePassSequenceStage(
|
||||
std::unique_ptr<ScopedInitializedPassSequence>& activeSequence,
|
||||
RenderPassSequence* sequence,
|
||||
const RenderContext& context,
|
||||
const RenderPassContext& passContext) {
|
||||
activeSequence = std::make_unique<ScopedInitializedPassSequence>(sequence, context);
|
||||
return activeSequence->IsReady() && activeSequence->Execute(passContext);
|
||||
}
|
||||
|
||||
void CopyIntermediateSurfaceLayout(
|
||||
const RenderSurface& templateSurface,
|
||||
RenderSurface& destinationSurface) {
|
||||
destinationSurface.SetSize(templateSurface.GetWidth(), templateSurface.GetHeight());
|
||||
if (templateSurface.HasCustomRenderArea()) {
|
||||
destinationSurface.SetRenderArea(templateSurface.GetRenderArea());
|
||||
} else {
|
||||
destinationSurface.ResetRenderArea();
|
||||
}
|
||||
|
||||
destinationSurface.ClearClearColorOverride();
|
||||
destinationSurface.SetAutoTransitionEnabled(true);
|
||||
}
|
||||
|
||||
bool ExecuteFullscreenPassSequenceStage(
|
||||
std::unique_ptr<ScopedInitializedPassSequence>& activeSequence,
|
||||
RenderPassSequence* sequence,
|
||||
const RenderContext& context,
|
||||
const RenderPassContext& passContext,
|
||||
FullscreenPassSurfaceCache* surfaceCache) {
|
||||
activeSequence = std::make_unique<ScopedInitializedPassSequence>(sequence, context);
|
||||
if (!activeSequence->IsReady()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sequence == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sequence->GetPassCount() <= 1u) {
|
||||
return sequence->GetPassCount() == 0u ||
|
||||
sequence->ExecutePass(0u, passContext);
|
||||
}
|
||||
|
||||
if (surfaceCache == nullptr ||
|
||||
passContext.sourceSurface == nullptr ||
|
||||
passContext.sourceColorView == nullptr ||
|
||||
!HasValidColorTarget(passContext.surface)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<RHI::RHIResourceView*>& colorAttachments = passContext.surface.GetColorAttachments();
|
||||
const RHI::Format outputFormat = colorAttachments[0]->GetFormat();
|
||||
const size_t intermediateSurfaceCount = std::min<size_t>(2u, sequence->GetPassCount() - 1u);
|
||||
if (!surfaceCache->EnsureSurfaces(
|
||||
context,
|
||||
passContext.surface.GetWidth(),
|
||||
passContext.surface.GetHeight(),
|
||||
outputFormat,
|
||||
intermediateSurfaceCount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const RenderSurface* currentSourceSurface = passContext.sourceSurface;
|
||||
RHI::RHIResourceView* currentSourceColorView = passContext.sourceColorView;
|
||||
RHI::ResourceStates currentSourceColorState = passContext.sourceColorState;
|
||||
|
||||
for (size_t passIndex = 0; passIndex < sequence->GetPassCount(); ++passIndex) {
|
||||
const bool isLastPass = (passIndex + 1u) == sequence->GetPassCount();
|
||||
const RenderSurface* outputSurface = &passContext.surface;
|
||||
FullscreenPassSurfaceCache::SurfaceEntry* intermediateEntry = nullptr;
|
||||
if (!isLastPass) {
|
||||
intermediateEntry = surfaceCache->GetSurfaceEntry(passIndex % intermediateSurfaceCount);
|
||||
if (intermediateEntry == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CopyIntermediateSurfaceLayout(passContext.surface, intermediateEntry->surface);
|
||||
intermediateEntry->surface.SetColorStateBefore(intermediateEntry->currentColorState);
|
||||
intermediateEntry->surface.SetColorStateAfter(RHI::ResourceStates::PixelShaderResource);
|
||||
outputSurface = &intermediateEntry->surface;
|
||||
}
|
||||
|
||||
const RenderPassContext chainedContext = {
|
||||
context,
|
||||
*outputSurface,
|
||||
passContext.sceneData,
|
||||
currentSourceSurface,
|
||||
currentSourceColorView,
|
||||
currentSourceColorState
|
||||
};
|
||||
if (!sequence->ExecutePass(passIndex, chainedContext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (intermediateEntry != nullptr) {
|
||||
intermediateEntry->currentColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
currentSourceSurface = &intermediateEntry->surface;
|
||||
currentSourceColorView = intermediateEntry->shaderResourceView;
|
||||
currentSourceColorState = intermediateEntry->currentColorState;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TryBuildRenderGraphTransientSurface(
|
||||
const RenderSurface& templateSurface,
|
||||
const RenderGraphExecutionContext& graphContext,
|
||||
RenderGraphTextureHandle textureHandle,
|
||||
RenderSurface& outSurface) {
|
||||
if (!textureHandle.IsValid() ||
|
||||
!graphContext.IsTransientTexture(textureHandle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RenderGraphTextureDesc textureDesc = {};
|
||||
RHI::RHIResourceView* renderTargetView =
|
||||
graphContext.ResolveTextureView(
|
||||
textureHandle,
|
||||
RenderGraphTextureViewType::RenderTarget);
|
||||
if (renderTargetView == nullptr ||
|
||||
!graphContext.TryGetTextureDesc(textureHandle, textureDesc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
outSurface = templateSurface;
|
||||
CopyIntermediateSurfaceLayout(templateSurface, outSurface);
|
||||
outSurface.SetColorAttachment(renderTargetView);
|
||||
outSurface.SetAutoTransitionEnabled(false);
|
||||
outSurface.SetSampleDesc(textureDesc.sampleCount, textureDesc.sampleQuality);
|
||||
outSurface.SetColorStateBefore(RHI::ResourceStates::RenderTarget);
|
||||
outSurface.SetColorStateAfter(RHI::ResourceStates::PixelShaderResource);
|
||||
return true;
|
||||
}
|
||||
|
||||
RenderSurface BuildGraphManagedImportedSurface(
|
||||
const RenderSurface& templateSurface,
|
||||
RHI::ResourceStates stateBefore,
|
||||
@@ -738,14 +594,6 @@ bool CanUseGraphManagedImportedSurface(
|
||||
return hasAnyTexture;
|
||||
}
|
||||
|
||||
bool ExecuteFullscreenPassSequencePass(
|
||||
RenderPassSequence* sequence,
|
||||
size_t passIndex,
|
||||
const RenderPassContext& passContext,
|
||||
const RenderGraphExecutionContext& graphContext,
|
||||
RenderGraphTextureHandle sourceColorHandle,
|
||||
RenderGraphTextureHandle outputColorHandle);
|
||||
|
||||
RenderPassContext BuildFrameStagePassContext(
|
||||
CameraFrameStage stage,
|
||||
const CameraFramePlan& plan,
|
||||
@@ -763,41 +611,28 @@ RenderPassContext BuildFrameStagePassContext(
|
||||
};
|
||||
}
|
||||
|
||||
bool ExecuteFrameStage(
|
||||
bool ExecuteRecordedFrameStage(
|
||||
CameraFrameStage stage,
|
||||
const CameraFramePlan& plan,
|
||||
const DirectionalShadowExecutionState& shadowState,
|
||||
const RenderSceneData& sceneData,
|
||||
CameraFrameExecutionState& executionState,
|
||||
const RenderPassContext* passContextOverride = nullptr) {
|
||||
const RenderPassContext defaultPassContext =
|
||||
BuildFrameStagePassContext(stage, plan, shadowState, sceneData);
|
||||
const RenderPassContext& passContext =
|
||||
passContextOverride != nullptr
|
||||
? *passContextOverride
|
||||
: defaultPassContext;
|
||||
|
||||
const RenderPassContext& passContext) {
|
||||
switch (stage) {
|
||||
case CameraFrameStage::PreScenePasses:
|
||||
return ExecutePassSequenceStage(
|
||||
executionState.preScenePasses,
|
||||
plan.GetPassSequence(stage),
|
||||
plan.request.context,
|
||||
passContext);
|
||||
case CameraFrameStage::ShadowCaster:
|
||||
return ExecuteScenePassRequest(
|
||||
executionState.shadowCasterPass,
|
||||
shadowState.shadowCasterRequest,
|
||||
plan.request.context,
|
||||
sceneData,
|
||||
passContextOverride != nullptr ? &passContext.surface : nullptr);
|
||||
&passContext.surface);
|
||||
case CameraFrameStage::DepthOnly:
|
||||
return ExecuteScenePassRequest(
|
||||
executionState.depthOnlyPass,
|
||||
plan.request.depthOnly,
|
||||
plan.request.context,
|
||||
sceneData,
|
||||
passContextOverride != nullptr ? &passContext.surface : nullptr);
|
||||
&passContext.surface);
|
||||
case CameraFrameStage::MainScene:
|
||||
return executionState.pipeline != nullptr &&
|
||||
executionState.pipeline->Render(
|
||||
@@ -808,39 +643,13 @@ bool ExecuteFrameStage(
|
||||
passContext.sourceSurface,
|
||||
passContext.sourceColorView,
|
||||
passContext.sourceColorState));
|
||||
case CameraFrameStage::PostProcess:
|
||||
return ExecuteFullscreenPassSequenceStage(
|
||||
executionState.postProcessPasses,
|
||||
plan.GetPassSequence(stage),
|
||||
plan.request.context,
|
||||
passContext,
|
||||
executionState.postProcessSurfaceCache);
|
||||
case CameraFrameStage::FinalOutput:
|
||||
return ExecuteFullscreenPassSequenceStage(
|
||||
executionState.finalOutputPasses,
|
||||
plan.GetPassSequence(stage),
|
||||
plan.request.context,
|
||||
passContext,
|
||||
executionState.finalOutputSurfaceCache);
|
||||
case CameraFrameStage::ObjectId:
|
||||
return !plan.request.objectId.IsRequested() ||
|
||||
ExecuteStandalonePass(
|
||||
executionState.objectIdPass,
|
||||
plan.request.context,
|
||||
passContext.surface,
|
||||
sceneData);
|
||||
case CameraFrameStage::PostScenePasses:
|
||||
return ExecutePassSequenceStage(
|
||||
executionState.postScenePasses,
|
||||
plan.GetPassSequence(stage),
|
||||
plan.request.context,
|
||||
passContext);
|
||||
case CameraFrameStage::OverlayPasses:
|
||||
return ExecutePassSequenceStage(
|
||||
executionState.overlayPasses,
|
||||
plan.GetPassSequence(stage),
|
||||
plan.request.context,
|
||||
passContext);
|
||||
executionState.objectIdPass,
|
||||
plan.request.context,
|
||||
passContext.surface,
|
||||
sceneData);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -1259,13 +1068,13 @@ bool ExecuteRenderGraphPlan(
|
||||
resolvedSourceColorView,
|
||||
resolvedSourceColorState
|
||||
};
|
||||
stageExecutionSucceeded = ExecuteFrameStage(
|
||||
stageExecutionSucceeded = ExecuteRecordedFrameStage(
|
||||
stage,
|
||||
plan,
|
||||
shadowState,
|
||||
sceneData,
|
||||
executionState,
|
||||
&passContextOverride);
|
||||
passContextOverride);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1338,9 +1147,7 @@ CameraRenderer::CameraRenderer(
|
||||
, m_objectIdPass(std::move(objectIdPass))
|
||||
, m_depthOnlyPass(std::move(depthOnlyPass))
|
||||
, m_shadowCasterPass(std::move(shadowCasterPass))
|
||||
, m_directionalShadowRuntime(std::make_unique<DirectionalShadowRuntime>())
|
||||
, m_postProcessSurfaceCache(std::make_unique<FullscreenPassSurfaceCache>())
|
||||
, m_finalOutputSurfaceCache(std::make_unique<FullscreenPassSurfaceCache>()) {
|
||||
, m_directionalShadowRuntime(std::make_unique<DirectionalShadowRuntime>()) {
|
||||
if (m_objectIdPass == nullptr) {
|
||||
m_objectIdPass = std::make_unique<Passes::BuiltinObjectIdPass>();
|
||||
}
|
||||
@@ -1358,9 +1165,7 @@ CameraRenderer::CameraRenderer(std::shared_ptr<const RenderPipelineAsset> pipeli
|
||||
, m_objectIdPass(std::make_unique<Passes::BuiltinObjectIdPass>())
|
||||
, m_depthOnlyPass(CreateDefaultDepthOnlyPass())
|
||||
, m_shadowCasterPass(CreateDefaultShadowCasterPass())
|
||||
, m_directionalShadowRuntime(std::make_unique<DirectionalShadowRuntime>())
|
||||
, m_postProcessSurfaceCache(std::make_unique<FullscreenPassSurfaceCache>())
|
||||
, m_finalOutputSurfaceCache(std::make_unique<FullscreenPassSurfaceCache>()) {
|
||||
, m_directionalShadowRuntime(std::make_unique<DirectionalShadowRuntime>()) {
|
||||
SetPipelineAsset(m_pipelineAsset);
|
||||
}
|
||||
|
||||
@@ -1460,98 +1265,6 @@ bool CameraRenderer::BuildSceneDataForPlan(
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool ExecuteFullscreenPassSequencePass(
|
||||
RenderPassSequence* sequence,
|
||||
size_t passIndex,
|
||||
const RenderPassContext& passContext,
|
||||
const RenderGraphExecutionContext& graphContext,
|
||||
RenderGraphTextureHandle sourceColorHandle,
|
||||
RenderGraphTextureHandle outputColorHandle) {
|
||||
if (sequence == nullptr || passIndex >= sequence->GetPassCount()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sequence->GetPassCount() <= 1u) {
|
||||
return sequence->ExecutePass(passIndex, passContext);
|
||||
}
|
||||
|
||||
const RenderSurface* currentSourceSurface = passContext.sourceSurface;
|
||||
RHI::RHIResourceView* currentSourceColorView = passContext.sourceColorView;
|
||||
RHI::ResourceStates currentSourceColorState = passContext.sourceColorState;
|
||||
RenderSurface transientSourceSurface = {};
|
||||
RenderSurface graphManagedImportedSourceSurface = {};
|
||||
if (sourceColorHandle.IsValid() &&
|
||||
graphContext.OwnsTextureTransitions(sourceColorHandle) &&
|
||||
graphContext.IsTransientTexture(sourceColorHandle)) {
|
||||
if (!TryBuildRenderGraphTransientSurface(
|
||||
passContext.surface,
|
||||
graphContext,
|
||||
sourceColorHandle,
|
||||
transientSourceSurface)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
currentSourceSurface = &transientSourceSurface;
|
||||
currentSourceColorView =
|
||||
graphContext.ResolveTextureView(
|
||||
sourceColorHandle,
|
||||
RenderGraphTextureViewType::ShaderResource);
|
||||
if (currentSourceColorView == nullptr) {
|
||||
return false;
|
||||
}
|
||||
currentSourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
} else if (sourceColorHandle.IsValid() &&
|
||||
graphContext.OwnsTextureTransitions(sourceColorHandle) &&
|
||||
currentSourceSurface != nullptr) {
|
||||
graphManagedImportedSourceSurface =
|
||||
BuildGraphManagedImportedSurface(
|
||||
*currentSourceSurface,
|
||||
RHI::ResourceStates::PixelShaderResource,
|
||||
RHI::ResourceStates::PixelShaderResource);
|
||||
currentSourceSurface = &graphManagedImportedSourceSurface;
|
||||
currentSourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
}
|
||||
|
||||
const RenderSurface* outputSurface = &passContext.surface;
|
||||
RenderSurface transientOutputSurface = {};
|
||||
RenderSurface graphManagedImportedOutputSurface = {};
|
||||
if (outputColorHandle.IsValid() &&
|
||||
graphContext.OwnsTextureTransitions(outputColorHandle) &&
|
||||
graphContext.IsTransientTexture(outputColorHandle)) {
|
||||
if (!TryBuildRenderGraphTransientSurface(
|
||||
passContext.surface,
|
||||
graphContext,
|
||||
outputColorHandle,
|
||||
transientOutputSurface)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
outputSurface = &transientOutputSurface;
|
||||
} else if (outputColorHandle.IsValid() &&
|
||||
graphContext.OwnsTextureTransitions(outputColorHandle)) {
|
||||
graphManagedImportedOutputSurface =
|
||||
BuildGraphManagedImportedSurface(
|
||||
passContext.surface,
|
||||
RHI::ResourceStates::RenderTarget,
|
||||
RHI::ResourceStates::PixelShaderResource);
|
||||
outputSurface = &graphManagedImportedOutputSurface;
|
||||
}
|
||||
|
||||
const RenderPassContext chainedContext = {
|
||||
passContext.renderContext,
|
||||
*outputSurface,
|
||||
passContext.sceneData,
|
||||
currentSourceSurface,
|
||||
currentSourceColorView,
|
||||
currentSourceColorState
|
||||
};
|
||||
return sequence->ExecutePass(passIndex, chainedContext);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool CameraRenderer::ExecuteRenderPlan(
|
||||
const CameraFramePlan& plan,
|
||||
const DirectionalShadowExecutionState& shadowState,
|
||||
@@ -1561,8 +1274,6 @@ bool CameraRenderer::ExecuteRenderPlan(
|
||||
executionState.objectIdPass = m_objectIdPass.get();
|
||||
executionState.depthOnlyPass = m_depthOnlyPass.get();
|
||||
executionState.shadowCasterPass = m_shadowCasterPass.get();
|
||||
executionState.postProcessSurfaceCache = m_postProcessSurfaceCache.get();
|
||||
executionState.finalOutputSurfaceCache = m_finalOutputSurfaceCache.get();
|
||||
return ExecuteRenderGraphPlan(plan, shadowState, sceneData, executionState);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user