On Mon, Oct 22, 2018 at 6:13 PM Ilia Mirkin <imir...@alum.mit.edu> wrote:
> On Mon, Oct 22, 2018 at 6:16 PM Jason Ekstrand <ja...@jlekstrand.net> > wrote: > > > > This should be useful for drivers that don't support real integers. > > > > Cc: Alyssa Rosenzweig <aly...@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
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev