#include "loader.h"
#include "loader_dri3_helper.h"
-static uint32_t
-dri3_format_for_depth(uint32_t depth)
-{
- switch (depth) {
- case 16:
- return __DRI_IMAGE_FORMAT_RGB565;
- case 24:
- return __DRI_IMAGE_FORMAT_XRGB8888;
- case 30:
- return __DRI_IMAGE_FORMAT_XRGB2101010;
- case 32:
- return __DRI_IMAGE_FORMAT_ARGB8888;
- default:
- return __DRI_IMAGE_FORMAT_NONE;
- }
-}
-
static struct dri3_egl_surface *
loader_drawable_to_egl_surface(struct loader_dri3_drawable *draw) {
size_t offset = offsetof(struct dri3_egl_surface, loader_drawable);
static EGLBoolean
dri3_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf);
+ xcb_drawable_t drawable = dri3_surf->loader_drawable.drawable;
(void) drv;
loader_dri3_drawable_fini(&dri3_surf->loader_drawable);
+ if (surf->Type == EGL_PBUFFER_BIT)
+ xcb_free_pixmap (dri2_dpy->conn, drawable);
+
dri2_fini_surface(surf);
free(surf);
dri_config = dri2_get_dri_config(dri2_conf, type,
dri3_surf->surf.base.GLColorspace);
+ if (!dri_config) {
+ _eglError(EGL_BAD_MATCH, "Unsupported surfacetype/colorspace configuration");
+ goto cleanup_pixmap;
+ }
+
if (loader_dri3_drawable_init(dri2_dpy->conn, drawable,
dri2_dpy->dri_screen,
dri2_dpy->is_different_gpu,
return NULL;
}
- format = dri3_format_for_depth(bp_reply->depth);
+ format = dri2_format_for_depth(dri2_dpy, bp_reply->depth);
if (format == __DRI_IMAGE_FORMAT_NONE) {
_eglError(EGL_BAD_PARAMETER,
"dri3_create_image_khr: unsupported pixmap depth");
return &dri2_img->base;
}
+#ifdef HAVE_DRI3_MODIFIERS
static _EGLImage *
dri3_create_image_khr_pixmap_from_buffers(_EGLDisplay *disp, _EGLContext *ctx,
EGLClientBuffer buffer,
return EGL_NO_IMAGE_KHR;
}
- format = dri3_format_for_depth(bp_reply->depth);
+ format = dri2_format_for_depth(dri2_dpy, bp_reply->depth);
if (format == __DRI_IMAGE_FORMAT_NONE) {
_eglError(EGL_BAD_PARAMETER,
"dri3_create_image_khr: unsupported pixmap depth");
return &dri2_img->base;
}
+#endif
static _EGLImage *
dri3_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
_EGLContext *ctx, EGLenum target,
EGLClientBuffer buffer, const EGLint *attr_list)
{
+#ifdef HAVE_DRI3_MODIFIERS
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+#endif
switch (target) {
case EGL_NATIVE_PIXMAP_KHR:
+#ifdef HAVE_DRI3_MODIFIERS
if (dri2_dpy->multibuffers_available)
return dri3_create_image_khr_pixmap_from_buffers(disp, ctx, buffer,
attr_list);
+#endif
return dri3_create_image_khr_pixmap(disp, ctx, buffer, attr_list);
default:
return dri2_create_image_khr(drv, disp, ctx, target, buffer, attr_list);
{
struct dri3_egl_surface *dri3_surf = dri3_egl_surface(draw);
- /* No-op for a pixmap or pbuffer surface */
- if (draw->Type == EGL_PIXMAP_BIT || draw->Type == EGL_PBUFFER_BIT)
- return EGL_FALSE;
-
return loader_dri3_swap_buffers_msc(&dri3_surf->loader_drawable,
0, 0, 0, 0,
draw->SwapBehavior == EGL_BUFFER_PRESERVED) != -1;
}
static int
-dri3_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
+dri3_query_buffer_age(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
{
struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf);
}
static EGLBoolean
-dri3_query_surface(_EGLDriver *drv, _EGLDisplay *dpy,
+dri3_query_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLSurface *surf, EGLint attribute,
EGLint *value)
{
break;
}
- return _eglQuerySurface(drv, dpy, surf, attribute, value);
+ return _eglQuerySurface(drv, disp, surf, attribute, value);
}
static __DRIdrawable *
}
static void
-dri3_close_screen_notify(_EGLDisplay *dpy)
+dri3_close_screen_notify(_EGLDisplay *disp)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
loader_dri3_close_screen(dri2_dpy->dri_screen);
}
.close_screen_notify = dri3_close_screen_notify,
};
+/* Only request versions of these protocols which we actually support. */
+#define DRI3_SUPPORTED_MAJOR 1
+#define PRESENT_SUPPORTED_MAJOR 1
+
+#ifdef HAVE_DRI3_MODIFIERS
+#define DRI3_SUPPORTED_MINOR 2
+#define PRESENT_SUPPORTED_MINOR 2
+#else
+#define PRESENT_SUPPORTED_MINOR 0
+#define DRI3_SUPPORTED_MINOR 0
+#endif
+
EGLBoolean
dri3_x11_connect(struct dri2_egl_display *dri2_dpy)
{
return EGL_FALSE;
dri3_query_cookie = xcb_dri3_query_version(dri2_dpy->conn,
- XCB_DRI3_MAJOR_VERSION,
- XCB_DRI3_MINOR_VERSION);
+ DRI3_SUPPORTED_MAJOR,
+ DRI3_SUPPORTED_MINOR);
present_query_cookie = xcb_present_query_version(dri2_dpy->conn,
- XCB_PRESENT_MAJOR_VERSION,
- XCB_PRESENT_MINOR_VERSION);
+ PRESENT_SUPPORTED_MAJOR,
+ PRESENT_SUPPORTED_MINOR);
dri3_query =
xcb_dri3_query_version_reply(dri2_dpy->conn, dri3_query_cookie, &error);
free(error);
return EGL_FALSE;
}
+
+ dri2_dpy->present_major_version = present_query->major_version;
+ dri2_dpy->present_minor_version = present_query->minor_version;
free(present_query);
dri2_dpy->fd = loader_dri3_open(dri2_dpy->conn, dri2_dpy->screen->root, 0);