Vulkan wayland swapchain is broken on 515.43.04

Vulkan swapchains seem to have stopped working on Wayland (Xwayland still works) with the 515.43.04 beta driver. It fails at swapchain related steps.

For example mpv on the waylandvk backend outputs:

[vo/gpu/vulkan/libplacebo] vk->CreateSwapchainKHR(vk->dev, &sinfo, PL_VK_ALLOC, &p->swapchain): VK_ERROR_INITIALIZATION_FAILED (../src/vulkan/swapchain.c:583)
[vo/gpu/vulkan/libplacebo] Failed (re)creating swapchain!
[vo/gpu/vulkan/libplacebo] Failed resizing swapchain: unknown size?
[vo/gpu/vulkan/libplacebo] Failed resizing swapchain: unknown size?
[vo/gpu/vulkan/libplacebo] Failed resizing swapchain: unknown size?

While vkcube seems to fail due to vkGetSwapchainImagesKHR returning 1486719820 as the image count, then segfaults shortly after.

valgrind vkcube -m wayland:

==190367== Memcheck, a memory error detector
==190367== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==190367== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==190367== Command: build/vkcube -m wayland
==190367== 
1 physical devices
vendor id 10de, device name NVIDIA GeForce GTX 1080
==190367== Use of uninitialised value of size 8
==190367==    at 0x6FE6CC3: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x10DC28: create_swapchain (main.c:776)
==190367==    by 0x10F094: init_wayland (main.c:1219)
==190367==    by 0x10F481: init_display (main.c:1682)
==190367==    by 0x10F820: main (main.c:1734)
==190367== 
==190367== Use of uninitialised value of size 8
==190367==    at 0x6FE6CC3: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x10DC67: create_swapchain (main.c:780)
==190367==    by 0x10F094: init_wayland (main.c:1219)
==190367==    by 0x10F481: init_display (main.c:1682)
==190367==    by 0x10F820: main (main.c:1734)
==190367== 
==190367== Use of uninitialised value of size 8
==190367==    at 0x6FE6CF8: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x10DC67: create_swapchain (main.c:780)
==190367==    by 0x10F094: init_wayland (main.c:1219)
==190367==    by 0x10F481: init_display (main.c:1682)
==190367==    by 0x10F820: main (main.c:1734)
==190367== 
==190367== Conditional jump or move depends on uninitialised value(s)
==190367==    at 0x6FE6D0A: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x10DC67: create_swapchain (main.c:780)
==190367==    by 0x10F094: init_wayland (main.c:1219)
==190367==    by 0x10F481: init_display (main.c:1682)
==190367==    by 0x10F820: main (main.c:1734)
==190367== 
==190367== Use of uninitialised value of size 8
==190367==    at 0x6FE6D0F: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x10DC67: create_swapchain (main.c:780)
==190367==    by 0x10F094: init_wayland (main.c:1219)
==190367==    by 0x10F481: init_display (main.c:1682)
==190367==    by 0x10F820: main (main.c:1734)
==190367== 
==190367== Invalid read of size 4
==190367==    at 0x709BE2A: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x709C889: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x10D0F9: init_buffer (main.c:274)
==190367==    by 0x10DCAB: create_swapchain (main.c:786)
==190367==    by 0x10F094: init_wayland (main.c:1219)
==190367==    by 0x10F481: init_display (main.c:1682)
==190367==    by 0x10F820: main (main.c:1734)
==190367==  Address 0x5ddd8f88c is not stack'd, malloc'd or (recently) free'd
==190367== 
==190367== 
==190367== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==190367==  Access not within mapped region at address 0x5DDD8F88C
==190367==    at 0x709BE2A: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x709C889: ??? (in /usr/lib/libnvidia-glcore.so.515.43.04)
==190367==    by 0x10D0F9: init_buffer (main.c:274)
==190367==    by 0x10DCAB: create_swapchain (main.c:786)
==190367==    by 0x10F094: init_wayland (main.c:1219)
==190367==    by 0x10F481: init_display (main.c:1682)
==190367==    by 0x10F820: main (main.c:1734)
==190367==  If you believe this happened as a result of a stack
==190367==  overflow in your program's main thread (unlikely but
==190367==  possible), you can try to increase the size of the
==190367==  main thread stack using the --main-stacksize= flag.
==190367==  The main thread stack size used in this run was 8388608.
==190367== 
==190367== HEAP SUMMARY:
==190367==     in use at exit: 8,172,385 bytes in 3,918 blocks
==190367==   total heap usage: 11,869 allocs, 7,951 frees, 215,635,283 bytes allocated
==190367== 
==190367== LEAK SUMMARY:
==190367==    definitely lost: 8,912 bytes in 29 blocks
==190367==    indirectly lost: 165,540 bytes in 903 blocks
==190367==      possibly lost: 641,726 bytes in 58 blocks
==190367==    still reachable: 7,356,207 bytes in 2,928 blocks
==190367==                       of which reachable via heuristic:
==190367==                         newarray           : 13,232 bytes in 12 blocks
==190367==                         multipleinheritance: 384 bytes in 2 blocks
==190367==         suppressed: 0 bytes in 0 blocks
==190367== Rerun with --leak-check=full to see details of leaked memory
==190367== 
==190367== Use --track-origins=yes to see where uninitialised values come from
==190367== For lists of detected and suppressed errors, rerun with: -s
==190367== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

Note vkcube’s Wayland backend requires this patch to work.

diff --git a/main.c b/main.c
index 9e307d1..b01ffe5 100644
--- a/main.c
+++ b/main.c
@@ -693,6 +693,7 @@ choose_surface_format(struct vkcube *vc)
       switch (formats[i].format) {
       case VK_FORMAT_R8G8B8A8_SRGB:
       case VK_FORMAT_B8G8R8A8_SRGB:
+      case VK_FORMAT_B8G8R8A8_UNORM:
          /* These formats are all fine */
          format = formats[i].format;
          break;

I’m also having this issue when trying to create a swapchain using a wayland surface on 515.43.04. Calling vkCreateSwapchainKHR just returns VK_ERROR_INITIALIZATION_FAILED. The validation layers don’t give an error either. vkcube-wayland just segfaults for me as well.
nvidia-bug-report.log.gz (821.7 KB)