From 2eaf6c41a4686028c0abc84d1be6fd48a67cf49f Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 18 Feb 2019 20:58:32 -0500 Subject: gpu: Use host address for caching instead of guest address. --- src/video_core/engines/kepler_memory.cpp | 4 +++- src/video_core/engines/maxwell_3d.cpp | 5 ++++- src/video_core/engines/maxwell_dma.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/video_core/engines') diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp index aae2a4019..daefa43a6 100644 --- a/src/video_core/engines/kepler_memory.cpp +++ b/src/video_core/engines/kepler_memory.cpp @@ -9,6 +9,7 @@ #include "video_core/engines/kepler_memory.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/rasterizer_interface.h" +#include "video_core/renderer_base.h" namespace Tegra::Engines { @@ -48,7 +49,8 @@ void KeplerMemory::ProcessData(u32 data) { // We have to invalidate the destination region to evict any outdated surfaces from the cache. // We do this before actually writing the new data because the destination address might contain // a dirty surface that will have to be written back to memory. - Core::System::GetInstance().GPU().InvalidateRegion(*dest_address, sizeof(u32)); + system.Renderer().Rasterizer().InvalidateRegion(ToCacheAddr(Memory::GetPointer(*dest_address)), + sizeof(u32)); Memory::Write32(*dest_address, data); system.GPU().Maxwell3D().dirty_flags.OnMemoryWrite(); diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 144e7fa82..49979694e 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -396,7 +396,10 @@ void Maxwell3D::ProcessCBData(u32 value) { const auto address = memory_manager.GpuToCpuAddress(buffer_address + regs.const_buffer.cb_pos); ASSERT_MSG(address, "Invalid GPU address"); - Memory::Write32(*address, value); + u8* ptr{Memory::GetPointer(*address)}; + rasterizer.InvalidateRegion(ToCacheAddr(ptr), sizeof(u32)); + std::memcpy(ptr, &value, sizeof(u32)); + dirty_flags.OnMemoryWrite(); // Increment the current buffer position. diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index 9dfea5999..415a6319a 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp @@ -9,6 +9,7 @@ #include "video_core/engines/maxwell_3d.h" #include "video_core/engines/maxwell_dma.h" #include "video_core/rasterizer_interface.h" +#include "video_core/renderer_base.h" #include "video_core/textures/decoders.h" namespace Tegra::Engines { @@ -92,12 +93,14 @@ void MaxwellDMA::HandleCopy() { const auto FlushAndInvalidate = [&](u32 src_size, u64 dst_size) { // TODO(Subv): For now, manually flush the regions until we implement GPU-accelerated // copying. - Core::System::GetInstance().GPU().FlushRegion(*source_cpu, src_size); + Core::System::GetInstance().Renderer().Rasterizer().FlushRegion( + ToCacheAddr(Memory::GetPointer(*source_cpu)), src_size); // We have to invalidate the destination region to evict any outdated surfaces from the // cache. We do this before actually writing the new data because the destination address // might contain a dirty surface that will have to be written back to memory. - Core::System::GetInstance().GPU().InvalidateRegion(*dest_cpu, dst_size); + Core::System::GetInstance().Renderer().Rasterizer().InvalidateRegion( + ToCacheAddr(Memory::GetPointer(*dest_cpu)), dst_size); }; if (regs.exec.is_dst_linear && !regs.exec.is_src_linear) { -- cgit v1.2.3