vulkan/wsi: warn about unset present_mode in PresentModeCompatibilityExt

A bug in vulkan tools, https://github.com/KhronosGroup/Vulkan-Tools/issues/846
causes vulkaninfo to crash in Mesa under wayland since the changes
in 5ceba97c

Handle the crashing case on wayland similarly to how other WSIs
do (nonsensically claiming a single compatible mode), and log
the condition once for all WSIs.

Fixes 5ceba97c2

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24888>
This commit is contained in:
Derek Foreman 2023-08-25 09:44:35 -05:00 committed by Marge Bot
parent a48beddb56
commit bf1c7ac5cf
4 changed files with 32 additions and 7 deletions

View file

@ -26,6 +26,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "util/log.h"
#include "vk_alloc.h"
#include "vk_dispatch_table.h"
#include <vulkan/vulkan.h>
@ -343,6 +344,15 @@ wsi_common_bind_swapchain_image(const struct wsi_device *wsi,
bool
wsi_common_vk_instance_supports_present_wait(const struct vk_instance *instance);
#define wsi_common_vk_warn_once(warning) \
do { \
static int warned = false; \
if (!warned) { \
mesa_loge(warning); \
warned = true; \
} \
} while (0)
#ifdef __cplusplus
}
#endif

View file

@ -1157,14 +1157,21 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface,
break;
}
} else {
switch (present_mode->presentMode) {
case VK_PRESENT_MODE_MAILBOX_KHR:
case VK_PRESENT_MODE_FIFO_KHR:
compat->presentModeCount = 2;
break;
default:
if (!present_mode) {
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityEXT "
"without a VkSurfacePresentModeEXT set. This is an "
"application bug.\n");
compat->presentModeCount = 1;
break;
} else {
switch (present_mode->presentMode) {
case VK_PRESENT_MODE_MAILBOX_KHR:
case VK_PRESENT_MODE_FIFO_KHR:
compat->presentModeCount = 2;
break;
default:
compat->presentModeCount = 1;
break;
}
}
}
break;

View file

@ -270,6 +270,10 @@ wsi_win32_surface_get_capabilities2(VkIcdSurfaceBase *surface,
compat->presentModeCount = 1;
}
} else {
if (!present_mode)
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityEXT "
"without a VkSurfacePresentModeEXT set. This is an "
"application bug.\n");
compat->presentModeCount = 1;
}
break;

View file

@ -788,6 +788,10 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
compat->presentModeCount = 1;
}
} else {
if (!present_mode)
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityEXT "
"without a VkSurfacePresentModeEXT set. This is an "
"application bug.\n");
compat->presentModeCount = 1;
}
break;