Implementing a 2-element orded list in an image buffer
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:
- new = value calculated in current fragment shader
- old and  identify the read/write value reference in the image buffer location 0 and 1
- if (new < old) then write old into old, write new into old
- else if (new < old) then write new into old
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?