egl/wayland: only supply LINEAR modifier when supported

If we supply modifiers to dri_create_image_with_modifiers() and
the driver doesn't support them, the function will fail. We pass
__DRI_IMAGE_USE_LINEAR anyways so stripping the modifier is fine.

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: 4c06515892 ("dri: revert INVALID modifier special-casing")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32535>
This commit is contained in:
Simon Ser
2024-12-07 13:12:40 +01:00
parent 655ac4fff6
commit d795b4712c

View File

@@ -45,11 +45,13 @@
#include "util/u_vector.h"
#include "util/format/u_formats.h"
#include "main/glconfig.h"
#include "pipe/p_screen.h"
#include "egl_dri2.h"
#include "eglglobals.h"
#include "kopper_interface.h"
#include "loader.h"
#include "loader_dri_helper.h"
#include "dri_screen.h"
#include "dri_util.h"
#include <loader_wayland_helper.h>
@@ -1193,14 +1195,25 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu &&
dri2_surf->back->linear_copy == NULL) {
uint64_t linear_mod = DRM_FORMAT_MOD_LINEAR;
const uint64_t *render_modifiers = NULL, *display_modifiers = NULL;
unsigned int render_num_modifiers = 0, display_num_modifiers = 0;
struct dri_image *linear_copy_display_gpu_image = NULL;
if (dri2_dpy->dri_screen_render_gpu->base.screen->resource_create_with_modifiers) {
render_modifiers = &linear_mod;
render_num_modifiers = 1;
}
if (dri2_dpy->dri_screen_display_gpu->base.screen->resource_create_with_modifiers) {
display_modifiers = &linear_mod;
display_num_modifiers = 1;
}
if (dri2_dpy->dri_screen_display_gpu) {
linear_copy_display_gpu_image = dri_create_image_with_modifiers(
dri2_dpy->dri_screen_display_gpu,
dri2_surf->base.Width, dri2_surf->base.Height,
linear_pipe_format, use_flags | __DRI_IMAGE_USE_LINEAR,
&linear_mod, 1, NULL);
display_modifiers, display_num_modifiers, NULL);
if (linear_copy_display_gpu_image) {
int i, ret = 1;
@@ -1285,7 +1298,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
dri2_dpy->dri_screen_render_gpu,
dri2_surf->base.Width, dri2_surf->base.Height,
linear_pipe_format, use_flags | __DRI_IMAGE_USE_LINEAR,
&linear_mod, 1, NULL);
render_modifiers, render_num_modifiers, NULL);
}
if (dri2_surf->back->linear_copy == NULL)