dri_is_thread_safe(void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
- _EGLDisplay *display = dri2_surf->base.Resource.Display;
+ MAYBE_UNUSED _EGLDisplay *display = dri2_surf->base.Resource.Display;
#ifdef HAVE_X11_PLATFORM
Display *xdpy = (Display*)display->PlatformDisplay;
bind_to_texture_rgb = 0;
bind_to_texture_rgba = 0;
- for (int i = 0; dri2_dpy->core->indexConfigAttrib(dri_config, i, &attrib,
- &value); ++i) {
+ for (int i = 0; i < __DRI_ATTRIB_MAX; ++i) {
+ if (!dri2_dpy->core->indexConfigAttrib(dri_config, i, &attrib, &value))
+ break;
+
switch (attrib) {
case __DRI_ATTRIB_RENDER_TYPE:
if (value & __DRI_ATTRIB_RGBA_BIT)
case _EGL_PLATFORM_SURFACELESS:
ret = dri2_initialize_surfaceless(drv, disp);
break;
+ case _EGL_PLATFORM_DEVICE:
+ ret = dri2_initialize_device(drv, disp);
+ break;
case _EGL_PLATFORM_X11:
ret = dri2_initialize_x11(drv, disp);
break;
EGLBoolean
dri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type,
- _EGLConfig *conf, const EGLint *attrib_list, EGLBoolean enable_out_fence)
+ _EGLConfig *conf, const EGLint *attrib_list,
+ EGLBoolean enable_out_fence, void *native_surface)
{
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
dri2_surf->enable_out_fence = enable_out_fence;
}
- return _eglInitSurface(surf, disp, type, conf, attrib_list);
+ return _eglInitSurface(surf, disp, type, conf, attrib_list, native_surface);
}
static void
dri2_surface_set_out_fence_fd(surf, fence_fd);
}
+EGLBoolean
+dri2_create_drawable(struct dri2_egl_display *dri2_dpy,
+ const __DRIconfig *config,
+ struct dri2_egl_surface *dri2_surf,
+ void *loaderPrivate)
+{
+ __DRIcreateNewDrawableFunc createNewDrawable;
+
+ if (dri2_dpy->image_driver)
+ createNewDrawable = dri2_dpy->image_driver->createNewDrawable;
+ else if (dri2_dpy->dri2)
+ createNewDrawable = dri2_dpy->dri2->createNewDrawable;
+ else if (dri2_dpy->swrast)
+ createNewDrawable = dri2_dpy->swrast->createNewDrawable;
+ else
+ return _eglError(EGL_BAD_ALLOC, "no createNewDrawable");
+
+ dri2_surf->dri_drawable = (*createNewDrawable)(dri2_dpy->dri_screen,
+ config, loaderPrivate);
+ if (dri2_surf->dri_drawable == NULL)
+ return _eglError(EGL_BAD_ALLOC, "createNewDrawable");
+
+ return EGL_TRUE;
+}
+
/**
* Called via eglMakeCurrent(), drv->API.MakeCurrent().
*/
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(img);
+ EGLint nplanes;
(void) drv;
if (!dri2_can_export_dma_buf_image(disp, img))
return EGL_FALSE;
+ /* EGL_MESA_image_dma_buf_export spec says:
+ * "If the number of fds is less than the number of planes, then
+ * subsequent fd slots should contain -1."
+ */
+ if (fds) {
+ /* Query nplanes so that we know how big the given array is. */
+ dri2_dpy->image->queryImage(dri2_img->dri_image,
+ __DRI_IMAGE_ATTRIB_NUM_PLANES, &nplanes);
+ memset(fds, -1, nplanes * sizeof(int));
+ }
+
/* rework later to provide multiple fds/strides/offsets */
if (fds)
dri2_dpy->image->queryImage(dri2_img->dri_image,