[Mesa-dev] [PATCH 15/17] glsl: Support double loop control (was: add double support)
Ilia Mirkin
imirkin at alum.mit.edu
Thu Feb 5 18:53:48 PST 2015
On Thu, Feb 5, 2015 at 2:16 PM, Matt Turner <mattst88 at gmail.com> wrote:
> On Thu, Feb 5, 2015 at 3:05 AM, Topi Pohjolainen
> <topi.pohjolainen at intel.com> wrote:
>> From: Dave Airlie <airlied at gmail.com>
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> ---
>> src/glsl/loop_controls.cpp | 19 +++++++++++++++----
>> 1 file changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
>> index 1c1d34f..9a99c21 100644
>> --- a/src/glsl/loop_controls.cpp
>> +++ b/src/glsl/loop_controls.cpp
>> @@ -102,10 +102,18 @@ 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()) {
>> + ir_expression *d2f =
>> + new(mem_ctx) ir_expression(ir_unop_d2f, glsl_type::float_type,
>> + iter, NULL);
>> + cast = new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type,
>> + (ir_rvalue*) d2f, NULL);
>
> Why are we doing f2i(d2f(iter)) instead of d2i(iter)?
Because originally we didn't have d2i, only later was the observation
made that d2f + f2i is lossy. Fixed.
More information about the mesa-dev
mailing list