From 1d83dadefba0db145aaf27e398f23841d8e2e8ad Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 30 Oct 2022 16:06:44 +0000 Subject: [PATCH] Drop size restruction bypass for frequently synced buffers In cases where large buffers are updated every draw this could seriously increase memory usage beyond 3GB in the megabuffer. --- app/src/main/cpp/skyline/gpu/buffer.cpp | 5 ++++- app/src/main/cpp/skyline/gpu/buffer.h | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/buffer.cpp b/app/src/main/cpp/skyline/gpu/buffer.cpp index b67649e2..4f7f162c 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.cpp +++ b/app/src/main/cpp/skyline/gpu/buffer.cpp @@ -354,8 +354,10 @@ namespace skyline::gpu { return BufferBinding{unifiedMegaBuffer.buffer, unifiedMegaBuffer.offset + offset, size}; } - if (size > MegaBufferingDisableThreshold && sequenceNumber < FrequentlySyncedThresholdHigh) + if (size > MegaBufferingDisableThreshold) { + megaBufferViewAccumulatedSize += size; return {}; + } size_t entryIdx{offset >> megaBufferTableShift}; size_t bufferEntryOffset{entryIdx << megaBufferTableShift}; @@ -409,6 +411,7 @@ namespace skyline::gpu { void Buffer::unlock() { tag = ContextTag{}; AllowAllBackingWrites(); + lastExecutionNumber = 0; mutex.unlock(); } diff --git a/app/src/main/cpp/skyline/gpu/buffer.h b/app/src/main/cpp/skyline/gpu/buffer.h index 4d2493bd..6bb15b51 100644 --- a/app/src/main/cpp/skyline/gpu/buffer.h +++ b/app/src/main/cpp/skyline/gpu/buffer.h @@ -69,7 +69,6 @@ namespace skyline::gpu { static constexpr u32 InitialSequenceNumber{1}; //!< Sequence number that all buffers start off with static constexpr u32 FrequentlySyncedThreshold{6}; //!< Threshold for the sequence number after which the buffer is considered elegible for megabuffering - static constexpr u32 FrequentlySyncedThresholdHigh{16}; //!< Threshold for the sequence number after which the buffer is considered elegible for megabuffering irrespective of view size u32 sequenceNumber{InitialSequenceNumber}; //!< Sequence number that is incremented after all modifications to the host side `backing` buffer, used to prevent redundant copies of the buffer being stored in the megabuffer by views constexpr static vk::DeviceSize MegaBufferingDisableThreshold{1024 * 256}; //!< The threshold at which a view is considered to be too large to be megabuffered (256KiB)