From b780d5b5c580a65a670de73140b743072efc0fd2 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 13 Jul 2021 03:33:08 +0200 Subject: DMAEngine: Accelerate BufferClear --- src/video_core/buffer_cache/buffer_cache.h | 65 ++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'src/video_core/buffer_cache') diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 2871682f6..5f5a59bba 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -164,11 +164,16 @@ public: /// Pop asynchronous downloads void PopAsyncFlushes(); - [[nodiscard]] bool DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount); + bool DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount); + + bool DMAClear(GPUVAddr src_address, u64 amount, u32 value); /// Return true when a CPU region is modified from the GPU [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); + /// Return true when a region is registered on the cache + [[nodiscard]] bool IsRegionRegistered(VAddr addr, size_t size); + /// Return true when a CPU region is modified from the CPU [[nodiscard]] bool IsRegionCpuModified(VAddr addr, size_t size); @@ -469,8 +474,8 @@ bool BufferCache
::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am if (!cpu_src_address || !cpu_dest_address) { return false; } - const bool source_dirty = IsRegionGpuModified(*cpu_src_address, amount); - const bool dest_dirty = IsRegionGpuModified(*cpu_dest_address, amount); + const bool source_dirty = IsRegionRegistered(*cpu_src_address, amount); + const bool dest_dirty = IsRegionRegistered(*cpu_dest_address, amount); if (!source_dirty && !dest_dirty) { return false; } @@ -515,7 +520,7 @@ bool BufferCache
::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
}
runtime.CopyBuffer(dest_buffer, src_buffer, copies);
- if (source_dirty) {
+ if (IsRegionGpuModified(*cpu_src_address, amount)) {
dest_buffer.MarkRegionAsGpuModified(*cpu_dest_address, amount);
}
std::vector ::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
return true;
}
+template ::DMAClear(GPUVAddr dst_address, u64 amount, u32 value) {
+ const std::optional ::BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr,
u32 size) {
@@ -781,6 +817,27 @@ bool BufferCache ::IsRegionGpuModified(VAddr addr, size_t size) {
return false;
}
+template ::IsRegionRegistered(VAddr addr, size_t size) {
+ const VAddr end_addr = addr + size;
+ const u64 page_end = Common::DivCeil(end_addr, PAGE_SIZE);
+ for (u64 page = addr >> PAGE_BITS; page < page_end;) {
+ const BufferId buffer_id = page_table[page];
+ if (!buffer_id) {
+ ++page;
+ continue;
+ }
+ Buffer& buffer = slot_buffers[buffer_id];
+ const VAddr buf_start_addr = buffer.CpuAddr();
+ const VAddr buf_end_addr = buf_start_addr + buffer.SizeBytes();
+ if (buf_start_addr < end_addr && addr < buf_end_addr) {
+ return true;
+ }
+ page = Common::DivCeil(end_addr, PAGE_SIZE);
+ }
+ return false;
+}
+
template ::IsRegionCpuModified(VAddr addr, size_t size) {
const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE);
--
cgit v1.2.3