bfe.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/assert.h"
  5. #include "common/common_types.h"
  6. #include "video_core/engines/shader_bytecode.h"
  7. #include "video_core/shader/shader_ir.h"
  8. namespace VideoCommon::Shader {
  9. using Tegra::Shader::Instruction;
  10. using Tegra::Shader::OpCode;
  11. u32 ShaderIR::DecodeBfe(BasicBlock& bb, u32 pc) {
  12. const Instruction instr = {program_code[pc]};
  13. const auto opcode = OpCode::Decode(instr);
  14. UNIMPLEMENTED_IF(instr.bfe.negate_b);
  15. Node op_a = GetRegister(instr.gpr8);
  16. op_a = GetOperandAbsNegInteger(op_a, false, instr.bfe.negate_a, false);
  17. switch (opcode->get().GetId()) {
  18. case OpCode::Id::BFE_IMM: {
  19. UNIMPLEMENTED_IF_MSG(instr.generates_cc,
  20. "Condition codes generation in BFE is not implemented");
  21. const Node inner_shift_imm = Immediate(static_cast<u32>(instr.bfe.GetLeftShiftValue()));
  22. const Node outer_shift_imm =
  23. Immediate(static_cast<u32>(instr.bfe.GetLeftShiftValue() + instr.bfe.shift_position));
  24. const Node inner_shift =
  25. Operation(OperationCode::ILogicalShiftLeft, NO_PRECISE, op_a, inner_shift_imm);
  26. const Node outer_shift =
  27. Operation(OperationCode::ILogicalShiftRight, NO_PRECISE, inner_shift, outer_shift_imm);
  28. SetRegister(bb, instr.gpr0, outer_shift);
  29. break;
  30. }
  31. default:
  32. UNIMPLEMENTED_MSG("Unhandled BFE instruction: {}", opcode->get().GetName());
  33. }
  34. return pc;
  35. }
  36. } // namespace VideoCommon::Shader