[Mesa-dev] [PATCH 6/7] gallium: Add TGSI_OPCODE_F2U to gallivm backend.

Paul Berry stereotype441 at gmail.com
Thu Jun 14 09:55:58 PDT 2012


On 14 June 2012 09:02, Roland Scheidegger <sroland at vmware.com> wrote:

> Am 14.06.2012 15:07, schrieb Paul Berry:
> > On 14 June 2012 05:10, Jose Fonseca <jfonseca at vmware.com
> > <mailto:jfonseca at vmware.com>> wrote:
> >
> >     lp_build_utrunc() doesn't exists yet.  For now, please use
> >     lp_build_itrunc() and add a /* FIXME: implement and use
> >     lp_build_utrunc() */ comment. It's not perfect, but it's no worse
> >     what's there now.
> >
> >     Jose
> >
> >
> > Ok, will do.  Thank you.
> btw I'm wondering how you'd actually do that in some semi-efficient manner?
> llvm has LLVMBuildFPToUI but x86 has no such conversion instructions
> they are all signed. I guess multiply by 0.5, convert to signed int,
> cast to unsigned and multiply by 2 isn't really the solution :-).
>

Playing around with gcc, it looks like it generally achieves
float->unsigned conversions by first converting to a 64-bit integer (using
the "fistpq" instruction on x86, or "cvttss2siq" on x86-64), then
truncating the upper 32 bits.


>
>
> >
> >
> >
> >     ----- Original Message -----
> >     > ---
> >     >  src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c |   12
> >     >  ++++++++++++
> >     >  1 files changed, 12 insertions(+), 0 deletions(-)
> >     >
> >     > diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> >     > b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> >     > index e0a5180..e48a0fd 100644
> >     > --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> >     > +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> >     > @@ -984,6 +984,17 @@ f2i_emit_cpu(
> >     >
> >      emit_data->args[0]);
> >     >  }
> >     >
> >     > +/* TGSI_OPCODE_F2U (CPU Only) */
> >     > +static void
> >     > +f2u_emit_cpu(
> >     > +   const struct lp_build_tgsi_action * action,
> >     > +   struct lp_build_tgsi_context * bld_base,
> >     > +   struct lp_build_emit_data * emit_data)
> >     > +{
> >     > +   emit_data->output[emit_data->chan] =
> >     > lp_build_utrunc(&bld_base->base,
> >     > +
> >     >
> >      emit_data->args[0]);
> >     > +}
> >     > +
> >     >  /* TGSI_OPCODE_FLR (CPU Only) */
> >     >
> >     >  static void
> >     > @@ -1561,6 +1572,7 @@ lp_set_default_actions_cpu(
> >     >     bld_base->op_actions[TGSI_OPCODE_EX2].emit = ex2_emit_cpu;
> >     >     bld_base->op_actions[TGSI_OPCODE_EXP].emit = exp_emit_cpu;
> >     >     bld_base->op_actions[TGSI_OPCODE_F2I].emit = f2i_emit_cpu;
> >     > +   bld_base->op_actions[TGSI_OPCODE_F2U].emit = f2u_emit_cpu;
> >     >     bld_base->op_actions[TGSI_OPCODE_FLR].emit = flr_emit_cpu;
> >     >
> >     >     bld_base->op_actions[TGSI_OPCODE_I2F].emit = i2f_emit_cpu;
> >     > --
> >     > 1.7.7.6
> >     >
> >     > _______________________________________________
> >     > mesa-dev mailing list
> >     > mesa-dev at lists.freedesktop.org <mailto:
> mesa-dev at lists.freedesktop.org>
> >     > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >     >
> >
> >
> >
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120614/45c1614b/attachment-0001.htm>


More information about the mesa-dev mailing list