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. This is done in the next patch set. Abdiel Janulgue (11): glsl: Add ir_unop_saturate glsl: Add constant evaluation of ir_unop_saturate glsl: Add a pass to lower ir_unop_saturate to clamp(x, 0, 1) ir_to_mesa, glsl_to_tgsi: lower ir_unop_saturate ir_to_mesa, glsl_to_tgsi: Add support for ir_unop_saturate ir_to_mesa, glsl_to_tgsi: Remove try_emit_saturate i965/fs: Add support for ir_unop_saturate i965/vec4: Add support for ir_unop_saturate i965/fs: Remove try_emit_saturate i965/vec4: Remove try_emit_saturate glsl: Implement saturate as ir_binop_saturate src/glsl/ir.cpp | 2 + src/glsl/ir.h | 1 + src/glsl/ir_builder.cpp | 6 +-- src/glsl/ir_constant_expression.cpp | 6 +++ src/glsl/ir_optimization.h | 1 + src/glsl/ir_validate.cpp | 1 + src/glsl/lower_instructions.cpp | 29 ++++++++++++ src/mesa/drivers/dri/i965/brw_fs.h | 1 - src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp | 1 + src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 41 ++--------------- src/mesa/drivers/dri/i965/brw_vec4.h | 1 - src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 25 ++-------- src/mesa/program/ir_to_mesa.cpp | 59 ++++-------------------- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 63 +++++--------------------- 14 files changed, 71 insertions(+), 166 deletions(-) _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev