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);