[Mesa-dev] [PATCH 07/11 v3] gbm: add handle2(drm buffer region name)
Zhao, Halley
halley.zhao at linux.intel.com
Thu Jun 21 01:17:37 PDT 2012
Thanks Ander. I updated the patch following your advice:
>From 6110f8c5ed0dc326e85d07a3c5408be5810db245 Mon Sep 17 00:00:00 2001
From: Zhao Halley <halley.zhao at intel.com>
Date: Thu, 14 Jun 2012 18:19:12 +0800
Subject: [PATCH 07/10] gbm: add shared_handle(drm buffer region name)
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
On Tue, 2012-06-19 at 15:47 +0300, Ander Conselvan de Oliveira wrote:
> On 06/14/2012 01:32 PM, Zhao Halley wrote:
> > ---
> > src/gbm/backends/dri/gbm_dri.c | 6 +++++-
> > src/gbm/main/gbm.c | 14 ++++++++++++++
> > src/gbm/main/gbm.h | 3 +++
> > src/gbm/main/gbmint.h | 1 +
> > 4 files changed, 23 insertions(+), 1 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..a71815f 100755
> > --- a/src/gbm/backends/dri/gbm_dri.c
> > +++ b/src/gbm/backends/dri/gbm_dri.c
> > @@ -392,6 +392,8 @@ gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm,
> > (int *)&bo->base.base.pitch);
> > dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FORMAT,
> > &dri_format);
> > + dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_NAME,
> > + (uint32_t *)&bo->base.base.handle2.u32);
>
> This will cause a name to be allocated for the region even if the user
> does not need it. Maybe this should be delayed until the user calls
> gbm_bo_get_handle2().
>
> > bo->base.base.format = gbm_dri_to_gbm_format(dri_format);
> >
> > @@ -460,7 +462,9 @@ gbm_dri_bo_create(struct gbm_device *gbm,
> > &bo->base.base.handle.s32);
> > dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
> > (int *)&bo->base.base.pitch);
> > -
> > + dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_NAME,
> > + (uint32_t *)&bo->base.base.handle2.u32);
>
> Same here.
>
> > +
>
> This line has whitespace errors.
>
> > return&bo->base.base;
> > }
> >
> > diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
> > old mode 100644
> > new mode 100755
> > index 3994f86..f445bb1
> > --- a/src/gbm/main/gbm.c
> > +++ b/src/gbm/main/gbm.c
> > @@ -231,6 +231,20 @@ gbm_bo_get_handle(struct gbm_bo *bo)
> > return bo->handle;
> > }
> >
> > +/** Get handle2 (buffer region name) of the buffer object
> > + *
> > + * 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_handle2(struct gbm_bo *bo)
>
> I think gbm_bo_get_shared_handle() is a better name for this. And the
> function documentation should explain what is the difference between
> this and the handle returned by gbm_bo_get_handle().
>
> BR,
> Ander
>
> > +{
> > + return bo->handle2;
> > +}
> > +
> > /** 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..25c9d37 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_handle2(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..5e48e89
> > --- a/src/gbm/main/gbmint.h
> > +++ b/src/gbm/main/gbmint.h
> > @@ -95,6 +95,7 @@ struct gbm_bo {
> > uint32_t pitch;
> > uint32_t format;
> > union gbm_bo_handle handle;
> > + union gbm_bo_handle handle2;
> > void *user_data;
> > void (*destroy_user_data)(struct gbm_bo *, void *);
> > };
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list