<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - llvmpipe: Fragment Shader with "return" in main causes back output"
href="https://bugs.freedesktop.org/show_bug.cgi?id=62357#c7">Comment # 7</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - llvmpipe: Fragment Shader with "return" in main causes back output"
href="https://bugs.freedesktop.org/show_bug.cgi?id=62357">bug 62357</a>
from <span class="vcard"><a class="email" href="mailto:sroland@vmware.com" title="Roland Scheidegger <sroland@vmware.com>"> <span class="fn">Roland Scheidegger</span></a>
</span></b>
<pre>After a quick look at the generated IR, it indeed seems broken.
However, it is broken the opposite way, that is the early exit path is ok but
if the path isn't taken it will pick zero as the output color.
So if you swap the test like so:
[test]
uniform vec4 v 1 0 1 0
Then it fails.
tgsi looks like this:
0: SLT TEMP[0].x, CONST[0].xxxx, IMM[0].xxxx
1: F2I TEMP[0].x, -TEMP[0]
2: SLT TEMP[1].x, IMM[0].yyyy, CONST[0].yyyy
3: F2I TEMP[1].x, -TEMP[1]
4: OR TEMP[1].x, TEMP[0].xxxx, TEMP[1].xxxx
5: SLT TEMP[2].x, CONST[0].zzzz, IMM[0].xxxx
6: F2I TEMP[2].x, -TEMP[2]
7: OR TEMP[1].x, TEMP[1].xxxx, TEMP[2].xxxx
8: IF TEMP[1].xxxx :0
9: MOV_SAT OUT[0], CONST[0]
10: RET
11: ENDIF
12: ADD TEMP[0], IMM[0].xxxx, -CONST[0]
13: MOV_SAT OUT[0], TEMP[0]
14: END
And the IR part like this:
%53 = fcmp une <8 x float> %52, zeroinitializer
%54 = sext <8 x i1> %53 to <8 x i32>
// %54 is the result of the if condition of line 8
...
%70 = call <8 x float> @llvm.x86.avx.max.ps.256(<8 x float> %57, <8 x float>
zeroinitializer)
%71 = call <8 x float> @llvm.x86.avx.min.ps.256(<8 x float> %70, <8 x float>
<float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float
1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float
1.000000e+00>)
// %71 contains mov_sat of line 9
%72 = bitcast <8 x i32> %54 to <8 x float>
// %72 is still condition of line 8 as float
%73 = call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float>
zeroinitializer, <8 x float> %71, <8 x float> %72)
// %73 contains the output going to color pack - you can see that if the
condition (%72) wasn't true, it simply selects zero.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>