nir: Restrict ufind_msb and ufind_msb_rev to 32- or 64-bit sources

4d802df3aa loosened the type restrictions
on these opcodes to enable support for 64-bit ballot operations.  In
doing so, it enabled 8-bit and 16-bit sizes as well.

It's impossible to get these sizes through GLSL or SPIR-V.  None of the
lowering in nir_opt_algebraic can handle non-32-bit sizes.  Almost no
drivers can handle non-32-bit sizes.

It doesn't seem possible to enforce anything other than "one bit size"
or "all bit sizes" in nir_opcodes.py.  The only way it seems possible to
enforce this is in nir_validate.  This is not ideal, but it be what it
be.

v2: Remove restriction on find_lsb. It is acutally possible to get this
via GLSL by doing findLSB() on a lowp value. findMSB declares its
parameter as highp, so that path is still impossible.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19042>
This commit is contained in:
Ian Romanick
2022-10-12 14:52:19 -07:00
committed by Marge Bot
parent 2d6f48f6ef
commit db6d1edc1b

View File

@@ -386,6 +386,21 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state)
src_bit_size == 64); src_bit_size == 64);
} }
/* In nir_opcodes.py, these are defined to take general uint or int
* sources. However, they're really only defined for 32-bit or 64-bit
* sources. This seems to be the only place to enforce this
* restriction.
*/
switch (instr->op) {
case nir_op_ufind_msb:
case nir_op_ufind_msb_rev:
validate_assert(state, src_bit_size == 32 || src_bit_size == 64);
break;
default:
break;
}
validate_alu_src(instr, i, state); validate_alu_src(instr, i, state);
} }