diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.cpp | 4 | ||||
| -rw-r--r-- | src/core/core.h | 2 | ||||
| -rw-r--r-- | src/core/memory.cpp | 25 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 06fba4ce5..b5f62690e 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -612,6 +612,10 @@ void System::PrepareReschedule(const u32 core_index) { | |||
| 612 | impl->kernel.PrepareReschedule(core_index); | 612 | impl->kernel.PrepareReschedule(core_index); |
| 613 | } | 613 | } |
| 614 | 614 | ||
| 615 | size_t System::GetCurrentHostThreadID() const { | ||
| 616 | return impl->kernel.GetCurrentHostThreadID(); | ||
| 617 | } | ||
| 618 | |||
| 615 | PerfStatsResults System::GetAndResetPerfStats() { | 619 | PerfStatsResults System::GetAndResetPerfStats() { |
| 616 | return impl->GetAndResetPerfStats(); | 620 | return impl->GetAndResetPerfStats(); |
| 617 | } | 621 | } |
diff --git a/src/core/core.h b/src/core/core.h index 4a5aba032..4f153154f 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -222,6 +222,8 @@ public: | |||
| 222 | /// Prepare the core emulation for a reschedule | 222 | /// Prepare the core emulation for a reschedule |
| 223 | void PrepareReschedule(u32 core_index); | 223 | void PrepareReschedule(u32 core_index); |
| 224 | 224 | ||
| 225 | [[nodiscard]] size_t GetCurrentHostThreadID() const; | ||
| 226 | |||
| 225 | /// Gets and resets core performance statistics | 227 | /// Gets and resets core performance statistics |
| 226 | [[nodiscard]] PerfStatsResults GetAndResetPerfStats(); | 228 | [[nodiscard]] PerfStatsResults GetAndResetPerfStats(); |
| 227 | 229 | ||
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index a9667463f..514ba0d66 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -13,10 +13,12 @@ | |||
| 13 | #include "common/swap.h" | 13 | #include "common/swap.h" |
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "core/device_memory.h" | 15 | #include "core/device_memory.h" |
| 16 | #include "core/hardware_properties.h" | ||
| 16 | #include "core/hle/kernel/k_page_table.h" | 17 | #include "core/hle/kernel/k_page_table.h" |
| 17 | #include "core/hle/kernel/k_process.h" | 18 | #include "core/hle/kernel/k_process.h" |
| 18 | #include "core/memory.h" | 19 | #include "core/memory.h" |
| 19 | #include "video_core/gpu.h" | 20 | #include "video_core/gpu.h" |
| 21 | #include "video_core/rasterizer_download_area.h" | ||
| 20 | 22 | ||
| 21 | namespace Core::Memory { | 23 | namespace Core::Memory { |
| 22 | 24 | ||
| @@ -243,7 +245,7 @@ struct Memory::Impl { | |||
| 243 | [&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount, | 245 | [&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount, |
| 244 | const u8* const host_ptr) { | 246 | const u8* const host_ptr) { |
| 245 | if constexpr (!UNSAFE) { | 247 | if constexpr (!UNSAFE) { |
| 246 | system.GPU().FlushRegion(GetInteger(current_vaddr), copy_amount); | 248 | HandleRasterizerDownload(GetInteger(current_vaddr), copy_amount); |
| 247 | } | 249 | } |
| 248 | std::memcpy(dest_buffer, host_ptr, copy_amount); | 250 | std::memcpy(dest_buffer, host_ptr, copy_amount); |
| 249 | }, | 251 | }, |
| @@ -334,7 +336,7 @@ struct Memory::Impl { | |||
| 334 | }, | 336 | }, |
| 335 | [&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount, | 337 | [&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount, |
| 336 | u8* const host_ptr) { | 338 | u8* const host_ptr) { |
| 337 | system.GPU().FlushRegion(GetInteger(current_vaddr), copy_amount); | 339 | HandleRasterizerDownload(GetInteger(current_vaddr), copy_amount); |
| 338 | WriteBlockImpl<false>(process, dest_addr, host_ptr, copy_amount); | 340 | WriteBlockImpl<false>(process, dest_addr, host_ptr, copy_amount); |
| 339 | }, | 341 | }, |
| 340 | [&](const std::size_t copy_amount) { | 342 | [&](const std::size_t copy_amount) { |
| @@ -373,7 +375,7 @@ struct Memory::Impl { | |||
| 373 | const std::size_t block_size) { | 375 | const std::size_t block_size) { |
| 374 | // dc ivac: Invalidate to point of coherency | 376 | // dc ivac: Invalidate to point of coherency |
| 375 | // GPU flush -> CPU invalidate | 377 | // GPU flush -> CPU invalidate |
| 376 | system.GPU().FlushRegion(GetInteger(current_vaddr), block_size); | 378 | HandleRasterizerDownload(GetInteger(current_vaddr), block_size); |
| 377 | }; | 379 | }; |
| 378 | return PerformCacheOperation(process, dest_addr, size, on_rasterizer); | 380 | return PerformCacheOperation(process, dest_addr, size, on_rasterizer); |
| 379 | } | 381 | } |
| @@ -462,7 +464,8 @@ struct Memory::Impl { | |||
| 462 | } | 464 | } |
| 463 | 465 | ||
| 464 | if (Settings::IsFastmemEnabled()) { | 466 | if (Settings::IsFastmemEnabled()) { |
| 465 | const bool is_read_enable = !Settings::IsGPULevelExtreme() || !cached; | 467 | const bool is_read_enable = |
| 468 | !Settings::values.use_reactive_flushing.GetValue() || !cached; | ||
| 466 | system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached); | 469 | system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached); |
| 467 | } | 470 | } |
| 468 | 471 | ||
| @@ -651,7 +654,7 @@ struct Memory::Impl { | |||
| 651 | LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, | 654 | LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, |
| 652 | GetInteger(vaddr)); | 655 | GetInteger(vaddr)); |
| 653 | }, | 656 | }, |
| 654 | [&]() { system.GPU().FlushRegion(GetInteger(vaddr), sizeof(T)); }); | 657 | [&]() { HandleRasterizerDownload(GetInteger(vaddr), sizeof(T)); }); |
| 655 | if (ptr) { | 658 | if (ptr) { |
| 656 | std::memcpy(&result, ptr, sizeof(T)); | 659 | std::memcpy(&result, ptr, sizeof(T)); |
| 657 | } | 660 | } |
| @@ -712,7 +715,19 @@ struct Memory::Impl { | |||
| 712 | return true; | 715 | return true; |
| 713 | } | 716 | } |
| 714 | 717 | ||
| 718 | void HandleRasterizerDownload(VAddr address, size_t size) { | ||
| 719 | const size_t core = system.GetCurrentHostThreadID(); | ||
| 720 | auto& current_area = rasterizer_areas[core]; | ||
| 721 | const VAddr end_address = address + size; | ||
| 722 | if (current_area.start_address <= address && end_address <= current_area.end_address) | ||
| 723 | [[likely]] { | ||
| 724 | return; | ||
| 725 | } | ||
| 726 | current_area = system.GPU().OnCPURead(address, size); | ||
| 727 | } | ||
| 728 | |||
| 715 | Common::PageTable* current_page_table = nullptr; | 729 | Common::PageTable* current_page_table = nullptr; |
| 730 | std::array<VideoCore::RasterizerDownloadArea, Core::Hardware::NUM_CPU_CORES> rasterizer_areas{}; | ||
| 716 | Core::System& system; | 731 | Core::System& system; |
| 717 | }; | 732 | }; |
| 718 | 733 | ||