On 14 June 2012 09:02, Roland Scheidegger <span dir="ltr">&lt;<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>&gt;</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">&gt; On 14 June 2012 05:10, Jose Fonseca &lt;<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     lp_build_utrunc() doesn&#39;t exists yet.  For now, please use<br>
&gt;     lp_build_itrunc() and add a /* FIXME: implement and use<br>
&gt;     lp_build_utrunc() */ comment. It&#39;s not perfect, but it&#39;s no worse<br>
&gt;     what&#39;s there now.<br>
&gt;<br>
&gt;     Jose<br>
&gt;<br>
&gt;<br>
&gt; Ok, will do.  Thank you.<br>
</div>btw I&#39;m wondering how you&#39;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&#39;t really the solution :-).<br></blockquote><div><br>Playing around with gcc, it looks like it generally achieves float-&gt;unsigned conversions by first converting to a 64-bit integer (using the &quot;fistpq&quot; instruction on x86, or &quot;cvttss2siq&quot; 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>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     ----- Original Message -----<br>
&gt;     &gt; ---<br>
&gt;     &gt;  src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c |   12<br>
&gt;     &gt;  ++++++++++++<br>
&gt;     &gt;  1 files changed, 12 insertions(+), 0 deletions(-)<br>
&gt;     &gt;<br>
&gt;     &gt; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
&gt;     &gt; b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
&gt;     &gt; index e0a5180..e48a0fd 100644<br>
&gt;     &gt; --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
&gt;     &gt; +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c<br>
&gt;     &gt; @@ -984,6 +984,17 @@ f2i_emit_cpu(<br>
&gt;     &gt;<br>
&gt;      emit_data-&gt;args[0]);<br>
&gt;     &gt;  }<br>
&gt;     &gt;<br>
&gt;     &gt; +/* TGSI_OPCODE_F2U (CPU Only) */<br>
&gt;     &gt; +static void<br>
&gt;     &gt; +f2u_emit_cpu(<br>
&gt;     &gt; +   const struct lp_build_tgsi_action * action,<br>
&gt;     &gt; +   struct lp_build_tgsi_context * bld_base,<br>
&gt;     &gt; +   struct lp_build_emit_data * emit_data)<br>
&gt;     &gt; +{<br>
&gt;     &gt; +   emit_data-&gt;output[emit_data-&gt;chan] =<br>
&gt;     &gt; lp_build_utrunc(&amp;bld_base-&gt;base,<br>
&gt;     &gt; +<br>
&gt;     &gt;<br>
&gt;      emit_data-&gt;args[0]);<br>
&gt;     &gt; +}<br>
&gt;     &gt; +<br>
&gt;     &gt;  /* TGSI_OPCODE_FLR (CPU Only) */<br>
&gt;     &gt;<br>
&gt;     &gt;  static void<br>
&gt;     &gt; @@ -1561,6 +1572,7 @@ lp_set_default_actions_cpu(<br>
&gt;     &gt;     bld_base-&gt;op_actions[TGSI_OPCODE_EX2].emit = ex2_emit_cpu;<br>
&gt;     &gt;     bld_base-&gt;op_actions[TGSI_OPCODE_EXP].emit = exp_emit_cpu;<br>
&gt;     &gt;     bld_base-&gt;op_actions[TGSI_OPCODE_F2I].emit = f2i_emit_cpu;<br>
&gt;     &gt; +   bld_base-&gt;op_actions[TGSI_OPCODE_F2U].emit = f2u_emit_cpu;<br>
&gt;     &gt;     bld_base-&gt;op_actions[TGSI_OPCODE_FLR].emit = flr_emit_cpu;<br>
&gt;     &gt;<br>
&gt;     &gt;     bld_base-&gt;op_actions[TGSI_OPCODE_I2F].emit = i2f_emit_cpu;<br>
&gt;     &gt; --<br>
&gt;     &gt; 1.7.7.6<br>
&gt;     &gt;<br>
&gt;     &gt; _______________________________________________<br>
&gt;     &gt; mesa-dev mailing list<br>
</div></div>&gt;     &gt; <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a> &lt;mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>&gt;<br>
&gt;     &gt; <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">&gt;     &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; mesa-dev mailing list<br>
&gt; <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
&gt; <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>