refactor(srp): require explicit managed renderer stage planning
This commit is contained in:
@@ -202,13 +202,6 @@ namespace XCEngine.Rendering.Universal
|
||||
protected virtual void FinalizeCameraFramePlan(
|
||||
ScriptableRenderPipelinePlanningContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyInferredFullscreenStageRequests(
|
||||
context);
|
||||
}
|
||||
|
||||
protected virtual void ConfigureRenderSceneSetup(
|
||||
@@ -245,131 +238,6 @@ namespace XCEngine.Rendering.Universal
|
||||
protected virtual void ReleaseRuntimeResources()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual RenderingData CreatePlanningRenderingData(
|
||||
ScriptableRenderPipelinePlanningContext context)
|
||||
{
|
||||
return context != null
|
||||
? new RenderingData(
|
||||
CameraFrameStage.MainScene,
|
||||
context.rendererIndex)
|
||||
: null;
|
||||
}
|
||||
|
||||
private void ApplyInferredFullscreenStageRequests(
|
||||
ScriptableRenderPipelinePlanningContext context)
|
||||
{
|
||||
RenderingData planningData =
|
||||
CreatePlanningRenderingData(context);
|
||||
if (planningData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BuildPassQueue(planningData);
|
||||
ApplyInferredStandaloneStageRequests(
|
||||
context);
|
||||
|
||||
bool hasPostProcessPass =
|
||||
HasQueuedPassForStage(
|
||||
CameraFrameStage.PostProcess);
|
||||
bool hasFinalOutputPass =
|
||||
HasQueuedPassForStage(
|
||||
CameraFrameStage.FinalOutput);
|
||||
bool needsFinalOutputDependency =
|
||||
context.HasFinalColorProcessing() ||
|
||||
context.IsStageRequested(
|
||||
CameraFrameStage.FinalOutput) ||
|
||||
hasFinalOutputPass;
|
||||
|
||||
if (hasPostProcessPass)
|
||||
{
|
||||
EnsureInferredPostProcessStage(
|
||||
context,
|
||||
needsFinalOutputDependency);
|
||||
}
|
||||
|
||||
if (hasFinalOutputPass &&
|
||||
!context.IsStageRequested(
|
||||
CameraFrameStage.FinalOutput))
|
||||
{
|
||||
context.RequestFullscreenStage(
|
||||
CameraFrameStage.FinalOutput,
|
||||
context.IsStageRequested(
|
||||
CameraFrameStage.PostProcess)
|
||||
? CameraFrameColorSource.PostProcessColor
|
||||
: CameraFrameColorSource.MainSceneColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyInferredStandaloneStageRequests(
|
||||
ScriptableRenderPipelinePlanningContext context)
|
||||
{
|
||||
if (!context.HasExplicitShadowCasterStageConfiguration() &&
|
||||
HasQueuedPassForStage(
|
||||
CameraFrameStage.ShadowCaster))
|
||||
{
|
||||
context.RequestShadowCasterStage();
|
||||
}
|
||||
|
||||
if (!context.HasExplicitDepthOnlyStageConfiguration() &&
|
||||
HasQueuedPassForStage(
|
||||
CameraFrameStage.DepthOnly))
|
||||
{
|
||||
context.RequestDepthOnlyStage();
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasQueuedPassForStage(
|
||||
CameraFrameStage stage)
|
||||
{
|
||||
for (int i = 0; i < m_activePassQueue.Count; ++i)
|
||||
{
|
||||
ScriptableRenderPass renderPass =
|
||||
m_activePassQueue[i];
|
||||
if (renderPass != null &&
|
||||
renderPass.SupportsStage(stage))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void EnsureInferredPostProcessStage(
|
||||
ScriptableRenderPipelinePlanningContext context,
|
||||
bool needsGraphManagedOutputColor)
|
||||
{
|
||||
if (!context.IsStageRequested(
|
||||
CameraFrameStage.PostProcess))
|
||||
{
|
||||
context.RequestFullscreenStage(
|
||||
CameraFrameStage.PostProcess,
|
||||
CameraFrameColorSource.MainSceneColor,
|
||||
needsGraphManagedOutputColor);
|
||||
return;
|
||||
}
|
||||
|
||||
CameraFrameColorSource source =
|
||||
context.GetStageColorSource(
|
||||
CameraFrameStage.PostProcess);
|
||||
if (!needsGraphManagedOutputColor ||
|
||||
source ==
|
||||
CameraFrameColorSource.ExplicitSurface ||
|
||||
context.UsesGraphManagedOutputColor(
|
||||
CameraFrameStage.PostProcess))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
context.ClearFullscreenStage(
|
||||
CameraFrameStage.PostProcess);
|
||||
context.RequestFullscreenStage(
|
||||
CameraFrameStage.PostProcess,
|
||||
source,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user