From ba3b867552718e1c287a883b487816564e77cafd Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 8 Aug 2023 15:33:33 +0100 Subject: [PATCH] egl/wayland: Query image FourCC for linear copies This entire pattern really wants to be a shared helper, to allocate a shadow linear image from another device and then import it across into the rendering GPU. Querying the FourCC from the DRIImage makes it easier to pull out into shared code. This temporarily makes the implementation more ugly, however it's already pretty hard on the eyes, so probably no great loss. Part-of: --- src/egl/drivers/dri2/platform_wayland.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index b5ca4ecc694..5eb124e0b3f 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -1141,7 +1141,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) &linear_mod, 1, NULL); if (linear_copy_display_gpu_image) { - int i, ret; + int i, ret = 1; + int fourcc; int num_planes = 0; int buffer_fds[4]; int strides[4]; @@ -1183,16 +1184,28 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) } } + ret &= dri2_dpy->image->queryImage(linear_copy_display_gpu_image, + __DRI_IMAGE_ATTRIB_FOURCC, + &fourcc); + if (!ret) { + do { + if (buffer_fds[i] != -1) + close(buffer_fds[i]); + } while (--i >= 0); + dri2_dpy->image->destroyImage(linear_copy_display_gpu_image); + return -1; + } + /* The linear buffer was created in the display GPU's vram, so we * need to make it visible to render GPU */ dri2_surf->back->linear_copy = dri2_dpy->image->createImageFromDmaBufs3( - dri2_dpy->dri_screen_render_gpu, dri2_surf->base.Width, - dri2_surf->base.Height, - loader_image_format_to_fourcc(linear_dri_image_format), - linear_mod, &buffer_fds[0], num_planes, &strides[0], - &offsets[0], __DRI_YUV_COLOR_SPACE_UNDEFINED, + dri2_dpy->dri_screen_render_gpu, + dri2_surf->base.Width, dri2_surf->base.Height, + fourcc, linear_mod, + &buffer_fds[0], num_planes, &strides[0], &offsets[0], + __DRI_YUV_COLOR_SPACE_UNDEFINED, __DRI_YUV_RANGE_UNDEFINED, __DRI_YUV_CHROMA_SITING_UNDEFINED, __DRI_YUV_CHROMA_SITING_UNDEFINED, 0, &error, dri2_surf->back);