diff --git a/rpcs3/Emu/RSX/VK/vkutils/device.cpp b/rpcs3/Emu/RSX/VK/vkutils/device.cpp index a11134e157..cedc83ec56 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/device.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/device.cpp @@ -686,13 +686,9 @@ namespace vk m_allocator = std::make_unique(dev, pdev); } - if (pgpu->props.deviceID == 0x13c2) - { - // GTX970 workaround/hack - // The driver reports a full working 4GB of memory which is incorrect. - // Limit to ~2.5GB to allow vma to avoid running over the headroom of 0.5G. - memory_map.device_local_total_bytes = 2560ULL * 0x100000ULL; - } + // Useful for debugging different VRAM configurations + const u64 vram_allocation_limit = g_cfg.video.vk.vram_allocation_limit * 0x100000ull; + memory_map.device_local_total_bytes = std::min(memory_map.device_local_total_bytes, vram_allocation_limit); } void render_device::destroy() diff --git a/rpcs3/Emu/RSX/VK/vkutils/memory.cpp b/rpcs3/Emu/RSX/VK/vkutils/memory.cpp index b3455cd87d..0c3213e4bf 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/memory.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/memory.cpp @@ -162,6 +162,23 @@ namespace vk allocatorInfo.physicalDevice = pdev; allocatorInfo.device = dev; + std::vector heap_limits; + const auto vram_allocation_limit = g_cfg.video.vk.vram_allocation_limit * 0x100000ull; + if (vram_allocation_limit < g_render_device->get_memory_mapping().device_local_total_bytes) + { + VkPhysicalDeviceMemoryProperties memory_properties; + vkGetPhysicalDeviceMemoryProperties(pdev, &memory_properties); + for (int i = 0; i < memory_properties.memoryHeapCount; ++i) + { + const u64 max_sz = (memory_properties.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) + ? vram_allocation_limit + : VK_WHOLE_SIZE; + + heap_limits.push_back(max_sz); + } + allocatorInfo.pHeapSizeLimit = heap_limits.data(); + } + CHECK_RESULT(vmaCreateAllocator(&allocatorInfo, &m_allocator)); // Allow fastest possible allocation on start diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index 9434b30876..aeaec1fb3a 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -191,6 +191,7 @@ struct cfg_root : cfg::node cfg::_bool asynchronous_texture_streaming{ this, "Asynchronous Texture Streaming 2", false }; cfg::uint<0, 100> rcas_sharpening_intensity{ this, "FidelityFX CAS Sharpening Intensity", 50, true }; cfg::_enum asynchronous_scheduler{ this, "Asynchronous Queue Scheduler", vk_gpu_scheduler_mode::safe }; + cfg::uint<256, 65536> vram_allocation_limit{ this, "VRAM allocation limit (MB)", 65536, false }; } vk{ this };