Browse Source

[vk] Add option to force smaller buffers

This can fix some games which run out of memory (Smash bros ultimate with 6 G&W) due to recent VMA changes

Signed-off-by: lizzie <lizzie@eden-emu.dev>
vk-fix-oom-force-maller-buffers
lizzie 4 weeks ago
committed by crueter
parent
commit
6c55017480
  1. 2
      src/common/settings.h
  2. 4
      src/qt_common/config/shared_translation.cpp
  3. 5
      src/video_core/renderer_vulkan/vk_query_cache.cpp
  4. 3
      src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp

2
src/common/settings.h

@ -525,6 +525,8 @@ struct Values {
Category::RendererAdvanced};
SwitchableSetting<bool> use_video_framerate{linkage, false, "use_video_framerate",
Category::RendererAdvanced};
SwitchableSetting<bool> force_smaller_buffers{linkage, false, "force_smaller_buffers",
Category::RendererAdvanced};
SwitchableSetting<bool> barrier_feedback_loops{linkage, true, "barrier_feedback_loops",
Category::RendererAdvanced};

4
src/qt_common/config/shared_translation.cpp

@ -319,6 +319,10 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QObject* parent)
tr("Sync to framerate of video playback"),
tr("Run the game at normal speed during video playback, even when the framerate is "
"unlocked."));
INSERT(Settings,
force_smaller_buffers,
tr("Force smaller buffers"),
tr("Forces buffers to be smaller, may cause reads/writes out of bounds for some games but can fix Out-of-memory errors."));
INSERT(Settings,
barrier_feedback_loops,
tr("Barrier feedback loops"),

5
src/video_core/renderer_vulkan/vk_query_cache.cpp

@ -15,6 +15,7 @@
#include <vector>
#include "video_core/renderer_vulkan/vk_texture_cache.h"
#include "common/bit_util.h"
#include "common/settings.h"
#include "common/common_types.h"
#include "video_core/engines/draw_manager.h"
#include "video_core/host1x/gpu_device_memory_manager.h"
@ -556,7 +557,9 @@ private:
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
.size = SamplesQueryBank::QUERY_SIZE * (1ULL << log_2),
.size = ::Settings::values.force_smaller_buffers.GetValue()
? (SamplesQueryBank::QUERY_SIZE * (1ULL << log_2))
: (SamplesQueryBank::QUERY_SIZE * num_needed),
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,

3
src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp

@ -14,6 +14,7 @@
#include "common/assert.h"
#include "common/bit_util.h"
#include "common/common_types.h"
#include "common/settings.h"
#include "common/literals.h"
#include "video_core/renderer_vulkan/vk_scheduler.h"
#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h"
@ -186,7 +187,7 @@ StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
.size = 1ULL << log2,
.size = ::Settings::values.force_smaller_buffers.GetValue() ? size : (1ULL << log2),
.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,

Loading…
Cancel
Save