From 5c7124e134395c4fe0dbc442a5b7b94f44d16aee Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Fri, 27 Dec 2019 17:49:27 +0100 Subject: [PATCH] r600/sfn: add emitVertex instructions More preparation for GS support Signed-off-by: Gert Wollny Part-of: --- .../drivers/r600/sfn/sfn_instruction_misc.cpp | 19 +++++++++++++++++++ .../drivers/r600/sfn/sfn_instruction_misc.h | 13 +++++++++++++ .../drivers/r600/sfn/sfn_ir_to_assembly.cpp | 13 +++++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp index 8d4fd7e1f39..0eac46abb2f 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.cpp @@ -27,6 +27,25 @@ #include "sfn_instruction_misc.h" namespace r600 { +EmitVertex::EmitVertex(int stream, bool cut): + Instruction (emit_vtx), + m_stream(stream), + m_cut(cut) +{ + +} + +bool EmitVertex::is_equal_to(const Instruction& lhs) const +{ + auto& oth = static_cast(lhs); + return oth.m_stream == m_stream && + oth.m_cut == m_cut; +} + +void EmitVertex::do_print(std::ostream& os) const +{ + os << (m_cut ? "EMIT_CUT_VERTEX @" : "EMIT_VERTEX @") << m_stream; +} WaitAck::WaitAck(int nack): Instruction (wait_ack), diff --git a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.h b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.h index 883b3cd9a0a..b7be59017ee 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instruction_misc.h +++ b/src/gallium/drivers/r600/sfn/sfn_instruction_misc.h @@ -31,6 +31,19 @@ namespace r600 { +class EmitVertex : public Instruction { +public: + EmitVertex(int stream, bool cut); + ECFOpCode op() const {return m_cut ? cf_cut_vertex: cf_emit_vertex;} + int stream() const { return m_stream;} +private: + + bool is_equal_to(const Instruction& lhs) const override; + void do_print(std::ostream& os) const override; + int m_stream; + bool m_cut; +}; + class WaitAck : public Instruction { public: WaitAck(int nack); 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 c6beddd79c7..a26054397d8 100644 --- a/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_ir_to_assembly.cpp @@ -53,6 +53,7 @@ private: bool emit_if_start(const IfInstruction & if_instr); bool emit_else(const ElseInstruction & else_instr); bool emit_endif(const IfElseEndInstruction & endif_instr); + bool emit_emit_vertex(const EmitVertex &instr); bool emit_loop_begin(const LoopBeginInstruction& instr); bool emit_loop_end(const LoopEndInstruction& instr); @@ -167,6 +168,8 @@ bool AssemblyFromShaderLegacyImpl::emit(const Instruction::Pointer i) return emit_streamout(static_cast(*i)); case Instruction::ring: return emit_memringwrite(static_cast(*i)); + case Instruction::emit_vtx: + return emit_emit_vertex(static_cast(*i)); case Instruction::wait_ack: return emit_wait_ack(static_cast(*i)); case Instruction::mem_wr_scratch: @@ -772,6 +775,16 @@ bool AssemblyFromShaderLegacyImpl::emit_vtx(const FetchInstruction& fetch_instr) return true; } +bool AssemblyFromShaderLegacyImpl::emit_emit_vertex(const EmitVertex &instr) +{ + int r = r600_bytecode_add_cfinst(m_bc, instr.op()); + if (!r) + m_bc->cf_last->count = instr.stream(); + assert(m_bc->cf_last->count < 4); + + return r == 0; +} + bool AssemblyFromShaderLegacyImpl::emit_wait_ack(const WaitAck& instr) { int r = r600_bytecode_add_cfinst(m_bc, instr.op()); -- 2.30.2