diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c index 57d10c4aa6d..f95530cc958 100644 --- a/src/vulkan/wsi/wsi_common_drm.c +++ b/src/vulkan/wsi/wsi_common_drm.c @@ -65,12 +65,14 @@ wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd) static uint32_t select_memory_type(const struct wsi_device *wsi, - VkMemoryPropertyFlags props, + bool want_device_local, uint32_t type_bits) { for (uint32_t i = 0; i < wsi->memory_props.memoryTypeCount; i++) { const VkMemoryType type = wsi->memory_props.memoryTypes[i]; - if ((type_bits & (1 << i)) && (type.propertyFlags & props) == props) + bool local = type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + + if ((type_bits & (1 << i)) && local == want_device_local) return i; } @@ -305,8 +307,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain, .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &memory_dedicated_info, .allocationSize = reqs.size, - .memoryTypeIndex = select_memory_type(wsi, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, - reqs.memoryTypeBits), + .memoryTypeIndex = select_memory_type(wsi, true, reqs.memoryTypeBits), }; result = wsi->AllocateMemory(chain->device, &memory_info, &chain->alloc, &image->memory); @@ -477,7 +478,7 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &prime_memory_dedicated_info, .allocationSize = linear_size, - .memoryTypeIndex = select_memory_type(wsi, 0, reqs.memoryTypeBits), + .memoryTypeIndex = select_memory_type(wsi, false, reqs.memoryTypeBits), }; result = wsi->AllocateMemory(chain->device, &prime_memory_info, &chain->alloc, &image->prime.memory); @@ -531,8 +532,7 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &memory_dedicated_info, .allocationSize = reqs.size, - .memoryTypeIndex = select_memory_type(wsi, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, - reqs.memoryTypeBits), + .memoryTypeIndex = select_memory_type(wsi, true, reqs.memoryTypeBits), }; result = wsi->AllocateMemory(chain->device, &memory_info, &chain->alloc, &image->memory);