egl: swap DRI_IMAGE checks for dmabuf/modifier support for driver check

this probably also enables usage on swrast when available

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30472>
This commit is contained in:
Mike Blumenkrantz
2024-07-29 09:58:33 -04:00
committed by Marge Bot
parent 20d3e1ad14
commit d86f39e7cf
3 changed files with 21 additions and 17 deletions

View File

@@ -719,6 +719,17 @@ dri2_setup_screen(_EGLDisplay *disp)
struct pipe_screen *pscreen = screen->base.screen;
unsigned int api_mask = screen->api_mask;
#ifdef HAVE_DRI3
bool has_modifiers = true;
if (disp->Platform == _EGL_PLATFORM_X11 ||
disp->Platform == _EGL_PLATFORM_XCB)
has_modifiers = dri2_dpy->multibuffers_available;
int caps = get_screen_param(disp, PIPE_CAP_DMABUF);
/* set if both import and export are suported */
dri2_dpy->has_modifiers = has_modifiers && util_bitcount(caps) == 2;
dri2_dpy->has_dmabuf_import = has_modifiers && caps & DRM_PRIME_CAP_IMPORT;
#endif
/*
* EGL 1.5 specification defines the default value to 1. Moreover,
* eglSwapInterval() is required to clamp requested value to the supported
@@ -800,8 +811,7 @@ dri2_setup_screen(_EGLDisplay *disp)
if (dri2_dpy->image) {
#ifdef HAVE_LIBDRM
if (dri2_dpy->image->base.version >= 11 &&
get_screen_param(disp, PIPE_CAP_DMABUF) & DRM_PRIME_CAP_EXPORT) {
if (get_screen_param(disp, PIPE_CAP_DMABUF) & DRM_PRIME_CAP_EXPORT) {
disp->Extensions.MESA_image_dma_buf_export = true;
}
#endif
@@ -817,8 +827,7 @@ dri2_setup_screen(_EGLDisplay *disp)
disp->Extensions.KHR_gl_texture_3D_image = EGL_TRUE;
#ifdef HAVE_LIBDRM
if (dri2_dpy->image->base.version >= 8 &&
dri2_dpy->image->createImageFromDmaBufs) {
if (dri2_dpy->has_dmabuf_import) {
disp->Extensions.EXT_image_dma_buf_import = EGL_TRUE;
disp->Extensions.EXT_image_dma_buf_import_modifiers = EGL_TRUE;
}
@@ -937,9 +946,7 @@ dri2_setup_extensions(_EGLDisplay *disp)
#ifdef HAVE_X11_PLATFORM
if (dri2_dpy->conn) {
bool err;
dri2_dpy->multibuffers_available = x11_dri3_check_multibuffer(dri2_dpy->conn, &err) &&
!err &&
(dri2_dpy->image && dri2_dpy->image->base.version >= 15);
dri2_dpy->multibuffers_available = x11_dri3_check_multibuffer(dri2_dpy->conn, &err);
}
#endif
if (disp->Options.Zink && !disp->Options.ForceSoftware &&
@@ -2598,8 +2605,7 @@ dri2_query_dma_buf_formats(_EGLDisplay *disp, EGLint max, EGLint *formats,
goto fail;
}
if (dri2_dpy->image->base.version < 15 ||
dri2_dpy->image->queryDmaBufFormats == NULL)
if (!dri2_dpy->has_dmabuf_import)
goto fail;
if (!dri_query_dma_buf_formats(dri2_dpy->dri_screen_render_gpu,
@@ -2646,8 +2652,7 @@ dri2_query_dma_buf_modifiers(_EGLDisplay *disp, EGLint format, EGLint max,
return dri2_egl_error_unlock(dri2_dpy, EGL_BAD_PARAMETER,
"invalid modifiers array");
if (dri2_dpy->image->base.version < 15 ||
dri2_dpy->image->queryDmaBufModifiers == NULL) {
if (!dri2_dpy->has_dmabuf_import) {
mtx_unlock(&dri2_dpy->lock);
return EGL_FALSE;
}
@@ -3065,7 +3070,6 @@ dri2_bind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy)
};
int flags = 0;
char *device_name;
uint64_t cap;
if (dri2_dpy->wl_server_drm)
goto fail;
@@ -3076,9 +3080,7 @@ dri2_bind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy)
if (!device_name)
goto fail;
if (drmGetCap(dri2_dpy->fd_render_gpu, DRM_CAP_PRIME, &cap) == 0 &&
cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
dri2_dpy->image->createImageFromDmaBufs != NULL)
if (dri2_dpy->has_modifiers)
flags |= WAYLAND_DRM_PRIME;
dri2_dpy->wl_server_drm =

View File

@@ -282,12 +282,14 @@ struct dri2_egl_display {
const __DRIextension **loader_extensions;
const __DRIextension **driver_extensions;
bool has_dmabuf_import;
bool has_modifiers;
bool multibuffers_available;
#ifdef HAVE_X11_PLATFORM
xcb_connection_t *conn;
xcb_screen_t *screen;
bool swap_available;
#ifdef HAVE_DRI3
bool multibuffers_available;
struct loader_screen_resources screen_resources;
#endif
#endif

View File

@@ -2318,7 +2318,7 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
* supported by the driver. We deprecated the support to GEM names API, so
* we bail out if the driver does not support Prime. */
if (!(dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME) ||
(dri2_dpy->image->createImageFromDmaBufs == NULL)) {
!dri2_dpy->has_dmabuf_import) {
_eglLog(_EGL_WARNING, "wayland-egl: display does not support prime");
goto cleanup;
}