[Mesa-dev] [PATCH 03/16] glsl: Use constant_expression_value instead of as_constant

Ian Romanick idr at freedesktop.org
Tue Jul 22 10:28:42 PDT 2014


On 07/21/2014 03:39 PM, Matt Turner wrote:
> On Mon, Jul 21, 2014 at 2:04 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> Just a few lines earlier we may have wrapped the index expression with
>> ir_unop_i2u expression.  Whenever that happens, as_constant will return
>> NULL, and that almost always happens.
> 
> Are you saying that since we just passed array_index to i2u we know it
> must be a constant? I can follow that much, but I don't see anything
> that really makes sure this is a constant.

The code tries really hard to just generate a constant offset for the
UBO access.  To implement this optimization, this code was assuming the
array index would be an ir_constant if the value was constant... but it
does this right after possibly wrapping the ir_constant with an
ir_expression.  This change just makes the optimization actually do what
it's intending to do by use ::constant_expression_value instead of
as_constant.



More information about the mesa-dev mailing list