<div dir="ltr"><div>SM3 hardware does have NaNs. Anyway, I'd like to have this SM3-specific behavior of TGSI_OPCODE_IF properly documented. We already generate different TGSI code for SM3 and SM4+ and there'll be much more differences in how things are done in the future (e.g. temporaries could be used in place of address registers in SM4, but not SM3).<br>
<br></div>Marek<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 11, 2013 at 10:12 PM, Roland Scheidegger <span dir="ltr"><<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Everything emitting those opcodes always assumed this is some sort of<br>
boolean until now, so treating them as floats always was sketchy. Note<br>
that the differences to treating them as uints or floats for comparisons<br>
to zero isn't large, it's the same for everything except -0.0 and NaNs,<br>
and I suspect hw which doesn't have integers doesn't have NaNs neither.<br>
Which would leave the -0.0 case but unless you happened to encode<br>
results of comparisons as -0.0 there should not be a problem neither -<br>
obviously this would not work for state trackers which really require<br>
the input be treated as uint but that should only ever affect things<br>
which require integers anyway I think.<br>
<br>
Roland<br>
<br>
Am 11.04.2013 21:31, schrieb Marek Olšák:<br>
<div class="im">> What about drivers without integer support? The IF instruction should<br>
> have 2 definitions: one for the drivers which support<br>
> PIPE_SHADER_CAP_INTEGERS, and the other one for those which don't.<br>
> Obviously, there is no way to change the behavior of the IF opcode if<br>
> you only have floats.<br>
><br>
> Marek<br>
><br>
><br>
> On Thu, Apr 11, 2013 at 5:20 AM, Zack Rusin <<a href="mailto:zackr@vmware.com">zackr@vmware.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:zackr@vmware.com">zackr@vmware.com</a>>> wrote:<br>
><br>
> As implemented in tgsi_exec they both test src operands on the bit<br>
> level and don't do floating point comperisons as some thought.<br>
> This documents them as such to avoid future confusion and fixes<br>
> their implementation in llvmpipe.<br>
><br>
> Could gallium driver developers make sure that they're handling<br>
> those instrunctions correctly? From my quick glance it seems<br>
> to be ok, but I don't know those codebases at all.<br>
><br>
</div>> Signed-off-by: Zack Rusin <<a href="mailto:zackr@vmware.com">zackr@vmware.com</a> <mailto:<a href="mailto:zackr@vmware.com">zackr@vmware.com</a>>><br>
<div><div class="h5">> ---<br>
> src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 10 ++++------<br>
> src/gallium/auxiliary/tgsi/tgsi_info.c | 2 ++<br>
> src/gallium/docs/source/tgsi.rst | 16 ++++++++++------<br>
> 3 files changed, 16 insertions(+), 12 deletions(-)<br>
><br>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c<br>
> b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c<br>
> index 853de09..8a29635 100644<br>
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c<br>
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c<br>
> @@ -2370,12 +2370,9 @@ breakc_emit(<br>
> struct lp_build_emit_data * emit_data)<br>
> {<br>
> struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base);<br>
> - LLVMBuilderRef builder = bld_base->base.gallivm->builder;<br>
> struct lp_build_context *uint_bld = &bld_base->uint_bld;<br>
> - LLVMValueRef unsigned_cond =<br>
> - LLVMBuildBitCast(builder, emit_data->args[0],<br>
> uint_bld->vec_type, "");<br>
> LLVMValueRef cond = lp_build_cmp(uint_bld, PIPE_FUNC_NOTEQUAL,<br>
> - unsigned_cond,<br>
> + emit_data->args[0],<br>
> uint_bld->zero);<br>
><br>
> lp_exec_break_condition(&bld->exec_mask, cond);<br>
> @@ -2389,9 +2386,10 @@ if_emit(<br>
> {<br>
> LLVMValueRef tmp;<br>
> struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base);<br>
> + struct lp_build_context *uint_bld = &bld_base->uint_bld;<br>
><br>
> - tmp = lp_build_cmp(&bld_base->base, PIPE_FUNC_NOTEQUAL,<br>
> - emit_data->args[0], bld->bld_base.base.zero);<br>
> + tmp = lp_build_cmp(uint_bld, PIPE_FUNC_NOTEQUAL,<br>
> + emit_data->args[0], uint_bld->zero);<br>
> lp_exec_mask_cond_push(&bld->exec_mask, tmp);<br>
> }<br>
><br>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c<br>
> b/src/gallium/auxiliary/tgsi/tgsi_info.c<br>
> index 1fadfec..f488351 100644<br>
> --- a/src/gallium/auxiliary/tgsi/tgsi_info.c<br>
> +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c<br>
> @@ -297,6 +297,8 @@ tgsi_opcode_infer_src_type( uint opcode )<br>
> case TGSI_OPCODE_TXF:<br>
> case TGSI_OPCODE_SAMPLE_I:<br>
> case TGSI_OPCODE_SAMPLE_I_MS:<br>
> + case TGSI_OPCODE_IF:<br>
> + case TGSI_OPCODE_BREAKC:<br>
> return TGSI_TYPE_UNSIGNED;<br>
> case TGSI_OPCODE_MOD:<br>
> case TGSI_OPCODE_I2F:<br>
> diff --git a/src/gallium/docs/source/tgsi.rst<br>
> b/src/gallium/docs/source/tgsi.rst<br>
> index 28308cb..e6d97d6 100644<br>
> --- a/src/gallium/docs/source/tgsi.rst<br>
> +++ b/src/gallium/docs/source/tgsi.rst<br>
> @@ -863,10 +863,19 @@ This instruction replicates its result.<br>
><br>
> TBD<br>
><br>
> +<br>
> +.. opcode:: BREAKC - Break Conditional<br>
> +<br>
> + Conditionally moves the point of execution to the instruction<br>
> after the<br>
> + next endloop or endswitch. The instruction must appear within a<br>
> loop/endloop<br>
> + or switch/endswitch. The 32-bit register supplied by src0 is<br>
> tested at a<br>
> + bit level (treat it as unsigned).<br>
> +<br>
><br>
> .. opcode:: IF - If<br>
><br>
> - TBD<br>
> + Branch based on logical OR result. The 32-bit register supplied<br>
> by src0 is<br>
> + tested at a bit level. If any bit is nonzero, it will evaluate to<br>
> true.<br>
><br>
><br>
> .. opcode:: ELSE - Else<br>
> @@ -1202,11 +1211,6 @@ XXX wait what<br>
><br>
> TBD<br>
><br>
> -<br>
> -.. opcode:: BREAKC - Break Conditional<br>
> -<br>
> - TBD<br>
> -<br>
> .. _doubleopcodes:<br>
><br>
> Double ISA<br>
> --<br>
> 1.7.10.4<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>
> 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></div>