RenderGraph Depth/Opaque Texture disabled Error

Avatar
  • updated
  • Fixed

I am trying to update my project to use RenderGraph support for newer  features being used by OpenXR. I have been using Shapes with RenderGraph disabled (Compatibility Mode) because Shapes was always throwing errors at me when using Immediate Mode drawing.

I took the time to make a new project using RenderGraph and implemented your sample IM drawing script, and too my surprise I didn't get the same errors I had in my project. After investigating I found the reason was the URPAsset between the 2 projects.

If both Depth Texture & Opaque Texture are disabled in the URPAsset and RenderGraph is enabled, Shapes will throw the following errors and then crash Unity:

NullReferenceException: Object reference not set to an instance of an object
Render Graph Execution error
InvalidOperationException: The CullingResults instance is no longer valid. This can happen if you re-use it across multiple frames.


I'll post the full log in the next comment.

My game targets the Meta Quest 3, and I need to have the Depth Texture & Opaque Texture disabled for performance reasons, and Shapes is heavily integrated into the game, I hope you can help me Freya!

Reporting a bug? please specify Unity version:
6000.0.51
Reporting a bug? please specify Shapes version:
4.5.1
Reporting a bug? please specify Render Pipeline:
URP
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Fixed

This is now fixed for the coming version! 


if you want to apply a hotfix until then, this should work:

builder.SetRenderAttachment( resourceData.activeColorTexture, 0, AccessFlags.Write );
builder.SetRenderAttachmentDepth( resourceData.activeDepthTexture, AccessFlags.Write );

Avatar
Justin Wasilenko

Hi Freya,

I gave this a try this morning to see if if fixes my issues. This seems to be working on the PC build. I haven't had a chance to try it on Quest.

At first I thought it was not working, because my immediate mode lines were not rendering on the PC build after making this change. But they showed in the editor. I have 4 Shapes shaders set in Always Included Shaders, however I had to switch to Keep All under Instancing Variants for it to work for now.

Excited to test out the Quest and see if all issues are fixed!

Avatar
Freya Holmér creator
  • Answer
  • Fixed

This is now fixed for the coming version! 


if you want to apply a hotfix until then, this should work:

builder.SetRenderAttachment( resourceData.activeColorTexture, 0, AccessFlags.Write );
builder.SetRenderAttachmentDepth( resourceData.activeDepthTexture, AccessFlags.Write );

Avatar
Justin Wasilenko

Thanks Patrick. I tried adding that line but I still get the errors without having Depth texture enabled. I appreciate you trying to help though!

Avatar
patrick hogenboom

Not sure if this is the same bug, but I remember that we had a depth-related issue in Shapes when moving to RenderGraph.
In the end a colleague of mine fixed it with this addition to ShapesRenderPass.cs

Image 911

Hope this helps, 
Patrick

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 <575c8d5d94a9444f82eba927ac72f8df>:0

RendererListParams.Validate() at <575c8d5d94a9444f82eba927ac72f8df>:0

ScriptableRenderContext.CreateRendererList() at <575c8d5d94a9444f82eba927ac72f8df>:0

RenderGraphResourceRegistry.CreateRendererLists() at ./Library/PackageCache/com.unity.render-pipelines.core@2be5e7224a10/Runtime/RenderGraph/RenderGraphResourceRegistry.cs:1204

1202: ref var rendererListResource = ref m_RendererListResources[rendererList];

1203: ref var desc = ref rendererListResource.desc;

-->1204: rendererListResource.rendererList = context.CreateRendererList(ref desc);

1205: m_ActiveRendererLists.Add(rendererListResource.rendererList);

1206: break;

RenderGraph.CompileNativeRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.core@2be5e7224a10/Runtime/RenderGraph/RenderGraph.Compiler.cs:32

30: }

--> 32: m_Resources.CreateRendererLists(m_RendererLists, m_RenderGraphContext.renderContext, m_RendererListCulling);

34: return nativeCompiler;

RenderGraph.Execute() at ./Library/PackageCache/com.unity.render-pipelines.core@2be5e7224a10/Runtime/RenderGraph/RenderGraph.cs:1225

1224: if (nativeRenderPassesEnabled)

-->1225: CompileNativeRenderGraph(graphHash);

1226: else

1227: CompileRenderGraph(graphHash);

GUIUtility.ProcessEvent()

Avatar
Justin Wasilenko

[Exception] NullReferenceException: Object reference not set to an instance of an object

RenderGraphResourceRegistry.GetRenderTargetInfo() at ./Library/PackageCache/com.unity.render-pipelines.core@2be5e7224a10/Runtime/RenderGraph/RenderGraphResourceRegistry.cs:714

712: // Lots of legacy if's and but's

713: TextureResource tex = GetTextureResource(res);

--> 714: if (tex.imported)

715: {

716: // Imported, try to get back to the original handle we imported and get the properties from there

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

353: }

--> 355: m_Resources.GetRenderTargetInfo(tex.handle, out var info);

357: // The old path is full of invalid uses that somehow work (or seemt to work) so we skip the tests if not using actual native renderpass

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

388: public void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags, int mipLevel, int depthSlice)

389: {

--> 390: CheckUseFragment(tex, false);

391: ResourceHandle result = UseResource(tex.handle, flags);

392: // Note the version for the attachments is a bit arbitrary so we just use the latest for now

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

194: void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags = AccessFlags.Write)

195: {

--> 196: SetRenderAttachment(tex, index, flags, 0, -1);

197: }

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

42: builder.AllowPassCulling( false );

43: UniversalResourceData resourceData = frameData.Get();

--> 44: builder.SetRenderAttachment( resourceData.cameraColor, 0, AccessFlags.Write );

45: builder.SetRenderFunc(

46: ( PassData dataParam, RasterGraphContext context ) => {

ScriptableRenderer.RecordCustomRenderGraphPassesInEventRange() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/ScriptableRenderer.cs:1247

1245: {

1246: if (pass.renderPassEvent >= eventStart && pass.renderPassEvent < eventEnd)

-->1247: pass.RecordRenderGraph(renderGraph, m_frameData);

1248: }

1249: }

ScriptableRenderer.RecordCustomRenderGraphPasses() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/ScriptableRenderer.cs:1266

1264: int range = ScriptableRenderPass.GetRenderPassEventRange(endInjectionPoint);

-->1266: RecordCustomRenderGraphPassesInEventRange(renderGraph, startInjectionPoint, endInjectionPoint + range);

1267: }

ScriptableRenderer.RecordCustomRenderGraphPasses() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/ScriptableRenderer.cs:1271

1269: internal void RecordCustomRenderGraphPasses(RenderGraph renderGraph, RenderPassEvent injectionPoint)

1270: {

-->1271: RecordCustomRenderGraphPasses(renderGraph, injectionPoint, injectionPoint);

1272: }

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

1431: DrawRenderGraphGizmos(renderGraph, frameData, resourceData.activeColorTexture, resourceData.activeDepthTexture, GizmoSubset.PreImageEffects);

-->1433: RecordCustomRenderGraphPasses(renderGraph, RenderPassEvent.BeforeRenderingPostProcessing);

1435: bool cameraTargetResolved = false;

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

802: OnMainRendering(renderGraph, context);

--> 804: OnAfterRendering(renderGraph);

806: EndRenderGraphXRRendering(renderGraph);

ScriptableRenderer.RecordRenderGraph() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/ScriptableRenderer.cs:1200

1198: using (new ProfilingScope(Profiling.recordRenderGraph))

1199: {

-->1200: OnRecordRenderGraph(renderGraph, context);

1201: }

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

8: static void RecordRenderGraph(RenderGraph renderGraph, ScriptableRenderContext context, ScriptableRenderer renderer)

9: {

--> 10: renderer.RecordRenderGraph(renderGraph, context);

11: }

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

23: renderGraph.BeginRecording(rgParams);

--> 24: RecordRenderGraph(renderGraph, context, renderer);

25: renderGraph.EndRecordingAndExecute();

26: }

UniversalRenderPipeline.RenderSingleCamera() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/UniversalRenderPipeline.cs:855

853: if (useRenderGraph)

854: {

--> 855: RecordAndExecuteRenderGraph(s_RenderGraph, context, renderer, cmd, cameraData.camera, cameraMetadata.name);

856: renderer.FinishRenderGraphRendering(cmd);

857: }

UniversalRenderPipeline.RenderSingleCameraInternal() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/UniversalRenderPipeline.cs:688

686: #endif

--> 688: RenderSingleCamera(context, cameraData);

689: }

UniversalRenderPipeline.RenderSingleCameraInternal() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/UniversalRenderPipeline.cs:663

661: camera.gameObject.TryGetComponent(out additionalCameraData);

--> 663: RenderSingleCameraInternal(context, camera, ref additionalCameraData, isLastBaseCamera);

664: }

UniversalRenderPipeline.Render() at ./Library/PackageCache/com.unity.render-pipelines.universal@a55da47cc43f/Runtime/UniversalRenderPipeline.cs:480

478: UpdateVolumeFramework(camera, null);

--> 480: RenderSingleCameraInternal(renderContext, camera, isLastBaseCamera);

481: }

482: }

RenderPipeline.InternalRender() at <575c8d5d94a9444f82eba927ac72f8df>:0

RenderPipelineManager.DoRenderLoop_Internal() at <575c8d5d94a9444f82eba927ac72f8df>:0

GUIUtility.ProcessEvent()