[Mesa-dev] Add support for GLSL IR saturate()

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Tue Jun 24 11:52:02 PDT 2014

On 24.06.2014 10:34, Matt Turner wrote:
> On Mon, Jun 23, 2014 at 10:27 PM, Abdiel Janulgue
> <abdiel.janulgue at linux.intel.com> wrote:
>> 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
> I think we'll want to reorder the series slightly, so that we don't
> remove the try_emit_sat functions until after we've started emitting
> ir_unop_saturate from ir_builder and until the opt_algebraic pass is
> in place.

I guess It'll be more straightforward to put both patch-sets into one
series and have the removal of try_emit_sat at the end after the
opt_algebraic pass.

> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

More information about the mesa-dev mailing list