summaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache
diff options
context:
space:
mode:
authorGravatar ameerj2023-05-27 21:46:15 -0400
committerGravatar ameerj2023-05-28 00:38:46 -0400
commit642c14f0c7ee71f1f4daa50cee84ec9143697af6 (patch)
tree864fae9c9389790e87f8f63341c89e09f6fed5bc /src/video_core/buffer_cache
parentMerge pull request #10414 from liamwhite/anv-push-descriptor (diff)
downloadyuzu-642c14f0c7ee71f1f4daa50cee84ec9143697af6.tar.gz
yuzu-642c14f0c7ee71f1f4daa50cee84ec9143697af6.tar.xz
yuzu-642c14f0c7ee71f1f4daa50cee84ec9143697af6.zip
OpenGL: Make use of persistent buffer maps in buffer cache downloads
Persistent buffer maps were already used by the texture cache, this extends their usage for the buffer cache. In my testing, using the memory maps for uploads was slower than the existing "ImmediateUpload" path, so the memory map usage is limited to downloads for the time being.
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h10
-rw-r--r--src/video_core/buffer_cache/buffer_cache_base.h1
2 files changed, 5 insertions, 6 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 65494097b..08bc66aaa 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -465,7 +465,6 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
465 465
466 if (committed_ranges.empty()) { 466 if (committed_ranges.empty()) {
467 if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { 467 if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) {
468
469 async_buffers.emplace_back(std::optional<Async_Buffer>{}); 468 async_buffers.emplace_back(std::optional<Async_Buffer>{});
470 } 469 }
471 return; 470 return;
@@ -526,7 +525,6 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
526 committed_ranges.clear(); 525 committed_ranges.clear();
527 if (downloads.empty()) { 526 if (downloads.empty()) {
528 if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { 527 if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) {
529
530 async_buffers.emplace_back(std::optional<Async_Buffer>{}); 528 async_buffers.emplace_back(std::optional<Async_Buffer>{});
531 } 529 }
532 return; 530 return;
@@ -678,7 +676,7 @@ void BufferCache<P>::BindHostIndexBuffer() {
678 const u32 size = index_buffer.size; 676 const u32 size = index_buffer.size;
679 const auto& draw_state = maxwell3d->draw_manager->GetDrawState(); 677 const auto& draw_state = maxwell3d->draw_manager->GetDrawState();
680 if (!draw_state.inline_index_draw_indexes.empty()) [[unlikely]] { 678 if (!draw_state.inline_index_draw_indexes.empty()) [[unlikely]] {
681 if constexpr (USE_MEMORY_MAPS) { 679 if constexpr (USE_MEMORY_MAPS_FOR_UPLOADS) {
682 auto upload_staging = runtime.UploadStagingBuffer(size); 680 auto upload_staging = runtime.UploadStagingBuffer(size);
683 std::array<BufferCopy, 1> copies{ 681 std::array<BufferCopy, 1> copies{
684 {BufferCopy{.src_offset = upload_staging.offset, .dst_offset = 0, .size = size}}}; 682 {BufferCopy{.src_offset = upload_staging.offset, .dst_offset = 0, .size = size}}};
@@ -1446,7 +1444,7 @@ bool BufferCache<P>::SynchronizeBufferNoModified(Buffer& buffer, VAddr cpu_addr,
1446template <class P> 1444template <class P>
1447void BufferCache<P>::UploadMemory(Buffer& buffer, u64 total_size_bytes, u64 largest_copy, 1445void BufferCache<P>::UploadMemory(Buffer& buffer, u64 total_size_bytes, u64 largest_copy,
1448 std::span<BufferCopy> copies) { 1446 std::span<BufferCopy> copies) {
1449 if constexpr (USE_MEMORY_MAPS) { 1447 if constexpr (USE_MEMORY_MAPS_FOR_UPLOADS) {
1450 MappedUploadMemory(buffer, total_size_bytes, copies); 1448 MappedUploadMemory(buffer, total_size_bytes, copies);
1451 } else { 1449 } else {
1452 ImmediateUploadMemory(buffer, largest_copy, copies); 1450 ImmediateUploadMemory(buffer, largest_copy, copies);
@@ -1457,7 +1455,7 @@ template <class P>
1457void BufferCache<P>::ImmediateUploadMemory([[maybe_unused]] Buffer& buffer, 1455void BufferCache<P>::ImmediateUploadMemory([[maybe_unused]] Buffer& buffer,
1458 [[maybe_unused]] u64 largest_copy, 1456 [[maybe_unused]] u64 largest_copy,
1459 [[maybe_unused]] std::span<const BufferCopy> copies) { 1457 [[maybe_unused]] std::span<const BufferCopy> copies) {
1460 if constexpr (!USE_MEMORY_MAPS) { 1458 if constexpr (!USE_MEMORY_MAPS_FOR_UPLOADS) {
1461 std::span<u8> immediate_buffer; 1459 std::span<u8> immediate_buffer;
1462 for (const BufferCopy& copy : copies) { 1460 for (const BufferCopy& copy : copies) {
1463 std::span<const u8> upload_span; 1461 std::span<const u8> upload_span;
@@ -1516,7 +1514,7 @@ bool BufferCache<P>::InlineMemory(VAddr dest_address, size_t copy_size,
1516 auto& buffer = slot_buffers[buffer_id]; 1514 auto& buffer = slot_buffers[buffer_id];
1517 SynchronizeBuffer(buffer, dest_address, static_cast<u32>(copy_size)); 1515 SynchronizeBuffer(buffer, dest_address, static_cast<u32>(copy_size));
1518 1516
1519 if constexpr (USE_MEMORY_MAPS) { 1517 if constexpr (USE_MEMORY_MAPS_FOR_UPLOADS) {
1520 auto upload_staging = runtime.UploadStagingBuffer(copy_size); 1518 auto upload_staging = runtime.UploadStagingBuffer(copy_size);
1521 std::array copies{BufferCopy{ 1519 std::array copies{BufferCopy{
1522 .src_offset = upload_staging.offset, 1520 .src_offset = upload_staging.offset,
diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h
index ac00d4d9d..7c6ef49d5 100644
--- a/src/video_core/buffer_cache/buffer_cache_base.h
+++ b/src/video_core/buffer_cache/buffer_cache_base.h
@@ -103,6 +103,7 @@ class BufferCache : public VideoCommon::ChannelSetupCaches<VideoCommon::ChannelI
103 static constexpr bool USE_MEMORY_MAPS = P::USE_MEMORY_MAPS; 103 static constexpr bool USE_MEMORY_MAPS = P::USE_MEMORY_MAPS;
104 static constexpr bool SEPARATE_IMAGE_BUFFERS_BINDINGS = P::SEPARATE_IMAGE_BUFFER_BINDINGS; 104 static constexpr bool SEPARATE_IMAGE_BUFFERS_BINDINGS = P::SEPARATE_IMAGE_BUFFER_BINDINGS;
105 static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = P::IMPLEMENTS_ASYNC_DOWNLOADS; 105 static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = P::IMPLEMENTS_ASYNC_DOWNLOADS;
106 static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = P::USE_MEMORY_MAPS_FOR_UPLOADS;
106 107
107 static constexpr BufferId NULL_BUFFER_ID{0}; 108 static constexpr BufferId NULL_BUFFER_ID{0};
108 109