bfe.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/node_helper.h"
  8. #include "video_core/shader/shader_ir.h"
  9. namespace VideoCommon::Shader {
  10. using Tegra::Shader::Instruction;
  11. using Tegra::Shader::OpCode;
  12. u32 ShaderIR::DecodeBfe(NodeBlock& bb, u32 pc) {
  13. const Instruction instr = {program_code[pc]};
  14. const auto opcode = OpCode::Decode(instr);
  15. UNIMPLEMENTED_IF(instr.bfe.negate_b);
  16. Node op_a = GetRegister(instr.gpr8);
  17. op_a = GetOperandAbsNegInteger(op_a, false, instr.bfe.negate_a, false);
  18. switch (opcode->get().GetId()) {
  19. case OpCode::Id::BFE_IMM: {
  20. UNIMPLEMENTED_IF_MSG(instr.generates_cc,
  21. "Condition codes generation in BFE is not implemented");
  22. const Node inner_shift_imm = Immediate(static_cast<u32>(instr.bfe.GetLeftShiftValue()));
  23. const Node outer_shift_imm =
  24. Immediate(static_cast<u32>(instr.bfe.GetLeftShiftValue() + instr.bfe.shift_position));
  25. const Node inner_shift =
  26. Operation(OperationCode::ILogicalShiftLeft, NO_PRECISE, op_a, inner_shift_imm);
  27. const Node outer_shift =
  28. Operation(OperationCode::ILogicalShiftRight, NO_PRECISE, inner_shift, outer_shift_imm);
  29. SetInternalFlagsFromInteger(bb, outer_shift, instr.generates_cc);
  30. SetRegister(bb, instr.gpr0, outer_shift);
  31. break;
  32. }
  33. default:
  34. UNIMPLEMENTED_MSG("Unhandled BFE instruction: {}", opcode->get().GetName());
  35. }
  36. return pc;
  37. }
  38. } // namespace VideoCommon::Shader