From 2ef4b6ed547e98675168e5c665a1b3800ce5c89a Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 11 Oct 2023 12:21:01 -0700 Subject: [PATCH] dri: Drop the old lookupEGLImage wrapper function. All the loaders implemented the split version. We don't need to maintain the old function and struct layout, because we're version locked between loader and driver. Part-of: --- src/egl/drivers/dri2/egl_dri2.c | 12 ----------- src/egl/drivers/dri2/egl_dri2.h | 3 --- src/egl/drivers/dri2/platform_drm.c | 1 - src/gallium/frontends/dri/dri_helpers.c | 15 -------------- src/gallium/frontends/dri/dri_helpers.h | 3 --- src/gallium/frontends/dri/dri_screen.c | 2 -- src/gallium/frontends/dri/dri_screen.h | 3 --- src/gallium/frontends/omx/tizonia/h264dprc.c | 4 +++- src/gallium/include/mesa_interface.h | 15 +------------- src/gbm/backends/dri/gbm_dri.c | 21 ++++++-------------- src/gbm/backends/dri/gbm_driint.h | 1 - 11 files changed, 10 insertions(+), 70 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 1c9399ccd2a..28a5828a275 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -587,21 +587,9 @@ dri2_lookup_egl_image_validated(void *image, void *data) return dri2_img->dri_image; } -__DRIimage * -dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data) -{ - (void)screen; - - if (!dri2_validate_egl_image(image, data)) - return NULL; - - return dri2_lookup_egl_image_validated(image, data); -} - const __DRIimageLookupExtension image_lookup_extension = { .base = {__DRI_IMAGE_LOOKUP, 2}, - .lookupEGLImage = dri2_lookup_egl_image, .validateEGLImage = dri2_validate_egl_image, .lookupEGLImageValidated = dri2_lookup_egl_image_validated, }; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 04cba570eee..765db0a8f2c 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -503,9 +503,6 @@ dri2_validate_egl_image(void *image, void *data); __DRIimage * dri2_lookup_egl_image_validated(void *image, void *data); -__DRIimage * -dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data); - void dri2_get_shifts_and_sizes(const __DRIcoreExtension *core, const __DRIconfig *config, int *shifts, diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 2011a81f876..7af3f0a61bb 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -634,7 +634,6 @@ dri2_initialize_drm(_EGLDisplay *disp) dri2_dpy->kopper = dri2_dpy->gbm_dri->kopper; dri2_dpy->driver_configs = dri2_dpy->gbm_dri->driver_configs; - dri2_dpy->gbm_dri->lookup_image = dri2_lookup_egl_image; dri2_dpy->gbm_dri->validate_image = dri2_validate_egl_image; dri2_dpy->gbm_dri->lookup_image_validated = dri2_lookup_egl_image_validated; dri2_dpy->gbm_dri->lookup_user_data = disp; diff --git a/src/gallium/frontends/dri/dri_helpers.c b/src/gallium/frontends/dri/dri_helpers.c index e6f0bd1ed8a..e93f6c9f523 100644 --- a/src/gallium/frontends/dri/dri_helpers.c +++ b/src/gallium/frontends/dri/dri_helpers.c @@ -256,21 +256,6 @@ const __DRI2fenceExtension dri2FenceExtension = { .get_fence_fd = dri2_get_fence_fd, }; -__DRIimage * -dri2_lookup_egl_image(struct dri_screen *screen, void *handle) -{ - const __DRIimageLookupExtension *loader = screen->dri2.image; - __DRIimage *img; - - if (!loader->lookupEGLImage) - return NULL; - - img = loader->lookupEGLImage(opaque_dri_screen(screen), - handle, screen->loaderPrivate); - - return img; -} - __DRIimage * dri2_create_image_from_renderbuffer(__DRIcontext *context, int renderbuffer, void *loaderPrivate, diff --git a/src/gallium/frontends/dri/dri_helpers.h b/src/gallium/frontends/dri/dri_helpers.h index 2877eca4fc8..e036129047e 100644 --- a/src/gallium/frontends/dri/dri_helpers.h +++ b/src/gallium/frontends/dri/dri_helpers.h @@ -59,9 +59,6 @@ bool dri2_yuv_dma_buf_supported(struct dri_screen *screen, const struct dri2_format_mapping *map); -__DRIimage * -dri2_lookup_egl_image(struct dri_screen *screen, void *handle); - bool dri2_validate_egl_image(struct dri_screen *screen, void *handle); diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c index 2ac6966a452..6dde9accb8a 100644 --- a/src/gallium/frontends/dri/dri_screen.c +++ b/src/gallium/frontends/dri/dri_screen.c @@ -623,8 +623,6 @@ dri_init_screen(struct dri_screen *screen, screen->base.set_background_context = dri_set_background_context; screen->base.validate_egl_image = dri_validate_egl_image; - screen->lookup_egl_image = dri2_lookup_egl_image; - if (pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES)) screen->target = PIPE_TEXTURE_2D; else diff --git a/src/gallium/frontends/dri/dri_screen.h b/src/gallium/frontends/dri/dri_screen.h index 65deb31ef35..226874b7487 100644 --- a/src/gallium/frontends/dri/dri_screen.h +++ b/src/gallium/frontends/dri/dri_screen.h @@ -111,9 +111,6 @@ struct dri_screen bool swrast_no_present; - /* hooks filled in by dri2 & drisw */ - __DRIimage * (*lookup_egl_image)(struct dri_screen *ctx, void *handle); - /* DRI exts that vary based on gallium pipe_screen caps. */ __DRIimageExtension image_extension; __DRI2bufferDamageExtension buffer_damage_extension; diff --git a/src/gallium/frontends/omx/tizonia/h264dprc.c b/src/gallium/frontends/omx/tizonia/h264dprc.c index 7a0063beace..e8ad22c8da4 100644 --- a/src/gallium/frontends/omx/tizonia/h264dprc.c +++ b/src/gallium/frontends/omx/tizonia/h264dprc.c @@ -174,7 +174,9 @@ static struct pipe_resource * st_omx_pipe_texture_from_eglimage(EGLDisplay egldi struct dri2_egl_display *dri2_egl_dpy = disp->DriverData; __DRIscreen *_dri_screen = dri2_egl_dpy->dri_screen; struct dri_screen *st_dri_screen = dri_screen(_dri_screen); - __DRIimage *_dri_image = st_dri_screen->lookup_egl_image(st_dri_screen, eglimage); + if (!st_dri_screen->validate_egl_image(st_dri_screen, eglimage)) + return NULL; + __DRIimage *_dri_image = st_dri_screen->lookup_egl_image_validated(st_dri_screen, eglimage); return _dri_image->texture; } diff --git a/src/gallium/include/mesa_interface.h b/src/gallium/include/mesa_interface.h index 890cf8db981..07dfa6f35cc 100644 --- a/src/gallium/include/mesa_interface.h +++ b/src/gallium/include/mesa_interface.h @@ -1731,28 +1731,15 @@ typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension; struct __DRIimageLookupExtensionRec { __DRIextension base; - /** - * Lookup EGLImage without validated. Equivalent to call - * validateEGLImage() then lookupEGLImageValidated(). - * - * \since 1 - */ - __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image, - void *loaderPrivate); - /** * Check if EGLImage is associated with the EGL display before lookup with * lookupEGLImageValidated(). It will hold EGLDisplay.Mutex, so is separated - * out from lookupEGLImage() to avoid deadlock. - * - * \since 2 + * out from lookupEGLImageValidated() to avoid deadlock. */ unsigned char (*validateEGLImage)(void *image, void *loaderPrivate); /** * Lookup EGLImage after validateEGLImage(). No lock in this function. - * - * \since 2 */ __DRIimage *(*lookupEGLImageValidated)(void *image, void *loaderPrivate); }; diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 6e3517b391d..6ed8ca6c319 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -55,17 +55,6 @@ #include "wayland-drm.h" #endif -static __DRIimage * -dri_lookup_egl_image(__DRIscreen *screen, void *image, void *data) -{ - struct gbm_dri_device *dri = data; - - if (dri->lookup_image == NULL) - return NULL; - - return dri->lookup_image(screen, image, dri->lookup_user_data); -} - static GLboolean dri_validate_egl_image(void *image, void *data) { @@ -205,7 +194,6 @@ static const __DRIuseInvalidateExtension use_invalidate = { static const __DRIimageLookupExtension image_lookup_extension = { .base = { __DRI_IMAGE_LOOKUP, 2 }, - .lookupEGLImage = dri_lookup_egl_image, .validateEGLImage = dri_validate_egl_image, .lookupEGLImageValidated = dri_lookup_egl_image_validated, }; @@ -331,7 +319,6 @@ dri_screen_create_for_driver(struct gbm_dri_device *dri, char *driver_name, bool } } - dri->lookup_image = NULL; dri->lookup_user_data = NULL; return 0; @@ -755,12 +742,16 @@ gbm_dri_bo_import(struct gbm_device *gbm, case GBM_BO_IMPORT_EGL_IMAGE: { - if (dri->lookup_image == NULL) { + if (dri->lookup_image_validated == NULL) { errno = EINVAL; return NULL; } - image = dri->lookup_image(dri->screen, buffer, dri->lookup_user_data); + if (!dri->validate_image(buffer, dri->lookup_user_data)) { + errno = EINVAL; + return NULL; + } + image = dri->lookup_image_validated(buffer, dri->lookup_user_data); image = dri->image->dupImage(image, NULL); dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FOURCC, &gbm_format); if (gbm_format == DRM_FORMAT_INVALID) { diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h index a456900ae4b..694fa307629 100644 --- a/src/gbm/backends/dri/gbm_driint.h +++ b/src/gbm/backends/dri/gbm_driint.h @@ -69,7 +69,6 @@ struct gbm_dri_device { const __DRIextension **loader_extensions; const __DRIextension **driver_extensions; - __DRIimage *(*lookup_image)(__DRIscreen *screen, void *image, void *data); GLboolean (*validate_image)(void *image, void *data); __DRIimage *(*lookup_image_validated)(void *image, void *data); void *lookup_user_data;