Minor GC because of closure in ShapesRenderPass using Render Graph API
There is a 128 Byte memory allocation each frame in the ShapesRenderPass when running Unity 6 with Render Graph API. The reason for this is the reference to the drawCommand field. This can be fixed by adding drawCommand as a field to the PassData and access that in the RenderFunc instead:
private class PassData { public DrawCommand drawCommand; } public override void RecordRenderGraph( RenderGraph renderGraph, ContextContainer frameData ) { using IRasterRenderGraphBuilder builder = renderGraph.AddRasterRenderPass( "Render Shapes", out var data ); builder.AllowPassCulling( false ); UniversalResourceData resourceData = frameData.Get(); builder.SetRenderAttachment( resourceData.cameraColor, 0, AccessFlags.Write ); data.drawCommand = drawCommand; builder.SetRenderFunc( ( PassData data, RasterGraphContext context ) => { data.drawCommand.AppendToBuffer( context.cmd ); } ); }
Reporting a bug? please specify Unity version:
Unity 6000.0.33f1
Reporting a bug? please specify Shapes version:
Shapes 4.5.0
Reporting a bug? please specify Render Pipeline:
URP