From 24f683fe810904ae7355ddb036e1e4f37f1480c4 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Fri, 27 Dec 2019 17:49:26 +0100 Subject: [PATCH] r600/sfn: Add the WaitAck instruction Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/Makefile.sources | 2 + src/gallium/drivers/r600/meson.build | 2 + .../drivers/r600/sfn/sfn_instruction_misc.cpp | 49 +++++++++++++++++++ .../drivers/r600/sfn/sfn_instruction_misc.h | 48 ++++++++++++++++++ .../drivers/r600/sfn/sfn_ir_to_assembly.cpp | 13 +++++ .../drivers/r600/sfn/sfn_shader_base.cpp | 1 + 6 files changed, 115 insertions(+) create mode 100644 src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp create mode 100644 src/gallium/drivers/r600/sfn/sfn_instruction_misc.h diff --git a/src/gallium/drivers/r600/Makefile.sources b/src/gallium/drivers/r600/Makefile.sources index 1981c02d6f5..8032e984229 100644 --- a/src/gallium/drivers/r600/Makefile.sources +++ b/src/gallium/drivers/r600/Makefile.sources @@ -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 \ diff --git a/src/gallium/drivers/r600/meson.build b/src/gallium/drivers/r600/meson.build index 771707229e8..6df33788691 100644 --- a/src/gallium/drivers/r600/meson.build +++ b/src/gallium/drivers/r600/meson.build @@ -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 index 00000000000..8d4fd7e1f39 --- /dev/null +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp @@ -0,0 +1,49 @@ +/* -*- mesa-c++ -*- + * + * Copyright (c) 2019 Collabora LTD + * + * Author: Gert Wollny + * + * 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(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 index 00000000000..883b3cd9a0a --- /dev/null +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.h @@ -0,0 +1,48 @@ +/* -*- mesa-c++ -*- + * + * Copyright (c) 2018-2019 Collabora LTD + * + * Author: Gert Wollny + * + * 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 diff --git a/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp b/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp index 11472927310..b8ceb7ff0c2 100644 --- a/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp @@ -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(*i)); case Instruction::streamout: return emit_streamout(static_cast(*i)); + case Instruction::wait_ack: + return emit_wait_ack(static_cast(*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 ds_opcode_map; bool AssemblyFromShaderLegacyImpl::copy_dst(r600_bytecode_alu_dst& dst, diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp index b238098773a..04e1ee58444 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp @@ -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 -- 2.30.2