NVIDIA / egl-wayland

The EGLStream-based Wayland external platform
MIT License
275 stars 43 forks source link

No sRGB surface format on Vulkan + Wayland #84

Closed wolfpld closed 7 months ago

wolfpld commented 11 months ago

The VK_KHR_wayland_surface extension provides only a single surface format VK_FORMAT_B8G8R8A8_UNORM with color space VK_COLOR_SPACE_SRGB_NONLINEAR_KHR.

This seems to be a spec violation, which states (https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html):

If pSurfaceFormats includes an entry whose value for colorSpace is VK_COLOR_SPACE_SRGB_NONLINEAR_KHR and whose value for format is a UNORM (or SRGB) format and the corresponding SRGB (or UNORM) format is a color renderable format for VK_IMAGE_TILING_OPTIMAL, then pSurfaceFormats must also contain an entry with the same value for colorSpace and format equal to the corresponding SRGB (or UNORM) format.

Listing supported formats shows that both VK_FORMAT_B8G8R8A8_UNORM and VK_FORMAT_B8G8R8A8_SRGB can indeed be used as a color attachment with optimal tiling.

Note that VK_KHR_xcb_surface and VK_KHR_xlib_surface extensions provide two surfaces, VK_FORMAT_B8G8R8A8_UNORM and VK_FORMAT_B8G8R8A8_SRGB.

This is with driver 535.54.03.

erik-kz commented 11 months ago

We've actually re-worked our Vulkan Wayland WSI pretty heavily for the next major release (545) and this issue has been fixed as part of that. Credit to @dkorkmazturk

As of that version, support for both SRGB and UNORM will be advertised.

wolfpld commented 11 months ago

Thanks for the update!

tim-rex commented 11 months ago

This issue sounds like it just might be the caues of a related issue I'm encountering.. (OpenGL rather than Vulkan) Is that likely or should this be tracked separately?

I'm seeing the following when running an OpenGL application on Wayland with nVidia proprietary drivers.. error 7: failed to import supplied dmabufs: Unsupported buffer format 875713345

This only occurs when creating an EGL Context having the following attrib to define an SRGB colourspace

const EGLAttrib egl_surface_attribs[] = {
                EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
                EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
                EGL_NONE,
            };

In case the following is relevant:

GL_RENDERER: NVIDIA GeForce GTX 970/PCIe/SSE2
GL_VERSION: 4.6.0 NVIDIA 535.54.03
Fedora 38
GNOME 44.2
Linux 6.3.12-200.fc38.x86_64
erik-kz commented 11 months ago

Hmm, I don't think that's quite the same issue. Upstream DRM formats don't actually distinguish between sRGB and linear color spaces. However, 875713345 is not a valid upstream DRM format. It looks like our EGL driver defines some extra NVIDIA-specific formats which are used by our embedded Tegra platform. If we're trying to use those on a regular Linux system, though, that's probably a bug.

tim-rex commented 11 months ago

Thanks @erik-kz I've raised #85 seperately

wolfpld commented 7 months ago

Closing as fixed.