Compute shaders and memory synchronization

What kind of behaviour should we expect when concurrent read/writes happens to an output buffer ?

If the GLSL TOP there is an ‘Output Type’ options which allows us to choose between write-only, read-only or read-write.

The documentation says :

Controls how the output textures will be accessed. If the textures will be read from (such as using previous frame’s values), then the access should be changed to Read-Write instead of Write Only.

What kind of memory-synchronization can we expect from this feature ?

I am running into determinism issue in a project of mine. It’s a particle simulation, where multiple particles can be rendered to the same pixel. I’d like to accumulate the particles’weight’ to this pixel. However when outputing the same data to two outputs using imageStore creates some differences between the two output buffer.

I am no expert and it seems like memory synchronization is a very technical subject when dealing with GPUs.

Please let me know if you need some samples.

Thanks :slight_smile:

You need to use atomic operations to accumulate values. In general only the Nvidia GPUs support atomic operations on floating point data though, so you may be limited as to which GPU you can do this on.

1 Like

Are you aware of any Palette item that I could take a look at while working with compute shaders and array uniforms ?

I do really struggle to find any use case of having a read write buffer if you don’t have any kind of memory synchronization available.
Is the output buffer pre-filled with the previous frame output ?

There is a parameter that controls if the outputs are cleared before executing a new cook. You can also use a Feedback TOP to feed back output into the input to build upon data from the last frame.