[Glamor] [PATCH] Allow to create textured pixmaps from gbm_bo without using gem names

zhigang gong zhigang.gong at gmail.com
Sat Nov 23 04:47:50 PST 2013


At the time I developed glamor, the extension of creating egl image from gl
texture was
not implemented in mesa. Now mesa already supported it,  and we can provide
these new
APIs to DDR driver. Just as you said, we may need a new API in libglamor.so
to query a
pixmap's type and texture unit id, then we don't need to access the
pixmap's private data
structure.

The new API you implemented will give DDR a chance to support DRI more
efficiently.
Currently, when the client want to create a dri2 buffer on a textured only
pixmap, it will
trigger a glamor_fixup function to create a new textured_drm pixmap and
then copy the
old buffer to this new buffer. Now we can avoid this extra copy with this
new API at that
case.

Thanks,
Zhigang Gong.

On Fri, Nov 22, 2013 at 6:45 AM, <davyaxel at free.fr> wrote:

> Hi,
>
> I've got pixmap->fd working with this experimental function (on intel):
>
> Bool glamor_egl_get_fd_from_pixmap(PixmapPtr pixmap, int* fd)
> {
>   struct glamor_pixmap_private * priv = glamor_get_pixmap_private(pixmap);
>   ScreenPtr screen = pixmap->drawable.pScreen;
>   ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
>   struct glamor_egl_screen_private *glamor_egl;
>   EGLImageKHR image;
>   GLuint texture;
>   Bool ret = FALSE;
>   struct gbm_bo* bo;
>   EGLint attribs[] = {
>         EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
>         EGL_GL_TEXTURE_LEVEL_KHR, 0,
>         EGL_NONE
>   };
>
>   glamor_egl = glamor_egl_get_screen_private(scrn);
>   switch (priv->type)
>   {
>     case GLAMOR_TEXTURE_DRM:
>     case GLAMOR_TEXTURE_ONLY:
>        glamor_egl_make_current(screen);
>        image = glamor_egl->egl_create_image_khr(glamor_egl->display,
>                          glamor_egl->context,
>                          EGL_GL_TEXTURE_2D_KHR,
>                          priv->base.fbo->tex, attribs);
>        if (image == EGL_NO_IMAGE_KHR)
>         goto leave;
>        bo = gbm_bo_import(glamor_egl->gbm,GBM_BO_IMPORT_EGL_IMAGE,image,0);
>        glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
>        ret = glamor_get_fd_from_bo(glamor_egl->fd,bo,fd);
>        if(ret)
>        {
>           glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
>           pixmap->devKind = gbm_bo_get_stride(bo);
>        }
>        gbm_bo_destroy(bo);
>        break;
>     default: return 0;
>   }
>   leave:
>   glamor_egl_restore_context(screen);
>         return ret;
> }
>
> int
> glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd)
> {
>   union gbm_bo_handle handle;
>   struct drm_prime_handle args;
>
>   handle = gbm_bo_get_handle(bo);
>   args.handle = handle.u32;
>   args.flags = DRM_CLOEXEC;
>   if (ioctl (gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args))
>     return FALSE;
>   *fd = args.fd;
>   return TRUE;
> }
>
>
> Of course there are some missing checks, etc.
> And it needs glamor_egl.c has access to the glamor_pixmap_private to get
> the texture.
> I think it would be better to have a function
> glamor_get_pixmap_texture_number that glamor_egl would have access to.
>
> Feel free to add comments
>
> Axel Davy
> _______________________________________________
> Glamor mailing list
> Glamor at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/glamor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/glamor/attachments/20131123/ee90b40a/attachment.html>


More information about the Glamor mailing list