From ae25e544c44bf562f0b01347d372e87e50f0a67d Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 15 Mar 2026 13:37:13 +0900 Subject: [PATCH] clients/simple-vulkan.c: fix find_memory_type() - Use "<" instead of "<=" in the loop condition - Remove `(1u << i) <= allowed` from the loop condition for simplicity - Use `(...propertyFlags & properties) == properties` instead of `(...propertyFlags & properties)` to ensure all requested properties are present Signed-off-by: Hiroaki Yamamoto --- clients/simple-vulkan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clients/simple-vulkan.c b/clients/simple-vulkan.c index ecc241d03..dd7463ca2 100644 --- a/clients/simple-vulkan.c +++ b/clients/simple-vulkan.c @@ -525,8 +525,11 @@ find_memory_type(struct window *window, uint32_t allowed, VkMemoryPropertyFlags VkPhysicalDeviceMemoryProperties mem_properties; vkGetPhysicalDeviceMemoryProperties(window->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;