[Mesa-dev] [PATCH] glsl: Fix array indexing when constant folding built-in functions.

Paul Berry stereotype441 at gmail.com
Tue Apr 2 12:15:26 PDT 2013


On 1 April 2013 11:43, Kenneth Graunke <kenneth at whitecape.org> wrote:

> On 04/01/2013 11:30 AM, Ian Romanick wrote:
>
>> On 03/29/2013 02:13 PM, Paul Berry wrote:
>>
>>> Mesa constant-folds built-in functions by using a miniature GLSL
>>> interpreter (see
>>> ir_function_signature::**constant_expression_evaluate_**
>>> expression_list()).
>>> This interpreter had a bug in its handling of array indexing, which
>>> caused expressions like "m[i][j]" (where m is a matrix) to be handled
>>> incorrectly.  Specifically, it incorrectly treated j as indexing into
>>> the whole matrix (rather than indexing just into the vector m[i]); as
>>> a result the offset computed for m[i] was lost and m[i][j] was treated
>>> as m[j][0].
>>>
>>> Fixes piglit tests inverse-mat[234].{vert,frag}.
>>>
>>> NOTE: This is a candidate for the 9.1 branch.
>>>
>>
>> Good catch.  The test case fails only in 9.1 and later because it
>> requires OpenGL 3.1, but I think the bug exists in earlier versions.
>>
>
I'm glad you mentioned this because it prompted me to investigate further.
It turns out that the test case *does* fail in 9.0, because 9.0 supports
OpenGL 3.1.  The bug doesn't exist in earlier versions, since the
"miniature GLSL interpreter" technique was implemented in the 9.0 timeframe.

I'll update the note to mark this patch as a candidate for 9.1 and 9.0.


>
>> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>> Bugzilla: https://bugs.freedesktop.org/**show_bug.cgi?id=57436<https://bugs.freedesktop.org/show_bug.cgi?id=57436>
>>
>> I already pushed my work-around to master (but not to 9.1).  You can
>> revert it when you push this change if you like.
>>
>
> I would like to keep the change to use dot(), as that seems like an actual
> improvement.  For the other changes, I guess I don't have a strong
> preference.
>
> --Ken
>

Sounds reasonable to me.  Will do.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130402/6de43691/attachment.html>


More information about the mesa-dev mailing list