Mesa (master): nir: Add another index to load_uniform to specify the range read

Jason Ekstrand jekstrand at kemper.freedesktop.org
Thu Apr 14 23:00:41 UTC 2016


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Tue Nov 24 13:52:49 2015 -0800

nir: Add another index to load_uniform to specify the range read

Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/compiler/nir/nir.h            | 7 +++++++
 src/compiler/nir/nir_intrinsics.h | 6 +++++-
 src/compiler/nir/nir_lower_io.c   | 5 +++++
 src/compiler/nir/nir_print.c      | 1 +
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 8067b41..9d48356 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -965,6 +965,12 @@ typedef enum {
     */
    NIR_INTRINSIC_UCP_ID = 4,
 
+   /**
+    * The amount of data, starting from BASE, that this instruction may
+    * access.  This is used to provide bounds if the offset is not constant.
+    */
+   NIR_INTRINSIC_RANGE = 5,
+
    NIR_INTRINSIC_NUM_INDEX_FLAGS,
 
 } nir_intrinsic_index_flag;
@@ -1028,6 +1034,7 @@ INTRINSIC_IDX_ACCESSORS(write_mask, WRMASK, unsigned)
 INTRINSIC_IDX_ACCESSORS(base, BASE, int)
 INTRINSIC_IDX_ACCESSORS(stream_id, STREAM_ID, unsigned)
 INTRINSIC_IDX_ACCESSORS(ucp_id, UCP_ID, unsigned)
+INTRINSIC_IDX_ACCESSORS(range, RANGE, unsigned)
 
 /**
  * \group texture information
diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
index dc7d42c..05507dc 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -293,6 +293,10 @@ SYSTEM_VALUE(helper_invocation, 1, 0, xx, xx, xx)
  * of the start of the variable being loaded and and the offset source is a
  * offset into that variable.
  *
+ * Uniform load operations have a second "range" index that specifies the
+ * range (starting at base) of the data from which we are loading.  If
+ * const_index[1] == 0, then the range is unknown.
+ *
  * Some load operations such as UBO/SSBO load and per_vertex loads take an
  * additional source to specify which UBO/SSBO/vertex to load from.
  *
@@ -306,7 +310,7 @@ SYSTEM_VALUE(helper_invocation, 1, 0, xx, xx, xx)
    INTRINSIC(load_##name, srcs, ARR(1, 1, 1, 1), true, 0, 0, num_indices, idx0, idx1, idx2, flags)
 
 /* src[] = { offset }. const_index[] = { base } */
-LOAD(uniform, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+LOAD(uniform, 1, 2, BASE, RANGE, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
 /* src[] = { buffer_index, offset }. No const_index */
 LOAD(ubo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
 /* src[] = { offset }. const_index[] = { base } */
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index 6840437..6d4a3d8 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -277,6 +277,11 @@ nir_lower_io_block(nir_block *block, void *void_state)
          nir_intrinsic_set_base(load,
             intrin->variables[0]->var->data.driver_location);
 
+         if (load->intrinsic == nir_intrinsic_load_uniform) {
+            nir_intrinsic_set_range(load,
+               state->type_size(intrin->variables[0]->var->type));
+         }
+
          if (per_vertex)
             load->src[0] = nir_src_for_ssa(vertex_index);
 
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 2d3fa27..bbb4edf 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -517,6 +517,7 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
       [NIR_INTRINSIC_WRMASK] = "wrmask",
       [NIR_INTRINSIC_STREAM_ID] = "stream-id",
       [NIR_INTRINSIC_UCP_ID] = "ucp-id",
+      [NIR_INTRINSIC_RANGE] = "range",
    };
    for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
       if (!info->index_map[idx])




More information about the mesa-commit mailing list