From 469875596a670de83d3331a98ed87b34e8f712cb Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 1 Jul 2021 13:38:25 -0700 Subject: [PATCH] vulkan/wsi: Fix prime blits to use system memory for the destination The intention here was to pass VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT to select_memory_types() when requesting device local memory, or simply pass 0 for the prime blit destination which should be in system memory. Unfortunately, that meant we did (type.propertyFlags & 0) == 0 which was vacuously true, causing us to not filter out device local types. Fixes hybrid display of Vulkan apps on Intel TGL+DG1 systems. Tested-by: Luis Felipe Strano Moraes Reviewed-by: Jason Ekstrand Reviewed-by: Lionel Landwerlin Reviewed-by: Dave Airlie Part-of: --- src/vulkan/wsi/wsi_common_drm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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);