Showing results for 
Search instead for 
Did you mean: 

Strange vertex-buffer corruption in Unity on Quest using compute shaders + Graphics.DrawProcedural?

Level 3
So here's a bug that's been plaguing me for the last 18 months. Initially I chalked it up to the Quest being quite new, and just walked away from it as a dev platform expecting it to be fixed eventually. I tried again recently, and this is still a problem!

Basically, when drawing more than a few thousand vertices with Graphics.DrawProcedural in a shader that uses SV_VertexID to fetch elements from a StructuredBuffer, things work perfectly fine in standalone builds, but on Quest everything goes crazy. All the vertices end up with bizarre positions, normals, etc, resulting in huge triangles going everywhere. Even stranger, vertices that aren't part of my system, such as the default Avatar hands, also have their vertices corrupted! I've experienced similar problems in the past using Graphics.DrawMeshInstancedIndirect

There's no difference if I'm running in OpenGL ES 3.1+AEP, OpenGL ES 3.2, or Vulkan. I've tried messing with all sorts of settings, with no luck. Has anyone had any luck with Compute Shaders + Quest? I have a sneaky suspicion that there's just some difficult-to-find documentation about threadgroup sizes or compute shader features that need to be managed properly for writing Compute Shaders in Unity for Open GL or Vulkan. But I'm also worried that there's just some bug in the integration of the Oculus SDK in Unity. Help?

I have a pair of videos, one showing what an earlier version of one of my apps looks like on PC, and the second video showing what the same app looks like through the lens on Quest. Notice both the complete polygonal mess in the background, and the strange spiky vertices on the Avatar hands. You can view the videos in this post on my website.

I also made several posts about a related issue with Graphics.DrawMeshInstancedIndirect on the Unity forum over a year ago, which you can view here

Level 4

@mptp I am experiencing the same issue and I was wondering if you fixed it already?

Hi! Yeah I did in the end, thanks to some help from Unity - as it turns out it was all my fault haha.


You can read about the solution to this here:


Long story short, the vertex shader needs to completely initialize its vertex output, and if it doesn't, but has 'inout' rather than 'out' in the function declaration, this error results. So either make sure you fully initialize the vertex or, preferably, just use the 'out' keyword.