157 lines
3.6 KiB
C#
157 lines
3.6 KiB
C#
using XCEngine;
|
|
using XCEngine.Rendering;
|
|
|
|
namespace XCEngine.Rendering.Universal
|
|
{
|
|
public abstract class ScriptableRendererFeature
|
|
{
|
|
private bool m_disposed;
|
|
private bool m_runtimeCreated;
|
|
private bool m_isActive = true;
|
|
private int m_runtimeStateVersion = 1;
|
|
private ScriptableRendererData m_owner;
|
|
|
|
protected ScriptableRendererFeature()
|
|
{
|
|
}
|
|
|
|
public bool isActive
|
|
{
|
|
get
|
|
{
|
|
return m_isActive;
|
|
}
|
|
set
|
|
{
|
|
if (m_isActive == value)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_isActive = value;
|
|
SetDirty();
|
|
}
|
|
}
|
|
|
|
internal void BindOwnerInstance(
|
|
ScriptableRendererData owner)
|
|
{
|
|
m_owner = owner;
|
|
}
|
|
|
|
internal int GetRuntimeStateVersionInstance()
|
|
{
|
|
return m_runtimeStateVersion;
|
|
}
|
|
|
|
internal void CreateInstance()
|
|
{
|
|
if (m_runtimeCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_disposed = false;
|
|
Create();
|
|
m_runtimeCreated = true;
|
|
}
|
|
|
|
internal void ReleaseRuntimeResourcesInstance()
|
|
{
|
|
if (m_disposed ||
|
|
!m_runtimeCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ReleaseRuntimeResources();
|
|
m_disposed = true;
|
|
m_runtimeCreated = false;
|
|
}
|
|
|
|
public virtual void Create()
|
|
{
|
|
}
|
|
|
|
public virtual void ConfigureCameraRenderRequest(
|
|
CameraRenderRequestContext context)
|
|
{
|
|
}
|
|
|
|
public virtual void ConfigureCameraFramePlan(
|
|
ScriptableRenderPipelinePlanningContext context)
|
|
{
|
|
}
|
|
|
|
public virtual void ConfigureRenderSceneSetup(
|
|
RenderSceneSetupContext context)
|
|
{
|
|
}
|
|
|
|
public virtual void ConfigureDirectionalShadowExecutionState(
|
|
DirectionalShadowExecutionContext context)
|
|
{
|
|
}
|
|
|
|
public virtual void AddRenderPasses(
|
|
ScriptableRenderer renderer,
|
|
RenderingData renderingData)
|
|
{
|
|
}
|
|
|
|
protected bool HasDirectionalShadow(
|
|
CameraRenderRequestContext context)
|
|
{
|
|
return context != null &&
|
|
InternalCalls
|
|
.Rendering_CameraRenderRequestContext_GetHasDirectionalShadow(
|
|
context.nativeHandle);
|
|
}
|
|
|
|
protected void ClearDirectionalShadow(
|
|
CameraRenderRequestContext context)
|
|
{
|
|
if (context == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
InternalCalls
|
|
.Rendering_CameraRenderRequestContext_ClearDirectionalShadow(
|
|
context.nativeHandle);
|
|
}
|
|
|
|
protected virtual void ReleaseRuntimeResources()
|
|
{
|
|
}
|
|
|
|
protected void SetDirty()
|
|
{
|
|
if (m_runtimeCreated &&
|
|
!m_disposed)
|
|
{
|
|
ReleaseRuntimeResources();
|
|
}
|
|
|
|
m_disposed = false;
|
|
m_runtimeCreated = false;
|
|
|
|
unchecked
|
|
{
|
|
++m_runtimeStateVersion;
|
|
}
|
|
|
|
if (m_runtimeStateVersion <= 0)
|
|
{
|
|
m_runtimeStateVersion = 1;
|
|
}
|
|
|
|
if (m_owner != null)
|
|
{
|
|
m_owner.InvalidateRendererFeaturesInstance();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|