Mesa (master): nir: Add texture sources and intrinsics for bindless

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 25 21:12:36 UTC 2019


Module: Mesa
Branch: master
Commit: 40074ebf743326a1b8ca3be36512db0978de6aac
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=40074ebf743326a1b8ca3be36512db0978de6aac

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Sun Oct 28 07:52:44 2018 -0500

nir: Add texture sources and intrinsics for bindless

On Intel, we have both bindless and bindful and we'd like to use them at
the same time if we can so we need to be able to distinguish at the NIR
level between the two.  This also fixes nir_lower_tex to properly handle
bindless in its tex_texture_size and get_texture_lod helpers.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

---

 src/compiler/nir/nir.h             |  2 ++
 src/compiler/nir/nir_intrinsics.py | 15 +++++++++------
 src/compiler/nir/nir_lower_tex.c   | 16 ++++++++++++----
 src/compiler/nir/nir_print.c       |  6 ++++++
 4 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 40c5dcfe4ac..e53b501d959 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1434,6 +1434,8 @@ typedef enum {
    nir_tex_src_sampler_deref, /* < deref pointing to the sampler */
    nir_tex_src_texture_offset, /* < dynamically uniform indirect offset */
    nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset */
+   nir_tex_src_texture_handle, /* < bindless texture handle */
+   nir_tex_src_sampler_handle, /* < bindless sampler handle */
    nir_tex_src_plane,          /* < selects plane for planar textures */
    nir_num_tex_src_types
 } nir_tex_src_type;
diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py
index ea092a991ca..148628645d0 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -306,12 +306,13 @@ atomic3("atomic_counter_comp_swap")
 
 # Image load, store and atomic intrinsics.
 #
-# All image intrinsics come in two versions.  One which take an image target
-# passed as a deref chain as the first source and one which takes an index or
-# handle as the first source.  In the first version, the image variable
-# contains the memory and layout qualifiers that influence the semantics of
-# the intrinsic.  In the second, the image format and access qualifiers are
-# provided as constant indices.
+# All image intrinsics come in three versions.  One which take an image target
+# passed as a deref chain as the first source, one which takes an index as the
+# first source, and one which takes a bindless handle as the first source.
+# In the first version, the image variable contains the memory and layout
+# qualifiers that influence the semantics of the intrinsic.  In the second and
+# third, the image format and access qualifiers are provided as constant
+# indices.
 #
 # All image intrinsics take a four-coordinate vector and a sample index as
 # 2nd and 3rd sources, determining the location within the image that will be
@@ -324,6 +325,8 @@ def image(name, src_comp=[], **kwargs):
     intrinsic("image_deref_" + name, src_comp=[1] + src_comp, **kwargs)
     intrinsic("image_" + name, src_comp=[1] + src_comp,
               indices=[IMAGE_DIM, IMAGE_ARRAY, FORMAT, ACCESS], **kwargs)
+    intrinsic("bindless_image_" + name, src_comp=[1] + src_comp,
+              indices=[IMAGE_DIM, IMAGE_ARRAY, FORMAT, ACCESS], **kwargs)
 
 image("load", src_comp=[4, 1], dest_comp=0, flags=[CAN_ELIMINATE])
 image("store", src_comp=[4, 1, 0])
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index 05d5a40f72c..eee1b3105d5 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -114,7 +114,9 @@ get_texture_size(nir_builder *b, nir_tex_instr *tex)
       if (tex->src[i].src_type == nir_tex_src_texture_deref ||
           tex->src[i].src_type == nir_tex_src_sampler_deref ||
           tex->src[i].src_type == nir_tex_src_texture_offset ||
-          tex->src[i].src_type == nir_tex_src_sampler_offset)
+          tex->src[i].src_type == nir_tex_src_sampler_offset ||
+          tex->src[i].src_type == nir_tex_src_texture_handle ||
+          tex->src[i].src_type == nir_tex_src_sampler_handle)
          num_srcs++;
    }
 
@@ -133,7 +135,9 @@ get_texture_size(nir_builder *b, nir_tex_instr *tex)
       if (tex->src[i].src_type == nir_tex_src_texture_deref ||
           tex->src[i].src_type == nir_tex_src_sampler_deref ||
           tex->src[i].src_type == nir_tex_src_texture_offset ||
-          tex->src[i].src_type == nir_tex_src_sampler_offset) {
+          tex->src[i].src_type == nir_tex_src_sampler_offset ||
+          tex->src[i].src_type == nir_tex_src_texture_handle ||
+          tex->src[i].src_type == nir_tex_src_sampler_handle) {
          nir_src_copy(&txs->src[idx].src, &tex->src[i].src, txs);
          txs->src[idx].src_type = tex->src[i].src_type;
          idx++;
@@ -163,7 +167,9 @@ get_texture_lod(nir_builder *b, nir_tex_instr *tex)
           tex->src[i].src_type == nir_tex_src_texture_deref ||
           tex->src[i].src_type == nir_tex_src_sampler_deref ||
           tex->src[i].src_type == nir_tex_src_texture_offset ||
-          tex->src[i].src_type == nir_tex_src_sampler_offset)
+          tex->src[i].src_type == nir_tex_src_sampler_offset ||
+          tex->src[i].src_type == nir_tex_src_texture_handle ||
+          tex->src[i].src_type == nir_tex_src_sampler_handle)
          num_srcs++;
    }
 
@@ -184,7 +190,9 @@ get_texture_lod(nir_builder *b, nir_tex_instr *tex)
           tex->src[i].src_type == nir_tex_src_texture_deref ||
           tex->src[i].src_type == nir_tex_src_sampler_deref ||
           tex->src[i].src_type == nir_tex_src_texture_offset ||
-          tex->src[i].src_type == nir_tex_src_sampler_offset) {
+          tex->src[i].src_type == nir_tex_src_sampler_offset ||
+          tex->src[i].src_type == nir_tex_src_texture_handle ||
+          tex->src[i].src_type == nir_tex_src_sampler_handle) {
          nir_src_copy(&tql->src[idx].src, &tex->src[i].src, tql);
          tql->src[idx].src_type = tex->src[i].src_type;
          idx++;
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 8e714e6666b..3172a3f23b9 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -968,6 +968,12 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
       case nir_tex_src_sampler_offset:
          fprintf(fp, "(sampler_offset)");
          break;
+      case nir_tex_src_texture_handle:
+         fprintf(fp, "(texture_handle)");
+         break;
+      case nir_tex_src_sampler_handle:
+         fprintf(fp, "(sampler_handle)");
+         break;
       case nir_tex_src_plane:
          fprintf(fp, "(plane)");
          break;




More information about the mesa-commit mailing list