diff options
author | ameerj <52414509+ameerj@users.noreply.github.com> | 2022-12-19 18:30:52 +0100 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2022-12-20 00:08:04 +0100 |
commit | 64869807e2e4604f3d6334feeaf890515e9edb81 (patch) | |
tree | 5af972e67d4713d1a10919e100985e2383225680 /src/common/scratch_buffer.h | |
parent | dma_pusher: Rework command_headers usage (diff) | |
download | yuzu-64869807e2e4604f3d6334feeaf890515e9edb81.tar yuzu-64869807e2e4604f3d6334feeaf890515e9edb81.tar.gz yuzu-64869807e2e4604f3d6334feeaf890515e9edb81.tar.bz2 yuzu-64869807e2e4604f3d6334feeaf890515e9edb81.tar.lz yuzu-64869807e2e4604f3d6334feeaf890515e9edb81.tar.xz yuzu-64869807e2e4604f3d6334feeaf890515e9edb81.tar.zst yuzu-64869807e2e4604f3d6334feeaf890515e9edb81.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/scratch_buffer.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/common/scratch_buffer.h b/src/common/scratch_buffer.h index afbe2eee1..59bb8a9ea 100644 --- a/src/common/scratch_buffer.h +++ b/src/common/scratch_buffer.h @@ -19,16 +19,16 @@ public: ScratchBuffer() = default; explicit ScratchBuffer(size_t initial_capacity) - : last_requested_size{initial_capacity}, capacity{initial_capacity}, + : last_requested_size{initial_capacity}, buffer_capacity{initial_capacity}, buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {} ~ScratchBuffer() = default; /// This will only grow the buffer's capacity if size is greater than the current capacity. void resize(size_t size) { - if (size > capacity) { - capacity = size; - buffer = Common::make_unique_for_overwrite<T[]>(capacity); + if (size > buffer_capacity) { + buffer_capacity = size; + buffer = Common::make_unique_for_overwrite<T[]>(buffer_capacity); } last_requested_size = size; } @@ -65,9 +65,13 @@ public: return last_requested_size; } + [[nodiscard]] size_t capacity() const noexcept { + return buffer_capacity; + } + private: size_t last_requested_size{}; - size_t capacity{}; + size_t buffer_capacity{}; std::unique_ptr<T[]> buffer{}; }; |