[Mesa-dev] mishandling of bool comparisons in GLSL->TGSI translator

Bryan Cain bryancain3 at gmail.com
Mon Oct 15 14:09:47 PDT 2012


Hi.  I'm still around to some extent, although I still need to submit
the changes to the ML for my geometry shader work from a couple of
months ago.  I don't have much free time anymore, but I'll try to take a
look at this soon.

-Bryan

On 10/15/2012 03:35 PM, Brian Paul wrote:
> 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
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121015/d0249d19/attachment.html>


More information about the mesa-dev mailing list