CopyCounterValue value wrong

Is this section still active? There doesn’t seem to be much traffic…

I’ve got an odd problem trying to get compute based rendering with an append buffer to work.
The code is essentially:

  • DispatchCompute to generate particles
  • CopyCounterValue from append buffer into indirect draw buffer
  • DispatchCompute to multiply vertex count by 3
  • DrawProceduralIndirect to draw particles, with the vertex shader generating 3 triangle vertices for each buffer vertex.

I’m doing this process twice in a row to render two particle systems. The first vertex count returned is 0, the second about 10% higher than expected. The actual buffer data generated by the compute shader looks as expected. Do I need to add any extra synchronisation to make sure the DispatchCompute completes before the CopyCounterValue copies the value?

Right now I’m not sure if this is my code problem, a driver problem, or a Unity problem. The events in a RenderDoc capture look reasonable.
I am using Unity 2021.3.16f1 with RTX 3050 Ti laptop GPU.

Solution: No synchronisation is required, as D3D11 handles this internally.
Bugs were in my code:

  • Unity is sharing state between compute shaders unless you manually create a copy. Which is a bit awkward as compute shaders are mostly code driven and there doesn’t seem to be a way to separate the properties from the shader.
  • problems that I thought were caused by synchronisation between pipelines were actually caused by a typo in the declaration of the structured buffer between compute and vertex shader, causing misalignment when read. Because the order in which items are written to the append buffer it looked more like a memory problem that a structure stride problem.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.