On 14 June 2012 09:02, Roland Scheidegger <span dir="ltr"><<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 14.06.2012 15:07, schrieb Paul Berry:<br>
<div class="im">> On 14 June 2012 05:10, Jose Fonseca <<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a>>> wrote:<br>
><br>
> lp_build_utrunc() doesn't exists yet. For now, please use<br>
> lp_build_itrunc() and add a /* FIXME: implement and use<br>
> lp_build_utrunc() */ comment. It's not perfect, but it's no worse<br>
> what's there now.<br>
><br>
> Jose<br>
><br>
><br>
> Ok, will do. Thank you.<br>
</div>btw I'm wondering how you'd actually do that in some semi-efficient manner?<br>
llvm has LLVMBuildFPToUI but x86 has no such conversion instructions<br>
they are all signed. I guess multiply by 0.5, convert to signed int,<br>
cast to unsigned and multiply by 2 isn't really the solution :-).<br></blockquote><div><br>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.<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
<br>
><br>
><br>
><br>
> ----- Original Message -----<br>
> > ---<br>
> > src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 12<br>
> > ++++++++++++<br>
> > 1 files changed, 12 insertions(+), 0 deletions(-)<br>
> ><br>
> > diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
> > b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
> > index e0a5180..e48a0fd 100644<br>
> > --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
> > +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
> > @@ -984,6 +984,17 @@ f2i_emit_cpu(<br>
> ><br>
> emit_data->args[0]);<br>
> > }<br>
> ><br>
> > +/* TGSI_OPCODE_F2U (CPU Only) */<br>
> > +static void<br>
> > +f2u_emit_cpu(<br>
> > + const struct lp_build_tgsi_action * action,<br>
> > + struct lp_build_tgsi_context * bld_base,<br>
> > + struct lp_build_emit_data * emit_data)<br>
> > +{<br>
> > + emit_data->output[emit_data->chan] =<br>
> > lp_build_utrunc(&bld_base->base,<br>
> > +<br>
> ><br>
> emit_data->args[0]);<br>
> > +}<br>
> > +<br>
> > /* TGSI_OPCODE_FLR (CPU Only) */<br>
> ><br>
> > static void<br>
> > @@ -1561,6 +1572,7 @@ lp_set_default_actions_cpu(<br>
> > bld_base->op_actions[TGSI_OPCODE_EX2].emit = ex2_emit_cpu;<br>
> > bld_base->op_actions[TGSI_OPCODE_EXP].emit = exp_emit_cpu;<br>
> > bld_base->op_actions[TGSI_OPCODE_F2I].emit = f2i_emit_cpu;<br>
> > + bld_base->op_actions[TGSI_OPCODE_F2U].emit = f2u_emit_cpu;<br>
> > bld_base->op_actions[TGSI_OPCODE_FLR].emit = flr_emit_cpu;<br>
> ><br>
> > bld_base->op_actions[TGSI_OPCODE_I2F].emit = i2f_emit_cpu;<br>
> > --<br>
> > 1.7.7.6<br>
> ><br>
> > _______________________________________________<br>
> > mesa-dev mailing list<br>
</div></div>> > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a> <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>><br>
> > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<div class="HOEnZb"><div class="h5">> ><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br>