vulkan: fix memory allocations (#17122)

This commit is contained in:
Ruben Ortlam 2025-11-09 16:14:41 +01:00 committed by GitHub
parent 802cef44bf
commit 392e09a608
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -2220,9 +2220,12 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, const std
} }
buf->memory_property_flags = req_flags; buf->memory_property_flags = req_flags;
bool done = false;
for (auto mtype_it = memory_type_indices.begin(); mtype_it != memory_type_indices.end(); mtype_it++) { for (auto mtype_it = memory_type_indices.begin(); mtype_it != memory_type_indices.end(); mtype_it++) {
try { try {
buf->device_memory = device->device.allocateMemory({ mem_req.size, *mtype_it, &mem_flags_info }); buf->device_memory = device->device.allocateMemory({ mem_req.size, *mtype_it, &mem_flags_info });
done = true;
break; break;
} catch (const vk::SystemError& e) { } catch (const vk::SystemError& e) {
// loop and retry // loop and retry
@ -2233,6 +2236,10 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, const std
} }
} }
} }
if (done) {
break;
}
} }
if (!buf->device_memory) { if (!buf->device_memory) {