diff options
| author | 2020-04-05 12:58:23 -0400 | |
|---|---|---|
| committer | 2020-04-06 09:21:46 -0400 | |
| commit | 9c0f40a1f5bea37b87a31e9f957c4d2a14a8e421 (patch) | |
| tree | 0aca3e4623f87ee57694b028bea75fdf2ae3c32c | |
| parent | Merge pull request #3513 from ReinUsesLisp/native-astc (diff) | |
| download | yuzu-9c0f40a1f5bea37b87a31e9f957c4d2a14a8e421.tar.gz yuzu-9c0f40a1f5bea37b87a31e9f957c4d2a14a8e421.tar.xz yuzu-9c0f40a1f5bea37b87a31e9f957c4d2a14a8e421.zip | |
GPU: Setup Flush/Invalidate to use VAddr instead of CacheAddr
| -rw-r--r-- | src/core/memory.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_asynch.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_asynch.h | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_synch.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_synch.h | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_thread.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_thread.h | 18 | ||||
| -rw-r--r-- | src/video_core/memory_manager.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/rasterizer_interface.h | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 22 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 28 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.h | 6 |
14 files changed, 77 insertions, 67 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index f0888327f..9ceb7fabc 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -242,7 +242,7 @@ struct Memory::Impl { | |||
| 242 | } | 242 | } |
| 243 | case Common::PageType::RasterizerCachedMemory: { | 243 | case Common::PageType::RasterizerCachedMemory: { |
| 244 | const u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); | 244 | const u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); |
| 245 | system.GPU().FlushRegion(ToCacheAddr(host_ptr), copy_amount); | 245 | system.GPU().FlushRegion(current_vaddr, copy_amount); |
| 246 | std::memcpy(dest_buffer, host_ptr, copy_amount); | 246 | std::memcpy(dest_buffer, host_ptr, copy_amount); |
| 247 | break; | 247 | break; |
| 248 | } | 248 | } |
| @@ -290,7 +290,7 @@ struct Memory::Impl { | |||
| 290 | } | 290 | } |
| 291 | case Common::PageType::RasterizerCachedMemory: { | 291 | case Common::PageType::RasterizerCachedMemory: { |
| 292 | u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); | 292 | u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); |
| 293 | system.GPU().InvalidateRegion(ToCacheAddr(host_ptr), copy_amount); | 293 | system.GPU().InvalidateRegion(current_vaddr, copy_amount); |
| 294 | std::memcpy(host_ptr, src_buffer, copy_amount); | 294 | std::memcpy(host_ptr, src_buffer, copy_amount); |
| 295 | break; | 295 | break; |
| 296 | } | 296 | } |
| @@ -337,7 +337,7 @@ struct Memory::Impl { | |||
| 337 | } | 337 | } |
| 338 | case Common::PageType::RasterizerCachedMemory: { | 338 | case Common::PageType::RasterizerCachedMemory: { |
| 339 | u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); | 339 | u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); |
| 340 | system.GPU().InvalidateRegion(ToCacheAddr(host_ptr), copy_amount); | 340 | system.GPU().InvalidateRegion(current_vaddr, copy_amount); |
| 341 | std::memset(host_ptr, 0, copy_amount); | 341 | std::memset(host_ptr, 0, copy_amount); |
| 342 | break; | 342 | break; |
| 343 | } | 343 | } |
| @@ -384,7 +384,7 @@ struct Memory::Impl { | |||
| 384 | } | 384 | } |
| 385 | case Common::PageType::RasterizerCachedMemory: { | 385 | case Common::PageType::RasterizerCachedMemory: { |
| 386 | const u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); | 386 | const u8* const host_ptr = GetPointerFromVMA(process, current_vaddr); |
| 387 | system.GPU().FlushRegion(ToCacheAddr(host_ptr), copy_amount); | 387 | system.GPU().FlushRegion(current_vaddr, copy_amount); |
| 388 | WriteBlock(process, dest_addr, host_ptr, copy_amount); | 388 | WriteBlock(process, dest_addr, host_ptr, copy_amount); |
| 389 | break; | 389 | break; |
| 390 | } | 390 | } |
| @@ -545,7 +545,7 @@ struct Memory::Impl { | |||
| 545 | break; | 545 | break; |
| 546 | case Common::PageType::RasterizerCachedMemory: { | 546 | case Common::PageType::RasterizerCachedMemory: { |
| 547 | const u8* const host_ptr = GetPointerFromVMA(vaddr); | 547 | const u8* const host_ptr = GetPointerFromVMA(vaddr); |
| 548 | system.GPU().FlushRegion(ToCacheAddr(host_ptr), sizeof(T)); | 548 | system.GPU().FlushRegion(vaddr, sizeof(T)); |
| 549 | T value; | 549 | T value; |
| 550 | std::memcpy(&value, host_ptr, sizeof(T)); | 550 | std::memcpy(&value, host_ptr, sizeof(T)); |
| 551 | return value; | 551 | return value; |
| @@ -587,7 +587,7 @@ struct Memory::Impl { | |||
| 587 | break; | 587 | break; |
| 588 | case Common::PageType::RasterizerCachedMemory: { | 588 | case Common::PageType::RasterizerCachedMemory: { |
| 589 | u8* const host_ptr{GetPointerFromVMA(vaddr)}; | 589 | u8* const host_ptr{GetPointerFromVMA(vaddr)}; |
| 590 | system.GPU().InvalidateRegion(ToCacheAddr(host_ptr), sizeof(T)); | 590 | system.GPU().InvalidateRegion(vaddr, sizeof(T)); |
| 591 | std::memcpy(host_ptr, &data, sizeof(T)); | 591 | std::memcpy(host_ptr, &data, sizeof(T)); |
| 592 | break; | 592 | break; |
| 593 | } | 593 | } |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index ced9d7e28..1a2d747be 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -270,13 +270,13 @@ public: | |||
| 270 | virtual void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) = 0; | 270 | virtual void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) = 0; |
| 271 | 271 | ||
| 272 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory | 272 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory |
| 273 | virtual void FlushRegion(CacheAddr addr, u64 size) = 0; | 273 | virtual void FlushRegion(VAddr addr, u64 size) = 0; |
| 274 | 274 | ||
| 275 | /// Notify rasterizer that any caches of the specified region should be invalidated | 275 | /// Notify rasterizer that any caches of the specified region should be invalidated |
| 276 | virtual void InvalidateRegion(CacheAddr addr, u64 size) = 0; | 276 | virtual void InvalidateRegion(VAddr addr, u64 size) = 0; |
| 277 | 277 | ||
| 278 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated | 278 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated |
| 279 | virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0; | 279 | virtual void FlushAndInvalidateRegion(VAddr addr, u64 size) = 0; |
| 280 | 280 | ||
| 281 | protected: | 281 | protected: |
| 282 | virtual void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const = 0; | 282 | virtual void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const = 0; |
diff --git a/src/video_core/gpu_asynch.cpp b/src/video_core/gpu_asynch.cpp index 925be8d7b..cc434faf7 100644 --- a/src/video_core/gpu_asynch.cpp +++ b/src/video_core/gpu_asynch.cpp | |||
| @@ -30,15 +30,15 @@ void GPUAsynch::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | |||
| 30 | gpu_thread.SwapBuffers(framebuffer); | 30 | gpu_thread.SwapBuffers(framebuffer); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | void GPUAsynch::FlushRegion(CacheAddr addr, u64 size) { | 33 | void GPUAsynch::FlushRegion(VAddr addr, u64 size) { |
| 34 | gpu_thread.FlushRegion(addr, size); | 34 | gpu_thread.FlushRegion(addr, size); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void GPUAsynch::InvalidateRegion(CacheAddr addr, u64 size) { | 37 | void GPUAsynch::InvalidateRegion(VAddr addr, u64 size) { |
| 38 | gpu_thread.InvalidateRegion(addr, size); | 38 | gpu_thread.InvalidateRegion(addr, size); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void GPUAsynch::FlushAndInvalidateRegion(CacheAddr addr, u64 size) { | 41 | void GPUAsynch::FlushAndInvalidateRegion(VAddr addr, u64 size) { |
| 42 | gpu_thread.FlushAndInvalidateRegion(addr, size); | 42 | gpu_thread.FlushAndInvalidateRegion(addr, size); |
| 43 | } | 43 | } |
| 44 | 44 | ||
diff --git a/src/video_core/gpu_asynch.h b/src/video_core/gpu_asynch.h index 265c62758..03fd0eef0 100644 --- a/src/video_core/gpu_asynch.h +++ b/src/video_core/gpu_asynch.h | |||
| @@ -27,9 +27,9 @@ public: | |||
| 27 | void Start() override; | 27 | void Start() override; |
| 28 | void PushGPUEntries(Tegra::CommandList&& entries) override; | 28 | void PushGPUEntries(Tegra::CommandList&& entries) override; |
| 29 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; | 29 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; |
| 30 | void FlushRegion(CacheAddr addr, u64 size) override; | 30 | void FlushRegion(VAddr addr, u64 size) override; |
| 31 | void InvalidateRegion(CacheAddr addr, u64 size) override; | 31 | void InvalidateRegion(VAddr addr, u64 size) override; |
| 32 | void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override; | 32 | void FlushAndInvalidateRegion(VAddr addr, u64 size) override; |
| 33 | void WaitIdle() const override; | 33 | void WaitIdle() const override; |
| 34 | 34 | ||
| 35 | protected: | 35 | protected: |
diff --git a/src/video_core/gpu_synch.cpp b/src/video_core/gpu_synch.cpp index bd5278a5c..6f38a672a 100644 --- a/src/video_core/gpu_synch.cpp +++ b/src/video_core/gpu_synch.cpp | |||
| @@ -26,15 +26,15 @@ void GPUSynch::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | |||
| 26 | renderer->SwapBuffers(framebuffer); | 26 | renderer->SwapBuffers(framebuffer); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | void GPUSynch::FlushRegion(CacheAddr addr, u64 size) { | 29 | void GPUSynch::FlushRegion(VAddr addr, u64 size) { |
| 30 | renderer->Rasterizer().FlushRegion(addr, size); | 30 | renderer->Rasterizer().FlushRegion(addr, size); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | void GPUSynch::InvalidateRegion(CacheAddr addr, u64 size) { | 33 | void GPUSynch::InvalidateRegion(VAddr addr, u64 size) { |
| 34 | renderer->Rasterizer().InvalidateRegion(addr, size); | 34 | renderer->Rasterizer().InvalidateRegion(addr, size); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void GPUSynch::FlushAndInvalidateRegion(CacheAddr addr, u64 size) { | 37 | void GPUSynch::FlushAndInvalidateRegion(VAddr addr, u64 size) { |
| 38 | renderer->Rasterizer().FlushAndInvalidateRegion(addr, size); | 38 | renderer->Rasterizer().FlushAndInvalidateRegion(addr, size); |
| 39 | } | 39 | } |
| 40 | 40 | ||
diff --git a/src/video_core/gpu_synch.h b/src/video_core/gpu_synch.h index 866a94c8c..4a6e9a01d 100644 --- a/src/video_core/gpu_synch.h +++ b/src/video_core/gpu_synch.h | |||
| @@ -26,9 +26,9 @@ public: | |||
| 26 | void Start() override; | 26 | void Start() override; |
| 27 | void PushGPUEntries(Tegra::CommandList&& entries) override; | 27 | void PushGPUEntries(Tegra::CommandList&& entries) override; |
| 28 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; | 28 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; |
| 29 | void FlushRegion(CacheAddr addr, u64 size) override; | 29 | void FlushRegion(VAddr addr, u64 size) override; |
| 30 | void InvalidateRegion(CacheAddr addr, u64 size) override; | 30 | void InvalidateRegion(VAddr addr, u64 size) override; |
| 31 | void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override; | 31 | void FlushAndInvalidateRegion(VAddr addr, u64 size) override; |
| 32 | void WaitIdle() const override {} | 32 | void WaitIdle() const override {} |
| 33 | 33 | ||
| 34 | protected: | 34 | protected: |
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 270c7ae0d..10cda686b 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp | |||
| @@ -77,15 +77,15 @@ void ThreadManager::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | |||
| 77 | PushCommand(SwapBuffersCommand(framebuffer ? std::make_optional(*framebuffer) : std::nullopt)); | 77 | PushCommand(SwapBuffersCommand(framebuffer ? std::make_optional(*framebuffer) : std::nullopt)); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | void ThreadManager::FlushRegion(CacheAddr addr, u64 size) { | 80 | void ThreadManager::FlushRegion(VAddr addr, u64 size) { |
| 81 | PushCommand(FlushRegionCommand(addr, size)); | 81 | PushCommand(FlushRegionCommand(addr, size)); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void ThreadManager::InvalidateRegion(CacheAddr addr, u64 size) { | 84 | void ThreadManager::InvalidateRegion(VAddr addr, u64 size) { |
| 85 | system.Renderer().Rasterizer().InvalidateRegion(addr, size); | 85 | system.Renderer().Rasterizer().InvalidateRegion(addr, size); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | void ThreadManager::FlushAndInvalidateRegion(CacheAddr addr, u64 size) { | 88 | void ThreadManager::FlushAndInvalidateRegion(VAddr addr, u64 size) { |
| 89 | // Skip flush on asynch mode, as FlushAndInvalidateRegion is not used for anything too important | 89 | // Skip flush on asynch mode, as FlushAndInvalidateRegion is not used for anything too important |
| 90 | InvalidateRegion(addr, size); | 90 | InvalidateRegion(addr, size); |
| 91 | } | 91 | } |
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index be36c580e..cd74ad330 100644 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h | |||
| @@ -47,26 +47,26 @@ struct SwapBuffersCommand final { | |||
| 47 | 47 | ||
| 48 | /// Command to signal to the GPU thread to flush a region | 48 | /// Command to signal to the GPU thread to flush a region |
| 49 | struct FlushRegionCommand final { | 49 | struct FlushRegionCommand final { |
| 50 | explicit constexpr FlushRegionCommand(CacheAddr addr, u64 size) : addr{addr}, size{size} {} | 50 | explicit constexpr FlushRegionCommand(VAddr addr, u64 size) : addr{addr}, size{size} {} |
| 51 | 51 | ||
| 52 | CacheAddr addr; | 52 | VAddr addr; |
| 53 | u64 size; | 53 | u64 size; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | /// Command to signal to the GPU thread to invalidate a region | 56 | /// Command to signal to the GPU thread to invalidate a region |
| 57 | struct InvalidateRegionCommand final { | 57 | struct InvalidateRegionCommand final { |
| 58 | explicit constexpr InvalidateRegionCommand(CacheAddr addr, u64 size) : addr{addr}, size{size} {} | 58 | explicit constexpr InvalidateRegionCommand(VAddr addr, u64 size) : addr{addr}, size{size} {} |
| 59 | 59 | ||
| 60 | CacheAddr addr; | 60 | VAddr addr; |
| 61 | u64 size; | 61 | u64 size; |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| 64 | /// Command to signal to the GPU thread to flush and invalidate a region | 64 | /// Command to signal to the GPU thread to flush and invalidate a region |
| 65 | struct FlushAndInvalidateRegionCommand final { | 65 | struct FlushAndInvalidateRegionCommand final { |
| 66 | explicit constexpr FlushAndInvalidateRegionCommand(CacheAddr addr, u64 size) | 66 | explicit constexpr FlushAndInvalidateRegionCommand(VAddr addr, u64 size) |
| 67 | : addr{addr}, size{size} {} | 67 | : addr{addr}, size{size} {} |
| 68 | 68 | ||
| 69 | CacheAddr addr; | 69 | VAddr addr; |
| 70 | u64 size; | 70 | u64 size; |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| @@ -111,13 +111,13 @@ public: | |||
| 111 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer); | 111 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer); |
| 112 | 112 | ||
| 113 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory | 113 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory |
| 114 | void FlushRegion(CacheAddr addr, u64 size); | 114 | void FlushRegion(VAddr addr, u64 size); |
| 115 | 115 | ||
| 116 | /// Notify rasterizer that any caches of the specified region should be invalidated | 116 | /// Notify rasterizer that any caches of the specified region should be invalidated |
| 117 | void InvalidateRegion(CacheAddr addr, u64 size); | 117 | void InvalidateRegion(VAddr addr, u64 size); |
| 118 | 118 | ||
| 119 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated | 119 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated |
| 120 | void FlushAndInvalidateRegion(CacheAddr addr, u64 size); | 120 | void FlushAndInvalidateRegion(VAddr addr, u64 size); |
| 121 | 121 | ||
| 122 | // Wait until the gpu thread is idle. | 122 | // Wait until the gpu thread is idle. |
| 123 | void WaitIdle() const; | 123 | void WaitIdle() const; |
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index f5d33f27a..cddef8d86 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp | |||
| @@ -81,12 +81,11 @@ GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) { | |||
| 81 | ASSERT((gpu_addr & page_mask) == 0); | 81 | ASSERT((gpu_addr & page_mask) == 0); |
| 82 | 82 | ||
| 83 | const u64 aligned_size{Common::AlignUp(size, page_size)}; | 83 | const u64 aligned_size{Common::AlignUp(size, page_size)}; |
| 84 | const CacheAddr cache_addr{ToCacheAddr(GetPointer(gpu_addr))}; | ||
| 85 | const auto cpu_addr = GpuToCpuAddress(gpu_addr); | 84 | const auto cpu_addr = GpuToCpuAddress(gpu_addr); |
| 86 | ASSERT(cpu_addr); | 85 | ASSERT(cpu_addr); |
| 87 | 86 | ||
| 88 | // Flush and invalidate through the GPU interface, to be asynchronous if possible. | 87 | // Flush and invalidate through the GPU interface, to be asynchronous if possible. |
| 89 | system.GPU().FlushAndInvalidateRegion(cache_addr, aligned_size); | 88 | system.GPU().FlushAndInvalidateRegion(*cpu_addr, aligned_size); |
| 90 | 89 | ||
| 91 | UnmapRange(gpu_addr, aligned_size); | 90 | UnmapRange(gpu_addr, aligned_size); |
| 92 | ASSERT(system.CurrentProcess() | 91 | ASSERT(system.CurrentProcess() |
| @@ -247,7 +246,7 @@ void MemoryManager::ReadBlock(GPUVAddr src_addr, void* dest_buffer, const std::s | |||
| 247 | const u8* src_ptr{page_table.pointers[page_index] + page_offset}; | 246 | const u8* src_ptr{page_table.pointers[page_index] + page_offset}; |
| 248 | // Flush must happen on the rasterizer interface, such that memory is always synchronous | 247 | // Flush must happen on the rasterizer interface, such that memory is always synchronous |
| 249 | // when it is read (even when in asynchronous GPU mode). Fixes Dead Cells title menu. | 248 | // when it is read (even when in asynchronous GPU mode). Fixes Dead Cells title menu. |
| 250 | rasterizer.FlushRegion(ToCacheAddr(src_ptr), copy_amount); | 249 | rasterizer.FlushRegion(page_table.backing_addr[page_index] + page_offset, copy_amount); |
| 251 | std::memcpy(dest_buffer, src_ptr, copy_amount); | 250 | std::memcpy(dest_buffer, src_ptr, copy_amount); |
| 252 | break; | 251 | break; |
| 253 | } | 252 | } |
| @@ -299,7 +298,8 @@ void MemoryManager::WriteBlock(GPUVAddr dest_addr, const void* src_buffer, const | |||
| 299 | u8* dest_ptr{page_table.pointers[page_index] + page_offset}; | 298 | u8* dest_ptr{page_table.pointers[page_index] + page_offset}; |
| 300 | // Invalidate must happen on the rasterizer interface, such that memory is always | 299 | // Invalidate must happen on the rasterizer interface, such that memory is always |
| 301 | // synchronous when it is written (even when in asynchronous GPU mode). | 300 | // synchronous when it is written (even when in asynchronous GPU mode). |
| 302 | rasterizer.InvalidateRegion(ToCacheAddr(dest_ptr), copy_amount); | 301 | rasterizer.InvalidateRegion(page_table.backing_addr[page_index] + page_offset, |
| 302 | copy_amount); | ||
| 303 | std::memcpy(dest_ptr, src_buffer, copy_amount); | 303 | std::memcpy(dest_ptr, src_buffer, copy_amount); |
| 304 | break; | 304 | break; |
| 305 | } | 305 | } |
| @@ -349,7 +349,7 @@ void MemoryManager::CopyBlock(GPUVAddr dest_addr, GPUVAddr src_addr, const std:: | |||
| 349 | // Flush must happen on the rasterizer interface, such that memory is always synchronous | 349 | // Flush must happen on the rasterizer interface, such that memory is always synchronous |
| 350 | // when it is copied (even when in asynchronous GPU mode). | 350 | // when it is copied (even when in asynchronous GPU mode). |
| 351 | const u8* src_ptr{page_table.pointers[page_index] + page_offset}; | 351 | const u8* src_ptr{page_table.pointers[page_index] + page_offset}; |
| 352 | rasterizer.FlushRegion(ToCacheAddr(src_ptr), copy_amount); | 352 | rasterizer.FlushRegion(page_table.backing_addr[page_index] + page_offset, copy_amount); |
| 353 | WriteBlock(dest_addr, src_ptr, copy_amount); | 353 | WriteBlock(dest_addr, src_ptr, copy_amount); |
| 354 | break; | 354 | break; |
| 355 | } | 355 | } |
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index 1a68e3caa..8ae5b9c4e 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -53,14 +53,14 @@ public: | |||
| 53 | virtual void FlushAll() = 0; | 53 | virtual void FlushAll() = 0; |
| 54 | 54 | ||
| 55 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory | 55 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory |
| 56 | virtual void FlushRegion(CacheAddr addr, u64 size) = 0; | 56 | virtual void FlushRegion(VAddr addr, u64 size) = 0; |
| 57 | 57 | ||
| 58 | /// Notify rasterizer that any caches of the specified region should be invalidated | 58 | /// Notify rasterizer that any caches of the specified region should be invalidated |
| 59 | virtual void InvalidateRegion(CacheAddr addr, u64 size) = 0; | 59 | virtual void InvalidateRegion(VAddr addr, u64 size) = 0; |
| 60 | 60 | ||
| 61 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory | 61 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory |
| 62 | /// and invalidated | 62 | /// and invalidated |
| 63 | virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0; | 63 | virtual void FlushAndInvalidateRegion(VAddr addr, u64 size) = 0; |
| 64 | 64 | ||
| 65 | /// Notify the rasterizer to send all written commands to the host GPU. | 65 | /// Notify the rasterizer to send all written commands to the host GPU. |
| 66 | virtual void FlushCommands() = 0; | 66 | virtual void FlushCommands() = 0; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 346feeb2f..261738830 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -656,28 +656,30 @@ void RasterizerOpenGL::Query(GPUVAddr gpu_addr, VideoCore::QueryType type, | |||
| 656 | 656 | ||
| 657 | void RasterizerOpenGL::FlushAll() {} | 657 | void RasterizerOpenGL::FlushAll() {} |
| 658 | 658 | ||
| 659 | void RasterizerOpenGL::FlushRegion(CacheAddr addr, u64 size) { | 659 | void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) { |
| 660 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | 660 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); |
| 661 | if (!addr || !size) { | 661 | if (!addr || !size) { |
| 662 | return; | 662 | return; |
| 663 | } | 663 | } |
| 664 | texture_cache.FlushRegion(addr, size); | 664 | CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr)); |
| 665 | buffer_cache.FlushRegion(addr, size); | 665 | texture_cache.FlushRegion(cache_addr, size); |
| 666 | query_cache.FlushRegion(addr, size); | 666 | buffer_cache.FlushRegion(cache_addr, size); |
| 667 | query_cache.FlushRegion(cache_addr, size); | ||
| 667 | } | 668 | } |
| 668 | 669 | ||
| 669 | void RasterizerOpenGL::InvalidateRegion(CacheAddr addr, u64 size) { | 670 | void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size) { |
| 670 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | 671 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); |
| 671 | if (!addr || !size) { | 672 | if (!addr || !size) { |
| 672 | return; | 673 | return; |
| 673 | } | 674 | } |
| 674 | texture_cache.InvalidateRegion(addr, size); | 675 | CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr)); |
| 675 | shader_cache.InvalidateRegion(addr, size); | 676 | texture_cache.InvalidateRegion(cache_addr, size); |
| 676 | buffer_cache.InvalidateRegion(addr, size); | 677 | shader_cache.InvalidateRegion(cache_addr, size); |
| 677 | query_cache.InvalidateRegion(addr, size); | 678 | buffer_cache.InvalidateRegion(cache_addr, size); |
| 679 | query_cache.InvalidateRegion(cache_addr, size); | ||
| 678 | } | 680 | } |
| 679 | 681 | ||
| 680 | void RasterizerOpenGL::FlushAndInvalidateRegion(CacheAddr addr, u64 size) { | 682 | void RasterizerOpenGL::FlushAndInvalidateRegion(VAddr addr, u64 size) { |
| 681 | if (Settings::values.use_accurate_gpu_emulation) { | 683 | if (Settings::values.use_accurate_gpu_emulation) { |
| 682 | FlushRegion(addr, size); | 684 | FlushRegion(addr, size); |
| 683 | } | 685 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 2d3be2437..212dad852 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -65,9 +65,9 @@ public: | |||
| 65 | void ResetCounter(VideoCore::QueryType type) override; | 65 | void ResetCounter(VideoCore::QueryType type) override; |
| 66 | void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) override; | 66 | void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) override; |
| 67 | void FlushAll() override; | 67 | void FlushAll() override; |
| 68 | void FlushRegion(CacheAddr addr, u64 size) override; | 68 | void FlushRegion(VAddr addr, u64 size) override; |
| 69 | void InvalidateRegion(CacheAddr addr, u64 size) override; | 69 | void InvalidateRegion(VAddr addr, u64 size) override; |
| 70 | void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override; | 70 | void FlushAndInvalidateRegion(VAddr addr, u64 size) override; |
| 71 | void FlushCommands() override; | 71 | void FlushCommands() override; |
| 72 | void TickFrame() override; | 72 | void TickFrame() override; |
| 73 | bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src, | 73 | bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src, |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 58c69b786..0ca72eb45 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -495,20 +495,28 @@ void RasterizerVulkan::Query(GPUVAddr gpu_addr, VideoCore::QueryType type, | |||
| 495 | 495 | ||
| 496 | void RasterizerVulkan::FlushAll() {} | 496 | void RasterizerVulkan::FlushAll() {} |
| 497 | 497 | ||
| 498 | void RasterizerVulkan::FlushRegion(CacheAddr addr, u64 size) { | 498 | void RasterizerVulkan::FlushRegion(VAddr addr, u64 size) { |
| 499 | texture_cache.FlushRegion(addr, size); | 499 | if (!addr || !size) { |
| 500 | buffer_cache.FlushRegion(addr, size); | 500 | return; |
| 501 | query_cache.FlushRegion(addr, size); | 501 | } |
| 502 | CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr)); | ||
| 503 | texture_cache.FlushRegion(cache_addr, size); | ||
| 504 | buffer_cache.FlushRegion(cache_addr, size); | ||
| 505 | query_cache.FlushRegion(cache_addr, size); | ||
| 502 | } | 506 | } |
| 503 | 507 | ||
| 504 | void RasterizerVulkan::InvalidateRegion(CacheAddr addr, u64 size) { | 508 | void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size) { |
| 505 | texture_cache.InvalidateRegion(addr, size); | 509 | if (!addr || !size) { |
| 506 | pipeline_cache.InvalidateRegion(addr, size); | 510 | return; |
| 507 | buffer_cache.InvalidateRegion(addr, size); | 511 | } |
| 508 | query_cache.InvalidateRegion(addr, size); | 512 | CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr)); |
| 513 | texture_cache.InvalidateRegion(cache_addr, size); | ||
| 514 | pipeline_cache.InvalidateRegion(cache_addr, size); | ||
| 515 | buffer_cache.InvalidateRegion(cache_addr, size); | ||
| 516 | query_cache.InvalidateRegion(cache_addr, size); | ||
| 509 | } | 517 | } |
| 510 | 518 | ||
| 511 | void RasterizerVulkan::FlushAndInvalidateRegion(CacheAddr addr, u64 size) { | 519 | void RasterizerVulkan::FlushAndInvalidateRegion(VAddr addr, u64 size) { |
| 512 | FlushRegion(addr, size); | 520 | FlushRegion(addr, size); |
| 513 | InvalidateRegion(addr, size); | 521 | InvalidateRegion(addr, size); |
| 514 | } | 522 | } |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 3185868e9..f642dde76 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h | |||
| @@ -118,9 +118,9 @@ public: | |||
| 118 | void ResetCounter(VideoCore::QueryType type) override; | 118 | void ResetCounter(VideoCore::QueryType type) override; |
| 119 | void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) override; | 119 | void Query(GPUVAddr gpu_addr, VideoCore::QueryType type, std::optional<u64> timestamp) override; |
| 120 | void FlushAll() override; | 120 | void FlushAll() override; |
| 121 | void FlushRegion(CacheAddr addr, u64 size) override; | 121 | void FlushRegion(VAddr addr, u64 size) override; |
| 122 | void InvalidateRegion(CacheAddr addr, u64 size) override; | 122 | void InvalidateRegion(VAddr addr, u64 size) override; |
| 123 | void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override; | 123 | void FlushAndInvalidateRegion(VAddr addr, u64 size) override; |
| 124 | void FlushCommands() override; | 124 | void FlushCommands() override; |
| 125 | void TickFrame() override; | 125 | void TickFrame() override; |
| 126 | bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src, | 126 | bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src, |