Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net> On Tue, Apr 12, 2016 at 1:05 AM, Samuel Iglesias Gonsálvez < sigles...@igalia.com> wrote:
> From: Iago Toral Quiroga <ito...@igalia.com> > > At least i965 hardware does not have native support for fract() on doubles. > --- > src/compiler/nir/nir.h | 1 + > src/compiler/nir/nir_lower_double_ops.c | 14 ++++++++++++++ > 2 files changed, 15 insertions(+) > > diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h > index 7c9e498..4a57e74 100644 > --- a/src/compiler/nir/nir.h > +++ b/src/compiler/nir/nir.h > @@ -2289,6 +2289,7 @@ typedef enum { > nir_lower_dtrunc = (1 << 3), > nir_lower_dfloor = (1 << 4), > nir_lower_dceil = (1 << 5), > + nir_lower_dfract = (1 << 6) > } nir_lower_doubles_options; > > void nir_lower_doubles(nir_shader *shader, nir_lower_doubles_options > options); > diff --git a/src/compiler/nir/nir_lower_double_ops.c > b/src/compiler/nir/nir_lower_double_ops.c > index 66e2be4..0f42c21 100644 > --- a/src/compiler/nir/nir_lower_double_ops.c > +++ b/src/compiler/nir/nir_lower_double_ops.c > @@ -417,6 +417,12 @@ lower_ceil(nir_builder *b, nir_ssa_def *src) > src)); > } > > +static nir_ssa_def * > +lower_fract(nir_builder *b, nir_ssa_def *src) > +{ > + return nir_fsub(b, src, nir_ffloor(b, src)); > +} > + > static void > lower_doubles_instr(nir_alu_instr *instr, nir_lower_doubles_options > options) > { > @@ -455,6 +461,11 @@ lower_doubles_instr(nir_alu_instr *instr, > nir_lower_doubles_options options) > return; > break; > > + case nir_op_ffract: > + if (!(options & nir_lower_dfract)) > + return; > + break; > + > default: > return; > } > @@ -487,6 +498,9 @@ lower_doubles_instr(nir_alu_instr *instr, > nir_lower_doubles_options options) > case nir_op_fceil: > result = lower_ceil(&bld, src); > break; > + case nir_op_ffract: > + result = lower_fract(&bld, src); > + break; > default: > unreachable("unhandled opcode"); > } > -- > 2.5.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev