From bdef22ff8530f936e10d9ca8bed288445f8bda20 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 16 Dec 2022 00:20:24 -0500 Subject: [PATCH] buffer_cache: Use Common::ScratchBuffer for ImmediateBuffer usage --- src/video_core/buffer_cache/buffer_cache.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 502b4d90a6..a8bd5585b0 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -20,6 +20,7 @@ #include "common/lru_cache.h" #include "common/microprofile.h" #include "common/polyfill_ranges.h" +#include "common/scratch_buffer.h" #include "common/settings.h" #include "core/memory.h" #include "video_core/buffer_cache/buffer_base.h" @@ -422,8 +423,7 @@ private: IntervalSet common_ranges; std::deque committed_ranges; - size_t immediate_buffer_capacity = 0; - std::unique_ptr immediate_buffer_alloc; + Common::ScratchBuffer immediate_buffer_alloc; struct LRUItemParams { using ObjectType = BufferId; @@ -1926,11 +1926,8 @@ std::span BufferCache

::ImmediateBufferWithData(VAddr cpu_addr, size template std::span BufferCache

::ImmediateBuffer(size_t wanted_capacity) { - if (wanted_capacity > immediate_buffer_capacity) { - immediate_buffer_capacity = wanted_capacity; - immediate_buffer_alloc = std::make_unique(wanted_capacity); - } - return std::span(immediate_buffer_alloc.get(), wanted_capacity); + immediate_buffer_alloc.resize(wanted_capacity); + return std::span(immediate_buffer_alloc.data(), wanted_capacity); } template