mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 20:20:18 +01:00
egl/dri2: seperate EGLImage validate and lookup
Version 2 of DRIImageLookupExtension add two interface for EGLImage validate and lookup. This is for resolving deak lock in the following commits. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12336>
This commit is contained in:
parent
5d74c33aaa
commit
dcf38724c7
3 changed files with 59 additions and 11 deletions
|
|
@ -1817,14 +1817,36 @@ struct __DRIimageExtensionRec {
|
||||||
* with new lookup functions.
|
* with new lookup functions.
|
||||||
*/
|
*/
|
||||||
#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
|
#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
|
||||||
#define __DRI_IMAGE_LOOKUP_VERSION 1
|
#define __DRI_IMAGE_LOOKUP_VERSION 2
|
||||||
|
|
||||||
typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
|
typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
|
||||||
struct __DRIimageLookupExtensionRec {
|
struct __DRIimageLookupExtensionRec {
|
||||||
__DRIextension base;
|
__DRIextension base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup EGLImage without validated. Equivalent to call
|
||||||
|
* validateEGLImage() then lookupEGLImageValidated().
|
||||||
|
*
|
||||||
|
* \since 1
|
||||||
|
*/
|
||||||
__DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
|
__DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
|
||||||
void *loaderPrivate);
|
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
|
||||||
|
*/
|
||||||
|
GLboolean (*validateEGLImage)(void *image, void *loaderPrivate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup EGLImage after validateEGLImage(). No lock in this function.
|
||||||
|
*
|
||||||
|
* \since 2
|
||||||
|
*/
|
||||||
|
__DRIimage *(*lookupEGLImageValidated)(void *image, void *loaderPrivate);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -649,33 +649,53 @@ dri2_add_pbuffer_configs_for_visuals(_EGLDisplay *disp)
|
||||||
return (config_count != 0);
|
return (config_count != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
__DRIimage *
|
GLboolean
|
||||||
dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
|
dri2_validate_egl_image(void *image, void *data)
|
||||||
{
|
{
|
||||||
_EGLDisplay *disp = data;
|
_EGLDisplay *disp = data;
|
||||||
struct dri2_egl_image *dri2_img;
|
|
||||||
_EGLImage *img;
|
_EGLImage *img;
|
||||||
|
|
||||||
(void) screen;
|
|
||||||
|
|
||||||
mtx_lock(&disp->Mutex);
|
mtx_lock(&disp->Mutex);
|
||||||
img = _eglLookupImage(image, disp);
|
img = _eglLookupImage(image, disp);
|
||||||
mtx_unlock(&disp->Mutex);
|
mtx_unlock(&disp->Mutex);
|
||||||
|
|
||||||
if (img == NULL) {
|
if (img == NULL) {
|
||||||
_eglError(EGL_BAD_PARAMETER, "dri2_lookup_egl_image");
|
_eglError(EGL_BAD_PARAMETER, "dri2_validate_egl_image");
|
||||||
return NULL;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
__DRIimage *
|
||||||
|
dri2_lookup_egl_image_validated(void *image, void *data)
|
||||||
|
{
|
||||||
|
struct dri2_egl_image *dri2_img;
|
||||||
|
|
||||||
|
(void)data;
|
||||||
|
|
||||||
dri2_img = dri2_egl_image(image);
|
dri2_img = dri2_egl_image(image);
|
||||||
|
|
||||||
return dri2_img->dri_image;
|
return dri2_img->dri_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
const __DRIimageLookupExtension image_lookup_extension = {
|
__DRIimage *
|
||||||
.base = { __DRI_IMAGE_LOOKUP, 1 },
|
dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
|
||||||
|
{
|
||||||
|
(void) screen;
|
||||||
|
|
||||||
.lookupEGLImage = dri2_lookup_egl_image
|
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dri2_extension_match {
|
struct dri2_extension_match {
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,12 @@ dri2_setup_extensions(_EGLDisplay *disp);
|
||||||
__DRIdrawable *
|
__DRIdrawable *
|
||||||
dri2_surface_get_dri_drawable(_EGLSurface *surf);
|
dri2_surface_get_dri_drawable(_EGLSurface *surf);
|
||||||
|
|
||||||
|
GLboolean
|
||||||
|
dri2_validate_egl_image(void *image, void *data);
|
||||||
|
|
||||||
|
__DRIimage *
|
||||||
|
dri2_lookup_egl_image_validated(void *image, void *data);
|
||||||
|
|
||||||
__DRIimage *
|
__DRIimage *
|
||||||
dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data);
|
dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue