[Mesa-dev] [PATCH v2 20/28] glsl: Support double loop control
Ilia Mirkin
imirkin at alum.mit.edu
Sat Feb 7 20:48:18 PST 2015
On Fri, Feb 6, 2015 at 3:58 AM, Ian Romanick <idr at freedesktop.org> wrote:
> On 02/06/2015 06:56 AM, Ilia Mirkin wrote:
>> From: Dave Airlie <airlied at gmail.com>
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> ---
>> src/glsl/loop_controls.cpp | 16 ++++++++++++----
>> 1 file changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
>> index 1c1d34f..412bb20 100644
>> --- a/src/glsl/loop_controls.cpp
>> +++ b/src/glsl/loop_controls.cpp
>> @@ -102,10 +102,15 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
>> return -1;
>>
>> if (!iter->type->is_integer()) {
>> - ir_rvalue *cast =
>> - new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type, iter,
>> - NULL);
>> -
>> + ir_rvalue *cast = NULL;
>> + if (iter->type->is_double()) {
>> + cast = new(mem_ctx) ir_expression(ir_unop_d2i, glsl_type::int_type, iter,
>> + NULL);
>> + } else {
>> + cast = new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type, iter,
>> + NULL);
>> + }
>
> I'd much prefer
>
> const ir_expression_operation op = iter->type->is_double()
> ? ir_unop_d2i : ir_unop_f2i;
> ir_rvalue *cast =
> new(mem_ctx) ir_expression(op, glsl_type::int_type, iter,
> NULL);
>
> or something similar.
OK
>
>> + assert(cast);
>
> Why the assertion?
It was like that when I got there :) I'm guessing it started out as a
switch in an earlier iteration? Or some silly compiler thing...
>
>> iter = cast->constant_expression_value();
>> }
>>
>> @@ -134,6 +139,9 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
>> case GLSL_TYPE_FLOAT:
>> iter = new(mem_ctx) ir_constant(float(iter_value + bias[i]));
>> break;
>> + case GLSL_TYPE_DOUBLE:
>> + iter = new(mem_ctx) ir_constant(double(iter_value + bias[i]));
>> + break;
>> default:
>> unreachable(!"Unsupported type for loop iterator.");
>> }
>>
>
More information about the mesa-dev
mailing list