Skip to content

Commit

Permalink
gbm/dri: implement image lookup extension version 2
Browse files Browse the repository at this point in the history
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Signed-off-by: Qiang Yu <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12336>
  • Loading branch information
yuq authored and Marge Bot committed Sep 9, 2021
1 parent dcf3872 commit 27d91fe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/egl/drivers/dri2/platform_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ dri2_initialize_drm(_EGLDisplay *disp)
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;

dri2_dpy->gbm_dri->get_buffers = dri2_drm_get_buffers;
Expand Down
28 changes: 26 additions & 2 deletions src/gbm/backends/dri/gbm_dri.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ dri_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
return dri->lookup_image(screen, image, dri->lookup_user_data);
}

static GLboolean
dri_validate_egl_image(void *image, void *data)
{
struct gbm_dri_device *dri = data;

if (dri->validate_image == NULL)
return false;

return dri->validate_image(image, dri->lookup_user_data);
}

static __DRIimage *
dri_lookup_egl_image_validated(void *image, void *data)
{
struct gbm_dri_device *dri = data;

if (dri->lookup_image_validated == NULL)
return NULL;

return dri->lookup_image_validated(image, dri->lookup_user_data);
}

static __DRIbuffer *
dri_get_buffers(__DRIdrawable * driDrawable,
int *width, int *height,
Expand Down Expand Up @@ -214,9 +236,11 @@ static const __DRIuseInvalidateExtension use_invalidate = {
};

static const __DRIimageLookupExtension image_lookup_extension = {
.base = { __DRI_IMAGE_LOOKUP, 1 },
.base = { __DRI_IMAGE_LOOKUP, 2 },

.lookupEGLImage = dri_lookup_egl_image
.lookupEGLImage = dri_lookup_egl_image,
.validateEGLImage = dri_validate_egl_image,
.lookupEGLImageValidated = dri_lookup_egl_image_validated,
};

static const __DRIdri2LoaderExtension dri2_loader_extension = {
Expand Down
2 changes: 2 additions & 0 deletions src/gbm/backends/dri/gbm_driint.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ struct gbm_dri_device {
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;

__DRIbuffer *(*get_buffers)(__DRIdrawable * driDrawable,
Expand Down

0 comments on commit 27d91fe

Please sign in to comment.