Skip to content

Commit 68d1e10

Browse files
darksylincakien-mga
authored andcommitted
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 godotengine#102830 Might potentially reopen godotengine#101850 (I doubt it, but it's possible) Must be backported to 4.4 (cherry picked from commit c543c56)
1 parent 56ba35a commit 68d1e10

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/vulkan/rendering_device_driver_vulkan.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,10 @@ RDD::BufferID RenderingDeviceDriverVulkan::buffer_create(uint64_t p_size, BitFie
15471547
} break;
15481548
case MEMORY_ALLOCATION_TYPE_GPU: {
15491549
vma_usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE;
1550+
if (!Engine::get_singleton()->is_extra_gpu_memory_tracking_enabled()) {
1551+
// We must set it right now or else vmaFindMemoryTypeIndexForBufferInfo will use wrong parameters.
1552+
alloc_create_info.usage = vma_usage;
1553+
}
15501554
alloc_create_info.preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
15511555
if (p_size <= SMALL_ALLOCATION_MAX_SIZE) {
15521556
uint32_t mem_type_index = 0;

0 commit comments

Comments
 (0)