diff options
| author | 2020-05-29 14:53:27 +1000 | |
|---|---|---|
| committer | 2020-05-30 11:40:04 +1000 | |
| commit | b032ebdfee1928c4458eaf15faa0cff299371e65 (patch) | |
| tree | 2528faa725bf604cf3e44dc38c8f20d6f69aee70 /src/video_core/engines | |
| parent | Merge pull request #4017 from ogniK5377/xbyak (diff) | |
| download | yuzu-b032ebdfee1928c4458eaf15faa0cff299371e65.tar.gz yuzu-b032ebdfee1928c4458eaf15faa0cff299371e65.tar.xz yuzu-b032ebdfee1928c4458eaf15faa0cff299371e65.zip | |
Implement macro JIT
Diffstat (limited to 'src/video_core/engines')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 19 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 19 |
2 files changed, 11 insertions, 27 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 004f6b261..934a1d6db 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -25,9 +25,8 @@ constexpr u32 MacroRegistersStart = 0xE00; | |||
| 25 | Maxwell3D::Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, | 25 | Maxwell3D::Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, |
| 26 | MemoryManager& memory_manager) | 26 | MemoryManager& memory_manager) |
| 27 | : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, | 27 | : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, |
| 28 | macro_interpreter{*this}, upload_state{memory_manager, regs.upload} { | 28 | macro_engine(GetMacroEngine(*this)), upload_state{memory_manager, regs.upload} { |
| 29 | dirty.flags.flip(); | 29 | dirty.flags.flip(); |
| 30 | |||
| 31 | InitializeRegisterDefaults(); | 30 | InitializeRegisterDefaults(); |
| 32 | } | 31 | } |
| 33 | 32 | ||
| @@ -116,7 +115,7 @@ void Maxwell3D::InitializeRegisterDefaults() { | |||
| 116 | mme_inline[MAXWELL3D_REG_INDEX(index_array.count)] = true; | 115 | mme_inline[MAXWELL3D_REG_INDEX(index_array.count)] = true; |
| 117 | } | 116 | } |
| 118 | 117 | ||
| 119 | void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters) { | 118 | void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32>&& parameters) { |
| 120 | // Reset the current macro. | 119 | // Reset the current macro. |
| 121 | executing_macro = 0; | 120 | executing_macro = 0; |
| 122 | 121 | ||
| @@ -125,7 +124,7 @@ void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u3 | |||
| 125 | ((method - MacroRegistersStart) >> 1) % static_cast<u32>(macro_positions.size()); | 124 | ((method - MacroRegistersStart) >> 1) % static_cast<u32>(macro_positions.size()); |
| 126 | 125 | ||
| 127 | // Execute the current macro. | 126 | // Execute the current macro. |
| 128 | macro_interpreter.Execute(macro_positions[entry], num_parameters, parameters); | 127 | macro_engine->Execute(macro_positions[entry], std::move(parameters)); |
| 129 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { | 128 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { |
| 130 | FlushMMEInlineDraw(); | 129 | FlushMMEInlineDraw(); |
| 131 | } | 130 | } |
| @@ -161,8 +160,7 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | |||
| 161 | 160 | ||
| 162 | // Call the macro when there are no more parameters in the command buffer | 161 | // Call the macro when there are no more parameters in the command buffer |
| 163 | if (is_last_call) { | 162 | if (is_last_call) { |
| 164 | CallMacroMethod(executing_macro, macro_params.size(), macro_params.data()); | 163 | CallMacroMethod(executing_macro, std::move(macro_params)); |
| 165 | macro_params.clear(); | ||
| 166 | } | 164 | } |
| 167 | return; | 165 | return; |
| 168 | } | 166 | } |
| @@ -197,7 +195,7 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | |||
| 197 | break; | 195 | break; |
| 198 | } | 196 | } |
| 199 | case MAXWELL3D_REG_INDEX(macros.data): { | 197 | case MAXWELL3D_REG_INDEX(macros.data): { |
| 200 | ProcessMacroUpload(arg); | 198 | macro_engine->AddCode(regs.macros.upload_address, arg); |
| 201 | break; | 199 | break; |
| 202 | } | 200 | } |
| 203 | case MAXWELL3D_REG_INDEX(macros.bind): { | 201 | case MAXWELL3D_REG_INDEX(macros.bind): { |
| @@ -306,8 +304,7 @@ void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, | |||
| 306 | 304 | ||
| 307 | // Call the macro when there are no more parameters in the command buffer | 305 | // Call the macro when there are no more parameters in the command buffer |
| 308 | if (amount == methods_pending) { | 306 | if (amount == methods_pending) { |
| 309 | CallMacroMethod(executing_macro, macro_params.size(), macro_params.data()); | 307 | CallMacroMethod(executing_macro, std::move(macro_params)); |
| 310 | macro_params.clear(); | ||
| 311 | } | 308 | } |
| 312 | return; | 309 | return; |
| 313 | } | 310 | } |
| @@ -420,9 +417,7 @@ void Maxwell3D::FlushMMEInlineDraw() { | |||
| 420 | } | 417 | } |
| 421 | 418 | ||
| 422 | void Maxwell3D::ProcessMacroUpload(u32 data) { | 419 | void Maxwell3D::ProcessMacroUpload(u32 data) { |
| 423 | ASSERT_MSG(regs.macros.upload_address < macro_memory.size(), | 420 | macro_engine->AddCode(regs.macros.upload_address++, data); |
| 424 | "upload_address exceeded macro_memory size!"); | ||
| 425 | macro_memory[regs.macros.upload_address++] = data; | ||
| 426 | } | 421 | } |
| 427 | 422 | ||
| 428 | void Maxwell3D::ProcessMacroBind(u32 data) { | 423 | void Maxwell3D::ProcessMacroBind(u32 data) { |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 05dd6b39b..077bc9841 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | #include "video_core/engines/engine_upload.h" | 23 | #include "video_core/engines/engine_upload.h" |
| 24 | #include "video_core/engines/shader_type.h" | 24 | #include "video_core/engines/shader_type.h" |
| 25 | #include "video_core/gpu.h" | 25 | #include "video_core/gpu.h" |
| 26 | #include "video_core/macro_interpreter.h" | 26 | #include "video_core/macro/macro.h" |
| 27 | #include "video_core/textures/texture.h" | 27 | #include "video_core/textures/texture.h" |
| 28 | 28 | ||
| 29 | namespace Core { | 29 | namespace Core { |
| @@ -1411,15 +1411,6 @@ public: | |||
| 1411 | 1411 | ||
| 1412 | const VideoCore::GuestDriverProfile& AccessGuestDriverProfile() const override; | 1412 | const VideoCore::GuestDriverProfile& AccessGuestDriverProfile() const override; |
| 1413 | 1413 | ||
| 1414 | /// Memory for macro code - it's undetermined how big this is, however 1MB is much larger than | ||
| 1415 | /// we've seen used. | ||
| 1416 | using MacroMemory = std::array<u32, 0x40000>; | ||
| 1417 | |||
| 1418 | /// Gets a reference to macro memory. | ||
| 1419 | const MacroMemory& GetMacroMemory() const { | ||
| 1420 | return macro_memory; | ||
| 1421 | } | ||
| 1422 | |||
| 1423 | bool ShouldExecute() const { | 1414 | bool ShouldExecute() const { |
| 1424 | return execute_on; | 1415 | return execute_on; |
| 1425 | } | 1416 | } |
| @@ -1468,16 +1459,14 @@ private: | |||
| 1468 | 1459 | ||
| 1469 | std::array<bool, Regs::NUM_REGS> mme_inline{}; | 1460 | std::array<bool, Regs::NUM_REGS> mme_inline{}; |
| 1470 | 1461 | ||
| 1471 | /// Memory for macro code | ||
| 1472 | MacroMemory macro_memory; | ||
| 1473 | |||
| 1474 | /// Macro method that is currently being executed / being fed parameters. | 1462 | /// Macro method that is currently being executed / being fed parameters. |
| 1475 | u32 executing_macro = 0; | 1463 | u32 executing_macro = 0; |
| 1476 | /// Parameters that have been submitted to the macro call so far. | 1464 | /// Parameters that have been submitted to the macro call so far. |
| 1477 | std::vector<u32> macro_params; | 1465 | std::vector<u32> macro_params; |
| 1478 | 1466 | ||
| 1479 | /// Interpreter for the macro codes uploaded to the GPU. | 1467 | /// Interpreter for the macro codes uploaded to the GPU. |
| 1480 | MacroInterpreter macro_interpreter; | 1468 | std::unique_ptr<MacroEngine> macro_engine; |
| 1469 | // MacroInterpreter macro_interpreter; | ||
| 1481 | 1470 | ||
| 1482 | static constexpr u32 null_cb_data = 0xFFFFFFFF; | 1471 | static constexpr u32 null_cb_data = 0xFFFFFFFF; |
| 1483 | struct { | 1472 | struct { |
| @@ -1506,7 +1495,7 @@ private: | |||
| 1506 | * @param num_parameters Number of arguments | 1495 | * @param num_parameters Number of arguments |
| 1507 | * @param parameters Arguments to the method call | 1496 | * @param parameters Arguments to the method call |
| 1508 | */ | 1497 | */ |
| 1509 | void CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters); | 1498 | void CallMacroMethod(u32 method, std::vector<u32>&& parameters); |
| 1510 | 1499 | ||
| 1511 | /// Handles writes to the macro uploading register. | 1500 | /// Handles writes to the macro uploading register. |
| 1512 | void ProcessMacroUpload(u32 data); | 1501 | void ProcessMacroUpload(u32 data); |