[Mesa-dev] [RFC 31/31] nir: Add a bool to float32 lowering pass
Jason Ekstrand
jason at jlekstrand.net
Mon Oct 22 23:43:19 UTC 2018
On Mon, Oct 22, 2018 at 6:13 PM Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> 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?
>
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.
--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181022/e73f8743/attachment.html>
More information about the mesa-dev
mailing list