https://bugs.freedesktop.org/show_bug.cgi?id=97988

--- Comment #11 from Marek Olšák <maraeo at gmail.com> ---
Thanks Grigori.

GLSL:
  color = fract(gl_FragCoord.y / 2) < 0.5 ?
             texture(texture0, texcoord0) :
             texture(texture1, texcoord0);

texture0 and texture1 are SMEM loads.

LLVM (SimplifyCFG) transforms it to:
  color = texture(fract(gl_FragCoord.y / 2) < 0.5 ? texture0 : texture1,
                  texcoord0);

That's a nice transformation. You don't have to use 2 SMEM loads, you can just
use one SMEM load depending on the result of the condition.

The problem is gl_FragCoord.y is a VGPR and texture0/1 are SGPRs, therefore
flat VMEM loads are used to load the descriptors. However, image_sample
requires descriptors in SGPRs, so v_readfirstlane is used. That effectively
uses the result of the condition from the first active lane, discarding the
results from all other lanes. The result would be exactly the same if the
compiler did: v_readfirstlane s0, gl_FragCoord.y;

The test case seems pretty trivial I wonder how many other apps are affected.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20161001/2c9732fe/attachment.html>

Reply via email to