[Mesa-dev] [PATCH 07/16] glsl: Add saturate to get_range

Ian Romanick idr at freedesktop.org
Wed Nov 19 10:46:18 PST 2014


On 11/16/2014 05:51 PM, Thomas Helland wrote:
> We can use the intersection function to reduce the range
> even further if the operand has bounds between 0.0 and 1.0.
> ---
>  src/glsl/opt_minmax.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
> index 341006e..b925aaa 100644
> --- a/src/glsl/opt_minmax.cpp
> +++ b/src/glsl/opt_minmax.cpp
> @@ -292,6 +292,13 @@ get_range(ir_rvalue *rval)
>           low = new(mem_ctx) ir_constant(-1.0f);
>           return minmax_range(low, high);
>  
> +      case ir_unop_saturate:
> +         high = new(mem_ctx) ir_constant(1.0f);
> +         low = new(mem_ctx) ir_constant(0.0f);
> +         r0 = get_range(expr->operands[0]);
> +         // We can get the intersection here to limit the range even more
> +         return range_intersection(r0, minmax_range(low, high));
> +

Like in the previous patch, why not

      return range_intersection(get_range(expr->operands[0]),
                                minmax_range(new(mem_ctx) ir_constant(0.0f),
                                             new(mem_ctx) ir_constant(1.0f)));

or

      r0 = minmax_range(new(mem_ctx) ir_constant(0.0f),
                        new(mem_ctx) ir_constant(1.0f));
      return range_intersection(get_range(expr->operands[0]), r0);

>        default:
>           break;
>        }
> 



More information about the mesa-dev mailing list