[Glamor] [PATCH] Allow to create textured pixmaps from gbm_bo without using gem names
davyaxel at free.fr
davyaxel at free.fr
Thu Nov 21 14:45:17 PST 2013
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
More information about the Glamor
mailing list