<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Oct 22, 2018 at 6:13 PM Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Oct 22, 2018 at 6:16 PM Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>> wrote:<br>
><br>
> This should be useful for drivers that don't support real integers.<br>
><br>
> Cc: Alyssa Rosenzweig <<a href="mailto:alyssa@rosenzweig.io" target="_blank">alyssa@rosenzweig.io</a>><br>
> ---<br>
>  src/compiler/Makefile.sources              |   1 +<br>
>  src/compiler/nir/meson.build               |   1 +<br>
>  src/compiler/nir/nir_lower_bool_to_float.c | 181 +++++++++++++++++++++<br>
>  3 files changed, 183 insertions(+)<br>
>  create mode 100644 src/compiler/nir/nir_lower_bool_to_float.c<br>
> +   nir_foreach_block(block, impl) {<br>
> +      nir_foreach_instr_safe(instr, block) {<br>
> +         switch (instr->type) {<br>
> +         case nir_instr_type_alu:<br>
> +            progress |= lower_alu_instr(&b, nir_instr_as_alu(instr));<br>
> +            break;<br>
> +<br>
> +         case nir_instr_type_load_const: {<br>
> +            nir_load_const_instr *load = nir_instr_as_load_const(instr);<br>
> +            if (load->def.bit_size == 1) {<br>
> +               nir_const_value value = load->value;<br>
> +               for (unsigned i = 0; i < load->def.num_components; i++)<br>
> +                  load->value.u32[i] = value.b[i] ? NIR_TRUE : NIR_FALSE;<br>
> +               load->def.bit_size = 32;<br>
> +               progress = true;<br>
> +            }<br>
> +            break;<br>
> +         }<br>
<br>
Should this instead rewrite the load_const to a 1.0f / 0.0f?<br></blockquote><div><br></div><div>Yup.  As you can tell, this is completely untested.  However, I think it does make the point that 1-bit bools aren't bad for float-only hardware which is why I did it.  I've fixed the bugs pointed out so far.</div><div><br></div><div>--Jason<br></div></div></div>