VK_KHR_wayland_surface wanted
Themaister opened this issue · 13 comments
Currently, the VK_KHR_xcb_surface implementation does not work on Wayland (although RADV does), triggering a segfault in vkCreateSwapchainKHR.
Like RADV, it would be great to have a wayland implementation as well, considering amdgpu-dri is being used by both.
Wayland support is in our work list.
Hi Themaister,
"Currently, the VK_KHR_xcb_surface implementation does not work on Wayland (although RADV does), "
do you mean VK_KHR_xcb_surface can work on native wayland in RADV? I think VK_KHR_xcb_surface can only work on X server not wayland, on native wayland, we have to use VK_KHR_wayland_surface.
Yes, VK_KHR_xcb_surface works on Gnome's wayland compositor because it uses xorg-wayland I assume to support "legacy" apps. Performance is kinda crap when doing that, but that's another story :p
The xwayland issue is fixed in latest code, please check it
Does not work for me. Fails in vkCreateSwapchainKHR for me on Wayland.
However, it does not segfault anymore, so something has improved.
I tried the LunarG "cube" sample to test.
@Themaister Thanks for verifying the issue, we will check it further
@Themaister, wayland support has been added in latest code, please give it a try. Any problem, please let us know. thanks
I tried latest master.
- I can now run VK_KHR_xcb_surface on wayland with AMDVLK. That is nice.
- Wayland using VK_KHR_wayland_surface does not work.
vkGetPhysicalDeviceSurfaceSupportKHR returns true for wayland,
but I get an error in vkGetPhysicalDeviceSurfaceCapabilitiesKHR.
To test this, I tried https://github.com/ARM-software/vulkan-sdk,
mkdir build
cd build
cmake .. -DPLATFORM=wayland
make -j8
./samples/rotating_texture/rotating_texture
Fails on https://github.com/ARM-software/vulkan-sdk/blob/master/platform/wsi/wsi.cpp#L554.
I added this patch to test GetPhysicalDeviceSurfaceSupportKHR:
diff --git a/platform/wsi/wsi.cpp b/platform/wsi/wsi.cpp
index 78f0c97..b439138 100644
--- a/platform/wsi/wsi.cpp
+++ b/platform/wsi/wsi.cpp
@@ -551,7 +551,20 @@ Result WSIPlatform::loadInstanceSymbols()
Result WSIPlatform::initSwapchain(const SwapchainDimensions &dim)
{
VkSurfaceCapabilitiesKHR surfaceProperties;
- VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu, surface, &surfaceProperties));
+ VkBool32 supported = VK_FALSE;
+ if (vkGetPhysicalDeviceSurfaceSupportKHR(gpu, 0, surface, &supported) != VK_SUCCESS)
+ supported = VK_FALSE;
+ if (!supported)
+ {
+ LOGE("Surface is not supported.\n");
+ return RESULT_ERROR_GENERIC;
+ }
+
+ if (vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu, surface, &surfaceProperties) != VK_SUCCESS)
+ {
+ LOGE("Failed to get surface caps.\n");
+ return RESULT_ERROR_GENERIC;
+ }
uint32_t formatCount;
vkGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &formatCount, nullptr);
RADV works fine on same application.
Did you build AMDVLK driver with "-DBUILD_WAYLAND_SUPPORT=ON"? And WSA (https://github.com/GPUOpen-Drivers/wsa) should be installed as well.
No, I'll try that.
Ok, I tried that, and now it seems to work just fine :)
VSync now appears butter smooth and tear-free unlike Xorg, but haven't done intensive testing.
Thanks a lot for Wayland support. I have reported to AUR for updated PKGBUILD.
cmake seems to need -DPAL_BUILD_WAYLAND=ON as well as -DBUILD_WAYLAND_SUPPORT=ON to build wayland support correctly.
Only "-DBUILD_WAYLAND_SUPPORT=ON" is necessary since BUILD_WAYLAND_SUPPORT is set "ON" automatically when BUILD_WAYLAND_SUPPORT is ON, though there is no issue when setting "ON" both.