Note that there are some explanatory texts on larger screens.

plurals
  1. POGLSL atomic counters (and branching) in fragment shaders
    primarykey
    data
    text
    <p>A fragment shader uses two atomic counters. It may or may not increment the first and may or may not increment the second (but never both). Before so modifying the counters, however, their current values are always read and --if the counters are then later modified-- those previously read values used for some custom logic. All this happens in a (most likely unrollable) loop.</p> <p>Envision a flow roughly like this:</p> <ul> <li>in some small unrollable loop, say FOR 0-20 (compile-time resolvable const)...</li> <li>get counter values for AC1 and AC2</li> <li>check some value:</li> <li>if x: set texel in uimage1D_A at index AC1, increment AC1</li> <li>else: set texel in uimage1D_B at index (imgwidth-AC2-1), increment AC2 </li> </ul> <p>Question: the shader queries the current counter value -- does it always get the "most current" value? Do I lose the massive parallelism of fragment shaders here (speaking in terms of of current-generation and future GPUs and drivers only)?</p> <p>As for the branching (if x) -- I compare a texel in another (<code>readonly restrict uniform</code>) <code>uimage1D</code> to a (<code>uniform</code>) <code>uint</code>. So one operand is definitely a uniform scalar, but the other is an <code>imageLoad().x</code> although the image is uniform -- is this sort of branching still "fully parallelized"? You can see both branches are each exactly two, almost identical instructions. Assuming a "perfectly optimizing" GLSL compiler, is this kind of branching likely introducing a stall?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload