From d9efe40dc924b8bfd93c0572bd70c0585f823628 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 14 Sep 2015 11:13:19 -0400 Subject: nir: add lowering for ffract Signed-off-by: Rob Clark Reviewed-by: Iago Toral Quiroga --- src/glsl/nir/nir.h | 3 +++ src/glsl/nir/nir_opt_algebraic.py | 1 + 2 files changed, 4 insertions(+) diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 4e4543ad5ec..fffb2f45719 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -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.) diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index acc3b04b118..43558a547b4 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -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'), -- cgit v1.2.3