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 <hrak1529@gmail.com>
This commit is contained in:
tokyo4j 2026-03-15 13:37:13 +09:00 committed by Hiroaki Yamamoto
parent 3534c77b66
commit ae25e544c4

View file

@ -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;