render/vulkan: undo alpha premult for 8-bpc ARGB/ABGR

When a texel from the Vulkan format VK_FORMAT_B8G8R8A8_SRGB is read,
the sRGB to linear conversion is applied independently to the R, G,
and B channels; the A channel has no influence on this. However,
DRM_FORMAT_ARGB8888 buffers are, per Wayland protocol, not encoded
in this fashion; one must first unpremultiply the color channels
before doing sRGB to linear conversion. This commit switches to
handling ARGB8888 and ABGR8888 formats using the general fragment
shader conversion from electrical to optical values.
master
Manuel Stoeckl 1 year ago committed by Simon Ser
parent fe6a432299
commit dbe7fb7027

@ -32,11 +32,6 @@ static const struct wlr_vk_format formats[] = {
.vk = VK_FORMAT_R8G8B8_SRGB, .vk = VK_FORMAT_R8G8B8_SRGB,
.is_srgb = true, .is_srgb = true,
}, },
{
.drm = DRM_FORMAT_ARGB8888,
.vk = VK_FORMAT_B8G8R8A8_SRGB,
.is_srgb = true,
},
{ {
.drm = DRM_FORMAT_XRGB8888, .drm = DRM_FORMAT_XRGB8888,
.vk = VK_FORMAT_B8G8R8A8_SRGB, .vk = VK_FORMAT_B8G8R8A8_SRGB,
@ -47,12 +42,16 @@ static const struct wlr_vk_format formats[] = {
.vk = VK_FORMAT_R8G8B8A8_SRGB, .vk = VK_FORMAT_R8G8B8A8_SRGB,
.is_srgb = true, .is_srgb = true,
}, },
// The Vulkan _SRGB formats correspond to unpremultiplied alpha, but
// the Wayland protocol specifies premultiplied alpha on electrical values
{
.drm = DRM_FORMAT_ARGB8888,
.vk = VK_FORMAT_B8G8R8A8_UNORM,
},
{ {
.drm = DRM_FORMAT_ABGR8888, .drm = DRM_FORMAT_ABGR8888,
.vk = VK_FORMAT_R8G8B8A8_SRGB, .vk = VK_FORMAT_R8G8B8A8_UNORM,
.is_srgb = true,
}, },
// Vulkan packed formats have the same channel order as DRM formats on // Vulkan packed formats have the same channel order as DRM formats on
// little endian systems. // little endian systems.
#if WLR_LITTLE_ENDIAN #if WLR_LITTLE_ENDIAN

Loading…
Cancel
Save