From be1a3f7a0fb330b7cc5ac007ccb2cb73d4795602 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 10 Jul 2021 18:19:10 +0200 Subject: accelerateDMA: Accelerate Buffer Copies. --- src/video_core/buffer_cache/buffer_cache.h | 81 +++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) (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 502feddba..c73ebb1f4 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -164,6 +164,8 @@ public: /// Pop asynchronous downloads void PopAsyncFlushes(); + [[nodiscard]] bool DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount); + /// Return true when a CPU region is modified from the GPU [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); @@ -430,6 +432,83 @@ void BufferCache
::DownloadMemory(VAddr cpu_addr, u64 size) {
});
}
+template ::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) {
+ const std::optional ::BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr,
u32 size) {
@@ -951,7 +1030,7 @@ void BufferCache ::UpdateIndexBuffer() {
const GPUVAddr gpu_addr_end = index_array.EndAddress();
const std::optional ::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
}
const bool source_dirty = IsRegionGpuModified(*cpu_src_address, amount);
const bool dest_dirty = IsRegionGpuModified(*cpu_dest_address, amount);
- if (!(source_dirty || dest_dirty)) {
+ if (!source_dirty && !dest_dirty) {
return false;
}
const IntervalType subtract_interval{*cpu_dest_address, *cpu_dest_address + amount};
- common_ranges.subtract(subtract_interval);
+ uncommitted_ranges.subtract(subtract_interval);
+ for (auto& interval_set : committed_ranges) {
+ interval_set.subtract(subtract_interval);
+ }
BufferId buffer_a;
BufferId buffer_b;
@@ -457,46 +490,28 @@ bool BufferCache ::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
} while (has_deleted_buffers);
auto& src_buffer = slot_buffers[buffer_a];
auto& dest_buffer = slot_buffers[buffer_b];
- SynchronizeBuffer(src_buffer, *cpu_src_address, amount);
- SynchronizeBuffer(dest_buffer, *cpu_dest_address, amount);
+ SynchronizeBuffer(src_buffer, *cpu_src_address, static_cast ::CommitAsyncFlushesHigh() {
const VAddr start_address = buffer_addr + range_offset;
const VAddr end_address = start_address + range_size;
- const IntervalType search_interval{cpu_addr, 1};
- auto it = common_ranges.lower_bound(search_interval);
- if (it == common_ranges.end()) {
- it = common_ranges.begin();
- }
- while (it != common_ranges.end()) {
- VAddr inter_addr_end = it->upper();
- VAddr inter_addr = it->lower();
- if (inter_addr >= end_address) {
- break;
- }
- if (inter_addr_end <= start_address) {
- it++;
- continue;
- }
- if (inter_addr_end > end_address) {
- inter_addr_end = end_address;
- }
- if (inter_addr < start_address) {
- inter_addr = start_address;
- }
- add_download(inter_addr, inter_addr_end);
- it++;
- }
+ ForEachWrittenRange(start_address, range_size, add_download);
const IntervalType subtract_interval{start_address, end_address};
common_ranges.subtract(subtract_interval);
});
@@ -816,7 +808,9 @@ void BufferCache ::BindHostIndexBuffer() {
const u32 size = index_buffer.size;
SynchronizeBuffer(buffer, index_buffer.cpu_addr, size);
if constexpr (HAS_FULL_INDEX_AND_PRIMITIVE_SUPPORT) {
- runtime.BindIndexBuffer(buffer, offset, size);
+ const u32 new_offset = offset + maxwell3d.regs.index_array.first *
+ maxwell3d.regs.index_array.FormatSizeInBytes();
+ runtime.BindIndexBuffer(buffer, new_offset, size);
} else {
runtime.BindIndexBuffer(maxwell3d.regs.draw.topology, maxwell3d.regs.index_array.format,
maxwell3d.regs.index_array.first, maxwell3d.regs.index_array.count,
@@ -1429,30 +1423,7 @@ void BufferCache ::DownloadBufferMemory(Buffer& buffer, VAddr cpu_addr, u64 si
const VAddr start_address = buffer_addr + range_offset;
const VAddr end_address = start_address + range_size;
- const IntervalType search_interval{start_address - range_size, 1};
- auto it = common_ranges.lower_bound(search_interval);
- if (it == common_ranges.end()) {
- it = common_ranges.begin();
- }
- while (it != common_ranges.end()) {
- VAddr inter_addr_end = it->upper();
- VAddr inter_addr = it->lower();
- if (inter_addr >= end_address) {
- break;
- }
- if (inter_addr_end <= start_address) {
- it++;
- continue;
- }
- if (inter_addr_end > end_address) {
- inter_addr_end = end_address;
- }
- if (inter_addr < start_address) {
- inter_addr = start_address;
- }
- add_download(inter_addr, inter_addr_end);
- it++;
- }
+ ForEachWrittenRange(start_address, range_size, add_download);
const IntervalType subtract_interval{start_address, end_address};
common_ranges.subtract(subtract_interval);
});
--
cgit v1.2.3