diff --git a/src/core/memory.cpp b/src/core/memory.cpp index a669e714e5..9e3880b04c 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -754,7 +754,7 @@ struct Memory::Impl { }; auto& gpu = system.GPU(); gpu_device_memory->ApplyOpOnPointer(p, scratch_buffers[core], [&](DAddr addr) { - if (flush) { + if (flush && gpu.MustFlushRegion(addr, size)) { void(gpu.OnCPURead(addr, size)); } gpu.InvalidateRegion(addr, size); diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 548a8bf809..c55c00cb4f 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -219,6 +219,10 @@ struct GPU::Impl { return renderer->ReadRasterizer()->OnCPUWrite(addr, size); } + bool MustFlushRegion(DAddr addr, u64 size) { + return renderer->ReadRasterizer()->MustFlushRegion(addr, size); + } + /// Notify rasterizer that any caches of the specified region should be flushed and invalidated void FlushAndInvalidateRegion(DAddr addr, u64 size) { gpu_thread.FlushAndInvalidateRegion(addr, size, is_async); @@ -480,6 +484,10 @@ void GPU::InvalidateRegion(DAddr addr, u64 size) { impl->InvalidateRegion(addr, size); } +bool GPU::MustFlushRegion(DAddr addr, u64 size) { + return impl->MustFlushRegion(addr, size); +} + bool GPU::OnCPUWrite(DAddr addr, u64 size) { return impl->OnCPUWrite(addr, size); } diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 538c4da85a..2a8419743b 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -246,6 +246,9 @@ public: /// Notify rasterizer that any caches of the specified region should be invalidated void InvalidateRegion(DAddr addr, u64 size); + /// Check if the specified memory area requires flushing to CPU memory + [[nodiscard]] bool MustFlushRegion(DAddr addr, u64 size); + /// Notify rasterizer that CPU is trying to write this area. It returns true if the area is /// sensible, false otherwise, addr and size must be a valid combination bool OnCPUWrite(DAddr addr, u64 size);