From ab1fa93abd4139b2a90f89901543237bc8f9e58b Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 15 Mar 2026 13:53:26 +0900 Subject: [PATCH] clients/simple-dmabuf-vulkan.c: fix find_memory_type() Same as simple-vulkan.c. Signed-off-by: Hiroaki Yamamoto --- clients/simple-dmabuf-vulkan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clients/simple-dmabuf-vulkan.c b/clients/simple-dmabuf-vulkan.c index 50be3496a..a5cf6cd0d 100644 --- a/clients/simple-dmabuf-vulkan.c +++ b/clients/simple-dmabuf-vulkan.c @@ -459,8 +459,11 @@ find_memory_type(struct display *display, uint32_t allowed, VkMemoryPropertyFlag VkPhysicalDeviceMemoryProperties mem_properties; vkGetPhysicalDeviceMemoryProperties(display->vk.phys_dev, &mem_properties); - for (unsigned i = 0; (1u << i) <= allowed && i <= mem_properties.memoryTypeCount; ++i) { - if ((allowed & (1u << i)) && (mem_properties.memoryTypes[i].propertyFlags & properties)) + for (unsigned i = 0; i < mem_properties.memoryTypeCount; ++i) { + bool is_allowed = allowed & (1u << i); + bool has_properties = + (mem_properties.memoryTypes[i].propertyFlags & properties) == properties; + if (is_allowed && has_properties) return i; } return -1;