diff options
| author | 2022-11-18 00:21:13 +0100 | |
|---|---|---|
| committer | 2023-01-01 16:43:57 -0500 | |
| commit | ce448ce770b6c329caec7ad1ae00e01dddb67b03 (patch) | |
| tree | 88a76a0416244c89d1031551b1a419a606324004 /src/video_core/macro | |
| parent | MacroHLE: Reduce massive calculations on sizing estimation. (diff) | |
| download | yuzu-ce448ce770b6c329caec7ad1ae00e01dddb67b03.tar.gz yuzu-ce448ce770b6c329caec7ad1ae00e01dddb67b03.tar.xz yuzu-ce448ce770b6c329caec7ad1ae00e01dddb67b03.zip | |
Revert Buffer cache changes and setup additional macros.
Diffstat (limited to 'src/video_core/macro')
| -rw-r--r-- | src/video_core/macro/macro.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/macro/macro_hle.cpp | 122 |
2 files changed, 120 insertions, 7 deletions
diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp index 01dd25f95..49c47dafe 100644 --- a/src/video_core/macro/macro.cpp +++ b/src/video_core/macro/macro.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 13 | #include "common/fs/fs.h" | 13 | #include "common/fs/fs.h" |
| 14 | #include "common/fs/path_util.h" | 14 | #include "common/fs/path_util.h" |
| 15 | #include "common/microprofile.h" | ||
| 15 | #include "common/settings.h" | 16 | #include "common/settings.h" |
| 16 | #include "video_core/engines/maxwell_3d.h" | 17 | #include "video_core/engines/maxwell_3d.h" |
| 17 | #include "video_core/macro/macro.h" | 18 | #include "video_core/macro/macro.h" |
| @@ -22,6 +23,8 @@ | |||
| 22 | #include "video_core/macro/macro_jit_x64.h" | 23 | #include "video_core/macro/macro_jit_x64.h" |
| 23 | #endif | 24 | #endif |
| 24 | 25 | ||
| 26 | MICROPROFILE_DEFINE(MacroHLE, "GPU", "Execute macro hle", MP_RGB(128, 192, 192)); | ||
| 27 | |||
| 25 | namespace Tegra { | 28 | namespace Tegra { |
| 26 | 29 | ||
| 27 | static void Dump(u64 hash, std::span<const u32> code) { | 30 | static void Dump(u64 hash, std::span<const u32> code) { |
| @@ -60,6 +63,7 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) { | |||
| 60 | if (compiled_macro != macro_cache.end()) { | 63 | if (compiled_macro != macro_cache.end()) { |
| 61 | const auto& cache_info = compiled_macro->second; | 64 | const auto& cache_info = compiled_macro->second; |
| 62 | if (cache_info.has_hle_program) { | 65 | if (cache_info.has_hle_program) { |
| 66 | MICROPROFILE_SCOPE(MacroHLE); | ||
| 63 | cache_info.hle_program->Execute(parameters, method); | 67 | cache_info.hle_program->Execute(parameters, method); |
| 64 | } else { | 68 | } else { |
| 65 | maxwell3d.RefreshParameters(); | 69 | maxwell3d.RefreshParameters(); |
| @@ -106,6 +110,7 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) { | |||
| 106 | if (auto hle_program = hle_macros->GetHLEProgram(cache_info.hash)) { | 110 | if (auto hle_program = hle_macros->GetHLEProgram(cache_info.hash)) { |
| 107 | cache_info.has_hle_program = true; | 111 | cache_info.has_hle_program = true; |
| 108 | cache_info.hle_program = std::move(hle_program); | 112 | cache_info.hle_program = std::move(hle_program); |
| 113 | MICROPROFILE_SCOPE(MacroHLE); | ||
| 109 | cache_info.hle_program->Execute(parameters, method); | 114 | cache_info.hle_program->Execute(parameters, method); |
| 110 | } else { | 115 | } else { |
| 111 | maxwell3d.RefreshParameters(); | 116 | maxwell3d.RefreshParameters(); |
diff --git a/src/video_core/macro/macro_hle.cpp b/src/video_core/macro/macro_hle.cpp index 638247e55..3eac50975 100644 --- a/src/video_core/macro/macro_hle.cpp +++ b/src/video_core/macro/macro_hle.cpp | |||
| @@ -86,7 +86,7 @@ public: | |||
| 86 | 86 | ||
| 87 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { | 87 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { |
| 88 | auto topology = static_cast<Maxwell::Regs::PrimitiveTopology>(parameters[0]); | 88 | auto topology = static_cast<Maxwell::Regs::PrimitiveTopology>(parameters[0]); |
| 89 | if (!IsTopologySafe(topology)) { | 89 | if (!maxwell3d.AnyParametersDirty() || !IsTopologySafe(topology)) { |
| 90 | Fallback(parameters); | 90 | Fallback(parameters); |
| 91 | return; | 91 | return; |
| 92 | } | 92 | } |
| @@ -117,8 +117,8 @@ private: | |||
| 117 | void Fallback(const std::vector<u32>& parameters) { | 117 | void Fallback(const std::vector<u32>& parameters) { |
| 118 | SCOPE_EXIT({ | 118 | SCOPE_EXIT({ |
| 119 | if (extended) { | 119 | if (extended) { |
| 120 | maxwell3d.CallMethod(0x8e3, 0x640, true); | 120 | maxwell3d.engine_state = Maxwell::EngineHint::None; |
| 121 | maxwell3d.CallMethod(0x8e4, 0, true); | 121 | maxwell3d.replace_table.clear(); |
| 122 | } | 122 | } |
| 123 | }); | 123 | }); |
| 124 | maxwell3d.RefreshParameters(); | 124 | maxwell3d.RefreshParameters(); |
| @@ -127,7 +127,8 @@ private: | |||
| 127 | const u32 vertex_first = parameters[3]; | 127 | const u32 vertex_first = parameters[3]; |
| 128 | const u32 vertex_count = parameters[1]; | 128 | const u32 vertex_count = parameters[1]; |
| 129 | 129 | ||
| 130 | if (maxwell3d.GetMaxCurrentVertices() < vertex_first + vertex_count) { | 130 | if (maxwell3d.AnyParametersDirty() && |
| 131 | maxwell3d.GetMaxCurrentVertices() < vertex_first + vertex_count) { | ||
| 131 | ASSERT_MSG(false, "Faulty draw!"); | 132 | ASSERT_MSG(false, "Faulty draw!"); |
| 132 | return; | 133 | return; |
| 133 | } | 134 | } |
| @@ -157,7 +158,7 @@ public: | |||
| 157 | 158 | ||
| 158 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { | 159 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { |
| 159 | auto topology = static_cast<Maxwell::Regs::PrimitiveTopology>(parameters[0]); | 160 | auto topology = static_cast<Maxwell::Regs::PrimitiveTopology>(parameters[0]); |
| 160 | if (!IsTopologySafe(topology)) { | 161 | if (!maxwell3d.AnyParametersDirty() || !IsTopologySafe(topology)) { |
| 161 | Fallback(parameters); | 162 | Fallback(parameters); |
| 162 | return; | 163 | return; |
| 163 | } | 164 | } |
| @@ -169,7 +170,11 @@ public: | |||
| 169 | } | 170 | } |
| 170 | const u32 estimate = static_cast<u32>(maxwell3d.EstimateIndexBufferSize()); | 171 | const u32 estimate = static_cast<u32>(maxwell3d.EstimateIndexBufferSize()); |
| 171 | const u32 base_size = std::max<u32>(minimum_limit, estimate); | 172 | const u32 base_size = std::max<u32>(minimum_limit, estimate); |
| 172 | maxwell3d.regs.draw.topology.Assign(topology); | 173 | const u32 element_base = parameters[4]; |
| 174 | const u32 base_instance = parameters[5]; | ||
| 175 | maxwell3d.regs.vertex_id_base = element_base; | ||
| 176 | maxwell3d.regs.global_base_vertex_index = element_base; | ||
| 177 | maxwell3d.regs.global_base_instance_index = base_instance; | ||
| 173 | maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; | 178 | maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; |
| 174 | maxwell3d.engine_state = Maxwell::EngineHint::OnHLEMacro; | 179 | maxwell3d.engine_state = Maxwell::EngineHint::OnHLEMacro; |
| 175 | maxwell3d.setHLEReplacementName(0, 0x640, Maxwell::HLEReplaceName::BaseVertex); | 180 | maxwell3d.setHLEReplacementName(0, 0x640, Maxwell::HLEReplaceName::BaseVertex); |
| @@ -186,6 +191,9 @@ public: | |||
| 186 | maxwell3d.draw_manager->DrawIndexedIndirect(topology, 0, base_size); | 191 | maxwell3d.draw_manager->DrawIndexedIndirect(topology, 0, base_size); |
| 187 | maxwell3d.engine_state = Maxwell::EngineHint::None; | 192 | maxwell3d.engine_state = Maxwell::EngineHint::None; |
| 188 | maxwell3d.replace_table.clear(); | 193 | maxwell3d.replace_table.clear(); |
| 194 | maxwell3d.regs.vertex_id_base = 0x0; | ||
| 195 | maxwell3d.regs.global_base_vertex_index = 0x0; | ||
| 196 | maxwell3d.regs.global_base_instance_index = 0x0; | ||
| 189 | } | 197 | } |
| 190 | 198 | ||
| 191 | private: | 199 | private: |
| @@ -195,6 +203,8 @@ private: | |||
| 195 | const u32 element_base = parameters[4]; | 203 | const u32 element_base = parameters[4]; |
| 196 | const u32 base_instance = parameters[5]; | 204 | const u32 base_instance = parameters[5]; |
| 197 | maxwell3d.regs.vertex_id_base = element_base; | 205 | maxwell3d.regs.vertex_id_base = element_base; |
| 206 | maxwell3d.regs.global_base_vertex_index = element_base; | ||
| 207 | maxwell3d.regs.global_base_instance_index = base_instance; | ||
| 198 | maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; | 208 | maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; |
| 199 | maxwell3d.engine_state = Maxwell::EngineHint::OnHLEMacro; | 209 | maxwell3d.engine_state = Maxwell::EngineHint::OnHLEMacro; |
| 200 | maxwell3d.setHLEReplacementName(0, 0x640, Maxwell::HLEReplaceName::BaseVertex); | 210 | maxwell3d.setHLEReplacementName(0, 0x640, Maxwell::HLEReplaceName::BaseVertex); |
| @@ -205,6 +215,8 @@ private: | |||
| 205 | parameters[3], parameters[1], element_base, base_instance, instance_count); | 215 | parameters[3], parameters[1], element_base, base_instance, instance_count); |
| 206 | 216 | ||
| 207 | maxwell3d.regs.vertex_id_base = 0x0; | 217 | maxwell3d.regs.vertex_id_base = 0x0; |
| 218 | maxwell3d.regs.global_base_vertex_index = 0x0; | ||
| 219 | maxwell3d.regs.global_base_instance_index = 0x0; | ||
| 208 | maxwell3d.engine_state = Maxwell::EngineHint::None; | 220 | maxwell3d.engine_state = Maxwell::EngineHint::None; |
| 209 | maxwell3d.replace_table.clear(); | 221 | maxwell3d.replace_table.clear(); |
| 210 | } | 222 | } |
| @@ -253,7 +265,6 @@ public: | |||
| 253 | return; | 265 | return; |
| 254 | } | 266 | } |
| 255 | 267 | ||
| 256 | maxwell3d.regs.draw.topology.Assign(topology); | ||
| 257 | const u32 padding = parameters[3]; // padding is in words | 268 | const u32 padding = parameters[3]; // padding is in words |
| 258 | 269 | ||
| 259 | // size of each indirect segment | 270 | // size of each indirect segment |
| @@ -335,6 +346,83 @@ private: | |||
| 335 | u32 minimum_limit{1 << 12}; | 346 | u32 minimum_limit{1 << 12}; |
| 336 | }; | 347 | }; |
| 337 | 348 | ||
| 349 | class HLE_C713C83D8F63CCF3 final : public HLEMacroImpl { | ||
| 350 | public: | ||
| 351 | explicit HLE_C713C83D8F63CCF3(Engines::Maxwell3D& maxwell3d_) : HLEMacroImpl(maxwell3d_) {} | ||
| 352 | |||
| 353 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { | ||
| 354 | maxwell3d.RefreshParameters(); | ||
| 355 | const u32 offset = (parameters[0] & 0x3FFFFFFF) << 2; | ||
| 356 | const u32 address = maxwell3d.regs.shadow_scratch[24]; | ||
| 357 | auto& const_buffer = maxwell3d.regs.const_buffer; | ||
| 358 | const_buffer.size = 0x7000; | ||
| 359 | const_buffer.address_high = (address >> 24) & 0xFF; | ||
| 360 | const_buffer.address_low = address << 8; | ||
| 361 | const_buffer.offset = offset; | ||
| 362 | } | ||
| 363 | }; | ||
| 364 | |||
| 365 | class HLE_D7333D26E0A93EDE final : public HLEMacroImpl { | ||
| 366 | public: | ||
| 367 | explicit HLE_D7333D26E0A93EDE(Engines::Maxwell3D& maxwell3d_) : HLEMacroImpl(maxwell3d_) {} | ||
| 368 | |||
| 369 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { | ||
| 370 | maxwell3d.RefreshParameters(); | ||
| 371 | const size_t index = parameters[0]; | ||
| 372 | const u32 address = maxwell3d.regs.shadow_scratch[42 + index]; | ||
| 373 | const u32 size = maxwell3d.regs.shadow_scratch[47 + index]; | ||
| 374 | auto& const_buffer = maxwell3d.regs.const_buffer; | ||
| 375 | const_buffer.size = size; | ||
| 376 | const_buffer.address_high = (address >> 24) & 0xFF; | ||
| 377 | const_buffer.address_low = address << 8; | ||
| 378 | } | ||
| 379 | }; | ||
| 380 | |||
| 381 | class HLE_BindShader final : public HLEMacroImpl { | ||
| 382 | public: | ||
| 383 | explicit HLE_BindShader(Engines::Maxwell3D& maxwell3d_) : HLEMacroImpl(maxwell3d_) {} | ||
| 384 | |||
| 385 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { | ||
| 386 | maxwell3d.RefreshParameters(); | ||
| 387 | auto& regs = maxwell3d.regs; | ||
| 388 | const u32 index = parameters[0]; | ||
| 389 | if ((parameters[1] - regs.shadow_scratch[28 + index]) == 0) { | ||
| 390 | return; | ||
| 391 | } | ||
| 392 | |||
| 393 | regs.pipelines[index & 0xF].offset = parameters[2]; | ||
| 394 | maxwell3d.dirty.flags[VideoCommon::Dirty::Shaders] = true; | ||
| 395 | regs.shadow_scratch[28 + index] = parameters[1]; | ||
| 396 | regs.shadow_scratch[34 + index] = parameters[2]; | ||
| 397 | |||
| 398 | const u32 address = parameters[4]; | ||
| 399 | auto& const_buffer = regs.const_buffer; | ||
| 400 | const_buffer.size = 0x10000; | ||
| 401 | const_buffer.address_high = (address >> 24) & 0xFF; | ||
| 402 | const_buffer.address_low = address << 8; | ||
| 403 | |||
| 404 | const size_t bind_group_id = parameters[3] & 0x7F; | ||
| 405 | auto& bind_group = regs.bind_groups[bind_group_id]; | ||
| 406 | bind_group.raw_config = 0x11; | ||
| 407 | maxwell3d.ProcessCBBind(bind_group_id); | ||
| 408 | } | ||
| 409 | }; | ||
| 410 | |||
| 411 | class HLE_SetRasterBoundingBox final : public HLEMacroImpl { | ||
| 412 | public: | ||
| 413 | explicit HLE_SetRasterBoundingBox(Engines::Maxwell3D& maxwell3d_) : HLEMacroImpl(maxwell3d_) {} | ||
| 414 | |||
| 415 | void Execute(const std::vector<u32>& parameters, [[maybe_unused]] u32 method) override { | ||
| 416 | maxwell3d.RefreshParameters(); | ||
| 417 | const u32 raster_mode = parameters[0]; | ||
| 418 | auto& regs = maxwell3d.regs; | ||
| 419 | const u32 raster_enabled = maxwell3d.regs.conservative_raster_enable; | ||
| 420 | const u32 scratch_data = maxwell3d.regs.shadow_scratch[52]; | ||
| 421 | regs.raster_bounding_box.raw = raster_mode & 0xFFFFF00F; | ||
| 422 | regs.raster_bounding_box.pad.Assign(scratch_data & raster_enabled); | ||
| 423 | } | ||
| 424 | }; | ||
| 425 | |||
| 338 | } // Anonymous namespace | 426 | } // Anonymous namespace |
| 339 | 427 | ||
| 340 | HLEMacro::HLEMacro(Engines::Maxwell3D& maxwell3d_) : maxwell3d{maxwell3d_} { | 428 | HLEMacro::HLEMacro(Engines::Maxwell3D& maxwell3d_) : maxwell3d{maxwell3d_} { |
| @@ -368,6 +456,26 @@ HLEMacro::HLEMacro(Engines::Maxwell3D& maxwell3d_) : maxwell3d{maxwell3d_} { | |||
| 368 | [](Engines::Maxwell3D& maxwell3d) -> std::unique_ptr<CachedMacro> { | 456 | [](Engines::Maxwell3D& maxwell3d) -> std::unique_ptr<CachedMacro> { |
| 369 | return std::make_unique<HLE_MultiLayerClear>(maxwell3d); | 457 | return std::make_unique<HLE_MultiLayerClear>(maxwell3d); |
| 370 | })); | 458 | })); |
| 459 | builders.emplace(0xC713C83D8F63CCF3ULL, | ||
| 460 | std::function<std::unique_ptr<CachedMacro>(Engines::Maxwell3D&)>( | ||
| 461 | [](Engines::Maxwell3D& maxwell3d) -> std::unique_ptr<CachedMacro> { | ||
| 462 | return std::make_unique<HLE_C713C83D8F63CCF3>(maxwell3d); | ||
| 463 | })); | ||
| 464 | builders.emplace(0xD7333D26E0A93EDEULL, | ||
| 465 | std::function<std::unique_ptr<CachedMacro>(Engines::Maxwell3D&)>( | ||
| 466 | [](Engines::Maxwell3D& maxwell3d) -> std::unique_ptr<CachedMacro> { | ||
| 467 | return std::make_unique<HLE_D7333D26E0A93EDE>(maxwell3d); | ||
| 468 | })); | ||
| 469 | builders.emplace(0xEB29B2A09AA06D38ULL, | ||
| 470 | std::function<std::unique_ptr<CachedMacro>(Engines::Maxwell3D&)>( | ||
| 471 | [](Engines::Maxwell3D& maxwell3d) -> std::unique_ptr<CachedMacro> { | ||
| 472 | return std::make_unique<HLE_BindShader>(maxwell3d); | ||
| 473 | })); | ||
| 474 | builders.emplace(0xDB1341DBEB4C8AF7ULL, | ||
| 475 | std::function<std::unique_ptr<CachedMacro>(Engines::Maxwell3D&)>( | ||
| 476 | [](Engines::Maxwell3D& maxwell3d) -> std::unique_ptr<CachedMacro> { | ||
| 477 | return std::make_unique<HLE_SetRasterBoundingBox>(maxwell3d); | ||
| 478 | })); | ||
| 371 | } | 479 | } |
| 372 | 480 | ||
| 373 | HLEMacro::~HLEMacro() = default; | 481 | HLEMacro::~HLEMacro() = default; |