From 8563e424483b94244b7fe475b61e7dbcae9e9675 Mon Sep 17 00:00:00 2001 From: yuzubot Date: Mon, 14 Feb 2022 13:02:45 +0000 Subject: [PATCH] "Merge Tagged PR 7812" --- src/video_core/buffer_cache/buffer_cache.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index fa26eb8b0..9d224b8a8 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -1469,19 +1469,29 @@ typename BufferCache

::OverlapResult BufferCache

::ResolveOverlaps(VAddr cpu overlap_ids.push_back(overlap_id); overlap.Pick(); const VAddr overlap_cpu_addr = overlap.CpuAddr(); + bool goes_left = false; if (overlap_cpu_addr < begin) { + goes_left = true; cpu_addr = begin = overlap_cpu_addr; } - end = std::max(end, overlap_cpu_addr + overlap.SizeBytes()); - + const VAddr overlap_end = overlap_cpu_addr + overlap.SizeBytes(); + bool goes_right = false; + if (overlap_end > end) { + goes_right = true; + end = overlap_end; + } stream_score += overlap.StreamScore(); if (stream_score > STREAM_LEAP_THRESHOLD && !has_stream_leap) { // When this memory region has been joined a bunch of times, we assume it's being used // as a stream buffer. Increase the size to skip constantly recreating buffers. has_stream_leap = true; - begin -= PAGE_SIZE * 256; - cpu_addr = begin; - end += PAGE_SIZE * 256; + if (goes_right) { + begin -= PAGE_SIZE * 256; + cpu_addr = begin; + } + if (goes_left) { + end += PAGE_SIZE * 256; + } } } return OverlapResult{