intel/brw: Move get_nir_def() higher to avoid UNDEF

While extending our backend to handle 16-bit sampler return payloads, we
found that in piglit's arb_texture_view-rendering-formats, the SIMD8 FS
was missing the sampling operation altogether. This was because we were
first emitting the texturing instruction, and then calling
get_nir_def(), which adds an UNDEF instruction when the destination is
smaller than the 32-bit. So the texturing was dead code elimated. Fix
this by calling get_nir_def() earlier.

Thank you to Kenneth Graunke for suggesting and guiding me throughout
this implementation.

Signed-off-by: Sushma Venkatesh Reddy <sushma.venkatesh.reddy@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30447>
This commit is contained in:
Sushma Venkatesh Reddy 2024-07-30 19:27:31 -07:00 committed by Marge Bot
parent 52be72e676
commit ddd9e043dc

View file

@ -8621,6 +8621,8 @@ fs_nir_emit_texture(nir_to_brw_state &ntb,
header_bits |= instr->component << 16;
}
brw_reg nir_def_reg = get_nir_def(ntb, instr->def);
brw_reg dst = bld.vgrf(brw_type_for_nir_type(devinfo, instr->dest_type), 4 + instr->is_sparse);
fs_inst *inst = bld.emit(opcode, dst, srcs, ARRAY_SIZE(srcs));
inst->offset = header_bits;
@ -8664,8 +8666,6 @@ fs_nir_emit_texture(nir_to_brw_state &ntb,
inst->keep_payload_trailing_zeros = true;
}
brw_reg nir_def_reg = get_nir_def(ntb, instr->def);
if (instr->op != nir_texop_query_levels && !instr->is_sparse) {
/* In most cases we can write directly to the result. */
inst->dst = nir_def_reg;