Avoid megabuffering buffers larger than the chunk size

This commit is contained in:
Billy Laws 2022-11-06 20:04:17 +00:00
parent b6f49884b3
commit e0bc0d3a97
3 changed files with 4 additions and 4 deletions

View File

@ -330,7 +330,7 @@ namespace skyline::gpu {
BufferBinding Buffer::TryMegaBufferView(const std::shared_ptr<FenceCycle> &pCycle, MegaBufferAllocator &allocator, u32 executionNumber, BufferBinding Buffer::TryMegaBufferView(const std::shared_ptr<FenceCycle> &pCycle, MegaBufferAllocator &allocator, u32 executionNumber,
vk::DeviceSize offset, vk::DeviceSize size) { vk::DeviceSize offset, vk::DeviceSize size) {
if (!everHadInlineUpdate && sequenceNumber < FrequentlySyncedThreshold) if ((!everHadInlineUpdate && sequenceNumber < FrequentlySyncedThreshold) || size >= MegaBufferChunkSize)
// Don't megabuffer buffers that have never had inline updates and are not frequently synced since performance is only going to be harmed as a result of the constant copying and there wont be any benefit since there are no GPU inline updates that would be avoided // Don't megabuffer buffers that have never had inline updates and are not frequently synced since performance is only going to be harmed as a result of the constant copying and there wont be any benefit since there are no GPU inline updates that would be avoided
return {}; return {};
@ -346,7 +346,7 @@ namespace skyline::gpu {
} }
// If more than half the buffer has been megabuffered in chunks within the same execution assume this will generally be the case for this buffer and just megabuffer the whole thing without chunking // If more than half the buffer has been megabuffered in chunks within the same execution assume this will generally be the case for this buffer and just megabuffer the whole thing without chunking
if (unifiedMegaBufferEnabled || megaBufferViewAccumulatedSize > (backing.size() / 2)) { if (unifiedMegaBufferEnabled || (megaBufferViewAccumulatedSize > (backing.size() / 2) && backing.size() < MegaBufferChunkSize)) {
if (!unifiedMegaBuffer) { if (!unifiedMegaBuffer) {
unifiedMegaBuffer = allocator.Push(pCycle, mirror, true); unifiedMegaBuffer = allocator.Push(pCycle, mirror, true);
unifiedMegaBufferEnabled = true; unifiedMegaBufferEnabled = true;

View File

@ -5,8 +5,6 @@
#include "megabuffer.h" #include "megabuffer.h"
namespace skyline::gpu { namespace skyline::gpu {
constexpr static vk::DeviceSize MegaBufferChunkSize{25 * 1024 * 1024}; //!< Size in bytes of a single megabuffer chunk (25MiB)
MegaBufferChunk::MegaBufferChunk(GPU &gpu) : backing{gpu.memory.AllocateBuffer(MegaBufferChunkSize)}, freeRegion{backing.subspan(PAGE_SIZE)} {} MegaBufferChunk::MegaBufferChunk(GPU &gpu) : backing{gpu.memory.AllocateBuffer(MegaBufferChunkSize)}, freeRegion{backing.subspan(PAGE_SIZE)} {}
bool MegaBufferChunk::TryReset() { bool MegaBufferChunk::TryReset() {

View File

@ -6,6 +6,8 @@
#include "memory_manager.h" #include "memory_manager.h"
namespace skyline::gpu { namespace skyline::gpu {
constexpr static vk::DeviceSize MegaBufferChunkSize{25 * 1024 * 1024}; //!< Size in bytes of a single megabuffer chunk (25MiB)
/** /**
* @brief A simple linearly allocated GPU-side buffer used to temporarily store buffer modifications allowing them to be replayed in-sequence on the GPU * @brief A simple linearly allocated GPU-side buffer used to temporarily store buffer modifications allowing them to be replayed in-sequence on the GPU
* @note This class is **not** thread-safe and any calls must be externally synchronized * @note This class is **not** thread-safe and any calls must be externally synchronized