summaryrefslogtreecommitdiff
path: root/src/core/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r--src/core/memory.cpp25
1 files changed, 20 insertions, 5 deletions
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
21namespace Core::Memory { 23namespace 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