summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-05-15 19:26:53 +0200
committerChristian König <[email protected]>2011-05-15 19:26:53 +0200
commit828540e491d88b9b6217e6568873a78462919ae8 (patch)
treec952145c1188cdf6b9c56902f8f5c189e090c278 /src/gallium/state_trackers
parent3db6514357a7c634045ae7bc7bba7d7dbf9d58c5 (diff)
parentbd5b7a6f7113da38a2c1f07a4a71e9993666a567 (diff)
Merge remote-tracking branch 'origin/master' into pipe-video
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/egl/Makefile2
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c5
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_api.c33
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_image.c27
-rw-r--r--src/gallium/state_trackers/egl/common/native.h2
-rw-r--r--src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h46
-rw-r--r--src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c57
-rw-r--r--src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h44
-rw-r--r--src/gallium/state_trackers/egl/drm/native_drm.c108
-rw-r--r--src/gallium/state_trackers/egl/drm/native_drm.h9
-rw-r--r--src/gallium/state_trackers/egl/wayland/native_drm.c69
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c69
-rw-r--r--src/gallium/state_trackers/egl/x11/x11_screen.c17
-rw-r--r--src/gallium/state_trackers/egl/x11/x11_screen.h6
-rw-r--r--src/gallium/state_trackers/wgl/stw_framebuffer.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c87
16 files changed, 543 insertions, 40 deletions
diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile
index 53673a78a94..763e7b58a49 100644
--- a/src/gallium/state_trackers/egl/Makefile
+++ b/src/gallium/state_trackers/egl/Makefile
@@ -6,6 +6,7 @@ common_INCLUDES = \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/auxiliary \
-I$(TOP)/src/egl/main \
+ -I$(TOP)/src/egl/wayland/wayland-drm/ \
-I$(TOP)/include
common_SOURCES = $(wildcard common/*.c)
@@ -56,6 +57,7 @@ endif
ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
EGL_OBJECTS += $(wayland_OBJECTS)
EGL_CPPFLAGS += -DHAVE_WAYLAND_BACKEND
+DEFINES += -DHAVE_WAYLAND_BACKEND
endif
ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
EGL_OBJECTS += $(drm_OBJECTS)
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 2c7f3bde4f0..4bd865638a3 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -552,6 +552,11 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
if (dpy->Platform == _EGL_PLATFORM_WAYLAND && gdpy->native->buffer)
dpy->Extensions.MESA_drm_image = EGL_TRUE;
+#ifdef EGL_WL_bind_wayland_display
+ if (gdpy->native->wayland_bufmgr)
+ dpy->Extensions.WL_bind_wayland_display = EGL_TRUE;
+#endif
+
if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
_eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)");
goto fail;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
index f1568329ecf..8b1821e0055 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -868,6 +868,34 @@ egl_g3d_show_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy,
#endif /* EGL_MESA_screen_surface */
+#ifdef EGL_WL_bind_wayland_display
+
+static EGLBoolean
+egl_g3d_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *dpy,
+ struct wl_display *wl_dpy)
+{
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+
+ if (!gdpy->native->wayland_bufmgr)
+ return EGL_FALSE;
+
+ return gdpy->native->wayland_bufmgr->bind_display(gdpy->native, wl_dpy);
+}
+
+static EGLBoolean
+egl_g3d_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *dpy,
+ struct wl_display *wl_dpy)
+{
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+
+ if (!gdpy->native->wayland_bufmgr)
+ return EGL_FALSE;
+
+ return gdpy->native->wayland_bufmgr->unbind_display(gdpy->native, wl_dpy);
+}
+
+#endif /* EGL_WL_bind_wayland_display */
+
void
egl_g3d_init_driver_api(_EGLDriver *drv)
{
@@ -897,6 +925,11 @@ egl_g3d_init_driver_api(_EGLDriver *drv)
drv->API.CreateDRMImageMESA = egl_g3d_create_drm_image;
drv->API.ExportDRMImageMESA = egl_g3d_export_drm_image;
#endif
+#ifdef EGL_WL_bind_wayland_display
+ drv->API.BindWaylandDisplayWL = egl_g3d_bind_wayland_display_wl;
+ drv->API.UnbindWaylandDisplayWL = egl_g3d_unbind_wayland_display_wl;
+
+#endif
#ifdef EGL_KHR_reusable_sync
drv->API.CreateSyncKHR = egl_g3d_create_sync;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.c b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
index e1c83168b3a..210b8c2ee82 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_image.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
@@ -179,6 +179,27 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
#endif /* EGL_MESA_drm_image */
+#ifdef EGL_WL_bind_wayland_display
+
+static struct pipe_resource *
+egl_g3d_reference_wl_buffer(_EGLDisplay *dpy, struct wl_buffer *buffer,
+ _EGLImage *img, const EGLint *attribs)
+{
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+ struct pipe_resource *resource = NULL, *tmp = NULL;
+
+ if (!gdpy->native->wayland_bufmgr)
+ return NULL;
+
+ tmp = gdpy->native->wayland_bufmgr->buffer_get_resource(gdpy->native, buffer);
+
+ pipe_resource_reference(&resource, tmp);
+
+ return resource;
+}
+
+#endif /* EGL_WL_bind_wayland_display */
+
_EGLImage *
egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
EGLenum target, EGLClientBuffer buffer,
@@ -210,6 +231,12 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
(EGLint) buffer, &gimg->base, attribs);
break;
#endif
+#ifdef EGL_WL_bind_wayland_display
+ case EGL_WAYLAND_BUFFER_WL:
+ ptex = egl_g3d_reference_wl_buffer(dpy,
+ (struct wl_buffer *) buffer, &gimg->base, attribs);
+ break;
+#endif
default:
ptex = NULL;
break;
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 9246f8c32a4..8646e52ed7c 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -40,6 +40,7 @@ extern "C" {
#include "native_buffer.h"
#include "native_modeset.h"
+#include "native_wayland_bufmgr.h"
/**
* Only color buffers are listed. The others are allocated privately through,
@@ -198,6 +199,7 @@ struct native_display {
const struct native_display_buffer *buffer;
const struct native_display_modeset *modeset;
+ const struct native_display_wayland_bufmgr *wayland_bufmgr;
};
/**
diff --git a/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h b/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h
new file mode 100644
index 00000000000..b29fd15c1ae
--- /dev/null
+++ b/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h
@@ -0,0 +1,46 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.11
+ *
+ * Copyright (C) 2011 Benjamin Franzke <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _NATIVE_WAYLAND_BUFMGR_H_
+#define _NATIVE_WAYLAND_BUFMGR_H_
+
+struct native_display;
+struct wl_display;
+struct wl_buffer;
+struct pipe_resource;
+
+struct native_display_wayland_bufmgr {
+ boolean (*bind_display)(struct native_display *ndpy,
+ struct wl_display *wl_dpy);
+
+ boolean (*unbind_display)(struct native_display *ndpy,
+ struct wl_display *wl_dpy);
+
+ struct pipe_resource *(*buffer_get_resource)(struct native_display *ndpy,
+ struct wl_buffer *buffer);
+
+};
+
+#endif /* _NATIVE_WAYLAND_BUFMGR_H_ */
diff --git a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c
new file mode 100644
index 00000000000..bc2cee4c386
--- /dev/null
+++ b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c
@@ -0,0 +1,57 @@
+#include <stdint.h>
+#include <string.h>
+
+#include "native.h"
+#include "util/u_inlines.h"
+#include "state_tracker/drm_driver.h"
+
+#ifdef HAVE_WAYLAND_BACKEND
+
+#include <wayland-server.h>
+#include <wayland-drm-server-protocol.h>
+
+#include "native_wayland_drm_bufmgr_helper.h"
+
+void *
+egl_g3d_wl_drm_helper_reference_buffer(void *user_data, uint32_t name,
+ int32_t width, int32_t height,
+ uint32_t stride,
+ struct wl_visual *visual)
+{
+ struct native_display *ndpy = user_data;
+ struct pipe_resource templ;
+ struct winsys_handle wsh;
+ enum pipe_format format = PIPE_FORMAT_B8G8R8A8_UNORM;
+
+ memset(&templ, 0, sizeof(templ));
+ templ.target = PIPE_TEXTURE_2D;
+ templ.format = format;
+ templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ templ.width0 = width;
+ templ.height0 = height;
+ templ.depth0 = 1;
+ templ.array_size = 1;
+
+ memset(&wsh, 0, sizeof(wsh));
+ wsh.handle = name;
+ wsh.stride = stride;
+
+ return ndpy->screen->resource_from_handle(ndpy->screen, &templ, &wsh);
+}
+
+void
+egl_g3d_wl_drm_helper_unreference_buffer(void *user_data, void *buffer)
+{
+ struct pipe_resource *resource = buffer;
+
+ pipe_resource_reference(&resource, NULL);
+}
+
+struct pipe_resource *
+egl_g3d_wl_drm_common_wl_buffer_get_resource(struct native_display *ndpy,
+ struct wl_buffer *buffer)
+{
+ return wayland_drm_buffer_get_buffer(buffer);
+}
+
+#endif
diff --git a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h
new file mode 100644
index 00000000000..71cb6c52b26
--- /dev/null
+++ b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h
@@ -0,0 +1,44 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.11
+ *
+ * Copyright (C) 2011 Benjamin Franzke <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _NATIVE_WAYLAND_DRM_BUFMGR_HELPER_H_
+#define _NATIVE_WAYLAND_DRM_BUFMGR_HELPER_H_
+
+#include "wayland-drm.h"
+
+void *
+egl_g3d_wl_drm_helper_reference_buffer(void *user_data, uint32_t name,
+ int32_t width, int32_t height,
+ uint32_t stride,
+ struct wl_visual *visual);
+
+void
+egl_g3d_wl_drm_helper_unreference_buffer(void *user_data, void *buffer);
+
+struct pipe_resource *
+egl_g3d_wl_drm_common_wl_buffer_get_resource(struct native_display *ndpy,
+ struct wl_buffer *buffer);
+
+#endif /* _NATIVE_WAYLAND_DRM_BUFMGR_HELPER_H_ */
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
index 9863329ff40..c89a6d4767e 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.c
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -23,6 +23,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -36,6 +37,10 @@
#include <radeon_drm.h>
#include "radeon/drm/radeon_drm_public.h"
+#ifdef HAVE_LIBUDEV
+#include <libudev.h>
+#endif
+
static boolean
drm_display_is_format_supported(struct native_display *ndpy,
enum pipe_format fmt, boolean is_color)
@@ -126,6 +131,9 @@ drm_display_destroy(struct native_display *ndpy)
ndpy_uninit(ndpy);
+ if (drmdpy->device_name)
+ FREE(drmdpy->device_name);
+
if (drmdpy->fd >= 0)
close(drmdpy->fd);
@@ -207,6 +215,101 @@ static struct native_display_buffer drm_display_buffer = {
drm_display_export_buffer
};
+static int
+drm_display_authenticate(void *user_data, uint32_t magic)
+{
+ struct native_display *ndpy = user_data;
+ struct drm_display *drmdpy = drm_display(ndpy);
+
+ return drmAuthMagic(drmdpy->fd, magic);
+}
+
+static char *
+drm_get_device_name(int fd)
+{
+ char *device_name = NULL;
+#ifdef HAVE_LIBUDEV
+ struct udev *udev;
+ struct udev_device *device;
+ struct stat buf;
+ const char *tmp;
+
+ udev = udev_new();
+ if (fstat(fd, &buf) < 0) {
+ _eglLog(_EGL_WARNING, "failed to stat fd %d", fd);
+ goto out;
+ }
+
+ device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
+ if (device == NULL) {
+ _eglLog(_EGL_WARNING,
+ "could not create udev device for fd %d", fd);
+ goto out;
+ }
+
+ tmp = udev_device_get_devnode(device);
+ if (!tmp)
+ goto out;
+ device_name = strdup(tmp);
+
+out:
+ udev_device_unref(device);
+ udev_unref(udev);
+
+#endif
+ return device_name;
+}
+
+#ifdef HAVE_WAYLAND_BACKEND
+
+static struct wayland_drm_callbacks wl_drm_callbacks = {
+ drm_display_authenticate,
+ egl_g3d_wl_drm_helper_reference_buffer,
+ egl_g3d_wl_drm_helper_unreference_buffer
+};
+
+static boolean
+drm_display_bind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct drm_display *drmdpy = drm_display(ndpy);
+
+ if (drmdpy->wl_server_drm)
+ return FALSE;
+
+ drmdpy->wl_server_drm = wayland_drm_init(wl_dpy,
+ drmdpy->device_name,
+ &wl_drm_callbacks, ndpy);
+
+ if (!drmdpy->wl_server_drm)
+ return FALSE;
+
+ return TRUE;
+}
+
+static boolean
+drm_display_unbind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct drm_display *drmdpy = drm_display(ndpy);
+
+ if (!drmdpy->wl_server_drm)
+ return FALSE;
+
+ wayland_drm_uninit(drmdpy->wl_server_drm);
+ drmdpy->wl_server_drm = NULL;
+
+ return TRUE;
+}
+
+static struct native_display_wayland_bufmgr drm_display_wayland_bufmgr = {
+ drm_display_bind_wayland_display,
+ drm_display_unbind_wayland_display,
+ egl_g3d_wl_drm_common_wl_buffer_get_resource
+};
+
+#endif /* HAVE_WAYLAND_BACKEND */
+
static struct native_display *
drm_create_display(int fd, struct native_event_handler *event_handler,
void *user_data)
@@ -218,6 +321,7 @@ drm_create_display(int fd, struct native_event_handler *event_handler,
return NULL;
drmdpy->fd = fd;
+ drmdpy->device_name = drm_get_device_name(fd);
drmdpy->event_handler = event_handler;
drmdpy->base.user_data = user_data;
@@ -231,6 +335,10 @@ drm_create_display(int fd, struct native_event_handler *event_handler,
drmdpy->base.get_configs = drm_display_get_configs;
drmdpy->base.buffer = &drm_display_buffer;
+#ifdef HAVE_WAYLAND_BACKEND
+ if (drmdpy->device_name)
+ drmdpy->base.wayland_bufmgr = &drm_display_wayland_bufmgr;
+#endif
drm_display_init_modeset(&drmdpy->base);
return &drmdpy->base;
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.h b/src/gallium/state_trackers/egl/drm/native_drm.h
index 7da9b45f23e..41cdc4f9d04 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.h
+++ b/src/gallium/state_trackers/egl/drm/native_drm.h
@@ -37,6 +37,10 @@
#include "common/native.h"
#include "common/native_helper.h"
+#ifdef HAVE_WAYLAND_BACKEND
+#include "common/native_wayland_drm_bufmgr_helper.h"
+#endif
+
struct drm_config;
struct drm_crtc;
struct drm_connector;
@@ -49,6 +53,7 @@ struct drm_display {
struct native_event_handler *event_handler;
int fd;
+ char *device_name;
struct drm_config *config;
/* for modesetting */
@@ -59,6 +64,10 @@ struct drm_display {
struct drm_surface **shown_surfaces;
/* save the original settings of the CRTCs */
struct drm_crtc *saved_crtcs;
+
+#ifdef HAVE_WAYLAND_BACKEND
+ struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
+#endif
};
struct drm_config {
diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c
index 604720f6e5f..f643c7cbbba 100644
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -45,6 +45,8 @@
#include "wayland-drm-client-protocol.h"
#include "wayland-egl-priv.h"
+#include "common/native_wayland_drm_bufmgr_helper.h"
+
#include <xf86drm.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -56,6 +58,7 @@ struct wayland_drm_display {
struct native_event_handler *event_handler;
struct wl_drm *wl_drm;
+ struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
int fd;
char *device_name;
boolean authenticated;
@@ -268,6 +271,71 @@ static struct native_display_buffer wayland_drm_display_buffer = {
wayland_drm_display_export_buffer
};
+static int
+wayland_drm_display_authenticate(void *user_data, uint32_t magic)
+{
+ struct native_display *ndpy = user_data;
+ struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
+ boolean current_authenticate, authenticated;
+
+ current_authenticate = drmdpy->authenticated;
+
+ wl_drm_authenticate(drmdpy->wl_drm, magic);
+ force_roundtrip(drmdpy->base.dpy);
+ authenticated = drmdpy->authenticated;
+
+ drmdpy->authenticated = current_authenticate;
+
+ return authenticated ? 0 : -1;
+}
+
+static struct wayland_drm_callbacks wl_drm_callbacks = {
+ wayland_drm_display_authenticate,
+ egl_g3d_wl_drm_helper_reference_buffer,
+ egl_g3d_wl_drm_helper_unreference_buffer
+};
+
+static boolean
+wayland_drm_display_bind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
+
+ if (drmdpy->wl_server_drm)
+ return FALSE;
+
+ drmdpy->wl_server_drm =
+ wayland_drm_init(wl_dpy, drmdpy->device_name,
+ &wl_drm_callbacks, ndpy);
+
+ if (!drmdpy->wl_server_drm)
+ return FALSE;
+
+ return TRUE;
+}
+
+static boolean
+wayland_drm_display_unbind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
+
+ if (!drmdpy->wl_server_drm)
+ return FALSE;
+
+ wayland_drm_uninit(drmdpy->wl_server_drm);
+ drmdpy->wl_server_drm = NULL;
+
+ return TRUE;
+}
+
+static struct native_display_wayland_bufmgr wayland_drm_display_wayland_bufmgr = {
+ wayland_drm_display_bind_wayland_display,
+ wayland_drm_display_unbind_wayland_display,
+ egl_g3d_wl_drm_common_wl_buffer_get_resource
+};
+
+
struct wayland_display *
wayland_create_drm_display(struct wl_display *dpy,
struct native_event_handler *event_handler,
@@ -294,6 +362,7 @@ wayland_create_drm_display(struct wl_display *dpy,
}
drmdpy->base.base.destroy = wayland_drm_display_destroy;
drmdpy->base.base.buffer = &wayland_drm_display_buffer;
+ drmdpy->base.base.wayland_bufmgr = &wayland_drm_display_wayland_bufmgr;
drmdpy->base.create_buffer = wayland_create_drm_buffer;
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 5afca67a4d4..a56d43428fc 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -38,6 +38,10 @@
#include "native_x11.h"
#include "x11_screen.h"
+#ifdef HAVE_WAYLAND_BACKEND
+#include "common/native_wayland_drm_bufmgr_helper.h"
+#endif
+
#ifdef GLX_DIRECT_RENDERING
struct dri2_display {
@@ -56,6 +60,9 @@ struct dri2_display {
int num_configs;
struct util_hash_table *surfaces;
+#ifdef HAVE_WAYLAND_BACKEND
+ struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
+#endif
};
struct dri2_surface {
@@ -802,6 +809,65 @@ dri2_display_hash_table_compare(void *key1, void *key2)
return ((char *) key1 - (char *) key2);
}
+static int
+dri2_display_authenticate(void *user_data, uint32_t magic)
+{
+ struct native_display *ndpy = user_data;
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
+
+ return x11_screen_authenticate(dri2dpy->xscr, magic);
+}
+
+#ifdef HAVE_WAYLAND_BACKEND
+
+static struct wayland_drm_callbacks wl_drm_callbacks = {
+ dri2_display_authenticate,
+ egl_g3d_wl_drm_helper_reference_buffer,
+ egl_g3d_wl_drm_helper_unreference_buffer
+};
+
+static boolean
+dri2_display_bind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
+
+ if (dri2dpy->wl_server_drm)
+ return FALSE;
+
+ dri2dpy->wl_server_drm = wayland_drm_init(wl_dpy,
+ x11_screen_get_device_name(dri2dpy->xscr),
+ &wl_drm_callbacks, ndpy);
+
+ if (!dri2dpy->wl_server_drm)
+ return FALSE;
+
+ return TRUE;
+}
+
+static boolean
+dri2_display_unbind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
+
+ if (!dri2dpy->wl_server_drm)
+ return FALSE;
+
+ wayland_drm_uninit(dri2dpy->wl_server_drm);
+ dri2dpy->wl_server_drm = NULL;
+
+ return TRUE;
+}
+
+static struct native_display_wayland_bufmgr dri2_display_wayland_bufmgr = {
+ dri2_display_bind_wayland_display,
+ dri2_display_unbind_wayland_display,
+ egl_g3d_wl_drm_common_wl_buffer_get_resource
+};
+
+#endif /* HAVE_WAYLAND_BACKEND */
+
struct native_display *
x11_create_dri2_display(Display *dpy,
struct native_event_handler *event_handler,
@@ -851,6 +917,9 @@ x11_create_dri2_display(Display *dpy,
dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface;
+#ifdef HAVE_WAYLAND_BACKEND
+ dri2dpy->base.wayland_bufmgr = &dri2_display_wayland_bufmgr;
+#endif
return &dri2dpy->base;
}
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c
index c919b79eac8..f1cc4400ba5 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.c
@@ -307,6 +307,23 @@ x11_screen_enable_dri2(struct x11_screen *xscr,
return xscr->dri_fd;
}
+char *
+x11_screen_get_device_name(struct x11_screen *xscr)
+{
+ return xscr->dri_device;
+}
+
+int
+x11_screen_authenticate(struct x11_screen *xscr, uint32_t id)
+{
+ boolean authenticated;
+
+ authenticated = DRI2Authenticate(xscr->dpy,
+ RootWindow(xscr->dpy, xscr->number), id);
+
+ return authenticated ? 0 : -1;
+}
+
/**
* Create/Destroy the DRI drawable.
*/
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h
index 2e313e0148e..acf1300e9d1 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.h
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.h
@@ -97,6 +97,12 @@ x11_screen_enable_dri2(struct x11_screen *xscr,
x11_drawable_invalidate_buffers invalidate_buffers,
void *user_data);
+char *
+x11_screen_get_device_name(struct x11_screen *xscr);
+
+int
+x11_screen_authenticate(struct x11_screen *xscr, uint32_t id);
+
void
x11_drawable_enable_dri2(struct x11_screen *xscr,
Drawable drawable, boolean on);
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c
index 4033365bfbe..7a689f9977d 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c
@@ -146,8 +146,6 @@ stw_framebuffer_get_size( struct stw_framebuffer *fb )
* maximized again.
*/
- assert(width == 0 && height == 0);
-
return;
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index 91c206f1872..b072f53aa91 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -49,9 +49,24 @@
#include "util/u_box.h"
#include "util/u_surface.h"
-#define DEBUG_PRINT 0
#define ROUND_UP_TEXTURES 1
+static INLINE void
+exa_debug_printf(const char *format, ...) _util_printf_format(1,2);
+
+static INLINE void
+exa_debug_printf(const char *format, ...)
+{
+#if 0
+ va_list ap;
+ va_start(ap, format);
+ _debug_vprintf(format, ap);
+ va_end(ap);
+#else
+ (void) format; /* silence warning */
+#endif
+}
+
/*
* Helper functions
*/
@@ -195,10 +210,8 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst,
if (!transfer)
return FALSE;
-#if DEBUG_PRINT
- debug_printf("------ ExaDownloadFromScreen(%d, %d, %d, %d, %d)\n",
+ exa_debug_printf("------ ExaDownloadFromScreen(%d, %d, %d, %d, %d)\n",
x, y, w, h, dst_pitch);
-#endif
util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0,
w, h, exa->pipe->transfer_map(exa->pipe, transfer),
@@ -229,10 +242,8 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
if (!transfer)
return FALSE;
-#if DEBUG_PRINT
- debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n",
+ exa_debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n",
x, y, w, h, src_pitch);
-#endif
util_copy_rect(exa->pipe->transfer_map(exa->pipe, transfer),
priv->tex->format, transfer->stride, 0, 0, w, h,
@@ -261,6 +272,8 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
if (!priv->tex)
return FALSE;
+ exa_debug_printf("ExaPrepareAccess %d\n", index);
+
if (priv->map_count == 0)
{
assert(pPix->drawable.width <= priv->tex->width0);
@@ -289,6 +302,8 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
priv->map_count++;
+ exa_debug_printf("ExaPrepareAccess %d prepared\n", index);
+
return TRUE;
}
@@ -308,6 +323,8 @@ ExaFinishAccess(PixmapPtr pPix, int index)
if (!priv->map_transfer)
return;
+ exa_debug_printf("ExaFinishAccess %d\n", index);
+
if (--priv->map_count == 0) {
assert(priv->map_transfer);
exa->pipe->transfer_unmap(exa->pipe, priv->map_transfer);
@@ -315,6 +332,8 @@ ExaFinishAccess(PixmapPtr pPix, int index)
priv->map_transfer = NULL;
pPix->devPrivate.ptr = NULL;
}
+
+ exa_debug_printf("ExaFinishAccess %d finished\n", index);
}
/***********************************************************************
@@ -329,9 +348,8 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
struct exa_context *exa = ms->exa;
-#if DEBUG_PRINT
- debug_printf("ExaPrepareSolid(0x%x)\n", fg);
-#endif
+ exa_debug_printf("ExaPrepareSolid(0x%x)\n", fg);
+
if (!exa->accel)
return FALSE;
@@ -364,9 +382,7 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
struct exa_context *exa = ms->exa;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
-#if DEBUG_PRINT
- debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1);
-#endif
+ exa_debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1);
if (x0 == 0 && y0 == 0 &&
x1 == pPixmap->drawable.width && y1 == pPixmap->drawable.height) {
@@ -388,8 +404,10 @@ ExaDoneSolid(PixmapPtr pPixmap)
if (!priv)
return;
-
+
+ exa_debug_printf("ExaDoneSolid\n");
xorg_composite_done(exa);
+ exa_debug_printf("ExaDoneSolid done\n");
}
/***********************************************************************
@@ -406,9 +424,7 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap);
-#if DEBUG_PRINT
- debug_printf("ExaPrepareCopy\n");
-#endif
+ exa_debug_printf("ExaPrepareCopy\n");
if (!exa->accel)
return FALSE;
@@ -488,10 +504,8 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
struct exa_context *exa = ms->exa;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
-#if DEBUG_PRINT
- debug_printf("\tExaCopy(srcx=%d, srcy=%d, dstX=%d, dstY=%d, w=%d, h=%d)\n",
+ exa_debug_printf("\tExaCopy(srcx=%d, srcy=%d, dstX=%d, dstY=%d, w=%d, h=%d)\n",
srcX, srcY, dstX, dstY, width, height);
-#endif
debug_assert(priv == exa->copy.dst);
(void) priv;
@@ -527,12 +541,16 @@ ExaDoneCopy(PixmapPtr pPixmap)
if (!priv)
return;
+ exa_debug_printf("ExaDoneCopy\n");
+
renderer_draw_flush(exa->renderer);
exa->copy.src = NULL;
exa->copy.dst = NULL;
pipe_surface_reference(&exa->copy.dst_surface, NULL);
pipe_resource_reference(&exa->copy.src_texture, NULL);
+
+ exa_debug_printf("ExaDoneCopy done\n");
}
@@ -584,19 +602,15 @@ ExaCheckComposite(int op,
ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
struct exa_context *exa = ms->exa;
-
-#if DEBUG_PRINT
- debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n",
- op, pSrcPicture, pMaskPicture, pDstPicture, accelerated);
-#endif
-
- if (!exa->accel)
- return FALSE;
-
- return xorg_composite_accelerated(op,
+ Bool accelerated = exa->accel && xorg_composite_accelerated(op,
pSrcPicture,
pMaskPicture,
pDstPicture);
+
+ exa_debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n",
+ op, pSrcPicture, pMaskPicture, pDstPicture, accelerated);
+
+ return accelerated;
}
@@ -613,14 +627,13 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
if (!exa->accel)
return FALSE;
-#if DEBUG_PRINT
- debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n",
+ exa_debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n",
op, pSrcPicture, pMaskPicture, pDstPicture);
- debug_printf("\tFormats: src(%s), mask(%s), dst(%s)\n",
+ exa_debug_printf("\tFormats: src(%s), mask(%s), dst(%s)\n",
pSrcPicture ? render_format_name(pSrcPicture->format) : "none",
pMaskPicture ? render_format_name(pMaskPicture->format) : "none",
pDstPicture ? render_format_name(pDstPicture->format) : "none");
-#endif
+
if (!exa->pipe)
XORG_FALLBACK("accel not enabled");
@@ -687,12 +700,10 @@ ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
struct exa_context *exa = ms->exa;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst);
-#if DEBUG_PRINT
- debug_printf("\tExaComposite(src[%d,%d], mask=[%d, %d], dst=[%d, %d], dim=[%d, %d])\n",
+ exa_debug_printf("\tExaComposite(src[%d,%d], mask=[%d, %d], dst=[%d, %d], dim=[%d, %d])\n",
srcX, srcY, maskX, maskY, dstX, dstY, width, height);
- debug_printf("\t Num bound samplers = %d\n",
+ exa_debug_printf("\t Num bound samplers = %d\n",
exa->num_bound_samplers);
-#endif
xorg_composite(exa, priv, srcX, srcY, maskX, maskY,
dstX, dstY, width, height);