[Mesa-dev] [PATCH] glsl: support unsigned increment in ir_loop controls

Ilia Mirkin imirkin at alum.mit.edu
Fri Mar 27 21:36:28 PDT 2015


On Wed, Aug 6, 2014 at 10:46 AM, Ian Romanick <idr at freedesktop.org> wrote:
> On 07/30/2014 04:11 AM, Tapani Pälli wrote:
>> Current version can create ir_expression where operands have
>> different base type, patch adds support for unsigned type.
>>
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> https://bugs.freedesktop.org/show_bug.cgi?id=80880
>> ---
>>  src/glsl/loop_controls.cpp | 18 +++++++++++++++---
>>  1 file changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
>> index 36b49eb..419f9c1 100644
>> --- a/src/glsl/loop_controls.cpp
>> +++ b/src/glsl/loop_controls.cpp
>> @@ -123,9 +123,21 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
>>     bool valid_loop = false;
>>
>>     for (unsigned i = 0; i < Elements(bias); i++) {
>> -      iter = (increment->type->is_integer())
>> -      ? new(mem_ctx) ir_constant(iter_value + bias[i])
>> -      : new(mem_ctx) ir_constant(float(iter_value + bias[i]));
>> +
>> +      /* Increment may be of type int, uint or float. */
>> +      switch (increment->type->base_type) {
>> +      case GLSL_TYPE_INT:
>> +         iter = new(mem_ctx) ir_constant(iter_value + bias[i]);
>> +         break;
>> +      case GLSL_TYPE_UINT:
>> +         iter = new(mem_ctx) ir_constant(unsigned(iter_value + bias[i]));
>> +         break;
>> +      case GLSL_TYPE_FLOAT:
>> +         iter = new(mem_ctx) ir_constant(float(iter_value + bias[i]));
>> +         break;
>> +      default:
>> +      assert(!"Unsupported type for loop iterator.");
>
> Right... because this code was written when we only had int and
> float types.
>
> Two things:
>
>   - Use spaces instead of tabs.  It looks like the surrounding code
>     uses tabs, and that's my fault.  We're trying to fix that in new
>     code.
>
>   - Change the assert to unreachable("Unsupported type for loop iterator.")

Tapani, looks like you made this unreachable(!"..."), which is wrong.
See the unreachable macro. You don't want the ! in there.

  -ilia


More information about the mesa-dev mailing list