Getting NullReferenceException When Building to Android and Using Immediate Mode Drawing
Whenever I load a scene where I am doing Immediate Mode Drawing after building to Android, using
using (Draw.Command(cam))
I get the following runtime error (I have Compatibility Mode disabled.):
2024/12/11 21:31:22.985 24901 25004 Error Unity NullReferenceException: Object reference not set to an instance of an object. 2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry.GetRenderTargetInfo (UnityEngine.Rendering.RenderGraphModule.ResourceHandle& res, UnityEngine.Rendering.RenderGraphModule.RenderTargetInfo& outInfo) [0x00000] in <00000000000000000000000000000000>:0 2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphBuilders.CheckUseFragment (UnityEngine.Rendering.RenderGraphModule.TextureHandle tex, System.Boolean isDepth) [0x00000] in <00000000000000000000000000000000>:0 2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphBuilders.SetRenderAttachment (UnityEngine.Rendering.RenderGraphModule.TextureHandle tex, System.Int32 index, UnityEngine.Rendering.RenderGraphModule.AccessFlags flags, System.Int32 mipLevel, System.Int32 depthSlice) [0x00000] in <00000000000000000000000000000000>:0 2024/12/11 21:31:22.985 24901 25004 Error Unity at Shapes.ShapesRenderPass.RecordRenderGraph (UnityEngine.Rendering.RenderGraphModule.RenderGraph renderGraph, UnityEngine.Renderi
If I disable the script that is using immediate mode drawing, the errors disappear.
While I am not getting that error, I get this message instead:
12-12 16:22:26.214 5757 5879 W Unity : VULKAN: GENERAL WARNING: The following warning was triggered: VKDBGUTILWARN003. Please refer to the Adreno Game Developer Guide for more information: https://developer.qualcomm.com/sites/default/files/docs/adreno-gpu/snapdragon-game-toolkit/learn_guides.html
12-12 16:22:26.214 5757 5879 W Unity : Objects:
12-12 16:22:26.214 5757 5879 W Unity : #0: { name = ExecuteRenderGraph (C0:C/XR, DS:C/X), type = VK_OBJECT_TYPE_RENDER_PASS, handle = 0xb40000722220dd00 }
12-12 16:22:26.214 5757 5879 W Unity :
Same Unity, Shapes, and URP version as the above. Using Quest 3 and Vulkan.
In my case, adding some Shape game objects to the scene they render just fine. However if I override DrawShapes(Camera cam) for Immediate mode (which I use extensively in my project) nothing gets rendered at all, just a black screen, and the above Vulkan warning being spammed in ADB. Even just doing a simple override like this will cause the black screen and nothing being rendered:
public override void DrawShapes(Camera cam) { using (Draw.Command(cam)) { // Nothing here } }