[Mesa-dev] [PATCH v2 53/82] nir: implement ir_ssbo_store

Iago Toral Quiroga itoral at igalia.com
Wed Jun 3 00:01:43 PDT 2015


---
 src/glsl/nir/glsl_to_nir.cpp  | 18 +++++++++++++++++-
 src/glsl/nir/nir_intrinsics.h | 12 ++++++------
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index d2c474a..647aa34 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -577,7 +577,23 @@ nir_visitor::visit(ir_end_primitive *ir)
 void
 nir_visitor::visit(ir_ssbo_store *ir)
 {
-   assert("Not implemented yet");
+   nir_intrinsic_op op;
+   ir_constant *const_offset = ir->offset->as_constant();
+   if (const_offset) {
+      op = nir_intrinsic_store_ssbo;
+   } else {
+      op = nir_intrinsic_store_ssbo_indirect;
+   }
+
+   nir_intrinsic_instr *store = nir_intrinsic_instr_create(this->shader, op);
+   store->num_components = ir->val->type->vector_elements;
+   store->const_index[0] = const_offset ? const_offset->value.u[0] : 0;
+   store->const_index[1] = ir->write_mask;
+   store->src[0] = evaluate_rvalue(ir->val);
+   store->src[1] = evaluate_rvalue(ir->block);
+   if (!const_offset)
+      store->src[2] = evaluate_rvalue(ir->offset);
+   add_instr(&store->instr, ir->val->type->vector_elements);
 }
 
 void
diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h
index 2351db3..82f59d7 100644
--- a/src/glsl/nir/nir_intrinsics.h
+++ b/src/glsl/nir/nir_intrinsics.h
@@ -175,12 +175,12 @@ LOAD(input, 0, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
  * offset.
  */
 
-#define STORE(name, num_indices, flags) \
-   INTRINSIC(store_##name, 1, ARR(0), false, 0, 0, num_indices, flags) \
-   INTRINSIC(store_##name##_indirect, 2, ARR(0, 1), false, 0, 0, \
+#define STORE(name, extra_srcs, num_indices, flags) \
+   INTRINSIC(store_##name, extra_srcs, ARR(0, 1), false, 0, 0, num_indices, flags) \
+   INTRINSIC(store_##name##_indirect, extra_srcs + 1, ARR(0, 1, 1), false, 0, 0, \
              num_indices, flags) \
 
-STORE(output, 1, 0)
-/* STORE(ssbo, 2, 0) */
+STORE(output, 1, 2, 0)
+STORE(ssbo, 2, 2, 0)
 
-LAST_INTRINSIC(store_output_indirect)
+LAST_INTRINSIC(store_ssbo_indirect)
-- 
1.9.1



More information about the mesa-dev mailing list