Intermittent render failure with URP's Render Graph

Avatar
  • updated

Having an interesting issue in 6000, where my ImmediateModeShapeDrawers produce an error with rendering in Edit Mode after several have been added to the scene (everything is fine in Play Mode!).

Some background

My setup includes several independent instances of ImmediateModeShapeDrawers set to "[ExecuteAlways]", but with the following general pattern:

Image 877

The objects get rendered by a singleton instance of ImmediateModeShapeDrawer which stores a reference to all individual instances on those scripts' OnEnable():

Image 878

I've tested in a fresh scene, and I am able to add up to 16 individual drawers:

Image 879

After adding just 1 more, rendering fails with the following errors:

1)

Render Graph Execution error
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

2)

Exception: Invalid version: 20
UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler.ResourcesData.get_Item (UnityEngine.Rendering.RenderGraphModule.ResourceHandle h) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/ResourcesData.cs:325)
UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.BuildGraph () (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs:261)
UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.Compile (UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry resources) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs:84)
UnityEngine.Rendering.RenderGraphModule.RenderGraph.CompileNativeRenderGraph (System.Int32 graphHash) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.Compiler.cs:20)
UnityEngine.Rendering.RenderGraphModule.RenderGraph.Execute () (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs:1221)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

3)

InvalidOperationException: Trying to use a texture (_InternalGradingLut) that was already released or not yet created. Make sure you declare it for reading in your pass or you don't read it before it's been written to at least once.
UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry.CheckTextureResource (UnityEngine.Rendering.RenderGraphModule.TextureResource texResource) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs:177)
UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry.GetTexture (UnityEngine.Rendering.RenderGraphModule.TextureHandle& handle) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs:185)
UnityEngine.Rendering.RenderGraphModule.TextureHandle.op_Implicit (UnityEngine.Rendering.RenderGraphModule.TextureHandle texture) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceTexture.cs:102)
UnityEngine.Rendering.Universal.Internal.ColorGradingLutPass+<>c.b__14_0 (UnityEngine.Rendering.Universal.Internal.ColorGradingLutPass+PassData data, UnityEngine.Rendering.RenderGraphModule.RasterGraphContext context) (at ./Library/PackageCache/com.unity.render-pipelines.universal/Runtime/Passes/ColorGradingLutPass.cs:302)
UnityEngine.Rendering.RenderGraphModule.RasterRenderGraphPass`1[PassData].Execute (UnityEngine.Rendering.RenderGraphModule.InternalRenderGraphContext renderGraphContext) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs:599)
UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.ExecuteGraphNode (UnityEngine.Rendering.RenderGraphModule.InternalRenderGraphContext& rgContext, UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry resources, UnityEngine.Rendering.RenderGraphModule.RenderGraphPass pass) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs:1326)
UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.ExecuteGraph (UnityEngine.Rendering.RenderGraphModule.InternalRenderGraphContext rgContext, UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry resources, System.Collections.Generic.List`1[UnityEngine.Rendering.RenderGraphModule.RenderGraphPass]& passes) (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs:1428)
UnityEngine.Rendering.RenderGraphModule.RenderGraph.ExecuteNativeRenderGraph () (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.Compiler.cs:42)
UnityEngine.Rendering.RenderGraphModule.RenderGraph.Execute () (at ./Library/PackageCache/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs:1233)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Workaround

I am able to completely bypass the issue by simply enabling compatibility mode with Render Graph, and this is entirely sufficient for me right now - but wondering if something's amiss with my potentially wonky setup or there's a sneaky bug.

Image 880

Thank you for this amazing tool and for any time spent investigating! 

Reporting a bug? please specify Unity version:
6000.0.30f1
Reporting a bug? please specify Shapes version:
4.5.0
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Justin Wasilenko

Just wanted to chime in here that I am experiencing a similar issue. I only use Shapes with Immediate-Mode Drawing. However if Compatibility Mode is disabled Shapes causes a whole bunch of errors and will then crash Unity after play mode is stopped.

In order to cause this problem all you need is a simple script to call ImmediateModelike this and the errors will appear.

public class ShapesRenderer : ImmediateModeShapeDrawer
{
public override void DrawShapes(Camera cam)
{
using (Draw.Command(cam))
{} } }

Unity version: 6000.0.39f1
Shapes version: 4.5.0

Render Pipeline: URP

[Exception] NullReferenceException: Object reference not set to an instance of an object
RenderGraphResourceRegistry.GetRenderTargetInfo() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphResourceRegistry.cs:714

RenderGraphBuilders.CheckUseFragment() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphBuilders.cs:355

RenderGraphBuilders.SetRenderAttachment() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphBuilders.cs:390

IRasterRenderGraphBuilder.SetRenderAttachment() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/IRenderGraphBuilder.cs:196

ShapesRenderPass.RecordRenderGraph() at /Shapes/Scripts/Runtime/Immediate Mode/ShapesRenderPass.cs:40

ScriptableRenderer.RecordCustomRenderGraphPassesInEventRange() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/ScriptableRenderer.cs:1222

ScriptableRenderer.RecordCustomRenderGraphPasses() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/ScriptableRenderer.cs:1241

ScriptableRenderer.RecordCustomRenderGraphPasses() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/ScriptableRenderer.cs:1246

UniversalRenderer.OnAfterRendering() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRendererRenderGraph.cs:1433

UniversalRenderer.OnRecordRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRendererRenderGraph.cs:804

ScriptableRenderer.RecordRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/ScriptableRenderer.cs:1175

UniversalRenderPipeline.RecordRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipelineRenderGraph.cs:10

UniversalRenderPipeline.RecordAndExecuteRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipelineRenderGraph.cs:24

UniversalRenderPipeline.RenderSingleCamera() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:857

UniversalRenderPipeline.RenderSingleCameraInternal() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:690

UniversalRenderPipeline.RenderSingleCameraInternal() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:665

UniversalRenderPipeline.Render() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:482

RenderPipeline.InternalRender() at <8e5a634840fd4c6b9a0a867163b727ec>:0

RenderPipelineManager.DoRenderLoop_Internal() at <8e5a634840fd4c6b9a0a867163b727ec>:0

GUIUtility.ProcessEvent()
Avatar
Justin Wasilenko
[Exception] InvalidOperationException: The CullingResults instance is no longer valid. This can happen if you re-use it across multiple frames.
CullingResults.Validate() at <8e5a634840fd4c6b9a0a867163b727ec>:0
RendererListParams.Validate() at <8e5a634840fd4c6b9a0a867163b727ec>:0
ScriptableRenderContext.CreateRendererList() at <8e5a634840fd4c6b9a0a867163b727ec>:0
RenderGraphResourceRegistry.CreateRendererLists() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphResourceRegistry.cs:1204
RenderGraph.CompileNativeRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraph.Compiler.cs:32
RenderGraph.Execute() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraph.cs:1221
GUIUtility.ProcessEvent()
Avatar
Justin Wasilenko
[Exception] ArgumentException: Trying to use an invalid resource (pass DrawOpaqueObjects).
RenderGraphBuilders.CheckResource() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphBuilders.cs:512
RenderGraphBuilders.UseResource() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphBuilders.cs:199
RenderGraphBuilders.UseTexture() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphBuilders.cs:291
RenderGraphBuilders.Dispose() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphBuilders.cs:131
RenderGraphBuilders.Dispose() at ./Library/PackageCache/com.unity.render-pipelines.core@38fdc9b96878/Runtime/RenderGraph/RenderGraphBuilders.cs:112
DrawObjectsPass.Render() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/Passes/DrawObjectsPass.cs:324
UniversalRenderer.OnMainRendering() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRendererRenderGraph.cs:1311
UniversalRenderer.OnRecordRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRendererRenderGraph.cs:802
ScriptableRenderer.RecordRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/ScriptableRenderer.cs:1175
UniversalRenderPipeline.RecordRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipelineRenderGraph.cs:10
UniversalRenderPipeline.RecordAndExecuteRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipelineRenderGraph.cs:24
UniversalRenderPipeline.RenderSingleCamera() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:857
UniversalRenderPipeline.RenderSingleCameraInternal() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:690
UniversalRenderPipeline.RenderSingleCameraInternal() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:665
UniversalRenderPipeline.Render() at ./Library/PackageCache/com.unity.render-pipelines.universal@0b68ece7aa54/Runtime/UniversalRenderPipeline.cs:482
RenderPipeline.InternalRender() at <8e5a634840fd4c6b9a0a867163b727ec>:0
RenderPipelineManager.DoRenderLoop_Internal() at <8e5a634840fd4c6b9a0a867163b727ec>:0
GUIUtility.ProcessEvent()