mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-12-20 14:13:06 +00:00
Buffer cache: Fixes, Clang and Feedback.
This commit is contained in:
parent
1a95a7cdd9
commit
1ae4b684ff
3 changed files with 10 additions and 11 deletions
|
@ -172,7 +172,7 @@ public:
|
||||||
[[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size);
|
[[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size);
|
||||||
|
|
||||||
/// Return true when a region is registered on the cache
|
/// Return true when a region is registered on the cache
|
||||||
[[nodiscard]] bool IsRegionRegistered(VAddr addr, size_t size) const;
|
[[nodiscard]] bool IsRegionRegistered(VAddr addr, size_t size);
|
||||||
|
|
||||||
/// Return true when a CPU region is modified from the CPU
|
/// Return true when a CPU region is modified from the CPU
|
||||||
[[nodiscard]] bool IsRegionCpuModified(VAddr addr, size_t size);
|
[[nodiscard]] bool IsRegionCpuModified(VAddr addr, size_t size);
|
||||||
|
@ -503,10 +503,6 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
|
||||||
auto& src_buffer = slot_buffers[buffer_a];
|
auto& src_buffer = slot_buffers[buffer_a];
|
||||||
auto& dest_buffer = slot_buffers[buffer_b];
|
auto& dest_buffer = slot_buffers[buffer_b];
|
||||||
SynchronizeBuffer(src_buffer, *cpu_src_address, static_cast<u32>(amount));
|
SynchronizeBuffer(src_buffer, *cpu_src_address, static_cast<u32>(amount));
|
||||||
const VAddr aligned_dst = Common::AlignUp(*cpu_dest_address, 64);
|
|
||||||
const u64 diff = aligned_dst - *cpu_dest_address;
|
|
||||||
const u64 new_amount = diff > amount ? 0 : amount - diff;
|
|
||||||
dest_buffer.UnmarkRegionAsCpuModified(aligned_dst, Common::AlignDown(new_amount, 64));
|
|
||||||
SynchronizeBuffer(dest_buffer, *cpu_dest_address, static_cast<u32>(amount));
|
SynchronizeBuffer(dest_buffer, *cpu_dest_address, static_cast<u32>(amount));
|
||||||
std::array copies{BufferCopy{
|
std::array copies{BufferCopy{
|
||||||
.src_offset = src_buffer.Offset(*cpu_src_address),
|
.src_offset = src_buffer.Offset(*cpu_src_address),
|
||||||
|
@ -552,21 +548,19 @@ bool BufferCache<P>::DMAClear(GPUVAddr dst_address, u64 amount, u32 value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntervalType subtract_interval{*cpu_dst_address, *cpu_dst_address + amount * sizeof(u32)};
|
const size_t size = amount * sizeof(u32);
|
||||||
|
const IntervalType subtract_interval{*cpu_dst_address, *cpu_dst_address + size};
|
||||||
ClearDownload(subtract_interval);
|
ClearDownload(subtract_interval);
|
||||||
common_ranges.subtract(subtract_interval);
|
common_ranges.subtract(subtract_interval);
|
||||||
|
|
||||||
const size_t size = amount * sizeof(u32);
|
|
||||||
BufferId buffer;
|
BufferId buffer;
|
||||||
do {
|
do {
|
||||||
has_deleted_buffers = false;
|
has_deleted_buffers = false;
|
||||||
buffer = FindBuffer(*cpu_dst_address, static_cast<u32>(size));
|
buffer = FindBuffer(*cpu_dst_address, static_cast<u32>(size));
|
||||||
} while (has_deleted_buffers);
|
} while (has_deleted_buffers);
|
||||||
|
|
||||||
auto& dest_buffer = slot_buffers[buffer];
|
auto& dest_buffer = slot_buffers[buffer];
|
||||||
const u32 offset = static_cast<u32>(*cpu_dst_address - dest_buffer.CpuAddr());
|
const u32 offset = static_cast<u32>(*cpu_dst_address - dest_buffer.CpuAddr());
|
||||||
runtime.ClearBuffer(dest_buffer, offset, size, value);
|
runtime.ClearBuffer(dest_buffer, offset, size, value);
|
||||||
dest_buffer.UnmarkRegionAsCpuModified(*cpu_dst_address, size);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +822,7 @@ bool BufferCache<P>::IsRegionGpuModified(VAddr addr, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
bool BufferCache<P>::IsRegionRegistered(VAddr addr, size_t size) const {
|
bool BufferCache<P>::IsRegionRegistered(VAddr addr, size_t size) {
|
||||||
const VAddr end_addr = addr + size;
|
const VAddr end_addr = addr + size;
|
||||||
const u64 page_end = Common::DivCeil(end_addr, PAGE_SIZE);
|
const u64 page_end = Common::DivCeil(end_addr, PAGE_SIZE);
|
||||||
for (u64 page = addr >> PAGE_BITS; page < page_end;) {
|
for (u64 page = addr >> PAGE_BITS; page < page_end;) {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/microprofile.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "video_core/engines/maxwell_3d.h"
|
#include "video_core/engines/maxwell_3d.h"
|
||||||
|
@ -12,6 +13,9 @@
|
||||||
#include "video_core/renderer_base.h"
|
#include "video_core/renderer_base.h"
|
||||||
#include "video_core/textures/decoders.h"
|
#include "video_core/textures/decoders.h"
|
||||||
|
|
||||||
|
MICROPROFILE_DECLARE(GPU_DMAEngine);
|
||||||
|
MICROPROFILE_DEFINE(GPU_DMAEngine, "GPU", "DMA Engine", MP_RGB(224, 224, 128));
|
||||||
|
|
||||||
namespace Tegra::Engines {
|
namespace Tegra::Engines {
|
||||||
|
|
||||||
using namespace Texture;
|
using namespace Texture;
|
||||||
|
@ -43,6 +47,7 @@ void MaxwellDMA::CallMultiMethod(u32 method, const u32* base_start, u32 amount,
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxwellDMA::Launch() {
|
void MaxwellDMA::Launch() {
|
||||||
|
MICROPROFILE_SCOPE(GPU_DMAEngine);
|
||||||
LOG_TRACE(Render_OpenGL, "DMA copy 0x{:x} -> 0x{:x}", static_cast<GPUVAddr>(regs.offset_in),
|
LOG_TRACE(Render_OpenGL, "DMA copy 0x{:x} -> 0x{:x}", static_cast<GPUVAddr>(regs.offset_in),
|
||||||
static_cast<GPUVAddr>(regs.offset_out));
|
static_cast<GPUVAddr>(regs.offset_out));
|
||||||
|
|
||||||
|
|
|
@ -327,7 +327,7 @@ void MemoryManager::WriteBlock(GPUVAddr gpu_dest_addr, const void* src_buffer, s
|
||||||
|
|
||||||
// Invalidate must happen on the rasterizer interface, such that memory is always
|
// Invalidate must happen on the rasterizer interface, such that memory is always
|
||||||
// synchronous when it is written (even when in asynchronous GPU mode).
|
// synchronous when it is written (even when in asynchronous GPU mode).
|
||||||
rasterizer->UnmapMemory(dest_addr, copy_amount);
|
rasterizer->InvalidateRegion(dest_addr, copy_amount);
|
||||||
system.Memory().WriteBlockUnsafe(dest_addr, src_buffer, copy_amount);
|
system.Memory().WriteBlockUnsafe(dest_addr, src_buffer, copy_amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue