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, 18 insertions, 7 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 8176a41be..609e775ae 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -24,6 +24,8 @@
24#include "core/hle/kernel/k_process.h" 24#include "core/hle/kernel/k_process.h"
25#include "core/memory.h" 25#include "core/memory.h"
26#include "video_core/gpu.h" 26#include "video_core/gpu.h"
27#include "video_core/host1x/gpu_device_memory_manager.h"
28#include "video_core/host1x/host1x.h"
27#include "video_core/rasterizer_download_area.h" 29#include "video_core/rasterizer_download_area.h"
28 30
29namespace Core::Memory { 31namespace Core::Memory {
@@ -638,15 +640,16 @@ struct Memory::Impl {
638 base * YUZU_PAGESIZE, (base + size) * YUZU_PAGESIZE); 640 base * YUZU_PAGESIZE, (base + size) * YUZU_PAGESIZE);
639 641
640 // During boot, current_page_table might not be set yet, in which case we need not flush 642 // During boot, current_page_table might not be set yet, in which case we need not flush
641 if (system.IsPoweredOn()) { 643 /*if (system.IsPoweredOn()) {
642 auto& gpu = system.GPU(); 644 auto& gpu = system.GPU();
643 for (u64 i = 0; i < size; i++) { 645 for (u64 i = 0; i < size; i++) {
644 const auto page = base + i; 646 const auto page = base + i;
645 if (page_table.pointers[page].Type() == Common::PageType::RasterizerCachedMemory) { 647 if (page_table.pointers[page].Type() == Common::PageType::RasterizerCachedMemory) {
648
646 gpu.FlushAndInvalidateRegion(page << YUZU_PAGEBITS, YUZU_PAGESIZE); 649 gpu.FlushAndInvalidateRegion(page << YUZU_PAGEBITS, YUZU_PAGESIZE);
647 } 650 }
648 } 651 }
649 } 652 }*/
650 653
651 const auto end = base + size; 654 const auto end = base + size;
652 ASSERT_MSG(end <= page_table.pointers.size(), "out of range mapping at {:016X}", 655 ASSERT_MSG(end <= page_table.pointers.size(), "out of range mapping at {:016X}",
@@ -811,10 +814,15 @@ struct Memory::Impl {
811 return true; 814 return true;
812 } 815 }
813 816
814 void HandleRasterizerDownload(VAddr address, size_t size) { 817 void HandleRasterizerDownload(VAddr v_address, size_t size) {
818 const auto* p = GetPointerImpl(
819 v_address, []() {}, []() {});
820 auto& gpu_device_memory = system.Host1x().MemoryManager();
821 DAddr address =
822 gpu_device_memory.GetAddressFromPAddr(system.DeviceMemory().GetRawPhysicalAddr(p));
815 const size_t core = system.GetCurrentHostThreadID(); 823 const size_t core = system.GetCurrentHostThreadID();
816 auto& current_area = rasterizer_read_areas[core]; 824 auto& current_area = rasterizer_read_areas[core];
817 const VAddr end_address = address + size; 825 const DAddr end_address = address + size;
818 if (current_area.start_address <= address && end_address <= current_area.end_address) 826 if (current_area.start_address <= address && end_address <= current_area.end_address)
819 [[likely]] { 827 [[likely]] {
820 return; 828 return;
@@ -822,7 +830,10 @@ struct Memory::Impl {
822 current_area = system.GPU().OnCPURead(address, size); 830 current_area = system.GPU().OnCPURead(address, size);
823 } 831 }
824 832
825 void HandleRasterizerWrite(VAddr address, size_t size) { 833 void HandleRasterizerWrite(VAddr v_address, size_t size) {
834 const auto* p = GetPointerImpl(
835 v_address, []() {}, []() {});
836 PAddr address = system.DeviceMemory().GetRawPhysicalAddr(p);
826 constexpr size_t sys_core = Core::Hardware::NUM_CPU_CORES - 1; 837 constexpr size_t sys_core = Core::Hardware::NUM_CPU_CORES - 1;
827 const size_t core = std::min(system.GetCurrentHostThreadID(), 838 const size_t core = std::min(system.GetCurrentHostThreadID(),
828 sys_core); // any other calls threads go to syscore. 839 sys_core); // any other calls threads go to syscore.
@@ -836,7 +847,7 @@ struct Memory::Impl {
836 } 847 }
837 }); 848 });
838 auto& current_area = rasterizer_write_areas[core]; 849 auto& current_area = rasterizer_write_areas[core];
839 VAddr subaddress = address >> YUZU_PAGEBITS; 850 PAddr subaddress = address >> YUZU_PAGEBITS;
840 bool do_collection = current_area.last_address == subaddress; 851 bool do_collection = current_area.last_address == subaddress;
841 if (!do_collection) [[unlikely]] { 852 if (!do_collection) [[unlikely]] {
842 do_collection = system.GPU().OnCPUWrite(address, size); 853 do_collection = system.GPU().OnCPUWrite(address, size);
@@ -849,7 +860,7 @@ struct Memory::Impl {
849 } 860 }
850 861
851 struct GPUDirtyState { 862 struct GPUDirtyState {
852 VAddr last_address; 863 PAddr last_address;
853 }; 864 };
854 865
855 void InvalidateRegion(Common::ProcessAddress dest_addr, size_t size) { 866 void InvalidateRegion(Common::ProcessAddress dest_addr, size_t size) {