From b9d4654fcaeb0313845f221135f4236c24ad2248 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Sep 2020 13:55:16 -0400 Subject: [PATCH 1/2] vulkan: Fix swapchain creation We end up with a surface that has size 0x0 at the time we create the Vulkan context, and that is a size that Vulkan doesn't like, so ensure we request at least 1x1. Fixes: #3147 --- gdk/gdkvulkancontext.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdk/gdkvulkancontext.c b/gdk/gdkvulkancontext.c index d4c36a7cd0..917b443f94 100644 --- a/gdk/gdkvulkancontext.c +++ b/gdk/gdkvulkancontext.c @@ -324,13 +324,13 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context, /* * Per https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#VkSurfaceCapabilitiesKHR - * the current extent may assume a special value, meaning that the extend should assume whatever + * the current extent may assume a special value, meaning that the extent should assume whatever * value the surface has. */ if (capabilities.currentExtent.width == -1 || capabilities.currentExtent.height == -1) { - capabilities.currentExtent.width = gdk_surface_get_width (surface) * gdk_surface_get_scale_factor (surface); - capabilities.currentExtent.height = gdk_surface_get_height (surface) * gdk_surface_get_scale_factor (surface); + capabilities.currentExtent.width = MAX (1, gdk_surface_get_width (surface) * gdk_surface_get_scale_factor (surface)); + capabilities.currentExtent.height = MAX (1, gdk_surface_get_height (surface) * gdk_surface_get_scale_factor (surface)); } res = GDK_VK_CHECK (vkCreateSwapchainKHR, device, From 2113f98c5c4dab041503a214e4b5e8e6a793db94 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Sep 2020 13:56:44 -0400 Subject: [PATCH 2/2] gdk: Don't create surfaces of size 0x0 Don't pass 0x0 as size when calling gdk_surface_new(). The Wayland backend takes us literally, and we end up with a surface that (temporarily) has these dimensions, confusing other APIs that we pass the size to, such as Vulkan. --- gdk/gdksurface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 3a03292251..3624aadeca 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -813,7 +813,7 @@ gdk_surface_new_toplevel (GdkDisplay *display) g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); return gdk_surface_new (display, GDK_SURFACE_TOPLEVEL, - NULL, 0, 0, 0, 0); + NULL, 0, 0, 1, 1); } /**