Module: Mesa
Branch: main
Commit: 3098000e712cb3f06165716ca426079eac221560
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3098000e712cb3f06165716ca426079eac221560

Author: Marek Olšák <[email protected]>
Date:   Wed Jul 20 22:55:04 2022 -0400

nir: add nir_texop_descriptor_amd

AMD will use it to emulate resinfo.

Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17693>

---

 src/compiler/nir/nir.c            | 5 +++++
 src/compiler/nir/nir.h            | 1 +
 src/compiler/spirv/spirv_to_nir.c | 5 +++++
 3 files changed, 11 insertions(+)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 0f181e89120..1e749911e34 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -3215,6 +3215,7 @@ nir_tex_instr_need_sampler(const nir_tex_instr *instr)
    case nir_texop_query_levels:
    case nir_texop_texture_samples:
    case nir_texop_samples_identical:
+   case nir_texop_descriptor_amd:
       return false;
    default:
       return true;
@@ -3260,6 +3261,9 @@ nir_tex_instr_result_size(const nir_tex_instr *instr)
    case nir_texop_fragment_mask_fetch_amd:
       return 1;
 
+   case nir_texop_descriptor_amd:
+      return instr->sampler_dim == GLSL_SAMPLER_DIM_BUF ? 4 : 8;
+
    default:
       if (instr->is_shadow && instr->is_new_style_shadow)
          return 1;
@@ -3276,6 +3280,7 @@ nir_tex_instr_is_query(const nir_tex_instr *instr)
    case nir_texop_lod:
    case nir_texop_texture_samples:
    case nir_texop_query_levels:
+   case nir_texop_descriptor_amd:
       return true;
    case nir_texop_tex:
    case nir_texop_txb:
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index ebc92b474c3..1a09f0118d0 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2154,6 +2154,7 @@ typedef enum {
    nir_texop_tex_prefetch,       /**< Regular texture look-up, eligible for 
pre-dispatch */
    nir_texop_fragment_fetch_amd,      /**< Multisample fragment color texture 
fetch */
    nir_texop_fragment_mask_fetch_amd, /**< Multisample fragment mask texture 
fetch */
+   nir_texop_descriptor_amd,     /**< Returns a buffer or image descriptor. */
 } nir_texop;
 
 /** Represents a texture instruction */
diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index 7c10c9729cf..6e0b54dd246 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -2826,8 +2826,13 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
       break;
    case nir_texop_txf_ms_mcs_intel:
       vtn_fail("unexpected nir_texop_txf_ms_mcs");
+      break;
    case nir_texop_tex_prefetch:
       vtn_fail("unexpected nir_texop_tex_prefetch");
+      break;
+   case nir_texop_descriptor_amd:
+      vtn_fail("unexpected nir_texop_descriptor_amd");
+      break;
    }
 
    unsigned idx = 4;

Reply via email to