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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
This commit is contained in:
Daniel Stone
2023-08-08 15:33:33 +01:00
committed by Marge Bot
parent 57c3343c2d
commit ba3b867552
+19 -6
View File
@@ -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);