mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-03-09 09:18:56 +01:00
vulkan: Add 4KB memory alignment for AMD and Qualcomm drivers
Adds special handling for memory allocation size on AMD and Qualcomm (Adreno) drivers by aligning allocations to 4KB boundaries. This fixes potential memory allocation issues on these drivers where unaligned allocations may fail or cause undefined behavior. Affected drivers: - AMD Proprietary (AMDVLK) - AMD Open Source (RADV) - Qualcomm Proprietary (Adreno)
This commit is contained in:
parent
a1cbcee7ab
commit
cf43fd8038
1 changed files with 6 additions and 1 deletions
|
@ -303,7 +303,12 @@ bool MemoryAllocator::TryAllocMemory(VkMemoryPropertyFlags flags, u32 type_mask,
|
|||
vk::DeviceMemory memory = device.GetLogical().TryAllocateMemory({
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.allocationSize = size,
|
||||
/* AMD drivers (including Adreno) require 4KB alignment */
|
||||
.allocationSize = (device.GetDriverID() == VK_DRIVER_ID_AMD_PROPRIETARY ||
|
||||
device.GetDriverID() == VK_DRIVER_ID_AMD_OPEN_SOURCE ||
|
||||
device.GetDriverID() == VK_DRIVER_ID_QUALCOMM_PROPRIETARY) ?
|
||||
((size + 4095) & ~4095) : /* AMD (AMDVLK, RADV, RadeonSI) & Adreno */
|
||||
size, /* Others (NVIDIA, Intel, Mali, etc) */
|
||||
.memoryTypeIndex = type,
|
||||
});
|
||||
if (!memory) {
|
||||
|
|
Loading…
Reference in a new issue