Files
XCEngine/managed/XCEngine.ScriptCore/Rendering/Core/ScriptableRenderContext.cs

171 lines
4.7 KiB
C#
Raw Normal View History

using System;
using XCEngine;
namespace XCEngine.Rendering
{
public sealed class ScriptableRenderContext
{
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
}
private readonly ulong m_nativeHandle;
internal ScriptableRenderContext(ulong nativeHandle)
{
m_nativeHandle = nativeHandle;
}
public CameraFrameStage stage =>
(CameraFrameStage)InternalCalls.Rendering_ScriptableRenderContext_GetStage(
m_nativeHandle);
internal ulong nativeHandle =>
m_nativeHandle;
public bool RecordScene()
{
return InternalCalls
.Rendering_ScriptableRenderContext_RecordScene(
m_nativeHandle);
}
public bool RecordOpaqueScenePhase()
{
return RecordScenePhaseInternal(
RecordedScenePhase.Opaque);
}
public bool RecordSkyboxScenePhase()
{
return RecordScenePhaseInternal(
RecordedScenePhase.Skybox);
}
public bool RecordTransparentScenePhase()
{
return RecordScenePhaseInternal(
RecordedScenePhase.Transparent);
}
public bool RecordBeforeOpaqueInjection()
{
return RecordSceneInjectionPointInternal(
RecordedSceneInjectionPoint.BeforeOpaque);
}
public bool RecordAfterOpaqueInjection()
{
return RecordSceneInjectionPointInternal(
RecordedSceneInjectionPoint.AfterOpaque);
}
public bool RecordBeforeSkyboxInjection()
{
return RecordSceneInjectionPointInternal(
RecordedSceneInjectionPoint.BeforeSkybox);
}
public bool RecordAfterSkyboxInjection()
{
return RecordSceneInjectionPointInternal(
RecordedSceneInjectionPoint.AfterSkybox);
}
public bool RecordBeforeTransparentInjection()
{
return RecordSceneInjectionPointInternal(
RecordedSceneInjectionPoint.BeforeTransparent);
}
public bool RecordAfterTransparentInjection()
{
return RecordSceneInjectionPointInternal(
RecordedSceneInjectionPoint.AfterTransparent);
}
public bool RecordColorScaleFullscreenPass(
Vector4 colorScale)
{
return RecordFullscreenPassInternal(
RecordedFullscreenPassType.ColorScale,
string.Empty,
string.Empty,
colorScale);
}
public bool RecordShaderVectorFullscreenPass(
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(
RecordedFullscreenPassType.ShaderVector,
shaderPath,
passName ?? string.Empty,
vectorPayload);
}
private bool RecordScenePhaseInternal(
RecordedScenePhase scenePhase)
{
return InternalCalls
.Rendering_ScriptableRenderContext_RecordScenePhase(
m_nativeHandle,
(int)scenePhase);
}
private bool RecordSceneInjectionPointInternal(
RecordedSceneInjectionPoint injectionPoint)
{
return InternalCalls
.Rendering_ScriptableRenderContext_RecordSceneInjectionPoint(
m_nativeHandle,
(int)injectionPoint);
}
private bool RecordFullscreenPassInternal(
RecordedFullscreenPassType passType,
string shaderPath,
string passName,
Vector4 vectorPayload)
{
return InternalCalls
.Rendering_ScriptableRenderContext_RecordFullscreenPass(
m_nativeHandle,
(int)passType,
shaderPath,
passName,
ref vectorPayload);
}
}
}