From: Samuel Iglesias Gonsalvez <sigles...@igalia.com>

Signed-off-by: Samuel Iglesias Gonsalvez <sigles...@igalia.com>
---
 src/glsl/nir/glsl_to_nir.cpp  | 10 ++++++++++
 src/glsl/nir/nir_intrinsics.h |  9 +++++++++
 2 files changed, 19 insertions(+)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index f80481b..d2c474a 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -1623,6 +1623,16 @@ nir_visitor::visit(ir_expression *ir)
          instr->src[2].swizzle[i] = 0;
       }
       break;
+   case ir_triop_ssbo_unsized_array_length: {
+      nir_intrinsic_instr *load = nir_intrinsic_instr_create(this->shader,
+                                     nir_intrinsic_ssbo_unsized_array_length);
+      load->num_components = ir->type->vector_elements;
+      load->src[0] = evaluate_rvalue(ir->operands[0]);
+      load->src[1] = evaluate_rvalue(ir->operands[1]);
+      load->src[2] = evaluate_rvalue(ir->operands[2]);
+      add_instr(&load->instr, ir->type->vector_elements);
+      return;
+   }
    case ir_quadop_bitfield_insert:
       instr = emit(nir_op_bitfield_insert, dest_size, srcs);
       for (unsigned i = 0; i < ir->operands[0]->type->vector_elements; i++) {
diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h
index b516830..2351db3 100644
--- a/src/glsl/nir/nir_intrinsics.h
+++ b/src/glsl/nir/nir_intrinsics.h
@@ -62,6 +62,15 @@ INTRINSIC(interp_var_at_offset, 1, ARR(2), true, 0, 1, 0,
           NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
 
 /*
+ * Shared storage buffer's unsized array length calculation. It takes the
+ * SSBO index, unsized array offset inside the shader storage block interface
+ * and stride of unsized array.
+ */
+
+INTRINSIC(ssbo_unsized_array_length, 3, ARR(1), true, 1, 0, 0,
+          NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+
+/*
  * a barrier is an intrinsic with no inputs/outputs but which can't be moved
  * around/optimized in general
  */
-- 
1.9.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to