[Mesa-dev] [PATCH 01/16] glsl: Add EmitNoSaturate to shader compiler options

Matt Turner mattst88 at gmail.com
Sun Nov 16 19:33:43 PST 2014


On Sun, Nov 16, 2014 at 5:51 PM, Thomas Helland
<thomashelland90 at gmail.com> wrote:
> This allows the backend to decide if it does not
> want saturates, or if it wants to combine min/max
> together by itself.
>
> Usefull for drivers that implement saturate with min/max
> as it can allow for some optimizations by min/max-pruning.
> Drivers like freedreno and vc4 will benefit.
> ---
> I have not made any drivers set the option.
> Probably some pipe-cap or something is needed
> in gallium to allow this?
> I could possibly find time to do a follow-up
> patch for this if someone leads me in the right direction.
>
> saturate() in ir_builder generates ir_unop_saturate unconditionally.
> If someone comes along later and does saturate()
> in some optimization pass, whithout checking the options,
> they will mess up possible optimizations for some backends.
> The cleanest way I could find for always doing the right
> thing was to write a lowering pass in opt_algebraic to
> lower ir_unop_sature into max(min(x, 1), 0);

We already have that, so no need for work in that area :)

See lower_instructions_visitor::sat_to_clamp().


More information about the mesa-dev mailing list