From d1f5953965f06b5e823efac66367c245c03acc08 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 10 Jul 2025 10:16:56 -0400 Subject: [PATCH] freedreno: use tex builder Signed-off-by: Alyssa Rosenzweig Reviewed-by: Konstantin Seurer Part-of: --- .../drivers/freedreno/freedreno_blitter.c | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_blitter.c b/src/gallium/drivers/freedreno/freedreno_blitter.c index 0479aa11bc1..a1e2f3d4f84 100644 --- a/src/gallium/drivers/freedreno/freedreno_blitter.c +++ b/src/gallium/drivers/freedreno/freedreno_blitter.c @@ -177,27 +177,6 @@ build_f16_copy_fs_shader(struct pipe_screen *pscreen, enum pipe_texture_target t if (util_texture_is_array(target)) ncoord++; - nir_tex_instr *tex = nir_tex_instr_create(b->shader, 2); - - tex->op = nir_texop_txf; - - /* Note: since we're just copying data, we rely on the HW ignoring the - * dest_type. Use isaml.3d so that a single shader can handle both 2D - * and 3D cases. - */ - tex->dest_type = nir_type_float16; - tex->is_array = util_texture_is_array(target); - tex->is_shadow = false; - tex->sampler_dim = dim[target]; - tex->coord_components = ncoord; - - tex->texture_index = 0; - tex->sampler_index = 0; - - b->shader->info.num_textures = 1; - BITSET_SET(b->shader->info.textures_used, 0); - BITSET_SET(b->shader->info.textures_used_by_txf, 0); - unsigned swiz[4] = { 0, 1, 2 }; /* tex coords are in components x/y/z, lod in w */ @@ -209,13 +188,20 @@ build_f16_copy_fs_shader(struct pipe_screen *pscreen, enum pipe_texture_target t nir_def *lod = nir_channel(b, nir_f2i32(b, input), 3); nir_def *coord = nir_swizzle(b, nir_f2i32(b, input), swiz, ncoord); - tex->src[0] = nir_tex_src_for_ssa(nir_tex_src_coord, coord); - tex->src[1] = nir_tex_src_for_ssa(nir_tex_src_lod, lod); + /* Note: since we're just copying data, we rely on the HW ignoring the + * dest_type. Use isaml.3d so that a single shader can handle both 2D + * and 3D cases. + */ + nir_def *tex = nir_txf(b, coord, .lod = lod, .texture_index = 0, + .dim = dim[target], + .is_array = util_texture_is_array(target), + .dest_type = nir_type_float16); - nir_def_init(&tex->instr, &tex->def, 4, 16); - nir_builder_instr_insert(b, &tex->instr); + b->shader->info.num_textures = 1; + BITSET_SET(b->shader->info.textures_used, 0); + BITSET_SET(b->shader->info.textures_used_by_txf, 0); - nir_store_var(b, out_color, &tex->def, 0xf); + nir_store_var(b, out_color, tex, 0xf); return b->shader; }