summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/decode/half_set.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-12-24 04:51:52 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-01-15 21:54:53 +0100
commitb11e0b94c7ce0d965a6149c98c48cda967ec3c04 (patch)
tree98fcb050f6d94ae33d1a26a020834d5c1bdf6b33 /src/video_core/shader/decode/half_set.cpp
parentshader_decode: Rework HSETP2 (diff)
downloadyuzu-b11e0b94c7ce0d965a6149c98c48cda967ec3c04.tar
yuzu-b11e0b94c7ce0d965a6149c98c48cda967ec3c04.tar.gz
yuzu-b11e0b94c7ce0d965a6149c98c48cda967ec3c04.tar.bz2
yuzu-b11e0b94c7ce0d965a6149c98c48cda967ec3c04.tar.lz
yuzu-b11e0b94c7ce0d965a6149c98c48cda967ec3c04.tar.xz
yuzu-b11e0b94c7ce0d965a6149c98c48cda967ec3c04.tar.zst
yuzu-b11e0b94c7ce0d965a6149c98c48cda967ec3c04.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/decode/half_set.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/video_core/shader/decode/half_set.cpp b/src/video_core/shader/decode/half_set.cpp
index af363d5d2..b4ac06144 100644
--- a/src/video_core/shader/decode/half_set.cpp
+++ b/src/video_core/shader/decode/half_set.cpp
@@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <array>
+
#include "common/assert.h"
#include "common/common_types.h"
#include "video_core/engines/shader_bytecode.h"
@@ -16,7 +18,47 @@ u32 ShaderIR::DecodeHalfSet(BasicBlock& bb, u32 pc) {
const Instruction instr = {program_code[pc]};
const auto opcode = OpCode::Decode(instr);
- UNIMPLEMENTED();
+ UNIMPLEMENTED_IF(instr.hset2.ftz != 0);
+
+ // instr.hset2.type_a
+ // instr.hset2.type_b
+ Node op_a = GetRegister(instr.gpr8);
+ Node op_b = [&]() {
+ switch (opcode->get().GetId()) {
+ case OpCode::Id::HSET2_R:
+ return GetRegister(instr.gpr20);
+ default:
+ UNREACHABLE();
+ return Immediate(0);
+ }
+ }();
+
+ op_a = GetOperandAbsNegHalf(op_a, instr.hset2.abs_a, instr.hset2.negate_a);
+ op_b = GetOperandAbsNegHalf(op_b, instr.hset2.abs_b, instr.hset2.negate_b);
+
+ const Node second_pred = GetPredicate(instr.hset2.pred39, instr.hset2.neg_pred);
+
+ MetaHalfArithmetic meta{false, {instr.hset2.type_a, instr.hset2.type_b}};
+ const Node comparison_pair = GetPredicateComparisonHalf(instr.hset2.cond, meta, op_a, op_b);
+
+ const OperationCode combiner = GetPredicateCombiner(instr.hset2.op);
+
+ // HSET2 operates on each half float in the pack.
+ std::array<Node, 2> values;
+ for (u32 i = 0; i < 2; ++i) {
+ const u32 raw_value = instr.hset2.bf ? 0x3c00 : 0xffff;
+ const Node true_value = Immediate(raw_value << (i * 16));
+ const Node false_value = Immediate(0);
+
+ const Node comparison =
+ Operation(OperationCode::LogicalPick2, comparison_pair, Immediate(i));
+ const Node predicate = Operation(combiner, comparison, second_pred);
+
+ values[i] = Operation(OperationCode::Select, NO_PRECISE, predicate, true_value, false_value);
+ }
+
+ const Node value = Operation(OperationCode::UBitwiseOr, NO_PRECISE, values[0], values[1]);
+ SetRegister(bb, instr.gpr0, value);
return pc;
}