gl-renderer: use correct read-back format and support WL_SHM_FORMAT_ABGR8888

PIXMAN_a8r8g8b8 / PIXMAN_a8b8g8r8 only matches GL_BGRA_EXT / GL_BGRA on little-endian.
So to have a GL format, we should use DRM_FORMAT_ARGB8888 / DRM_FORMAT_ABGR8888.

Without GL_EXT_read_format_bgra, the read-back format is DRM_FORMAT_ABGR8888.
Then weston-screenshooter fails to create a wl_shm buffer with WL_SHM_FORMAT_ABGR8888,
unless it has been added with wl_display_add_shm_format.

Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
This commit is contained in:
Loïc Yhuel 2023-09-11 18:42:22 +02:00 committed by Marius Vlad
parent 8ac621d672
commit 71616edc4d
1 changed files with 3 additions and 2 deletions

View File

@ -3988,6 +3988,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_NV12); wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_NV12);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_YUYV); wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_YUYV);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XYUV8888); wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XYUV8888);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR8888);
#if __BYTE_ORDER == __LITTLE_ENDIAN #if __BYTE_ORDER == __LITTLE_ENDIAN
if (gr->has_texture_type_2_10_10_10_rev) { if (gr->has_texture_type_2_10_10_10_rev) {
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR2101010); wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR2101010);
@ -4164,9 +4165,9 @@ gl_renderer_setup(struct weston_compositor *ec)
} }
if (weston_check_egl_extension(extensions, "GL_EXT_read_format_bgra")) if (weston_check_egl_extension(extensions, "GL_EXT_read_format_bgra"))
ec->read_format = pixel_format_get_info_by_pixman(PIXMAN_a8r8g8b8); ec->read_format = pixel_format_get_info(DRM_FORMAT_ARGB8888);
else else
ec->read_format = pixel_format_get_info_by_pixman(PIXMAN_a8b8g8r8); ec->read_format = pixel_format_get_info(DRM_FORMAT_ABGR8888);
if (gr->gl_version < gr_gl_version(3, 0) && if (gr->gl_version < gr_gl_version(3, 0) &&
!weston_check_egl_extension(extensions, "GL_EXT_unpack_subimage")) { !weston_check_egl_extension(extensions, "GL_EXT_unpack_subimage")) {