diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index 346025602b9..fc30beeb0d2 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -26,6 +26,7 @@ #include #include +#include "util/log.h" #include "vk_alloc.h" #include "vk_dispatch_table.h" #include @@ -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 diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 51b9e18cc14..21fe7a57c72 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -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; diff --git a/src/vulkan/wsi/wsi_common_win32.cpp b/src/vulkan/wsi/wsi_common_win32.cpp index 89276a198ca..34b0c64ff22 100644 --- a/src/vulkan/wsi/wsi_common_win32.cpp +++ b/src/vulkan/wsi/wsi_common_win32.cpp @@ -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; diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 6dd22b5804b..ce5e9146097 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -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;