it can be shared among processed --- src/gbm/backends/dri/gbm_dri.c | 13 +++++++++++++ src/gbm/main/gbm.c | 18 ++++++++++++++++++ src/gbm/main/gbm.h | 3 +++ src/gbm/main/gbmint.h | 2 ++ 4 files changed, 36 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/gbm/main/gbm.c mode change 100644 => 100755 src/gbm/main/gbmint.h
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 9e2bd83..0646b47 100755 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -345,6 +345,18 @@ gbm_dri_to_gbm_format(uint32_t dri_format) return ret; } +static union gbm_bo_handle +gbm_dri_bo_get_shared_handle(struct gbm_bo *_bo) +{ + struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); + struct gbm_dri_bo *bo = gbm_dri_bo(_bo); + + dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_NAME, + (uint32_t *) &bo->base.base.shared_handle.u32); + + return bo->base.base.shared_handle; +} + static struct gbm_bo * gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm, void *egl_dpy, void *egl_img, @@ -522,6 +534,7 @@ dri_device_create(int fd) dri->base.base.destroy = dri_destroy; dri->base.base.surface_create = gbm_dri_surface_create; dri->base.base.surface_destroy = gbm_dri_surface_destroy; + dri->base.base.bo_get_shared_handle = gbm_dri_bo_get_shared_handle; dri->base.type = GBM_DRM_DRIVER_TYPE_DRI; dri->base.base.name = "drm"; diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c old mode 100644 new mode 100755 index 3994f86..017cb2d --- a/src/gbm/main/gbm.c +++ b/src/gbm/main/gbm.c @@ -231,6 +231,24 @@ gbm_bo_get_handle(struct gbm_bo *bo) return bo->handle; } +/** Get shared handle(global buffer region name) of the buffer object, + * this handle can be shared among processes + * + * This is stored in the platform generic union gbm_bo_handle type. However + * the format of this handle is platform specific. + * + * \param bo The buffer object + * \return Returns the handle of the allocated buffer object + */ +GBM_EXPORT union gbm_bo_handle +gbm_bo_get_shared_handle(struct gbm_bo *bo) +{ + if (bo->shared_handle.u32) return bo->shared_handle; + + return bo->gbm->bo_get_shared_handle(bo); + +} + /** Write data into the buffer object * * If the buffer object was created with the GBM_BO_USE_WRITE flag, diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h index b2a0aa3..68309fb 100755 --- a/src/gbm/main/gbm.h +++ b/src/gbm/main/gbm.h @@ -257,6 +257,9 @@ gbm_bo_get_device(struct gbm_bo *bo); union gbm_bo_handle gbm_bo_get_handle(struct gbm_bo *bo); +union gbm_bo_handle +gbm_bo_get_shared_handle(struct gbm_bo *bo); + int gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count); diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h old mode 100644 new mode 100755 index 8eb8671..6327f94 --- a/src/gbm/main/gbmint.h +++ b/src/gbm/main/gbmint.h @@ -70,6 +70,7 @@ struct gbm_device { void *egl_dpy, void *egl_img, uint32_t width, uint32_t height, uint32_t usage); + union gbm_bo_handle (*bo_get_shared_handle)(struct gbm_bo *bo); int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data); void (*bo_destroy)(struct gbm_bo *bo); @@ -95,6 +96,7 @@ struct gbm_bo { uint32_t pitch; uint32_t format; union gbm_bo_handle handle; + union gbm_bo_handle shared_handle; // global handle can be shared among processes void *user_data; void (*destroy_user_data)(struct gbm_bo *, void *); }; -- 1.7.5.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev