UAV and Compute Buffer inconsistencies?

Ok, so I currently trying out UAVs (Unordered Access Views) and I stumbled upon an error I’m not quite sure what to do about.

I’m writing to a ComputeBuffer and increment its values each time i press update. If the values get higher than 1, I just loop back to 0 so we have an endless cycle of changing values. This is done via SetRandomWriteTarget and I write to this buffer from my vertex program (it is an RWStructuredBuffer and has exactly the size of the vertex count of the mesh. So i can just read the data out via the vertexID in shader)

9764592--1398744--2024-04-11-17-16-08.gif

Now the problem. While this works all fine and dandy, I noticed that after some time randomly it seems that certain values get added more than once. If you watch the Gif you can see how all values are the same at first, but after some time, some inconsistencies appear (as if certain increments where added 2 times instead of one)

Does anyone have and idea how I could go about fixing that? Or is this just a limitation of UAVs that sometimes errors can occur?

1 Like

Now I haven’t directly resolved the inconsistency problem, but I opted for an alternative way of writing my code, where I don’t read and add values from the computebuffer, but instead write the complete world position inside which doesn’t change even if a vertex writes multiple times into the same value. And I use that as a lookup later on, so it stays stable this way.