[Mesa-dev] mishandling of bool comparisons in GLSL->TGSI translator
Brian Paul
brianp at vmware.com
Mon Oct 15 13:35:46 PDT 2012
Jose found a problem in the GLSL->TGSI translater with respect to
boolean array comparisions when PIPE_SHADER_CAP_INTEGERS=1. I dug
into it a bit.
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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vs-bool-array-3.shader_test
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121015/f8a9098a/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glsl-bool.patch
Type: application/pgp-keys
Size: 1126 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121015/f8a9098a/attachment.key>
More information about the mesa-dev
mailing list