[Mesa-dev] Clamp/saturate optimizations V2

Matt Turner mattst88 at gmail.com
Mon Jul 7 11:18:42 PDT 2014


On Mon, Jul 7, 2014 at 6:56 AM, Abdiel Janulgue
<abdiel.janulgue at linux.intel.com> wrote:
> V2 of clamp/saturate optimizations
>
> This patch series add the plumbing to support the GLSL IR instruction saturate().
> Previously, saturate is implemented as min/max instructions. Most GPUs, however,
> can probably perform saturate for free. With these changes, we can allow saturate
> to be optimized as a single instruction.
>
> In addition, the optimization try_emit_saturate was previously used to optimize
> min/max operations to a saturate operation. It didn't work for code such as
> min(max(a, b), c) where (b == 0.0 and c < 1.0) and related cases.
> With this infrastructure in place, we can optimize those operations easily in the
> do_algebraic pass.
>
> Changes since v1:
>  - Only remove the old try_emit_saturate operations after the new optimizations are
>    in place. (Matt, Ian)
>  - Output [min/max](saturate(x),b) instead of saturate([min/max](x,b)) as suggested
>    by Ilia Mirkin.
>  - The change above required some refactoring in the fs/vec4 backend to allow
>    propagation of certain instructions with saturate flag to SEL. For other instructions,
>    we don't propagate saturate instructions, similar to the previous behaviour.
>
> Results:
>
> helped: shaders/0ad/9.shader_test fs16:                   38 -> 37 (-2.63%)
> helped: shaders/0ad/9.shader_test fs8:                    38 -> 37 (-2.63%)
> helped: shaders/gst-gl-tunnel.frag fs16:                  65 -> 64 (-1.54%)
> helped: shaders/gst-gl-tunnel.frag fs8:                   65 -> 64 (-1.54%)
>
> total instructions in shared programs: 41595 -> 41591 (-0.01%)
> instructions in affected programs:     206 -> 202 (-1.94%)

Off-list:

You'll need to run this with the closed shader-db branch on teamforge:
https://git-amr-2.devtools.intel.com/gerrit/gitweb?p=otc_gen_graphics-shader-db.git

There are a lot of instruction count regressions that'll need to be
investigated.


More information about the mesa-dev mailing list