mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-18 03:17:32 +01:00
video_core: memory_manager: Flush/invalidate asynchronously on Unmap.
- Minor perf improvement.
This commit is contained in:
parent
e545c2322c
commit
d65fa7d65c
@ -9,6 +9,7 @@
|
|||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/kernel/vm_manager.h"
|
#include "core/hle/kernel/vm_manager.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
#include "video_core/gpu.h"
|
||||||
#include "video_core/memory_manager.h"
|
#include "video_core/memory_manager.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "video_core/rasterizer_interface.h"
|
||||||
|
|
||||||
@ -84,7 +85,9 @@ GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) {
|
|||||||
const auto cpu_addr = GpuToCpuAddress(gpu_addr);
|
const auto cpu_addr = GpuToCpuAddress(gpu_addr);
|
||||||
ASSERT(cpu_addr);
|
ASSERT(cpu_addr);
|
||||||
|
|
||||||
rasterizer.FlushAndInvalidateRegion(cache_addr, aligned_size);
|
// Flush and invalidate through the GPU interface, to be asynchronous if possible.
|
||||||
|
system.GPU().FlushAndInvalidateRegion(cache_addr, aligned_size);
|
||||||
|
|
||||||
UnmapRange(gpu_addr, aligned_size);
|
UnmapRange(gpu_addr, aligned_size);
|
||||||
ASSERT(system.CurrentProcess()
|
ASSERT(system.CurrentProcess()
|
||||||
->VMManager()
|
->VMManager()
|
||||||
@ -242,6 +245,8 @@ void MemoryManager::ReadBlock(GPUVAddr src_addr, void* dest_buffer, const std::s
|
|||||||
switch (page_table.attributes[page_index]) {
|
switch (page_table.attributes[page_index]) {
|
||||||
case Common::PageType::Memory: {
|
case Common::PageType::Memory: {
|
||||||
const u8* src_ptr{page_table.pointers[page_index] + page_offset};
|
const u8* src_ptr{page_table.pointers[page_index] + page_offset};
|
||||||
|
// Flush must happen on the rasterizer interface, such that memory is always synchronous
|
||||||
|
// when it is read (even when in asynchronous GPU mode). Fixes Dead Cells title menu.
|
||||||
rasterizer.FlushRegion(ToCacheAddr(src_ptr), copy_amount);
|
rasterizer.FlushRegion(ToCacheAddr(src_ptr), copy_amount);
|
||||||
std::memcpy(dest_buffer, src_ptr, copy_amount);
|
std::memcpy(dest_buffer, src_ptr, copy_amount);
|
||||||
break;
|
break;
|
||||||
@ -292,6 +297,8 @@ void MemoryManager::WriteBlock(GPUVAddr dest_addr, const void* src_buffer, const
|
|||||||
switch (page_table.attributes[page_index]) {
|
switch (page_table.attributes[page_index]) {
|
||||||
case Common::PageType::Memory: {
|
case Common::PageType::Memory: {
|
||||||
u8* dest_ptr{page_table.pointers[page_index] + page_offset};
|
u8* dest_ptr{page_table.pointers[page_index] + page_offset};
|
||||||
|
// Invalidate must happen on the rasterizer interface, such that memory is always
|
||||||
|
// synchronous when it is written (even when in asynchronous GPU mode).
|
||||||
rasterizer.InvalidateRegion(ToCacheAddr(dest_ptr), copy_amount);
|
rasterizer.InvalidateRegion(ToCacheAddr(dest_ptr), copy_amount);
|
||||||
std::memcpy(dest_ptr, src_buffer, copy_amount);
|
std::memcpy(dest_ptr, src_buffer, copy_amount);
|
||||||
break;
|
break;
|
||||||
@ -339,6 +346,8 @@ void MemoryManager::CopyBlock(GPUVAddr dest_addr, GPUVAddr src_addr, const std::
|
|||||||
|
|
||||||
switch (page_table.attributes[page_index]) {
|
switch (page_table.attributes[page_index]) {
|
||||||
case Common::PageType::Memory: {
|
case Common::PageType::Memory: {
|
||||||
|
// Flush must happen on the rasterizer interface, such that memory is always synchronous
|
||||||
|
// when it is copied (even when in asynchronous GPU mode).
|
||||||
const u8* src_ptr{page_table.pointers[page_index] + page_offset};
|
const u8* src_ptr{page_table.pointers[page_index] + page_offset};
|
||||||
rasterizer.FlushRegion(ToCacheAddr(src_ptr), copy_amount);
|
rasterizer.FlushRegion(ToCacheAddr(src_ptr), copy_amount);
|
||||||
WriteBlock(dest_addr, src_ptr, copy_amount);
|
WriteBlock(dest_addr, src_ptr, copy_amount);
|
||||||
|
Loading…
Reference in New Issue
Block a user