Hi,

I need to implement an ordered list of 2 elements for use in a fragment shader.
My 2 elements are ivec4's, no int/uint.
For this I need to do the following:

Given:
- new = value calculated in current fragment shader
- old[0] and [1] identify the read/write value reference in the image buffer location 0 and 1

Algorithm:
- if (new < old[0]) then write old[0] into old[1], write new into old[0]
- else if (new < old[1]) then write new into old[1]

I want my whole algorithm code block to be executed in an atomic way, as a whole.
How can I do this in my fragment shader code? Shall I use a memoryBarrier() here?

Thanks,
Fred