summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ameerj2022-12-16 00:20:24 -0500
committerGravatar ameerj2022-12-19 18:08:04 -0500
commitbdef22ff8530f936e10d9ca8bed288445f8bda20 (patch)
treee2db1d1c995a67108172d7165de8ca7580c788ec /src
parentvideo_core: Add usages of ScratchBuffer (diff)
downloadyuzu-bdef22ff8530f936e10d9ca8bed288445f8bda20.tar.gz
yuzu-bdef22ff8530f936e10d9ca8bed288445f8bda20.tar.xz
yuzu-bdef22ff8530f936e10d9ca8bed288445f8bda20.zip
buffer_cache: Use Common::ScratchBuffer for ImmediateBuffer usage
Diffstat (limited to 'src')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h11
1 files 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 502b4d90a..a8bd5585b 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -20,6 +20,7 @@
20#include "common/lru_cache.h" 20#include "common/lru_cache.h"
21#include "common/microprofile.h" 21#include "common/microprofile.h"
22#include "common/polyfill_ranges.h" 22#include "common/polyfill_ranges.h"
23#include "common/scratch_buffer.h"
23#include "common/settings.h" 24#include "common/settings.h"
24#include "core/memory.h" 25#include "core/memory.h"
25#include "video_core/buffer_cache/buffer_base.h" 26#include "video_core/buffer_cache/buffer_base.h"
@@ -422,8 +423,7 @@ private:
422 IntervalSet common_ranges; 423 IntervalSet common_ranges;
423 std::deque<IntervalSet> committed_ranges; 424 std::deque<IntervalSet> committed_ranges;
424 425
425 size_t immediate_buffer_capacity = 0; 426 Common::ScratchBuffer<u8> immediate_buffer_alloc;
426 std::unique_ptr<u8[]> immediate_buffer_alloc;
427 427
428 struct LRUItemParams { 428 struct LRUItemParams {
429 using ObjectType = BufferId; 429 using ObjectType = BufferId;
@@ -1926,11 +1926,8 @@ std::span<const u8> BufferCache<P>::ImmediateBufferWithData(VAddr cpu_addr, size
1926 1926
1927template <class P> 1927template <class P>
1928std::span<u8> BufferCache<P>::ImmediateBuffer(size_t wanted_capacity) { 1928std::span<u8> BufferCache<P>::ImmediateBuffer(size_t wanted_capacity) {
1929 if (wanted_capacity > immediate_buffer_capacity) { 1929 immediate_buffer_alloc.resize(wanted_capacity);
1930 immediate_buffer_capacity = wanted_capacity; 1930 return std::span<u8>(immediate_buffer_alloc.data(), wanted_capacity);
1931 immediate_buffer_alloc = std::make_unique<u8[]>(wanted_capacity);
1932 }
1933 return std::span<u8>(immediate_buffer_alloc.get(), wanted_capacity);
1934} 1931}
1935 1932
1936template <class P> 1933template <class P>