Bridge managed render funcs to command buffers

This commit is contained in:
2026-04-27 16:11:54 +08:00
parent 2e6643b4d1
commit 048ca7b362
10 changed files with 697 additions and 27 deletions

View File

@@ -2607,6 +2607,83 @@ namespace Gameplay
}
}
internal static class ManagedCommandBufferRenderFuncProbeState
{
public static int RenderFuncCallCount;
public static int ClearSucceededCount;
public static Vector4 LastClearColor;
public static void Reset()
{
RenderFuncCallCount = 0;
ClearSucceededCount = 0;
LastClearColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
}
}
internal sealed class ManagedCommandBufferRenderFuncProbePipeline
: ScriptableRenderPipeline
{
protected override bool SupportsStageRenderGraph(
CameraFrameStage stage)
{
return stage == CameraFrameStage.MainScene;
}
protected override bool RecordStageRenderGraph(
ScriptableRenderContext context)
{
if (context == null ||
!context.primaryColorTarget.isValid)
{
return false;
}
return context
.AddRasterPass(
"Managed.CommandBufferRenderFunc")
.SetColorAttachment(
context.primaryColorTarget)
.SetRenderFunc(
rasterContext =>
{
Color clearColor =
new Color(
0.20f,
0.40f,
0.60f,
1.0f);
ManagedCommandBufferRenderFuncProbeState
.RenderFuncCallCount++;
ManagedCommandBufferRenderFuncProbeState
.LastClearColor =
new Vector4(
clearColor.r,
clearColor.g,
clearColor.b,
clearColor.a);
if (rasterContext != null &&
rasterContext.cmd != null &&
rasterContext.cmd.ClearRenderTarget(
clearColor))
{
ManagedCommandBufferRenderFuncProbeState
.ClearSucceededCount++;
}
})
.Commit();
}
}
public sealed class ManagedCommandBufferRenderFuncProbeAsset
: ScriptableRenderPipelineAsset
{
protected override ScriptableRenderPipeline CreatePipeline()
{
return new ManagedCommandBufferRenderFuncProbePipeline();
}
}
internal sealed class ManagedRenderPipelineProbe
: ProbeSceneRenderer
{
@@ -3338,6 +3415,32 @@ namespace Gameplay
}
}
public sealed class ManagedCommandBufferRenderFuncRuntimeSelectionProbe
: MonoBehaviour
{
public int ObservedRenderFuncCallCount;
public int ObservedClearSucceededCount;
public Vector4 ObservedLastClearColor;
public void Start()
{
ManagedCommandBufferRenderFuncProbeState.Reset();
}
public void Update()
{
ObservedRenderFuncCallCount =
ManagedCommandBufferRenderFuncProbeState
.RenderFuncCallCount;
ObservedClearSucceededCount =
ManagedCommandBufferRenderFuncProbeState
.ClearSucceededCount;
ObservedLastClearColor =
ManagedCommandBufferRenderFuncProbeState
.LastClearColor;
}
}
public sealed class ManagedRenderContextCameraDataRuntimeSelectionProbe
: MonoBehaviour
{