Vulkan Wayland WSI returns empty surface formats
System information
System: Host: Gorgatron Kernel: 5.10.60.1-microsoft-standard-WSL2 x86_64 bits: 64 compiler: N/A Desktop: N/A dm: N/A
Distro: Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: Topology: 12-Core model: AMD Ryzen 9 5900X bits: 64 type: MT MCP arch: Zen 3 L2 cache: 6144 KiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 177600
Speed: 3700 MHz min/max: N/A Core speeds (MHz): 1: 3700 2: 3700 3: 3700 4: 3700 5: 3700 6: 3700 7: 3700 8: 3700
9: 3700 10: 3700 11: 3700 12: 3700 13: 3700 14: 3700 15: 3700 16: 3700 17: 3700 18: 3700 19: 3700 20: 3700 21: 3700
22: 3700 23: 3700 24: 3700
Graphics: Device-1: Microsoft driver: dxgkrnl v: N/A bus ID: 14fb:00:00.0 chip ID: 1414:008e
Display: wayland-0 server: Microsoft Corporation X.org 11.0 driver: dxgkrnl
resolution: 3440x1440~60Hz, 3440x1440~60Hz
OpenGL: renderer: llvmpipe (LLVM 13.0.1 256 bits) v: 4.5 Mesa 21.3.4 (git-bfe18835b5) direct render: Yes
Describe the issue
Calling vkGetPhysicalDeviceSurfaceFormatsKHR
on Wayland with Lavapipe returns an empty list (this adapter does not support any surface formats!)
Digging into the code, the bug appears here: https://gitlab.freedesktop.org/mesa/mesa/-/blob/f6ffefba3e466a71a1a3099e1385bee09920e088/src/vulkan/wsi/wsi_common_wayland.c#L360-367
These formats are added without has_opaque_format
.
When querying surface formats, these are filtered out: https://gitlab.freedesktop.org/mesa/mesa/-/blob/f6ffefba3e466a71a1a3099e1385bee09920e088/src/vulkan/wsi/wsi_common_wayland.c#L776-781
I made a patch to fix this, and it works for me.
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 09a4f67b226..cdaf495f2f3 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -344,10 +344,10 @@ wsi_wl_display_add_wl_shm_format(struct wsi_wl_display *display,
case WL_SHM_FORMAT_ABGR8888:
wsi_wl_display_add_vk_format(display, formats,
VK_FORMAT_R8G8B8A8_SRGB,
- true, false);
+ true, true);
wsi_wl_display_add_vk_format(display, formats,
VK_FORMAT_R8G8B8A8_UNORM,
- true, false);
+ true, true);
break;
case WL_SHM_FORMAT_XRGB8888:
wsi_wl_display_add_vk_format(display, formats,
@@ -360,10 +360,10 @@ wsi_wl_display_add_wl_shm_format(struct wsi_wl_display *display,
case WL_SHM_FORMAT_ARGB8888:
wsi_wl_display_add_vk_format(display, formats,
VK_FORMAT_B8G8R8A8_SRGB,
- true, false);
+ true, true);
wsi_wl_display_add_vk_format(display, formats,
VK_FORMAT_B8G8R8A8_UNORM,
- true, false);
+ true, true);
break;
}
}
Any extra information would be greatly appreciated
I'm testing with a graphics stack that goes through wgpu
(Rust implementation of WebGPU) on Windows 11 + WSL2 + Ubuntu 20.04. One of the supported adapters in this environment is Vulkan (via Lavapipe). My app crashes when querying surface formats because this bug causes Lavapipe to be incapable of supporting the WebGPU required surface formats.