[Mesa-dev] [RFC 31/31] nir: Add a bool to float32 lowering pass

Ilia Mirkin imirkin at alum.mit.edu
Mon Oct 22 23:13:22 UTC 2018


On Mon, Oct 22, 2018 at 6:16 PM Jason Ekstrand <jason at jlekstrand.net> wrote:
>
> This should be useful for drivers that don't support real integers.
>
> Cc: Alyssa Rosenzweig <alyssa at rosenzweig.io>
> ---
>  src/compiler/Makefile.sources              |   1 +
>  src/compiler/nir/meson.build               |   1 +
>  src/compiler/nir/nir_lower_bool_to_float.c | 181 +++++++++++++++++++++
>  3 files changed, 183 insertions(+)
>  create mode 100644 src/compiler/nir/nir_lower_bool_to_float.c
> +   nir_foreach_block(block, impl) {
> +      nir_foreach_instr_safe(instr, block) {
> +         switch (instr->type) {
> +         case nir_instr_type_alu:
> +            progress |= lower_alu_instr(&b, nir_instr_as_alu(instr));
> +            break;
> +
> +         case nir_instr_type_load_const: {
> +            nir_load_const_instr *load = nir_instr_as_load_const(instr);
> +            if (load->def.bit_size == 1) {
> +               nir_const_value value = load->value;
> +               for (unsigned i = 0; i < load->def.num_components; i++)
> +                  load->value.u32[i] = value.b[i] ? NIR_TRUE : NIR_FALSE;
> +               load->def.bit_size = 32;
> +               progress = true;
> +            }
> +            break;
> +         }

Should this instead rewrite the load_const to a 1.0f / 0.0f?


More information about the mesa-dev mailing list