<div dir="ltr">At the time I developed glamor, the extension of creating egl image from gl texture was<div>not implemented in mesa. Now mesa already supported it,  and we can provide these new</div><div>APIs to DDR driver. Just as you said, we may need a new API in libglamor.so to query a</div>
<div>pixmap's type and texture unit id, then we don't need to access the pixmap's private data</div><div>structure.</div><div><br></div><div>The new API you implemented will give DDR a chance to support DRI more efficiently.</div>
<div>Currently, when the client want to create a dri2 buffer on a textured only pixmap, it will</div><div>trigger a glamor_fixup function to create a new textured_drm pixmap and then copy the</div><div>old buffer to this new buffer. Now we can avoid this extra copy with this new API at that</div>
<div>case.</div><div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks,</div><div class="gmail_extra">Zhigang Gong.<br><br><div class="gmail_quote">On Fri, Nov 22, 2013 at 6:45 AM,  <span dir="ltr"><<a href="mailto:davyaxel@free.fr" target="_blank">davyaxel@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
I've got pixmap->fd working with this experimental function (on intel):<br>
<br>
Bool glamor_egl_get_fd_from_pixmap(PixmapPtr pixmap, int* fd)<br>
{<br>
  struct glamor_pixmap_private * priv = glamor_get_pixmap_private(pixmap);<br>
<div class="im">  ScreenPtr screen = pixmap->drawable.pScreen;<br>
</div>  ScrnInfoPtr scrn = xf86ScreenToScrn(screen);<br>
  struct glamor_egl_screen_private *glamor_egl;<br>
  EGLImageKHR image;<br>
  GLuint texture;<br>
  Bool ret = FALSE;<br>
  struct gbm_bo* bo;<br>
  EGLint attribs[] = {<br>
        EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,<br>
        EGL_GL_TEXTURE_LEVEL_KHR, 0,<br>
        EGL_NONE<br>
  };<br>
<br>
  glamor_egl = glamor_egl_get_screen_private(scrn);<br>
  switch (priv->type)<br>
  {<br>
    case GLAMOR_TEXTURE_DRM:<br>
    case GLAMOR_TEXTURE_ONLY:<br>
       glamor_egl_make_current(screen);<br>
<div class="im">       image = glamor_egl->egl_create_image_khr(glamor_egl->display,<br>
</div>                         glamor_egl->context,<br>
                         EGL_GL_TEXTURE_2D_KHR,<br>
                         priv->base.fbo->tex, attribs);<br>
       if (image == EGL_NO_IMAGE_KHR)<br>
        goto leave;<br>
       bo = gbm_bo_import(glamor_egl->gbm,GBM_BO_IMPORT_EGL_IMAGE,image,0);<br>
       glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);<br>
       ret = glamor_get_fd_from_bo(glamor_egl->fd,bo,fd);<br>
       if(ret)<br>
       {<br>
          glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);<br>
          pixmap->devKind = gbm_bo_get_stride(bo);<br>
       }<br>
       gbm_bo_destroy(bo);<br>
       break;<br>
    default: return 0;<br>
  }<br>
  leave:<br>
  glamor_egl_restore_context(screen);<br>
        return ret;<br>
}<br>
<br>
int<br>
glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd)<br>
{<br>
  union gbm_bo_handle handle;<br>
  struct drm_prime_handle args;<br>
<br>
  handle = gbm_bo_get_handle(bo);<br>
  args.handle = handle.u32;<br>
  args.flags = DRM_CLOEXEC;<br>
  if (ioctl (gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args))<br>
    return FALSE;<br>
  *fd = args.fd;<br>
  return TRUE;<br>
}<br>
<br>
<br>
Of course there are some missing checks, etc.<br>
And it needs glamor_egl.c has access to the glamor_pixmap_private to get the texture.<br>
I think it would be better to have a function glamor_get_pixmap_texture_number that glamor_egl would have access to.<br>
<br>
Feel free to add comments<br>
<br>
Axel Davy<br>
<div class=""><div class="h5">_______________________________________________<br>
Glamor mailing list<br>
<a href="mailto:Glamor@lists.freedesktop.org">Glamor@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/glamor" target="_blank">http://lists.freedesktop.org/mailman/listinfo/glamor</a><br>
</div></div></blockquote></div><br></div></div></div>