From 44325c40a253395b463ebde85b288adbf691b430 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 6 May 2026 12:37:22 +0200 Subject: [PATCH] asahi: fix compute blitter for float16 image copies Fixes OpenCL CTS clCopyImage tests with CL_HALF_FLOAT --- src/gallium/drivers/asahi/agx_blit.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_blit.c b/src/gallium/drivers/asahi/agx_blit.c index 5d770ef1ab7..1ea7a572abb 100644 --- a/src/gallium/drivers/asahi/agx_blit.c +++ b/src/gallium/drivers/asahi/agx_blit.c @@ -111,6 +111,13 @@ asahi_blit_compute_shader(struct pipe_context *ctx, struct asahi_blit_key *key) nir_iand(b, in_bounds, nir_ilt(b, logical_id_el_2d, dimensions_el_2d)); } + unsigned bit_size = 32; + nir_alu_type dst_type = nir_type_uint32; + if (util_format_is_float16(key->dst_format)) { + bit_size = 16; + dst_type = nir_type_float16; + } + nir_def *colour0, *colour1; nir_push_if(b, nir_ball(b, in_bounds)); { @@ -127,15 +134,15 @@ asahi_blit_compute_shader(struct pipe_context *ctx, struct asahi_blit_key *key) colour0 = nir_tex(b, coords_el_nd, .texture_index = 0, .sampler_index = 0, .backend_flags = AGX_TEXTURE_FLAG_NO_CLAMP, .dim = GLSL_SAMPLER_DIM_2D, .is_array = key->array, - .dest_type = nir_type_uint32); + .dest_type = dst_type); } nir_push_else(b, NULL); { /* For out-of-bounds pixels, copy in the destination */ colour1 = nir_image_load( - b, 4, 32, nir_imm_int(b, 0), nir_pad_vec4(b, image_pos_nd), zero, zero, + b, 4, bit_size, nir_imm_int(b, 0), nir_pad_vec4(b, image_pos_nd), zero, zero, .image_array = key->array, .image_dim = GLSL_SAMPLER_DIM_2D, - .access = ACCESS_IN_BOUNDS, .dest_type = nir_type_uint32); + .access = ACCESS_IN_BOUNDS, .dest_type = dst_type); } nir_pop_if(b, NULL); nir_def *color = nir_if_phi(b, colour0, colour1);