r600/sfn: Add the WaitAck instruction
authorGert Wollny <gert.wollny@collabora.com>
Fri, 27 Dec 2019 16:49:26 +0000 (17:49 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 10 Feb 2020 19:09:08 +0000 (19:09 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3225>

src/gallium/drivers/r600/Makefile.sources
src/gallium/drivers/r600/meson.build
src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp [new file with mode: 0644]
src/gallium/drivers/r600/sfn/sfn_instruction_misc.h [new file with mode: 0644]
src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp
src/gallium/drivers/r600/sfn/sfn_shader_base.cpp

index 1981c02..8032e98 100644 (file)
@@ -114,6 +114,8 @@ CXX_SOURCES = \
        sfn/sfn_instruction_export.h \
        sfn/sfn_instruction_fetch.cpp \
        sfn/sfn_instruction_fetch.h \
+       sfn/sfn_instruction_misc.cpp \
+       sfn/sfn_instruction_misc.h \
        sfn/sfn_instruction_tex.cpp \
        sfn/sfn_instruction_tex.h \
        sfn/sfn_ir_to_assembly.cpp \
index 7717072..6df3378 100644 (file)
@@ -131,6 +131,8 @@ files_r600 = files(
   'sfn/sfn_instruction_export.h',
   'sfn/sfn_instruction_fetch.cpp',
   'sfn/sfn_instruction_fetch.h',
+  'sfn/sfn_instruction_misc.cpp',
+  'sfn/sfn_instruction_misc.h',
   'sfn/sfn_instruction_tex.cpp',
   'sfn/sfn_instruction_tex.h',
   'sfn/sfn_ir_to_assembly.cpp',
diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp
new file mode 100644 (file)
index 0000000..8d4fd7e
--- /dev/null
@@ -0,0 +1,49 @@
+/* -*- mesa-c++  -*-
+ *
+ * Copyright (c) 2019 Collabora LTD
+ *
+ * Author: Gert Wollny <gert.wollny@collabora.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "sfn_instruction_misc.h"
+
+namespace r600 {
+
+WaitAck::WaitAck(int nack):
+   Instruction (wait_ack),
+   m_nack(nack)
+{
+
+}
+
+bool WaitAck::is_equal_to(const Instruction& lhs) const
+{
+   const auto& l = dynamic_cast<const WaitAck&>(lhs);
+   return m_nack == l.m_nack;
+}
+
+void WaitAck::do_print(std::ostream& os) const
+{
+   os << "WAIT_ACK @" << m_nack;
+}
+
+}
diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.h b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.h
new file mode 100644 (file)
index 0000000..883b3cd
--- /dev/null
@@ -0,0 +1,48 @@
+/* -*- mesa-c++  -*-
+ *
+ * Copyright (c) 2018-2019 Collabora LTD
+ *
+ * Author: Gert Wollny <gert.wollny@collabora.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef SFN_INSTRUCTION_MISC_H
+#define SFN_INSTRUCTION_MISC_H
+
+#include "sfn_instruction_base.h"
+
+namespace r600 {
+
+class WaitAck : public Instruction {
+public:
+   WaitAck(int nack);
+   ECFOpCode op() const {return cf_wait_ack;}
+   int n_ack() const {return m_nack;}
+private:
+
+   bool is_equal_to(const Instruction& lhs) const override;
+   void do_print(std::ostream& os) const override;
+   int m_nack;
+};
+
+}
+
+#endif // SFN_INSTRUCTION_MISC_H
index 1147292..b8ceb7f 100644 (file)
@@ -27,6 +27,7 @@
 #include "sfn_ir_to_assembly.h"
 #include "sfn_conditionaljumptracker.h"
 #include "sfn_callstack.h"
+#include "sfn_instruction_misc.h"
 #include "sfn_instruction_fetch.h"
 
 #include "../r600_shader.h"
@@ -56,6 +57,7 @@ private:
    bool emit_loop_end(const LoopEndInstruction& instr);
    bool emit_loop_break(const LoopBreakInstruction& instr);
    bool emit_loop_continue(const LoopContInstruction& instr);
+   bool emit_wait_ack(const WaitAck& instr);
 
    bool emit_load_addr(PValue addr);
    bool emit_fs_pixel_export(const ExportInstruction & exi);
@@ -161,6 +163,8 @@ bool AssemblyFromShaderLegacyImpl::emit(const Instruction::Pointer i)
       return emit_loop_continue(static_cast<const LoopContInstruction&>(*i));
    case Instruction::streamout:
       return emit_streamout(static_cast<const StreamOutIntruction&>(*i));
+   case Instruction::wait_ack:
+      return emit_wait_ack(static_cast<const WaitAck&>(*i));
    default:
       return false;
    }
@@ -736,6 +740,15 @@ bool AssemblyFromShaderLegacyImpl::emit_vtx(const FetchInstruction& fetch_instr)
    return true;
 }
 
+bool AssemblyFromShaderLegacyImpl::emit_wait_ack(const WaitAck& instr)
+{
+   int r = r600_bytecode_add_cfinst(m_bc, instr.op());
+   if (!r)
+      m_bc->cf_last->cf_addr = instr.n_ack();
+
+   return r == 0;
+}
+
 extern const std::map<ESDOp, int> ds_opcode_map;
 
 bool AssemblyFromShaderLegacyImpl::copy_dst(r600_bytecode_alu_dst& dst,
index b238098..04e1ee5 100644 (file)
@@ -31,6 +31,7 @@
 #include "sfn_shader_fragment.h"
 #include "sfn_ir_to_assembly.h"
 #include "sfn_nir.h"
+#include "sfn_instruction_misc.h"
 #include "sfn_instruction_fetch.h"
 
 #include <iostream>