[Mesa-dev] [PATCH 2/7] st/glsl_to_tgsi: implement shader_group_vote and shader_ballot intrinsics

Nicolai Hähnle nhaehnle at gmail.com
Wed Apr 19 08:56:48 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 36 ++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 4a92cab..2517a05 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -477,20 +477,21 @@ public:
    virtual void visit(ir_barrier *);
    /*@}*/
 
    void visit_expression(ir_expression *, st_src_reg *) ATTRIBUTE_NOINLINE;
 
    void visit_atomic_counter_intrinsic(ir_call *);
    void visit_ssbo_intrinsic(ir_call *);
    void visit_membar_intrinsic(ir_call *);
    void visit_shared_intrinsic(ir_call *);
    void visit_image_intrinsic(ir_call *);
+   void visit_generic_intrinsic(ir_call *, unsigned op);
 
    st_src_reg result;
 
    /** List of variable_storage */
    exec_list variables;
 
    /** List of immediate_storage */
    exec_list immediates;
    unsigned num_immediates;
 
@@ -3907,20 +3908,42 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
 
    if (imgvar->data.image_coherent)
       inst->buffer_access |= TGSI_MEMORY_COHERENT;
    if (imgvar->data.image_restrict)
       inst->buffer_access |= TGSI_MEMORY_RESTRICT;
    if (imgvar->data.image_volatile)
       inst->buffer_access |= TGSI_MEMORY_VOLATILE;
 }
 
 void
+glsl_to_tgsi_visitor::visit_generic_intrinsic(ir_call *ir, unsigned op)
+{
+   ir->return_deref->accept(this);
+   st_dst_reg dst = st_dst_reg(this->result);
+
+   st_src_reg src[4] = { undef_src, undef_src, undef_src, undef_src };
+   unsigned num_src = 0;
+   foreach_in_list(ir_rvalue, param, &ir->actual_parameters) {
+      assert(num_src < ARRAY_SIZE(src));
+
+      this->result.file = PROGRAM_UNDEFINED;
+      param->accept(this);
+      assert(this->result.file != PROGRAM_UNDEFINED);
+
+      src[num_src] = this->result;
+      num_src++;
+   }
+
+   emit_asm(ir, op, dst, src[0], src[1], src[2], src[3]);
+}
+
+void
 glsl_to_tgsi_visitor::visit(ir_call *ir)
 {
    ir_function_signature *sig = ir->callee;
 
    /* Filter out intrinsics */
    switch (sig->intrinsic_id) {
    case ir_intrinsic_atomic_counter_read:
    case ir_intrinsic_atomic_counter_increment:
    case ir_intrinsic_atomic_counter_predecrement:
    case ir_intrinsic_atomic_counter_add:
@@ -3988,25 +4011,38 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
       ir->return_deref->accept(this);
 
       st_dst_reg dst = st_dst_reg(this->result);
       dst.writemask = TGSI_WRITEMASK_XY;
 
       emit_asm(ir, TGSI_OPCODE_CLOCK, dst);
       return;
    }
 
    case ir_intrinsic_vote_all:
+      visit_generic_intrinsic(ir, TGSI_OPCODE_VOTE_ALL);
+      return;
    case ir_intrinsic_vote_any:
+      visit_generic_intrinsic(ir, TGSI_OPCODE_VOTE_ANY);
+      return;
    case ir_intrinsic_vote_eq:
+      visit_generic_intrinsic(ir, TGSI_OPCODE_VOTE_EQ);
+      return;
    case ir_intrinsic_ballot:
+      visit_generic_intrinsic(ir, TGSI_OPCODE_BALLOT);
+      return;
    case ir_intrinsic_read_first_invocation:
+      visit_generic_intrinsic(ir, TGSI_OPCODE_READ_FIRST);
+      return;
    case ir_intrinsic_read_invocation:
+      visit_generic_intrinsic(ir, TGSI_OPCODE_READ_INVOC);
+      return;
+
    case ir_intrinsic_invalid:
    case ir_intrinsic_generic_load:
    case ir_intrinsic_generic_store:
    case ir_intrinsic_generic_atomic_add:
    case ir_intrinsic_generic_atomic_and:
    case ir_intrinsic_generic_atomic_or:
    case ir_intrinsic_generic_atomic_xor:
    case ir_intrinsic_generic_atomic_min:
    case ir_intrinsic_generic_atomic_max:
    case ir_intrinsic_generic_atomic_exchange:
-- 
2.9.3



More information about the mesa-dev mailing list