summaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-07-06 22:23:10 +0200
committerGravatar Fernando Sahmkow2021-07-09 22:20:36 +0200
commit63915bf2de3358029cb5e904f51f6b147b64bfa1 (patch)
tree590fda8b8ef117ac71499443bb89dfd031d271c9 /src/video_core/buffer_cache
parentVideocore: Address Feedback & CLANG Format. (diff)
downloadyuzu-63915bf2de3358029cb5e904f51f6b147b64bfa1.tar.gz
yuzu-63915bf2de3358029cb5e904f51f6b147b64bfa1.tar.xz
yuzu-63915bf2de3358029cb5e904f51f6b147b64bfa1.zip
Fence Manager: Add fences on Reference Count.
Diffstat (limited to 'src/video_core/buffer_cache')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index dc2b1f447..3faa7e0d0 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -586,7 +586,9 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
586 cpu_addr_base += u64(std::max<s64>(difference2, 0)); 586 cpu_addr_base += u64(std::max<s64>(difference2, 0));
587 const u64 new_size = cpu_addr_end2 - cpu_addr_base; 587 const u64 new_size = cpu_addr_end2 - cpu_addr_base;
588 const u64 new_offset = cpu_addr_base - buffer.CpuAddr(); 588 const u64 new_offset = cpu_addr_base - buffer.CpuAddr();
589 ASSERT(!IsRegionCpuModified(cpu_addr_base, new_size)); 589 if (IsRegionCpuModified(cpu_addr_base, new_size)) {
590 return;
591 }
590 downloads.push_back({ 592 downloads.push_back({
591 BufferCopy{ 593 BufferCopy{
592 .src_offset = new_offset, 594 .src_offset = new_offset,
@@ -596,8 +598,15 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
596 buffer_id, 598 buffer_id,
597 }); 599 });
598 total_size_bytes += new_size; 600 total_size_bytes += new_size;
599 buffer.UnmarkRegionAsGpuModified(cpu_addr_base, new_size);
600 largest_copy = std::max(largest_copy, new_size); 601 largest_copy = std::max(largest_copy, new_size);
602 constexpr u64 align_mask = ~(32ULL - 1);
603 const VAddr align_up_address = (cpu_addr_base + 31) & align_mask;
604 const u64 difference = align_up_address - cpu_addr_base;
605 if (difference > new_size) {
606 return;
607 }
608 const u64 fixed_size = new_size - difference;
609 buffer.UnmarkRegionAsGpuModified(align_up_address, fixed_size & align_mask);
601 }); 610 });
602 }); 611 });
603 } 612 }
@@ -1380,7 +1389,8 @@ typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr s
1380 // Binding the whole map range would be technically correct, but games have large maps that make 1389 // Binding the whole map range would be technically correct, but games have large maps that make
1381 // this approach unaffordable for now. 1390 // this approach unaffordable for now.
1382 static constexpr u32 arbitrary_extra_bytes = 0xc000; 1391 static constexpr u32 arbitrary_extra_bytes = 0xc000;
1383 const u32 bytes_to_map_end = static_cast<u32>(gpu_memory.BytesToMapEnd(gpu_addr)); 1392 const u32 bytes_to_map_end =
1393 std::max(size, static_cast<u32>(gpu_memory.BytesToMapEnd(gpu_addr)));
1384 const Binding binding{ 1394 const Binding binding{
1385 .cpu_addr = *cpu_addr, 1395 .cpu_addr = *cpu_addr,
1386 .size = std::min(size + arbitrary_extra_bytes, bytes_to_map_end), 1396 .size = std::min(size + arbitrary_extra_bytes, bytes_to_map_end),