From c5de33e48e4054fb7ff62d1d5e990ba6a46df71d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 3 Feb 2025 15:43:24 -0500 Subject: [PATCH] nir: add image_min_lod_agx for EXT_image_view_min_lod emulation. Signed-off-by: Alyssa Rosenzweig Acked-by: Konstantin Seurer Part-of: --- src/compiler/nir/nir.c | 3 +++ src/compiler/nir/nir.h | 2 ++ src/compiler/nir/nir_print.c | 3 +++ src/compiler/nir/nir_validate.c | 4 ++++ src/compiler/spirv/spirv_to_nir.c | 1 + 5 files changed, 13 insertions(+) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 14d52dbd2de..5d308de3f86 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -3167,6 +3167,7 @@ nir_tex_instr_need_sampler(const nir_tex_instr *instr) case nir_texop_texture_samples: case nir_texop_samples_identical: case nir_texop_descriptor_amd: + case nir_texop_image_min_lod_agx: return false; default: return true; @@ -3212,6 +3213,7 @@ nir_tex_instr_result_size(const nir_tex_instr *instr) case nir_texop_samples_identical: case nir_texop_fragment_mask_fetch_amd: case nir_texop_lod_bias_agx: + case nir_texop_image_min_lod_agx: case nir_texop_has_custom_border_color_agx: return 1; @@ -3247,6 +3249,7 @@ nir_tex_instr_is_query(const nir_tex_instr *instr) case nir_texop_descriptor_amd: case nir_texop_sampler_descriptor_amd: case nir_texop_lod_bias_agx: + case nir_texop_image_min_lod_agx: case nir_texop_custom_border_color_agx: case nir_texop_has_custom_border_color_agx: case nir_texop_hdr_dim_nv: diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index e65b7efc432..adb72904e29 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2376,6 +2376,8 @@ typedef enum nir_texop { nir_texop_sampler_descriptor_amd, /** Returns the sampler's LOD bias */ nir_texop_lod_bias_agx, + /** Returns the image view's min LOD */ + nir_texop_image_min_lod_agx, /** Returns a bool indicating that the sampler uses a custom border colour */ nir_texop_has_custom_border_color_agx, /** Returns the sampler's custom border colour (if has_custom_border_agx) */ diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 11900390946..188211cf9b6 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -1772,6 +1772,9 @@ print_tex_instr(nir_tex_instr *instr, print_state *state) case nir_texop_lod_bias_agx: fprintf(fp, "lod_bias_agx "); break; + case nir_texop_image_min_lod_agx: + fprintf(fp, "image_min_lod_agx "); + break; case nir_texop_has_custom_border_color_agx: fprintf(fp, "has_custom_border_color_agx "); break; diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 5504c8d7cee..041578c3848 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -828,6 +828,10 @@ validate_tex_src_texture_deref(nir_tex_instr *instr, validate_state *state, case nir_texop_lod_bias_agx: validate_assert(state, nir_alu_type_get_base_type(instr->dest_type) == nir_type_float); break; + case nir_texop_image_min_lod_agx: + validate_assert(state, instr->dest_type == nir_type_float16 || + instr->dest_type == nir_type_uint16); + break; case nir_texop_samples_identical: case nir_texop_has_custom_border_color_agx: validate_assert(state, nir_alu_type_get_base_type(instr->dest_type) == nir_type_bool); diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 3e3452ab4e4..b3ad9be8e2b 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -3322,6 +3322,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, vtn_fail("unexpected nir_texop_*descriptor_amd"); break; case nir_texop_lod_bias_agx: + case nir_texop_image_min_lod_agx: case nir_texop_custom_border_color_agx: case nir_texop_has_custom_border_color_agx: vtn_fail("unexpected nir_texop_*_agx");