diff options
| -rw-r--r-- | src/video_core/macro_interpreter.cpp | 71 | ||||
| -rw-r--r-- | src/video_core/macro_interpreter.h | 80 |
2 files changed, 79 insertions, 72 deletions
diff --git a/src/video_core/macro_interpreter.cpp b/src/video_core/macro_interpreter.cpp index dbaeac6db..42031d80a 100644 --- a/src/video_core/macro_interpreter.cpp +++ b/src/video_core/macro_interpreter.cpp | |||
| @@ -11,6 +11,77 @@ | |||
| 11 | MICROPROFILE_DEFINE(MacroInterp, "GPU", "Execute macro interpreter", MP_RGB(128, 128, 192)); | 11 | MICROPROFILE_DEFINE(MacroInterp, "GPU", "Execute macro interpreter", MP_RGB(128, 128, 192)); |
| 12 | 12 | ||
| 13 | namespace Tegra { | 13 | namespace Tegra { |
| 14 | namespace { | ||
| 15 | enum class Operation : u32 { | ||
| 16 | ALU = 0, | ||
| 17 | AddImmediate = 1, | ||
| 18 | ExtractInsert = 2, | ||
| 19 | ExtractShiftLeftImmediate = 3, | ||
| 20 | ExtractShiftLeftRegister = 4, | ||
| 21 | Read = 5, | ||
| 22 | Unused = 6, // This operation doesn't seem to be a valid encoding. | ||
| 23 | Branch = 7, | ||
| 24 | }; | ||
| 25 | } // Anonymous namespace | ||
| 26 | |||
| 27 | enum class MacroInterpreter::ALUOperation : u32 { | ||
| 28 | Add = 0, | ||
| 29 | AddWithCarry = 1, | ||
| 30 | Subtract = 2, | ||
| 31 | SubtractWithBorrow = 3, | ||
| 32 | // Operations 4-7 don't seem to be valid encodings. | ||
| 33 | Xor = 8, | ||
| 34 | Or = 9, | ||
| 35 | And = 10, | ||
| 36 | AndNot = 11, | ||
| 37 | Nand = 12 | ||
| 38 | }; | ||
| 39 | |||
| 40 | enum class MacroInterpreter::ResultOperation : u32 { | ||
| 41 | IgnoreAndFetch = 0, | ||
| 42 | Move = 1, | ||
| 43 | MoveAndSetMethod = 2, | ||
| 44 | FetchAndSend = 3, | ||
| 45 | MoveAndSend = 4, | ||
| 46 | FetchAndSetMethod = 5, | ||
| 47 | MoveAndSetMethodFetchAndSend = 6, | ||
| 48 | MoveAndSetMethodSend = 7 | ||
| 49 | }; | ||
| 50 | |||
| 51 | enum class MacroInterpreter::BranchCondition : u32 { | ||
| 52 | Zero = 0, | ||
| 53 | NotZero = 1, | ||
| 54 | }; | ||
| 55 | |||
| 56 | union MacroInterpreter::Opcode { | ||
| 57 | u32 raw; | ||
| 58 | BitField<0, 3, Operation> operation; | ||
| 59 | BitField<4, 3, ResultOperation> result_operation; | ||
| 60 | BitField<4, 1, BranchCondition> branch_condition; | ||
| 61 | // If set on a branch, then the branch doesn't have a delay slot. | ||
| 62 | BitField<5, 1, u32> branch_annul; | ||
| 63 | BitField<7, 1, u32> is_exit; | ||
| 64 | BitField<8, 3, u32> dst; | ||
| 65 | BitField<11, 3, u32> src_a; | ||
| 66 | BitField<14, 3, u32> src_b; | ||
| 67 | // The signed immediate overlaps the second source operand and the alu operation. | ||
| 68 | BitField<14, 18, s32> immediate; | ||
| 69 | |||
| 70 | BitField<17, 5, ALUOperation> alu_operation; | ||
| 71 | |||
| 72 | // Bitfield instructions data | ||
| 73 | BitField<17, 5, u32> bf_src_bit; | ||
| 74 | BitField<22, 5, u32> bf_size; | ||
| 75 | BitField<27, 5, u32> bf_dst_bit; | ||
| 76 | |||
| 77 | u32 GetBitfieldMask() const { | ||
| 78 | return (1 << bf_size) - 1; | ||
| 79 | } | ||
| 80 | |||
| 81 | s32 GetBranchTarget() const { | ||
| 82 | return static_cast<s32>(immediate * sizeof(u32)); | ||
| 83 | } | ||
| 84 | }; | ||
| 14 | 85 | ||
| 15 | MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {} | 86 | MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {} |
| 16 | 87 | ||
diff --git a/src/video_core/macro_interpreter.h b/src/video_core/macro_interpreter.h index 76b6a895b..631146d89 100644 --- a/src/video_core/macro_interpreter.h +++ b/src/video_core/macro_interpreter.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <optional> | 8 | #include <optional> |
| 9 | #include <vector> | ||
| 10 | 9 | ||
| 11 | #include "common/bit_field.h" | 10 | #include "common/bit_field.h" |
| 12 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| @@ -28,75 +27,11 @@ public: | |||
| 28 | void Execute(u32 offset, std::size_t num_parameters, const u32* parameters); | 27 | void Execute(u32 offset, std::size_t num_parameters, const u32* parameters); |
| 29 | 28 | ||
| 30 | private: | 29 | private: |
| 31 | enum class Operation : u32 { | 30 | enum class ALUOperation : u32; |
| 32 | ALU = 0, | 31 | enum class BranchCondition : u32; |
| 33 | AddImmediate = 1, | 32 | enum class ResultOperation : u32; |
| 34 | ExtractInsert = 2, | ||
| 35 | ExtractShiftLeftImmediate = 3, | ||
| 36 | ExtractShiftLeftRegister = 4, | ||
| 37 | Read = 5, | ||
| 38 | Unused = 6, // This operation doesn't seem to be a valid encoding. | ||
| 39 | Branch = 7, | ||
| 40 | }; | ||
| 41 | |||
| 42 | enum class ALUOperation : u32 { | ||
| 43 | Add = 0, | ||
| 44 | AddWithCarry = 1, | ||
| 45 | Subtract = 2, | ||
| 46 | SubtractWithBorrow = 3, | ||
| 47 | // Operations 4-7 don't seem to be valid encodings. | ||
| 48 | Xor = 8, | ||
| 49 | Or = 9, | ||
| 50 | And = 10, | ||
| 51 | AndNot = 11, | ||
| 52 | Nand = 12 | ||
| 53 | }; | ||
| 54 | |||
| 55 | enum class ResultOperation : u32 { | ||
| 56 | IgnoreAndFetch = 0, | ||
| 57 | Move = 1, | ||
| 58 | MoveAndSetMethod = 2, | ||
| 59 | FetchAndSend = 3, | ||
| 60 | MoveAndSend = 4, | ||
| 61 | FetchAndSetMethod = 5, | ||
| 62 | MoveAndSetMethodFetchAndSend = 6, | ||
| 63 | MoveAndSetMethodSend = 7 | ||
| 64 | }; | ||
| 65 | 33 | ||
| 66 | enum class BranchCondition : u32 { | 34 | union Opcode; |
| 67 | Zero = 0, | ||
| 68 | NotZero = 1, | ||
| 69 | }; | ||
| 70 | |||
| 71 | union Opcode { | ||
| 72 | u32 raw; | ||
| 73 | BitField<0, 3, Operation> operation; | ||
| 74 | BitField<4, 3, ResultOperation> result_operation; | ||
| 75 | BitField<4, 1, BranchCondition> branch_condition; | ||
| 76 | BitField<5, 1, u32> | ||
| 77 | branch_annul; // If set on a branch, then the branch doesn't have a delay slot. | ||
| 78 | BitField<7, 1, u32> is_exit; | ||
| 79 | BitField<8, 3, u32> dst; | ||
| 80 | BitField<11, 3, u32> src_a; | ||
| 81 | BitField<14, 3, u32> src_b; | ||
| 82 | // The signed immediate overlaps the second source operand and the alu operation. | ||
| 83 | BitField<14, 18, s32> immediate; | ||
| 84 | |||
| 85 | BitField<17, 5, ALUOperation> alu_operation; | ||
| 86 | |||
| 87 | // Bitfield instructions data | ||
| 88 | BitField<17, 5, u32> bf_src_bit; | ||
| 89 | BitField<22, 5, u32> bf_size; | ||
| 90 | BitField<27, 5, u32> bf_dst_bit; | ||
| 91 | |||
| 92 | u32 GetBitfieldMask() const { | ||
| 93 | return (1 << bf_size) - 1; | ||
| 94 | } | ||
| 95 | |||
| 96 | s32 GetBranchTarget() const { | ||
| 97 | return static_cast<s32>(immediate * sizeof(u32)); | ||
| 98 | } | ||
| 99 | }; | ||
| 100 | 35 | ||
| 101 | union MethodAddress { | 36 | union MethodAddress { |
| 102 | u32 raw; | 37 | u32 raw; |
| @@ -149,9 +84,10 @@ private: | |||
| 149 | 84 | ||
| 150 | Engines::Maxwell3D& maxwell3d; | 85 | Engines::Maxwell3D& maxwell3d; |
| 151 | 86 | ||
| 152 | u32 pc; ///< Current program counter | 87 | /// Current program counter |
| 153 | std::optional<u32> | 88 | u32 pc; |
| 154 | delayed_pc; ///< Program counter to execute at after the delay slot is executed. | 89 | /// Program counter to execute at after the delay slot is executed. |
| 90 | std::optional<u32> delayed_pc; | ||
| 155 | 91 | ||
| 156 | static constexpr std::size_t NumMacroRegisters = 8; | 92 | static constexpr std::size_t NumMacroRegisters = 8; |
| 157 | 93 | ||