refactor(srp): hide universal recording helpers behind base apis
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using XCEngine;
|
||||
using XCEngine.Rendering;
|
||||
|
||||
@@ -5,6 +6,29 @@ namespace XCEngine.Rendering.Universal
|
||||
{
|
||||
public abstract class ScriptableRenderPass
|
||||
{
|
||||
private enum RecordedScenePhase
|
||||
{
|
||||
Opaque = 0,
|
||||
Skybox = 1,
|
||||
Transparent = 3
|
||||
}
|
||||
|
||||
private enum RecordedSceneInjectionPoint
|
||||
{
|
||||
BeforeOpaque = 0,
|
||||
AfterOpaque = 1,
|
||||
BeforeSkybox = 2,
|
||||
AfterSkybox = 3,
|
||||
BeforeTransparent = 4,
|
||||
AfterTransparent = 5
|
||||
}
|
||||
|
||||
private enum RecordedFullscreenPassType
|
||||
{
|
||||
ColorScale = 0,
|
||||
ShaderVector = 1
|
||||
}
|
||||
|
||||
protected ScriptableRenderPass()
|
||||
{
|
||||
}
|
||||
@@ -35,6 +59,120 @@ namespace XCEngine.Rendering.Universal
|
||||
ScriptableRenderContext context,
|
||||
RenderingData renderingData);
|
||||
|
||||
protected bool RecordScene(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return context != null &&
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_RecordScene(
|
||||
context.nativeHandle);
|
||||
}
|
||||
|
||||
protected bool RecordOpaqueScenePhase(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordScenePhaseInternal(
|
||||
context,
|
||||
RecordedScenePhase.Opaque);
|
||||
}
|
||||
|
||||
protected bool RecordSkyboxScenePhase(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordScenePhaseInternal(
|
||||
context,
|
||||
RecordedScenePhase.Skybox);
|
||||
}
|
||||
|
||||
protected bool RecordTransparentScenePhase(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordScenePhaseInternal(
|
||||
context,
|
||||
RecordedScenePhase.Transparent);
|
||||
}
|
||||
|
||||
protected bool RecordBeforeOpaqueInjection(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordSceneInjectionPointInternal(
|
||||
context,
|
||||
RecordedSceneInjectionPoint.BeforeOpaque);
|
||||
}
|
||||
|
||||
protected bool RecordAfterOpaqueInjection(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordSceneInjectionPointInternal(
|
||||
context,
|
||||
RecordedSceneInjectionPoint.AfterOpaque);
|
||||
}
|
||||
|
||||
protected bool RecordBeforeSkyboxInjection(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordSceneInjectionPointInternal(
|
||||
context,
|
||||
RecordedSceneInjectionPoint.BeforeSkybox);
|
||||
}
|
||||
|
||||
protected bool RecordAfterSkyboxInjection(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordSceneInjectionPointInternal(
|
||||
context,
|
||||
RecordedSceneInjectionPoint.AfterSkybox);
|
||||
}
|
||||
|
||||
protected bool RecordBeforeTransparentInjection(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordSceneInjectionPointInternal(
|
||||
context,
|
||||
RecordedSceneInjectionPoint.BeforeTransparent);
|
||||
}
|
||||
|
||||
protected bool RecordAfterTransparentInjection(
|
||||
ScriptableRenderContext context)
|
||||
{
|
||||
return RecordSceneInjectionPointInternal(
|
||||
context,
|
||||
RecordedSceneInjectionPoint.AfterTransparent);
|
||||
}
|
||||
|
||||
protected bool RecordColorScaleFullscreenPass(
|
||||
ScriptableRenderContext context,
|
||||
Vector4 colorScale)
|
||||
{
|
||||
return RecordFullscreenPassInternal(
|
||||
context,
|
||||
RecordedFullscreenPassType.ColorScale,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
colorScale);
|
||||
}
|
||||
|
||||
protected bool RecordShaderVectorFullscreenPass(
|
||||
ScriptableRenderContext context,
|
||||
string shaderPath,
|
||||
Vector4 vectorPayload,
|
||||
string passName = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(shaderPath))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"Fullscreen shader path cannot be null or empty.",
|
||||
nameof(shaderPath));
|
||||
}
|
||||
|
||||
return RecordFullscreenPassInternal(
|
||||
context,
|
||||
RecordedFullscreenPassType.ShaderVector,
|
||||
shaderPath,
|
||||
passName ?? string.Empty,
|
||||
vectorPayload);
|
||||
}
|
||||
|
||||
internal static bool TryResolveStage(
|
||||
RenderPassEvent passEvent,
|
||||
out CameraFrameStage stage)
|
||||
@@ -65,6 +203,45 @@ namespace XCEngine.Rendering.Universal
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool RecordScenePhaseInternal(
|
||||
ScriptableRenderContext context,
|
||||
RecordedScenePhase scenePhase)
|
||||
{
|
||||
return context != null &&
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_RecordScenePhase(
|
||||
context.nativeHandle,
|
||||
(int)scenePhase);
|
||||
}
|
||||
|
||||
private bool RecordSceneInjectionPointInternal(
|
||||
ScriptableRenderContext context,
|
||||
RecordedSceneInjectionPoint injectionPoint)
|
||||
{
|
||||
return context != null &&
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_RecordSceneInjectionPoint(
|
||||
context.nativeHandle,
|
||||
(int)injectionPoint);
|
||||
}
|
||||
|
||||
private bool RecordFullscreenPassInternal(
|
||||
ScriptableRenderContext context,
|
||||
RecordedFullscreenPassType passType,
|
||||
string shaderPath,
|
||||
string passName,
|
||||
Vector4 vectorPayload)
|
||||
{
|
||||
return context != null &&
|
||||
InternalCalls
|
||||
.Rendering_ScriptableRenderContext_RecordFullscreenPass(
|
||||
context.nativeHandle,
|
||||
(int)passType,
|
||||
shaderPath,
|
||||
passName,
|
||||
ref vectorPayload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user