nir/fold_16bit_sampler_conversions: Fix src type mismatches.

Gitlab: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5996
Fixes: fb29cef8 ("nir: add many passes that lower and optimize 16-bit input/outputs and samplers")
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14895>
(cherry picked from commit b5fe1187ec)
This commit is contained in:
Georg Lehmann 2022-02-24 21:35:43 +01:00 committed by Dylan Baker
parent 162dccc199
commit ec60ee3b56
2 changed files with 10 additions and 6 deletions

View file

@ -1980,7 +1980,7 @@
"description": "nir/fold_16bit_sampler_conversions: Fix src type mismatches.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"because_sha": "fb29cef8ddabdd05aeddc5220017bb28a83bb19c"
},
{

View file

@ -460,6 +460,8 @@ nir_fold_16bit_sampler_conversions(nir_shader *nir,
src_alu = nir_instr_as_alu(src);
b.cursor = nir_before_instr(src);
nir_alu_type src_type = nir_tex_instr_src_type(tex, i);
if (src_alu->op == nir_op_mov) {
assert(!"The IR shouldn't contain any movs to make this pass"
" effective.");
@ -470,8 +472,8 @@ nir_fold_16bit_sampler_conversions(nir_shader *nir,
if (nir_op_is_vec(src_alu->op)) {
/* See if the vector is made of f16->f32 opcodes. */
unsigned num = nir_dest_num_components(src_alu->dest.dest);
bool is_f16_to_f32 = true;
bool is_u16_to_u32 = true;
bool is_f16_to_f32 = src_type == nir_type_float;
bool is_u16_to_u32 = src_type & (nir_type_int | nir_type_uint);
for (unsigned comp = 0; comp < num; comp++) {
nir_instr *instr = src_alu->src[comp].src.ssa->parent_instr;
@ -504,9 +506,11 @@ nir_fold_16bit_sampler_conversions(nir_shader *nir,
nir_instr_rewrite_src_ssa(&tex->instr, &tex->src[i].src,
&new_vec->dest.dest.ssa);
changed = true;
} else if (is_f16_to_f32_conversion(&src_alu->instr) ||
is_u16_to_u32_conversion(&src_alu->instr) ||
is_i16_to_i32_conversion(&src_alu->instr)) {
} else if ((is_f16_to_f32_conversion(&src_alu->instr) &&
src_type == nir_type_float) ||
((is_u16_to_u32_conversion(&src_alu->instr) ||
is_i16_to_i32_conversion(&src_alu->instr)) &&
src_type & (nir_type_int | nir_type_uint))) {
/* Handle scalar sources. */
replace_with_mov(&b, &tex->instr, &tex->src[i].src, src_alu);
changed = true;