Expose native camera frame planning controls to managed pipeline assets and renderer features. Allow managed planning to override fullscreen stage heuristics while keeping CameraFramePlan as the native execution contract. Add scripting coverage, probe assets, and archive the phase plan after build, test, and editor smoke validation.
179 lines
5.0 KiB
C#
179 lines
5.0 KiB
C#
using System;
|
|
using XCEngine;
|
|
using XCEngine.Rendering;
|
|
|
|
namespace XCEngine.Rendering.Universal
|
|
{
|
|
public abstract class ScriptableRendererData : Object
|
|
{
|
|
private ScriptableRendererFeature[] m_rendererFeatures;
|
|
private ScriptableRenderer m_rendererInstance;
|
|
|
|
protected ScriptableRendererData()
|
|
{
|
|
}
|
|
|
|
internal ScriptableRenderer CreateRendererInstance()
|
|
{
|
|
return GetRendererInstance();
|
|
}
|
|
|
|
internal ScriptableRenderer GetRendererInstance()
|
|
{
|
|
if (m_rendererInstance == null)
|
|
{
|
|
m_rendererInstance = CreateRenderer();
|
|
}
|
|
|
|
return m_rendererInstance;
|
|
}
|
|
|
|
internal ScriptableRendererFeature[] CreateRendererFeaturesInstance()
|
|
{
|
|
return GetRendererFeatures();
|
|
}
|
|
|
|
internal string GetPipelineRendererAssetKeyInstance()
|
|
{
|
|
return GetPipelineRendererAssetKey();
|
|
}
|
|
|
|
internal void ReleaseRuntimeResourcesInstance()
|
|
{
|
|
if (m_rendererInstance != null)
|
|
{
|
|
m_rendererInstance.ReleaseRuntimeResourcesInstance();
|
|
m_rendererInstance = null;
|
|
m_rendererFeatures = null;
|
|
ReleaseRuntimeResources();
|
|
return;
|
|
}
|
|
|
|
if (m_rendererFeatures != null)
|
|
{
|
|
for (int i = 0; i < m_rendererFeatures.Length; ++i)
|
|
{
|
|
ScriptableRendererFeature rendererFeature =
|
|
m_rendererFeatures[i];
|
|
if (rendererFeature != null)
|
|
{
|
|
rendererFeature.ReleaseRuntimeResourcesInstance();
|
|
}
|
|
}
|
|
|
|
m_rendererFeatures = null;
|
|
}
|
|
|
|
ReleaseRuntimeResources();
|
|
}
|
|
|
|
internal void ConfigureCameraRenderRequestInstance(
|
|
CameraRenderRequestContext context)
|
|
{
|
|
ConfigureCameraRenderRequest(context);
|
|
|
|
ScriptableRendererFeature[] rendererFeatures =
|
|
GetRendererFeatures();
|
|
for (int i = 0; i < rendererFeatures.Length; ++i)
|
|
{
|
|
ScriptableRendererFeature rendererFeature =
|
|
rendererFeatures[i];
|
|
if (rendererFeature == null ||
|
|
!rendererFeature.isActive)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
rendererFeature.ConfigureCameraRenderRequest(
|
|
context);
|
|
}
|
|
}
|
|
|
|
internal void ConfigureCameraFramePlanInstance(
|
|
ScriptableRenderPipelinePlanningContext context)
|
|
{
|
|
ConfigureCameraFramePlan(context);
|
|
|
|
ScriptableRendererFeature[] rendererFeatures =
|
|
GetRendererFeatures();
|
|
for (int i = 0; i < rendererFeatures.Length; ++i)
|
|
{
|
|
ScriptableRendererFeature rendererFeature =
|
|
rendererFeatures[i];
|
|
if (rendererFeature == null ||
|
|
!rendererFeature.isActive)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
rendererFeature.ConfigureCameraFramePlan(
|
|
context);
|
|
}
|
|
}
|
|
|
|
protected virtual ScriptableRenderer CreateRenderer()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected virtual void ConfigureCameraRenderRequest(
|
|
CameraRenderRequestContext context)
|
|
{
|
|
}
|
|
|
|
protected virtual void ConfigureCameraFramePlan(
|
|
ScriptableRenderPipelinePlanningContext context)
|
|
{
|
|
}
|
|
|
|
protected virtual string GetPipelineRendererAssetKey()
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
protected virtual ScriptableRendererFeature[] CreateRendererFeatures()
|
|
{
|
|
return Array.Empty<ScriptableRendererFeature>();
|
|
}
|
|
|
|
protected virtual void ReleaseRuntimeResources()
|
|
{
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
private ScriptableRendererFeature[] GetRendererFeatures()
|
|
{
|
|
if (m_rendererFeatures == null)
|
|
{
|
|
m_rendererFeatures =
|
|
CreateRendererFeatures() ??
|
|
Array.Empty<ScriptableRendererFeature>();
|
|
}
|
|
|
|
return m_rendererFeatures;
|
|
}
|
|
}
|
|
}
|
|
|