refactor(rendering): formalize camera-stage fallback surface contract
This commit is contained in:
@@ -59,5 +59,51 @@ RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
depthTarget);
|
||||
}
|
||||
|
||||
CameraFrameStageFallbackSurfaceResolution ResolveCameraFrameStageFallbackSurfaceResolution(
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
bool graphOwnsSourceTransitions,
|
||||
bool graphOwnsOutputTransitions) {
|
||||
CameraFrameStageFallbackSurfaceResolution resolution = {};
|
||||
resolution.hasSourceSurface = stageState.hasSourceSurface;
|
||||
resolution.sourceColorView = stageState.sourceColorView;
|
||||
resolution.sourceColorState = stageState.sourceColorState;
|
||||
resolution.outputSurface = graphOwnsOutputTransitions
|
||||
? BuildGraphManagedPassSurface(stageState.surfaceTemplate)
|
||||
: stageState.surfaceTemplate;
|
||||
|
||||
if (!stageState.hasSourceSurface) {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
resolution.sourceSurface = stageState.sourceSurfaceTemplate;
|
||||
if (IsCameraFrameFullscreenSequenceStage(stageState.stage) &&
|
||||
graphOwnsSourceTransitions) {
|
||||
resolution.sourceSurface =
|
||||
BuildGraphManagedImportedSurface(
|
||||
stageState.sourceSurfaceTemplate,
|
||||
RHI::ResourceStates::PixelShaderResource,
|
||||
RHI::ResourceStates::PixelShaderResource);
|
||||
resolution.sourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
}
|
||||
|
||||
return resolution;
|
||||
}
|
||||
|
||||
RenderPassContext BuildCameraFrameStageFallbackPassContext(
|
||||
const CameraFrameStageFallbackSurfaceResolution& resolution,
|
||||
const RenderContext& renderContext,
|
||||
const RenderSceneData& sceneData) {
|
||||
return {
|
||||
renderContext,
|
||||
resolution.outputSurface,
|
||||
sceneData,
|
||||
resolution.hasSourceSurface
|
||||
? &resolution.sourceSurface
|
||||
: nullptr,
|
||||
resolution.sourceColorView,
|
||||
resolution.sourceColorState
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
|
||||
struct CameraFrameStageFallbackSurfaceResolution {
|
||||
RenderSurface sourceSurface = {};
|
||||
RenderSurface outputSurface = {};
|
||||
bool hasSourceSurface = false;
|
||||
RHI::RHIResourceView* sourceColorView = nullptr;
|
||||
RHI::ResourceStates sourceColorState = RHI::ResourceStates::Common;
|
||||
};
|
||||
|
||||
CameraFrameRenderGraphSourceBinding BuildCameraFrameStageGraphSourceBinding(
|
||||
const CameraFrameStageGraphBuildState& stageState);
|
||||
|
||||
@@ -28,5 +36,15 @@ RenderGraphRecordingContext BuildCameraFrameStageGraphRecordingContext(
|
||||
std::vector<RenderGraphTextureHandle> colorTargets,
|
||||
RenderGraphTextureHandle depthTarget);
|
||||
|
||||
CameraFrameStageFallbackSurfaceResolution ResolveCameraFrameStageFallbackSurfaceResolution(
|
||||
const CameraFrameStageGraphBuildState& stageState,
|
||||
bool graphOwnsSourceTransitions,
|
||||
bool graphOwnsOutputTransitions);
|
||||
|
||||
RenderPassContext BuildCameraFrameStageFallbackPassContext(
|
||||
const CameraFrameStageFallbackSurfaceResolution& resolution,
|
||||
const RenderContext& renderContext,
|
||||
const RenderSceneData& sceneData);
|
||||
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
|
||||
@@ -128,49 +128,20 @@ void AddCameraFrameStageFallbackRasterPass(
|
||||
return;
|
||||
}
|
||||
|
||||
const RenderSurface* resolvedSourceSurface =
|
||||
capturedStageState.hasSourceSurface
|
||||
? &capturedStageState.sourceSurfaceTemplate
|
||||
: nullptr;
|
||||
RHI::RHIResourceView* resolvedSourceColorView =
|
||||
capturedStageState.sourceColorView;
|
||||
RHI::ResourceStates resolvedSourceColorState =
|
||||
capturedStageState.sourceColorState;
|
||||
RenderSurface graphManagedSourceSurface = {};
|
||||
if (IsCameraFrameFullscreenSequenceStage(capturedStageState.stage) &&
|
||||
capturedStageState.hasSourceSurface &&
|
||||
CanUseGraphManagedImportedSurface(
|
||||
capturedStageState.sourceSurface,
|
||||
executionContext)) {
|
||||
graphManagedSourceSurface =
|
||||
BuildGraphManagedImportedSurface(
|
||||
capturedStageState.sourceSurfaceTemplate,
|
||||
RHI::ResourceStates::PixelShaderResource,
|
||||
RHI::ResourceStates::PixelShaderResource);
|
||||
resolvedSourceSurface = &graphManagedSourceSurface;
|
||||
resolvedSourceColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
}
|
||||
|
||||
const RenderSurface* resolvedOutputSurface =
|
||||
&capturedStageState.surfaceTemplate;
|
||||
RenderSurface graphManagedOutputSurface = {};
|
||||
if (CanUseGraphManagedImportedSurface(
|
||||
capturedStageState.outputSurface,
|
||||
executionContext)) {
|
||||
graphManagedOutputSurface =
|
||||
BuildGraphManagedPassSurface(
|
||||
capturedStageState.surfaceTemplate);
|
||||
resolvedOutputSurface = &graphManagedOutputSurface;
|
||||
}
|
||||
|
||||
const RenderPassContext passContextOverride = {
|
||||
planPtr->request.context,
|
||||
*resolvedOutputSurface,
|
||||
*sceneDataPtr,
|
||||
resolvedSourceSurface,
|
||||
resolvedSourceColorView,
|
||||
resolvedSourceColorState
|
||||
};
|
||||
const CameraFrameStageFallbackSurfaceResolution surfaceResolution =
|
||||
ResolveCameraFrameStageFallbackSurfaceResolution(
|
||||
capturedStageState,
|
||||
CanUseGraphManagedImportedSurface(
|
||||
capturedStageState.sourceSurface,
|
||||
executionContext),
|
||||
CanUseGraphManagedImportedSurface(
|
||||
capturedStageState.outputSurface,
|
||||
executionContext));
|
||||
const RenderPassContext passContextOverride =
|
||||
BuildCameraFrameStageFallbackPassContext(
|
||||
surfaceResolution,
|
||||
planPtr->request.context,
|
||||
*sceneDataPtr);
|
||||
*stageExecutionSucceeded = ExecuteCameraFrameRecordedStage(
|
||||
capturedStageState.stage,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user