[Mesa-dev] [PATCH 01/15] nir: Add another index to load_uniform to specify the range read

Jason Ekstrand jason at jlekstrand.net
Wed Dec 9 20:23:45 PST 2015


---
 src/glsl/nir/nir_intrinsics.h | 7 +++++--
 src/glsl/nir/nir_lower_io.c   | 5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h
index 63df21e..c329a82 100644
--- a/src/glsl/nir/nir_intrinsics.h
+++ b/src/glsl/nir/nir_intrinsics.h
@@ -236,6 +236,9 @@ SYSTEM_VALUE(helper_invocation, 1, 0)
  * 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 index that specifies the size of the
+ * variable being loaded.  If const_index[1] == 0, then the size 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.
  *
@@ -248,8 +251,8 @@ SYSTEM_VALUE(helper_invocation, 1, 0)
 #define LOAD(name, srcs, indices, flags) \
    INTRINSIC(load_##name, srcs, ARR(1, 1, 1, 1), true, 0, 0, indices, flags)
 
-/* src[] = { offset }. const_index[] = { base } */
-LOAD(uniform, 1, 1, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+/* src[] = { offset }. const_index[] = { base, size } */
+LOAD(uniform, 1, 2, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
 /* src[] = { buffer_index, offset }. No const_index */
 LOAD(ubo, 2, 0, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
 /* src[] = { offset }. const_index[0] = { base } */
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index a2723d5..b73ceec 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -216,6 +216,11 @@ nir_lower_io_block(nir_block *block, void *void_state)
          load->const_index[0] =
             intrin->variables[0]->var->data.driver_location;
 
+         if (load->intrinsic == nir_intrinsic_load_uniform) {
+            load->const_index[1] =
+               state->type_size(intrin->variables[0]->var->type);
+         }
+
          if (per_vertex)
             load->src[0] = nir_src_for_ssa(vertex_index);
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list