318 lines
11 KiB
C#
318 lines
11 KiB
C#
using XCEngine;
|
|
|
|
namespace Gameplay
|
|
{
|
|
public sealed class LegacyRenderPipelineApiProbeAsset : RenderPipelineAsset
|
|
{
|
|
}
|
|
|
|
public sealed class RenderPipelineApiProbeAsset : ScriptableRenderPipelineAsset
|
|
{
|
|
}
|
|
|
|
public sealed class ManagedRenderPipelineProbeAsset : ScriptableRenderPipelineAsset
|
|
{
|
|
public static int CreatePipelineCallCount;
|
|
|
|
protected override ScriptableRenderPipeline CreatePipeline()
|
|
{
|
|
CreatePipelineCallCount++;
|
|
return new ManagedRenderPipelineProbe();
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedPostProcessRenderPipelineProbeAsset : ScriptableRenderPipelineAsset
|
|
{
|
|
protected override ScriptableRenderPipeline CreatePipeline()
|
|
{
|
|
return new ManagedPostProcessRenderPipelineProbe();
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedForwardRenderPipelineProbeAsset
|
|
: ScriptableRenderPipelineAsset
|
|
{
|
|
public static int CreatePipelineCallCount;
|
|
|
|
protected override ScriptableRenderPipeline CreatePipeline()
|
|
{
|
|
CreatePipelineCallCount++;
|
|
return new ManagedForwardRenderPipelineProbe();
|
|
}
|
|
|
|
protected override void ConfigureCameraFramePlan(
|
|
ScriptableRenderPipelinePlanningContext context)
|
|
{
|
|
context.ClearPostProcessStage();
|
|
context.RequestPostProcessStage(
|
|
CameraFrameColorSource.MainSceneColor,
|
|
false);
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedPlannedFullscreenRenderPipelineProbeAsset
|
|
: ScriptableRenderPipelineAsset
|
|
{
|
|
protected override ScriptableRenderPipeline CreatePipeline()
|
|
{
|
|
return new ManagedPlannedFullscreenRenderPipelineProbe();
|
|
}
|
|
|
|
protected override void ConfigureCameraFramePlan(
|
|
ScriptableRenderPipelinePlanningContext context)
|
|
{
|
|
context.ClearPostProcessStage();
|
|
context.ClearFinalOutputStage();
|
|
context.RequestPostProcessStage(
|
|
CameraFrameColorSource.MainSceneColor,
|
|
true);
|
|
context.RequestFinalOutputStage(
|
|
CameraFrameColorSource.PostProcessColor);
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedCameraRequestConfiguredRenderPipelineProbeAsset
|
|
: ScriptableRenderPipelineAsset
|
|
{
|
|
protected override ScriptableRenderPipeline CreatePipeline()
|
|
{
|
|
return new ManagedRenderPipelineProbe();
|
|
}
|
|
|
|
protected override void ConfigureCameraRenderRequest(
|
|
ScriptableRenderPipelineCameraRequestContext context)
|
|
{
|
|
if (context != null && context.hasDirectionalShadow)
|
|
{
|
|
context.ClearDirectionalShadow();
|
|
}
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedRenderPipelineProbe : ScriptableRenderPipeline
|
|
{
|
|
public static int SupportsStageCallCount;
|
|
public static int RecordStageCallCount;
|
|
|
|
protected override bool SupportsStageRenderGraph(
|
|
CameraFrameStage stage)
|
|
{
|
|
SupportsStageCallCount++;
|
|
return stage == CameraFrameStage.MainScene;
|
|
}
|
|
|
|
protected override bool RecordStageRenderGraph(
|
|
ScriptableRenderContext context)
|
|
{
|
|
RecordStageCallCount++;
|
|
return context != null &&
|
|
context.stage == CameraFrameStage.MainScene &&
|
|
context.RecordSceneInjectionPoint(
|
|
SceneRenderInjectionPoint.BeforeOpaque) &&
|
|
context.RecordScenePhase(ScenePhase.Opaque) &&
|
|
context.RecordSceneInjectionPoint(
|
|
SceneRenderInjectionPoint.AfterOpaque) &&
|
|
context.RecordSceneInjectionPoint(
|
|
SceneRenderInjectionPoint.BeforeSkybox) &&
|
|
context.RecordScenePhase(ScenePhase.Skybox) &&
|
|
context.RecordSceneInjectionPoint(
|
|
SceneRenderInjectionPoint.AfterSkybox) &&
|
|
context.RecordSceneInjectionPoint(
|
|
SceneRenderInjectionPoint.BeforeTransparent) &&
|
|
context.RecordScenePhase(ScenePhase.Transparent) &&
|
|
context.RecordSceneInjectionPoint(
|
|
SceneRenderInjectionPoint.AfterTransparent);
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedPostProcessRenderPipelineProbe : ScriptableRenderPipeline
|
|
{
|
|
protected override bool SupportsStageRenderGraph(
|
|
CameraFrameStage stage)
|
|
{
|
|
return stage == CameraFrameStage.PostProcess;
|
|
}
|
|
|
|
protected override bool RecordStageRenderGraph(
|
|
ScriptableRenderContext context)
|
|
{
|
|
return context != null &&
|
|
context.stage == CameraFrameStage.PostProcess &&
|
|
context.RecordFullscreenPass(
|
|
FullscreenPassDescriptor.CreateColorScale(
|
|
new Vector4(1.10f, 0.95f, 0.90f, 1.0f))) &&
|
|
context.RecordFullscreenPass(
|
|
FullscreenPassDescriptor.CreateColorScale(
|
|
new Vector4(0.95f, 1.05f, 1.10f, 1.0f)));
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedForwardRenderPipelineProbe
|
|
: ScriptableRenderPipeline
|
|
{
|
|
public static int SupportsMainSceneCallCount;
|
|
public static int SupportsPostProcessCallCount;
|
|
public static int RecordMainSceneCallCount;
|
|
public static int RecordSceneCallCount;
|
|
public static int RecordPostProcessCallCount;
|
|
|
|
protected override bool SupportsStageRenderGraph(
|
|
CameraFrameStage stage)
|
|
{
|
|
if (stage == CameraFrameStage.MainScene)
|
|
{
|
|
SupportsMainSceneCallCount++;
|
|
return true;
|
|
}
|
|
|
|
if (stage == CameraFrameStage.PostProcess)
|
|
{
|
|
SupportsPostProcessCallCount++;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
protected override bool RecordStageRenderGraph(
|
|
ScriptableRenderContext context)
|
|
{
|
|
if (context == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (context.stage == CameraFrameStage.MainScene)
|
|
{
|
|
RecordMainSceneCallCount++;
|
|
bool recorded = context.RecordScene();
|
|
if (recorded)
|
|
{
|
|
RecordSceneCallCount++;
|
|
}
|
|
|
|
return recorded;
|
|
}
|
|
|
|
if (context.stage == CameraFrameStage.PostProcess)
|
|
{
|
|
RecordPostProcessCallCount++;
|
|
return context.RecordFullscreenPass(
|
|
FullscreenPassDescriptor.CreateColorScale(
|
|
new Vector4(1.03f, 0.98f, 0.94f, 1.0f)));
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedPlannedFullscreenRenderPipelineProbe
|
|
: ScriptableRenderPipeline
|
|
{
|
|
protected override bool SupportsStageRenderGraph(
|
|
CameraFrameStage stage)
|
|
{
|
|
return stage == CameraFrameStage.PostProcess ||
|
|
stage == CameraFrameStage.FinalOutput;
|
|
}
|
|
|
|
protected override bool RecordStageRenderGraph(
|
|
ScriptableRenderContext context)
|
|
{
|
|
return context != null &&
|
|
(context.stage == CameraFrameStage.PostProcess ||
|
|
context.stage == CameraFrameStage.FinalOutput) &&
|
|
context.RecordFullscreenPass(
|
|
FullscreenPassDescriptor.CreateColorScale(
|
|
new Vector4(1.05f, 1.0f, 0.95f, 1.0f)));
|
|
}
|
|
}
|
|
|
|
public sealed class RenderPipelineApiProbe : MonoBehaviour
|
|
{
|
|
public bool InitialTypeWasNull;
|
|
public bool InvalidSelectionRejected;
|
|
public bool InvalidSelectionMentionsScriptableBase;
|
|
public bool SelectionRoundTripSucceeded;
|
|
public string SelectedPipelineTypeName = string.Empty;
|
|
|
|
public void Start()
|
|
{
|
|
InitialTypeWasNull = GraphicsSettings.renderPipelineAssetType == null;
|
|
|
|
try
|
|
{
|
|
GraphicsSettings.renderPipelineAssetType =
|
|
typeof(LegacyRenderPipelineApiProbeAsset);
|
|
InvalidSelectionRejected = false;
|
|
}
|
|
catch (System.ArgumentException ex)
|
|
{
|
|
InvalidSelectionRejected = true;
|
|
InvalidSelectionMentionsScriptableBase =
|
|
ex.Message.Contains("ScriptableRenderPipelineAsset");
|
|
}
|
|
|
|
GraphicsSettings.renderPipelineAssetType =
|
|
typeof(RenderPipelineApiProbeAsset);
|
|
System.Type selectedType = GraphicsSettings.renderPipelineAssetType;
|
|
SelectionRoundTripSucceeded =
|
|
selectedType == typeof(RenderPipelineApiProbeAsset);
|
|
SelectedPipelineTypeName = selectedType != null
|
|
? selectedType.FullName ?? string.Empty
|
|
: string.Empty;
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedRenderPipelineRuntimeSelectionProbe : MonoBehaviour
|
|
{
|
|
public void Start()
|
|
{
|
|
ManagedRenderPipelineProbeAsset.CreatePipelineCallCount = 0;
|
|
ManagedRenderPipelineProbe.SupportsStageCallCount = 0;
|
|
ManagedRenderPipelineProbe.RecordStageCallCount = 0;
|
|
GraphicsSettings.renderPipelineAssetType =
|
|
typeof(ManagedRenderPipelineProbeAsset);
|
|
}
|
|
}
|
|
|
|
public sealed class ManagedForwardRenderPipelineRuntimeSelectionProbe
|
|
: MonoBehaviour
|
|
{
|
|
public int ObservedCreatePipelineCallCount;
|
|
public int ObservedSupportsMainSceneCallCount;
|
|
public int ObservedSupportsPostProcessCallCount;
|
|
public int ObservedRecordMainSceneCallCount;
|
|
public int ObservedRecordSceneCallCount;
|
|
public int ObservedRecordPostProcessCallCount;
|
|
|
|
public void Start()
|
|
{
|
|
ManagedForwardRenderPipelineProbeAsset.CreatePipelineCallCount = 0;
|
|
ManagedForwardRenderPipelineProbe.SupportsMainSceneCallCount = 0;
|
|
ManagedForwardRenderPipelineProbe.SupportsPostProcessCallCount = 0;
|
|
ManagedForwardRenderPipelineProbe.RecordMainSceneCallCount = 0;
|
|
ManagedForwardRenderPipelineProbe.RecordSceneCallCount = 0;
|
|
ManagedForwardRenderPipelineProbe.RecordPostProcessCallCount = 0;
|
|
GraphicsSettings.renderPipelineAssetType =
|
|
typeof(ManagedForwardRenderPipelineProbeAsset);
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
ObservedCreatePipelineCallCount =
|
|
ManagedForwardRenderPipelineProbeAsset.CreatePipelineCallCount;
|
|
ObservedSupportsMainSceneCallCount =
|
|
ManagedForwardRenderPipelineProbe.SupportsMainSceneCallCount;
|
|
ObservedSupportsPostProcessCallCount =
|
|
ManagedForwardRenderPipelineProbe.SupportsPostProcessCallCount;
|
|
ObservedRecordMainSceneCallCount =
|
|
ManagedForwardRenderPipelineProbe.RecordMainSceneCallCount;
|
|
ObservedRecordSceneCallCount =
|
|
ManagedForwardRenderPipelineProbe.RecordSceneCallCount;
|
|
ObservedRecordPostProcessCallCount =
|
|
ManagedForwardRenderPipelineProbe.RecordPostProcessCallCount;
|
|
}
|
|
}
|
|
}
|