nir: Add another index to load_uniform to specify the range read
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 24 Nov 2015 21:52:49 +0000 (13:52 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 14 Dec 2015 22:28:31 +0000 (14:28 -0800)
src/glsl/nir/nir_intrinsics.h
src/glsl/nir/nir_lower_io.c

index 9811fb391debd546354796f264e79d7751128e6f..5b10423078d8ad7fbe833052de72977066f349ca 100644 (file)
@@ -263,6 +263,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.
  *
@@ -275,8 +278,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[] = { base } */
index 3d646eb14b4a4a84a08c2b1ce85f494ca8330667..c1f034ba59866b8a715738c521120e3d726a7664 100644 (file)
@@ -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);