Fix incorrect parameters passed to VMA

If the allocation is small enough that it enters the

if (p_size <= SMALL_ALLOCATION_MAX_SIZE) {} block, Godot would call
vmaFindMemoryTypeIndexForBufferInfo with the wrong parameters.

This can cause vmaFindMemoryTypeIndexForBufferInfo to potentially
misbehave on some cards or drivers.

Fixes regression introduced in #102830
Might potentially reopen #101850 (I doubt it, but it's possible)

Must be backported to 4.4
This commit is contained in:
Matias N. Goldberg 2025-03-06 19:56:52 -03:00
parent 134da37497
commit c543c5615c

View file

@ -1547,6 +1547,10 @@ RDD::BufferID RenderingDeviceDriverVulkan::buffer_create(uint64_t p_size, BitFie
} break;
case MEMORY_ALLOCATION_TYPE_GPU: {
vma_usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE;
if (!Engine::get_singleton()->is_extra_gpu_memory_tracking_enabled()) {
// We must set it right now or else vmaFindMemoryTypeIndexForBufferInfo will use wrong parameters.
alloc_create_info.usage = vma_usage;
}
alloc_create_info.preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
if (p_size <= SMALL_ALLOCATION_MAX_SIZE) {
uint32_t mem_type_index = 0;