nir: add nir_texop_sampler_descriptor_amd
authorMarek Olšák <marek.olsak@amd.com>
Fri, 28 Oct 2022 12:32:02 +0000 (08:32 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 13 Dec 2022 20:33:05 +0000 (20:33 +0000)
We'll use it to query the min/mag filter in the shader.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19422>

src/amd/llvm/ac_nir_to_llvm.c
src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_print.c
src/compiler/nir/nir_validate.c
src/compiler/spirv/spirv_to_nir.c

index 7e89d45..89b1af3 100644 (file)
@@ -4767,13 +4767,19 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
 
    /* Don't use the waterfall loop when returning a descriptor. */
    tex_fetch_ptrs(ctx, instr, wctx, &args.resource, &args.sampler, &fmask_ptr,
-                  instr->op != nir_texop_descriptor_amd);
+                  instr->op != nir_texop_descriptor_amd &&
+                  instr->op != nir_texop_sampler_descriptor_amd);
 
    if (instr->op == nir_texop_descriptor_amd) {
       result = args.resource;
       goto write_result;
    }
 
+   if (instr->op == nir_texop_sampler_descriptor_amd) {
+      result = args.sampler;
+      goto write_result;
+   }
+
    for (unsigned i = 0; i < instr->num_srcs; i++) {
       switch (instr->src[i].src_type) {
       case nir_tex_src_coord: {
index 5983274..c579755 100644 (file)
@@ -3237,6 +3237,9 @@ nir_tex_instr_result_size(const nir_tex_instr *instr)
    case nir_texop_descriptor_amd:
       return instr->sampler_dim == GLSL_SAMPLER_DIM_BUF ? 4 : 8;
 
+   case nir_texop_sampler_descriptor_amd:
+      return 4;
+
    default:
       if (instr->is_shadow && instr->is_new_style_shadow)
          return 1;
@@ -3254,6 +3257,7 @@ nir_tex_instr_is_query(const nir_tex_instr *instr)
    case nir_texop_texture_samples:
    case nir_texop_query_levels:
    case nir_texop_descriptor_amd:
+   case nir_texop_sampler_descriptor_amd:
       return true;
    case nir_texop_tex:
    case nir_texop_txb:
index d81c04a..0a551ad 100644 (file)
@@ -2198,6 +2198,7 @@ typedef enum {
    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_sampler_descriptor_amd, /**< Returns a sampler descriptor. */
 } nir_texop;
 
 /** Represents a texture instruction */
index dd1b1d2..da56f7e 100644 (file)
@@ -1275,6 +1275,9 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
    case nir_texop_descriptor_amd:
       fprintf(fp, "descriptor_amd ");
       break;
+   case nir_texop_sampler_descriptor_amd:
+      fprintf(fp, "sampler_descriptor_amd ");
+      break;
    default:
       unreachable("Invalid texture operation");
       break;
index 14af0e6..166dca8 100644 (file)
@@ -900,6 +900,7 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)
                                 glsl_type_is_sampler(deref->type));
          switch (instr->op) {
          case nir_texop_descriptor_amd:
+         case nir_texop_sampler_descriptor_amd:
             break;
          case nir_texop_lod:
             validate_assert(state, nir_alu_type_get_base_type(instr->dest_type) == nir_type_float);
index 5f60227..5dbd90c 100644 (file)
@@ -2844,7 +2844,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
       vtn_fail("unexpected nir_texop_tex_prefetch");
       break;
    case nir_texop_descriptor_amd:
-      vtn_fail("unexpected nir_texop_descriptor_amd");
+   case nir_texop_sampler_descriptor_amd:
+      vtn_fail("unexpected nir_texop_*descriptor_amd");
       break;
    }