nir: add lowering for ffract

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
This commit is contained in:
Rob Clark 2015-09-14 11:13:19 -04:00
parent 47e18a5957
commit d9efe40dc9
2 changed files with 4 additions and 0 deletions

View file

@ -1440,6 +1440,9 @@ typedef struct nir_shader_compiler_options {
*/
bool fdot_replicates;
/** lowers ffract to fsub+ffloor: */
bool lower_ffract;
/**
* Does the driver support real 32-bit integers? (Otherwise, integers
* are simulated by floats.)

View file

@ -76,6 +76,7 @@ optimizations = [
(('flrp', a, a, b), a),
(('flrp', 0.0, a, b), ('fmul', a, b)),
(('flrp', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp'),
(('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
(('fadd', ('fmul', a, ('fadd', 1.0, ('fneg', c))), ('fmul', b, c)), ('flrp', a, b, c), '!options->lower_flrp'),
(('fadd', a, ('fmul', c, ('fadd', b, ('fneg', a)))), ('flrp', a, b, c), '!options->lower_flrp'),
(('ffma', a, b, c), ('fadd', ('fmul', a, b), c), 'options->lower_ffma'),