From: Ian Romanick Date: Wed, 12 Oct 2022 21:52:19 +0000 (-0700) Subject: nir: Restrict ufind_msb and ufind_msb_rev to 32- or 64-bit sources X-Git-Tag: upstream/23.3.3~11838 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db6d1edc1b614540d0c558571d5b0b09f7d8adef;p=platform%2Fupstream%2Fmesa.git nir: Restrict ufind_msb and ufind_msb_rev to 32- or 64-bit sources 4d802df3aac353970aae93699223fb15b24f8408 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 Part-of: --- diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 6d25151..40d7829 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -386,6 +386,21 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state) 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); }