summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-10-01 16:00:32 -0500
committerMarge Bot <[email protected]>2020-01-17 18:27:29 +0000
commita218f132786118c6e0be64d5b85fe9a5c18c634d (patch)
treefe3ed8ae4a2af521b8170cf3bf1d043eabe88a0f /src/vulkan
parent210e68874bbf5321adc6e6464a80526c177f8741 (diff)
vulkan/wsi: Filter modifiers with ImageFormatProperties
Just because a modifier is returned for the given format, that doesn't mean it works with all usages and flags. We need to filter the list by calling vkGetPhysicalDeviceImageFormatProperties2. Reviewed-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3434>
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/wsi/wsi_common.c34
-rw-r--r--src/vulkan/wsi/wsi_common.h1
2 files changed, 34 insertions, 1 deletions
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index cc5e233093f..216b3cafc79 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -96,6 +96,7 @@ wsi_device_init(struct wsi_device *wsi,
WSI_GET_CB(GetMemoryFdKHR);
WSI_GET_CB(GetPhysicalDeviceFormatProperties);
WSI_GET_CB(GetPhysicalDeviceFormatProperties2KHR);
+ WSI_GET_CB(GetPhysicalDeviceImageFormatProperties2);
WSI_GET_CB(ResetFences);
WSI_GET_CB(QueueSubmit);
WSI_GET_CB(WaitForFences);
@@ -413,7 +414,38 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
wsi->GetPhysicalDeviceFormatProperties2KHR(wsi->pdevice,
pCreateInfo->imageFormat,
&format_props);
- modifier_prop_count = modifier_props_list.drmFormatModifierCount;
+
+ /* Call GetImageFormatProperties with every modifier and filter the list
+ * down to those that we know work.
+ */
+ modifier_prop_count = 0;
+ for (uint32_t i = 0; i < modifier_props_list.drmFormatModifierCount; i++) {
+ VkPhysicalDeviceImageDrmFormatModifierInfoEXT mod_info = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT,
+ .drmFormatModifier = modifier_props[i].drmFormatModifier,
+ .sharingMode = pCreateInfo->imageSharingMode,
+ .queueFamilyIndexCount = pCreateInfo->queueFamilyIndexCount,
+ .pQueueFamilyIndices = pCreateInfo->pQueueFamilyIndices,
+ };
+ VkPhysicalDeviceImageFormatInfo2 format_info = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
+ .format = pCreateInfo->imageFormat,
+ .type = VK_IMAGE_TYPE_2D,
+ .tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT,
+ .usage = pCreateInfo->imageUsage,
+ .flags = 0,
+ };
+ VkImageFormatProperties2 format_props = {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2,
+ .pNext = NULL,
+ };
+ __vk_append_struct(&format_info, &mod_info);
+ result = wsi->GetPhysicalDeviceImageFormatProperties2(wsi->pdevice,
+ &format_info,
+ &format_props);
+ if (result == VK_SUCCESS)
+ modifier_props[modifier_prop_count++] = modifier_props[i];
+ }
uint32_t max_modifier_count = 0;
for (uint32_t l = 0; l < num_modifier_lists; l++)
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 8d633039331..5c331e2a996 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -154,6 +154,7 @@ struct wsi_device {
WSI_CB(GetMemoryFdKHR);
WSI_CB(GetPhysicalDeviceFormatProperties);
WSI_CB(GetPhysicalDeviceFormatProperties2KHR);
+ WSI_CB(GetPhysicalDeviceImageFormatProperties2);
WSI_CB(ResetFences);
WSI_CB(QueueSubmit);
WSI_CB(WaitForFences);