Comment # 12 on bug 97988 from
(In reply to Marek Olšák from comment #11)
> 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.

I think the best solution here would be to teach the backend how to do a scalar
select based on value of vccz.


You are receiving this mail because: