r600/sfn: remove duplicate barriers
authorGert Wollny <gert.wollny@collabora.com>
Mon, 8 Feb 2021 16:32:00 +0000 (17:32 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 22 Feb 2021 20:43:02 +0000 (20:43 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9167>

src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp

index 5006977..76faba1 100644 (file)
@@ -94,6 +94,7 @@ public:
    int m_loop_nesting;
    int m_nliterals_in_group;
    std::set<int> vtx_fetch_results;
+   bool m_last_op_was_barrier;
 };
 
 
@@ -159,6 +160,8 @@ bool AssemblyFromShaderLegacyImpl::emit(const Instruction::Pointer i)
    if (i->type() != Instruction::vtx)
        vtx_fetch_results.clear();
 
+   m_last_op_was_barrier &= i->type() == Instruction::alu;
+
    sfn_log << SfnLog::assembly << "Emit from '" << *i << "\n";
    switch (i->type()) {
    case Instruction::alu:
@@ -219,7 +222,8 @@ AssemblyFromShaderLegacyImpl::AssemblyFromShaderLegacyImpl(r600_shader *sh,
    has_pos_output(false),
    has_param_output(false),
    m_loop_nesting(0),
-   m_nliterals_in_group(0)
+   m_nliterals_in_group(0),
+   m_last_op_was_barrier(false)
 {
    m_max_color_exports = MAX2(m_key->ps.nr_cbufs, 1);
 }
@@ -250,6 +254,11 @@ bool AssemblyFromShaderLegacyImpl::emit_alu(const AluInstruction& ai, ECFAluOpCo
       return false;
    }
 
+   if (m_last_op_was_barrier && ai.opcode() == op0_group_barrier)
+      return true;
+
+   m_last_op_was_barrier = ai.opcode() == op0_group_barrier;
+
    unsigned old_nliterals_in_group = m_nliterals_in_group;
    for (unsigned i = 0; i < ai.n_sources(); ++i) {
       auto& s = ai.src(i);