diff --git a/src/compiler/nir/nir_lower_printf.c b/src/compiler/nir/nir_lower_printf.c index 3263c001691..2997012a7f9 100644 --- a/src/compiler/nir/nir_lower_printf.c +++ b/src/compiler/nir/nir_lower_printf.c @@ -311,8 +311,11 @@ void nir_printf_fmt_at_px(nir_builder *b, unsigned ptr_bit_size, unsigned x_px, { va_list ap; - nir_def *xy_px = nir_f2u32(b,nir_load_frag_coord(b)); - nir_def *is_at_px = nir_ball_iequal(b, nir_imm_ivec2(b, x_px, y_px), xy_px); + nir_def *xy_px = b->shader->options->has_pixel_coord ? + nir_load_pixel_coord(b) : nir_f2u32(b, nir_load_frag_coord(b)); + nir_def *is_at_px = b->shader->options->has_pixel_coord ? + nir_ball_iequal(b, nir_imm_uvec2_intN(b, x_px, y_px, 16), xy_px) : + nir_ball_iequal(b, nir_imm_ivec2(b, x_px, y_px), xy_px); nir_push_if(b, is_at_px); va_start(ap, fmt); diff --git a/src/compiler/nir/nir_shader_compiler_options.h b/src/compiler/nir/nir_shader_compiler_options.h index 36565059ba6..aca07312a77 100644 --- a/src/compiler/nir/nir_shader_compiler_options.h +++ b/src/compiler/nir/nir_shader_compiler_options.h @@ -612,6 +612,9 @@ typedef struct nir_shader_compiler_options { /** Backend supports pack_32_4x8 or pack_32_4x8_split. */ bool has_pack_32_4x8; + /** Backend supports nir_load_pixel_coord */ + bool has_pixel_coord; + /** Backend supports nir_load_texture_scale and prefers it over txs for nir * lowerings. */ bool has_texture_scaling;