On Thu, Feb 18, 2010 at 12:04:14PM -0500, Kristian Høgsberg wrote:
> 2010/2/12 Ian Romanick <i...@freedesktop.org>:
> >> +static _EGLImage *
> >> +dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
> >> +                   _EGLContext *ctx, EGLenum target,
> >> +                   EGLClientBuffer buffer, const EGLint *attr_list)
> >> +{
> >> +   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
> >> +   struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
> >> +   struct dri2_egl_image *dri2_img;
> >> +   unsigned int attachments[1];
> >> +   xcb_drawable_t drawable;
> >> +   xcb_dri2_get_buffers_cookie_t cookie;
> >> +   xcb_dri2_dri2_buffer_t *buffers;
> >> +   xcb_dri2_get_buffers_reply_t *reply;
> >> +
> >> +   dri2_img = malloc(sizeof *dri2_img);
> >> +   if (!dri2_img) {
> >> +      _eglError(EGL_BAD_ALLOC, "dri2_create_image_khr");
> >> +      return EGL_NO_IMAGE_KHR;
> >> +   }
> >> +
> >> +   if (!_eglInitImage(&dri2_img->base, disp, attr_list))
> >> +      return EGL_NO_IMAGE_KHR;
> >> +
> >> +   switch (target) {
> >> +   case EGL_NATIVE_PIXMAP_KHR:
> >> +      drawable = (xcb_drawable_t) buffer;
> >> +      xcb_dri2_create_drawable (dri2_dpy->conn, drawable);
> >> +      attachments[0] = XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT;
> >> +      cookie = xcb_dri2_get_buffers_unchecked (dri2_dpy->conn,
> >> +                                            drawable, 1, 1, attachments);
> >> +      reply = xcb_dri2_get_buffers_reply (dri2_dpy->conn, cookie, NULL);
> >> +      buffers = xcb_dri2_get_buffers_buffers (reply);
> >> +      if (buffers == NULL) {
> >> +      free(dri2_img);
> >> +      return NULL;
> >> +      }
> >> +
> >> +      dri2_img->width = reply->width;
> >> +      dri2_img->height = reply->height;
> >> +      dri2_img->name = buffers[0].name;
> >> +      dri2_img->pitch = buffers[0].pitch / buffers[0].cpp;
> >> +      dri2_img->cpp = buffers[0].cpp;
> >> +      free(reply);
> >> +      break;
> >> +
> >> +   default:
> >> +      _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
> >> +      free(dri2_img);
> >> +      return EGL_NO_IMAGE_KHR;
> >> +   }
> >> +
> >> +   dri2_img->dri_image =
> >> +      dri2_dpy->image->createImageFromName(dri2_ctx->dri_context,
> >> +                                        dri2_img->width,
> >> +                                        dri2_img->height,
> >> +                                        GL_RGBA,
> >> +                                        dri2_img->name,
> >> +                                        dri2_img->pitch,
> >> +                                        dri2_img);
> >> +
> > Since applications call this function directly, should this give an
> > error if dri2_dpy->image is NULL, or is it okay to just segfault?
> If __DRIimage isn't available, eglInitializeDisplay fails.  I suppose
> we should make that optional and just not advertise any EGLImage
> extensions instead.
It should be noted that eglapi.c does not check if an extension is
available before dispatching (while it probably should).

BTW, it seems

  dri2_dpy->base.Extensions.KHR_image_base and
  dri2_dpy->base.Extensions.KHR_image_pixmap

are not set in the patch to advertise the extensions.

-- 
o...@lunarg.com

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to