From 1545dc94b4f871caf75bf64cf45c571ba2ee5e1f Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Tue, 7 May 2024 12:01:23 +0200 Subject: [PATCH] broadcom/compiler: simplify v3d_vir_emit_tex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the past where backends had to deal with nir_register we needed a specific path for them here because nir_def_components_read only worked on ssa defs, but now that we got rid of nir_register we only have nir_def and we don't need to go out of our way to do this and we can just always use nir_def_components_read. Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/compiler/v3d_tex.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/broadcom/compiler/v3d_tex.c b/src/broadcom/compiler/v3d_tex.c index 0cde2014423..52035d23318 100644 --- a/src/broadcom/compiler/v3d_tex.c +++ b/src/broadcom/compiler/v3d_tex.c @@ -248,29 +248,9 @@ v3d_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr) /* Limit the number of channels returned to both how many the NIR * instruction writes and how many the instruction could produce. */ - nir_intrinsic_instr *store = nir_store_reg_for_def(&instr->def); - if (store == NULL) { - p0_unpacked.return_words_of_texture_data = - nir_def_components_read(&instr->def); - } else { - nir_def *reg = store->src[1].ssa; - nir_intrinsic_instr *decl = nir_reg_get_decl(reg); - unsigned reg_num_components = - nir_intrinsic_num_components(decl); - - /* For the non-ssa case we don't have a full equivalent to - * nir_def_components_read. This is a problem for the 16 - * bit case. nir_lower_tex will not change the destination as - * nir_tex_instr_dest_size will still return 4. The driver is - * just expected to not store on other channels, so we - * manually ensure that here. - */ - uint32_t num_components = output_type_32_bit ? - MIN2(reg_num_components, 4) : - MIN2(reg_num_components, 2); - - p0_unpacked.return_words_of_texture_data = (1 << num_components) - 1; - } + uint32_t components_read = nir_def_components_read(&instr->def); + p0_unpacked.return_words_of_texture_data = output_type_32_bit ? + (components_read & 0xf): (components_read & 0x3); assert(p0_unpacked.return_words_of_texture_data != 0); struct V3D42_TMU_CONFIG_PARAMETER_2 p2_unpacked = {