refactor(rendering): split managed SRP layers and namespaces
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using XCEngine;
|
||||
using XCEngine.Rendering;
|
||||
using XCEngine.Rendering.Renderer;
|
||||
using XCEngine.Rendering.FirstParty;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
@@ -30,50 +33,52 @@ namespace Gameplay
|
||||
|
||||
internal sealed class SceneInjectionPass : ScriptableRenderPass
|
||||
{
|
||||
private readonly SceneRenderInjectionPoint m_injectionPoint;
|
||||
private readonly Func<RendererRecordingContext, bool> m_recordAction;
|
||||
|
||||
public SceneInjectionPass(
|
||||
RenderPassEvent passEvent,
|
||||
SceneRenderInjectionPoint injectionPoint)
|
||||
Func<RendererRecordingContext, bool> recordAction)
|
||||
{
|
||||
renderPassEvent = passEvent;
|
||||
m_injectionPoint = injectionPoint;
|
||||
m_recordAction = recordAction;
|
||||
}
|
||||
|
||||
protected override bool RecordRenderGraph(
|
||||
ScriptableRenderContext context,
|
||||
RendererRecordingContext context,
|
||||
RenderingData renderingData)
|
||||
{
|
||||
return context != null &&
|
||||
renderingData != null &&
|
||||
renderingData.isMainSceneStage &&
|
||||
context.RecordSceneInjectionPoint(m_injectionPoint);
|
||||
m_recordAction != null &&
|
||||
m_recordAction(context);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class ScenePhasePass : ScriptableRenderPass
|
||||
{
|
||||
private readonly ScenePhase m_scenePhase;
|
||||
private readonly Func<RendererRecordingContext, bool> m_recordAction;
|
||||
private readonly Action m_onRecorded;
|
||||
|
||||
public ScenePhasePass(
|
||||
RenderPassEvent passEvent,
|
||||
ScenePhase scenePhase,
|
||||
Func<RendererRecordingContext, bool> recordAction,
|
||||
Action onRecorded = null)
|
||||
{
|
||||
renderPassEvent = passEvent;
|
||||
m_scenePhase = scenePhase;
|
||||
m_recordAction = recordAction;
|
||||
m_onRecorded = onRecorded;
|
||||
}
|
||||
|
||||
protected override bool RecordRenderGraph(
|
||||
ScriptableRenderContext context,
|
||||
RendererRecordingContext context,
|
||||
RenderingData renderingData)
|
||||
{
|
||||
bool recorded = context != null &&
|
||||
renderingData != null &&
|
||||
renderingData.isMainSceneStage &&
|
||||
context.RecordScenePhase(m_scenePhase);
|
||||
m_recordAction != null &&
|
||||
m_recordAction(context);
|
||||
if (recorded && m_onRecorded != null)
|
||||
{
|
||||
m_onRecorded();
|
||||
@@ -85,23 +90,24 @@ namespace Gameplay
|
||||
|
||||
internal sealed class FullscreenPass : ScriptableRenderPass
|
||||
{
|
||||
private readonly FullscreenPassDescriptor m_descriptor;
|
||||
private readonly Func<RendererRecordingContext, bool> m_recordAction;
|
||||
|
||||
public FullscreenPass(
|
||||
RenderPassEvent passEvent,
|
||||
FullscreenPassDescriptor descriptor)
|
||||
Func<RendererRecordingContext, bool> recordAction)
|
||||
{
|
||||
renderPassEvent = passEvent;
|
||||
m_descriptor = descriptor;
|
||||
m_recordAction = recordAction;
|
||||
}
|
||||
|
||||
protected override bool RecordRenderGraph(
|
||||
ScriptableRenderContext context,
|
||||
RendererRecordingContext context,
|
||||
RenderingData renderingData)
|
||||
{
|
||||
return context != null &&
|
||||
renderingData != null &&
|
||||
context.RecordFullscreenPass(m_descriptor);
|
||||
m_recordAction != null &&
|
||||
m_recordAction(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,40 +129,40 @@ namespace Gameplay
|
||||
m_beforeOpaquePass =
|
||||
new SceneInjectionPass(
|
||||
RenderPassEvent.BeforeRenderingOpaques,
|
||||
SceneRenderInjectionPoint.BeforeOpaque);
|
||||
context => context.RecordBeforeOpaqueInjection());
|
||||
m_opaquePass =
|
||||
new ScenePhasePass(
|
||||
RenderPassEvent.RenderOpaques,
|
||||
ScenePhase.Opaque,
|
||||
context => context.RecordOpaqueScenePhase(),
|
||||
onOpaqueRecorded);
|
||||
m_afterOpaquePass =
|
||||
new SceneInjectionPass(
|
||||
RenderPassEvent.AfterRenderingOpaques,
|
||||
SceneRenderInjectionPoint.AfterOpaque);
|
||||
context => context.RecordAfterOpaqueInjection());
|
||||
m_beforeSkyboxPass =
|
||||
new SceneInjectionPass(
|
||||
RenderPassEvent.BeforeRenderingSkybox,
|
||||
SceneRenderInjectionPoint.BeforeSkybox);
|
||||
context => context.RecordBeforeSkyboxInjection());
|
||||
m_skyboxPass =
|
||||
new ScenePhasePass(
|
||||
RenderPassEvent.RenderSkybox,
|
||||
ScenePhase.Skybox);
|
||||
context => context.RecordSkyboxScenePhase());
|
||||
m_afterSkyboxPass =
|
||||
new SceneInjectionPass(
|
||||
RenderPassEvent.AfterRenderingSkybox,
|
||||
SceneRenderInjectionPoint.AfterSkybox);
|
||||
context => context.RecordAfterSkyboxInjection());
|
||||
m_beforeTransparentPass =
|
||||
new SceneInjectionPass(
|
||||
RenderPassEvent.BeforeRenderingTransparents,
|
||||
SceneRenderInjectionPoint.BeforeTransparent);
|
||||
context => context.RecordBeforeTransparentInjection());
|
||||
m_transparentPass =
|
||||
new ScenePhasePass(
|
||||
RenderPassEvent.RenderTransparents,
|
||||
ScenePhase.Transparent);
|
||||
context => context.RecordTransparentScenePhase());
|
||||
m_afterTransparentPass =
|
||||
new SceneInjectionPass(
|
||||
RenderPassEvent.AfterRenderingTransparents,
|
||||
SceneRenderInjectionPoint.AfterTransparent);
|
||||
context => context.RecordAfterTransparentInjection());
|
||||
}
|
||||
|
||||
public override void AddRenderPasses(
|
||||
@@ -228,17 +234,23 @@ namespace Gameplay
|
||||
internal sealed class ProbePostProcessRenderer : ScriptableRenderer
|
||||
{
|
||||
public ProbePostProcessRenderer(
|
||||
FullscreenPassDescriptor firstPass,
|
||||
FullscreenPassDescriptor secondPass)
|
||||
Vector4 firstVectorPayload,
|
||||
Vector4 secondVectorPayload)
|
||||
{
|
||||
AddFeature(
|
||||
new FullscreenFeature(
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.BeforeRenderingPostProcessing,
|
||||
firstPass),
|
||||
context => context.RecordShaderVectorFullscreenPass(
|
||||
BuiltinShaderPaths.ColorScalePostProcess,
|
||||
firstVectorPayload,
|
||||
"ColorScale")),
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.AfterRenderingPostProcessing,
|
||||
secondPass)));
|
||||
context => context.RecordShaderVectorFullscreenPass(
|
||||
BuiltinShaderPaths.ColorScalePostProcess,
|
||||
secondVectorPayload,
|
||||
"ColorScale"))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +265,7 @@ namespace Gameplay
|
||||
new FullscreenFeature(
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.BeforeRenderingPostProcessing,
|
||||
FullscreenPassDescriptor.CreateColorScale(
|
||||
context => context.RecordColorScaleFullscreenPass(
|
||||
postProcessScale))));
|
||||
}
|
||||
}
|
||||
@@ -262,17 +274,16 @@ namespace Gameplay
|
||||
{
|
||||
public ProbePlannedFullscreenRenderer()
|
||||
{
|
||||
FullscreenPassDescriptor descriptor =
|
||||
FullscreenPassDescriptor.CreateColorScale(
|
||||
new Vector4(1.05f, 1.0f, 0.95f, 1.0f));
|
||||
AddFeature(
|
||||
new FullscreenFeature(
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.BeforeRenderingPostProcessing,
|
||||
descriptor),
|
||||
context => context.RecordColorScaleFullscreenPass(
|
||||
new Vector4(1.05f, 1.0f, 0.95f, 1.0f))),
|
||||
new FullscreenPass(
|
||||
RenderPassEvent.BeforeRenderingFinalOutput,
|
||||
descriptor)));
|
||||
context => context.RecordColorScaleFullscreenPass(
|
||||
new Vector4(1.05f, 1.0f, 0.95f, 1.0f)))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,7 +429,7 @@ namespace Gameplay
|
||||
}
|
||||
|
||||
protected override bool RecordRenderGraph(
|
||||
ScriptableRenderContext context,
|
||||
RendererRecordingContext context,
|
||||
RenderingData renderingData)
|
||||
{
|
||||
if (context == null ||
|
||||
@@ -649,7 +660,7 @@ namespace Gameplay
|
||||
}
|
||||
|
||||
protected override bool RecordRenderGraph(
|
||||
ScriptableRenderContext context,
|
||||
RendererRecordingContext context,
|
||||
RenderingData renderingData)
|
||||
{
|
||||
if (context == null ||
|
||||
@@ -867,7 +878,8 @@ namespace Gameplay
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ManagedRenderPipelineProbe : ScriptableRenderPipeline
|
||||
public sealed class ManagedRenderPipelineProbe
|
||||
: RendererBackedRenderPipeline
|
||||
{
|
||||
public static int SupportsStageCallCount;
|
||||
public static int RecordStageCallCount;
|
||||
@@ -892,24 +904,19 @@ namespace Gameplay
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ManagedPostProcessRenderPipelineProbe : ScriptableRenderPipeline
|
||||
public sealed class ManagedPostProcessRenderPipelineProbe
|
||||
: RendererBackedRenderPipeline
|
||||
{
|
||||
protected override ScriptableRenderer CreateRenderer()
|
||||
{
|
||||
return new ProbePostProcessRenderer(
|
||||
FullscreenPassDescriptor.CreateShaderVector(
|
||||
BuiltinShaderPaths.ColorScalePostProcess,
|
||||
new Vector4(1.10f, 0.95f, 0.90f, 1.0f),
|
||||
"ColorScale"),
|
||||
FullscreenPassDescriptor.CreateShaderVector(
|
||||
BuiltinShaderPaths.ColorScalePostProcess,
|
||||
new Vector4(0.95f, 1.05f, 1.10f, 1.0f),
|
||||
"ColorScale"));
|
||||
new Vector4(1.10f, 0.95f, 0.90f, 1.0f),
|
||||
new Vector4(0.95f, 1.05f, 1.10f, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ManagedForwardRenderPipelineProbe
|
||||
: ScriptableRenderPipeline
|
||||
: RendererBackedRenderPipeline
|
||||
{
|
||||
public static int SupportsMainSceneCallCount;
|
||||
public static int SupportsPostProcessCallCount;
|
||||
@@ -976,7 +983,7 @@ namespace Gameplay
|
||||
}
|
||||
|
||||
public sealed class ManagedPlannedFullscreenRenderPipelineProbe
|
||||
: ScriptableRenderPipeline
|
||||
: RendererBackedRenderPipeline
|
||||
{
|
||||
protected override ScriptableRenderer CreateRenderer()
|
||||
{
|
||||
@@ -985,7 +992,7 @@ namespace Gameplay
|
||||
}
|
||||
|
||||
public sealed class ManagedRenderContextCameraDataProbe
|
||||
: ScriptableRenderPipeline
|
||||
: RendererBackedRenderPipeline
|
||||
{
|
||||
protected override ScriptableRenderer CreateRenderer()
|
||||
{
|
||||
@@ -994,7 +1001,7 @@ namespace Gameplay
|
||||
}
|
||||
|
||||
public sealed class ManagedRenderContextStageColorDataProbe
|
||||
: ScriptableRenderPipeline
|
||||
: RendererBackedRenderPipeline
|
||||
{
|
||||
protected override ScriptableRenderer CreateRenderer()
|
||||
{
|
||||
@@ -1561,3 +1568,4 @@ namespace Gameplay
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user