2018-12-20 23:09:21 +01:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "video_core/engines/shader_bytecode.h"
|
2019-06-05 03:44:06 +02:00
|
|
|
#include "video_core/shader/node_helper.h"
|
2018-12-20 23:09:21 +01:00
|
|
|
#include "video_core/shader/shader_ir.h"
|
|
|
|
|
|
|
|
namespace VideoCommon::Shader {
|
|
|
|
|
|
|
|
using Tegra::Shader::Instruction;
|
|
|
|
using Tegra::Shader::OpCode;
|
|
|
|
|
2019-01-30 06:09:40 +01:00
|
|
|
u32 ShaderIR::DecodeRegisterSetPredicate(NodeBlock& bb, u32 pc) {
|
2018-12-20 23:09:21 +01:00
|
|
|
const Instruction instr = {program_code[pc]};
|
|
|
|
const auto opcode = OpCode::Decode(instr);
|
|
|
|
|
2018-12-23 21:24:18 +01:00
|
|
|
UNIMPLEMENTED_IF(instr.r2p.mode != Tegra::Shader::R2pMode::Pr);
|
|
|
|
|
|
|
|
const Node apply_mask = [&]() {
|
|
|
|
switch (opcode->get().GetId()) {
|
|
|
|
case OpCode::Id::R2P_IMM:
|
|
|
|
return Immediate(static_cast<u32>(instr.r2p.immediate_mask));
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return Immediate(static_cast<u32>(instr.r2p.immediate_mask));
|
|
|
|
}
|
|
|
|
}();
|
2018-12-26 06:58:47 +01:00
|
|
|
const Node mask = GetRegister(instr.gpr8);
|
|
|
|
const auto offset = static_cast<u32>(instr.r2p.byte) * 8;
|
2018-12-23 21:24:18 +01:00
|
|
|
|
|
|
|
constexpr u32 programmable_preds = 7;
|
|
|
|
for (u64 pred = 0; pred < programmable_preds; ++pred) {
|
2018-12-26 06:58:47 +01:00
|
|
|
const auto shift = static_cast<u32>(pred);
|
2018-12-23 21:24:18 +01:00
|
|
|
|
2018-12-26 06:58:47 +01:00
|
|
|
const Node apply_compare = BitfieldExtract(apply_mask, shift, 1);
|
2018-12-25 07:46:14 +01:00
|
|
|
const Node condition =
|
|
|
|
Operation(OperationCode::LogicalUNotEqual, apply_compare, Immediate(0));
|
2018-12-23 21:24:18 +01:00
|
|
|
|
2018-12-26 06:58:47 +01:00
|
|
|
const Node value_compare = BitfieldExtract(mask, offset + shift, 1);
|
2018-12-25 07:46:14 +01:00
|
|
|
const Node value = Operation(OperationCode::LogicalUNotEqual, value_compare, Immediate(0));
|
2018-12-23 21:24:18 +01:00
|
|
|
|
|
|
|
const Node code = Operation(OperationCode::LogicalAssign, GetPredicate(pred), value);
|
|
|
|
bb.push_back(Conditional(condition, {code}));
|
|
|
|
}
|
2018-12-20 23:09:21 +01:00
|
|
|
|
|
|
|
return pc;
|
|
|
|
}
|
|
|
|
|
2019-05-22 23:24:35 +02:00
|
|
|
} // namespace VideoCommon::Shader
|