The attached shader_runner case shows the issue.
Basically, the comparison of boolean values (which are unsigned integers) winds up being done with TGSI_OPCODE_SEQ instead of USEQ:
VERT
DCL IN[0]
DCL OUT[0], POSITION
DCL OUT[1], GENERIC[12]
DCL CONST[0..1]
DCL TEMP[0], LOCAL
DCL TEMP[1], LOCAL
IMM UINT32 {4294967295, 0, 0, 0}
IMM FLT32 { 1.0000, 0.0000, 0.0000, 0.0000}
0: SEQ TEMP[0].x, CONST[0].xxxx, IMM[0].xxxx <<< UINT operands!
1: F2I TEMP[0].x, -TEMP[0]
2: SEQ TEMP[1].x, CONST[1].xxxx, IMM[0].xxxx <<< UINT operands!
3: F2I TEMP[1].x, -TEMP[1]
4: AND TEMP[0].x, TEMP[0].xxxx, TEMP[1].xxxx
5: IF TEMP[0].xxxx :0
6: MOV TEMP[0], IMM[1].xyyx
7: ELSE :0
8: MOV TEMP[0], IMM[1].yxyx
9: ENDIF
10: MOV OUT[1], TEMP[0]
11: MOV OUT[0], IN[0]
12: END
The correct code sequence should be:
0: USEQ TEMP[0].x, CONST[0].xxxx, IMM[0].xxxx
1: USEQ TEMP[1].x, CONST[1].xxxx, IMM[0].xxxx
2: AND TEMP[0].x, TEMP[0].xxxx, TEMP[1].xxxx
3: IF TEMP[0].xxxx :0
4: MOV TEMP[0], IMM[1].xyyx
5: ELSE :0
6: MOV TEMP[0], IMM[1].yxyx
7: ENDIF
8: MOV OUT[1], TEMP[0]
9: MOV OUT[0], IN[0]
10: END
The attached patch for glsl_to_tgsi_visitor::get_opcode() fixes the
issue but the first assert which I added fails if it's enabled.
AFAICT, by time we get into glsl_to_tgsi_visitor::get_opcode() we
should have scalar operands, not arrays. It's not clear to me how to
fix that.
I'm hoping someone who's spent more time on glsl_to_tgsi.cpp (is Bryan Cain still around?) can take a look at this. Thanks.
-Brian
[require]
GLSL >= 1.20
[vertex shader]
#version 120
varying vec4 color;
uniform bool[2] ub = bool[2](bool(0), bool(1));
void main()
{
if (ub == bool[2](bool(1), bool(1))) {
color = vec4(1, 0, 0, 1);
} else {
color = vec4(0, 1, 0, 1);
}
gl_Position = gl_Vertex;
}
[fragment shader]
#version 120
varying vec4 color;
void main()
{
gl_FragColor = color;
}
[test]
draw rect -1 -1 2 2
probe all rgb 0 1 0
glsl-bool.patch
Description: application/pgp-keys
_______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
