From 38d3a4887359b55193b57f31a80921b956c90443 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 20 Dec 2019 17:56:30 -0300 Subject: shader/p2r: Implement P2R Pr P2R dumps predicate or condition codes state to a register. This is useful for unit testing. --- src/video_core/shader/decode/register_set_predicate.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/video_core/shader/decode/register_set_predicate.cpp b/src/video_core/shader/decode/register_set_predicate.cpp index ff8245020..8d54cce34 100644 --- a/src/video_core/shader/decode/register_set_predicate.cpp +++ b/src/video_core/shader/decode/register_set_predicate.cpp @@ -34,10 +34,11 @@ u32 ShaderIR::DecodeRegisterSetPredicate(NodeBlock& bb, u32 pc) { } }(); + const auto offset = static_cast(instr.p2r_r2p.byte) * 8; + switch (opcode->get().GetId()) { case OpCode::Id::R2P_IMM: { const Node mask = GetRegister(instr.gpr8); - const auto offset = static_cast(instr.p2r_r2p.byte) * 8; for (u64 pred = 0; pred < NUM_PROGRAMMABLE_PREDICATES; ++pred) { const auto shift = static_cast(pred); @@ -55,6 +56,19 @@ u32 ShaderIR::DecodeRegisterSetPredicate(NodeBlock& bb, u32 pc) { } break; } + case OpCode::Id::P2R_IMM: { + Node value = Immediate(0); + for (u64 pred = 0; pred < NUM_PROGRAMMABLE_PREDICATES; ++pred) { + Node bit = Operation(OperationCode::Select, GetPredicate(pred), Immediate(1U << pred), + Immediate(0)); + value = Operation(OperationCode::UBitwiseOr, std::move(value), std::move(bit)); + } + value = Operation(OperationCode::UBitwiseAnd, std::move(value), apply_mask); + value = BitfieldInsert(GetRegister(instr.gpr8), std::move(value), offset, 8); + + SetRegister(bb, instr.gpr0, std::move(value)); + break; + } default: UNIMPLEMENTED_MSG("Unhandled P2R/R2R instruction: {}", opcode->get().GetName()); break; -- cgit v1.2.3