[packages/Mesa] Added Wayland 1.2 compatibility patches, release 22
wiget
wiget at pld-linux.org
Fri Sep 27 12:29:11 CEST 2013
commit 4469c4e7a5e9270740c23fd6ea36d1b064d46614
Author: Artur Frysiak <artur at frysiak.net>
Date: Fri Sep 27 12:22:09 2013 +0200
Added Wayland 1.2 compatibility patches, release 22
...-Simplify-native_wayland_drm_bufmgr_helpe.patch | 811 +++++++++++++++++++++
...-Don-t-add-a-listener-for-wl_drm-twice-in.patch | 29 +
0003-egl-Update-to-Wayland-1.2-server-API.patch | 518 +++++++++++++
...-Commit-the-rest-of-the-native_wayland_dr.patch | 76 ++
Mesa.spec | 10 +-
5 files changed, 1443 insertions(+), 1 deletion(-)
---
diff --git a/Mesa.spec b/Mesa.spec
index 41c2d16..6dcf152 100644
--- a/Mesa.spec
+++ b/Mesa.spec
@@ -33,12 +33,16 @@ Summary: Free OpenGL implementation
Summary(pl.UTF-8): Wolnodostępna implementacja standardu OpenGL
Name: Mesa
Version: 9.2.0
-Release: 1
+Release: 2
License: MIT (core) and others - see license.html file
Group: X11/Libraries
Source0: ftp://ftp.freedesktop.org/pub/mesa/9.2/%{name}Lib-%{version}.tar.bz2
# Source0-md5: 4185b6aae890bc62a964f4b24cc1aca8
Patch0: %{name}-link.patch
+Patch1: 0001-gallium-egl-Simplify-native_wayland_drm_bufmgr_helpe.patch
+Patch2: 0002-gallium-egl-Don-t-add-a-listener-for-wl_drm-twice-in.patch
+Patch3: 0003-egl-Update-to-Wayland-1.2-server-API.patch
+Patch4: 0004-gallium-egl-Commit-the-rest-of-the-native_wayland_dr.patch
URL: http://www.mesa3d.org/
BuildRequires: autoconf >= 2.60
BuildRequires: automake
@@ -980,6 +984,10 @@ Sterownik Mesa softpipe dla API vdpau.
%prep
%setup -q
%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
%build
%{__libtoolize}
diff --git a/0001-gallium-egl-Simplify-native_wayland_drm_bufmgr_helpe.patch b/0001-gallium-egl-Simplify-native_wayland_drm_bufmgr_helpe.patch
new file mode 100644
index 0000000..134c417
--- /dev/null
+++ b/0001-gallium-egl-Simplify-native_wayland_drm_bufmgr_helpe.patch
@@ -0,0 +1,811 @@
+From 6a973189d22ae1fef08e90ab6a8f6ee18ad4f33e Mon Sep 17 00:00:00 2001
+From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
+Date: Thu, 18 Jul 2013 15:11:23 +0300
+Subject: [PATCH 1/4] gallium-egl: Simplify native_wayland_drm_bufmgr_helper
+ interface
+
+The helper provides a series of functions to easy the implementation
+of the WL_bind_wayland_display extension on different platforms. But
+even with the helpers there was still a bit of duplicated code between
+platforms, with the drm authentication being the only part that
+differs.
+
+This patch changes the bufmgr interface to provide a self contained
+object with a create function that takes a drm authentication callback
+as an argument. That way all the helper functions are made static and
+the "_helper" suffix was removed from the sources file name.
+
+This change also removes the mix of Wayland client and server code in
+the wayland drm platform source file. All the uses of libwayland-server
+are now contained in native_wayland_drm_bufmgr.c.
+
+Changes to the drm platform are only compile tested.
+
+Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
+---
+ src/gallium/state_trackers/egl/Makefile.am | 2 +-
+ src/gallium/state_trackers/egl/common/native.h | 2 +-
+ .../egl/common/native_wayland_drm_bufmgr.c | 214 +++++++++++++++++++++
+ ...bufmgr_helper.h => native_wayland_drm_bufmgr.h} | 26 +--
+ .../egl/common/native_wayland_drm_bufmgr_helper.c | 106 ----------
+ src/gallium/state_trackers/egl/drm/native_drm.c | 52 +----
+ src/gallium/state_trackers/egl/drm/native_drm.h | 2 +-
+ .../state_trackers/egl/wayland/native_drm.c | 93 +++------
+ src/gallium/state_trackers/egl/x11/native_dri2.c | 87 +++------
+ 9 files changed, 276 insertions(+), 308 deletions(-)
+ create mode 100644 src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c
+ rename src/gallium/state_trackers/egl/common/{native_wayland_drm_bufmgr_helper.h => native_wayland_drm_bufmgr.h} (59%)
+ delete mode 100644 src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c
+
+diff --git a/src/gallium/state_trackers/egl/Makefile.am b/src/gallium/state_trackers/egl/Makefile.am
+index f78b36e..126fafc 100644
+--- a/src/gallium/state_trackers/egl/Makefile.am
++++ b/src/gallium/state_trackers/egl/Makefile.am
+@@ -38,7 +38,7 @@ libegl_la_SOURCES = \
+ common/egl_g3d_st.c \
+ common/egl_g3d_sync.c \
+ common/native_helper.c \
+- common/native_wayland_drm_bufmgr_helper.c
++ common/native_wayland_drm_bufmgr.c
+
+ if HAVE_EGL_PLATFORM_X11
+ libegl_la_SOURCES += \
+diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
+index 431bd3f..797933d 100644
+--- a/src/gallium/state_trackers/egl/common/native.h
++++ b/src/gallium/state_trackers/egl/common/native.h
+@@ -245,7 +245,7 @@ struct native_display {
+
+ const struct native_display_buffer *buffer;
+ const struct native_display_modeset *modeset;
+- const struct native_display_wayland_bufmgr *wayland_bufmgr;
++ struct native_display_wayland_bufmgr *wayland_bufmgr;
+ };
+
+ /**
+diff --git a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c
+new file mode 100644
+index 0000000..1603a3a
+--- /dev/null
++++ b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c
+@@ -0,0 +1,214 @@
++#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.h"
++
++#include "wayland-drm.h"
++
++struct wayland_drm_bufmgr {
++ struct native_display_wayland_bufmgr base;
++
++ struct wl_drm *wl_server_drm;
++ char *device_name;
++
++ void *user_data;
++
++ wayland_drm_bufmgr_authenticate_func authenticate;
++};
++
++static INLINE struct wayland_drm_bufmgr *
++wayland_drm_bufmgr(const struct native_display_wayland_bufmgr *base)
++{
++ return (struct wayland_drm_bufmgr *) base;
++}
++
++static int
++wayland_drm_bufmgr_authenticate(void *user_data, uint32_t magic)
++{
++ struct native_display *ndpy = user_data;
++ struct wayland_drm_bufmgr *bufmgr;
++
++ bufmgr = wayland_drm_bufmgr(ndpy->wayland_bufmgr);
++
++ return bufmgr->authenticate(user_data, magic);
++}
++
++static void
++wayland_drm_bufmgr_reference_buffer(void *user_data, uint32_t name, int fd,
++ struct wl_drm_buffer *buffer)
++{
++ struct native_display *ndpy = user_data;
++ struct pipe_resource templ;
++ struct winsys_handle wsh;
++ enum pipe_format pf;
++
++ switch (buffer->format) {
++ case WL_DRM_FORMAT_ARGB8888:
++ pf = PIPE_FORMAT_B8G8R8A8_UNORM;
++ break;
++ case WL_DRM_FORMAT_XRGB8888:
++ pf = PIPE_FORMAT_B8G8R8X8_UNORM;
++ break;
++ default:
++ pf = PIPE_FORMAT_NONE;
++ break;
++ }
++
++ if (pf == PIPE_FORMAT_NONE)
++ return;
++
++ memset(&templ, 0, sizeof(templ));
++ templ.target = PIPE_TEXTURE_2D;
++ templ.format = pf;
++ templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
++ templ.width0 = buffer->buffer.width;
++ templ.height0 = buffer->buffer.height;
++ templ.depth0 = 1;
++ templ.array_size = 1;
++
++ memset(&wsh, 0, sizeof(wsh));
++ wsh.handle = name;
++ wsh.stride = buffer->stride[0];
++
++ buffer->driver_buffer =
++ ndpy->screen->resource_from_handle(ndpy->screen, &templ, &wsh);
++}
++
++static void
++wayland_drm_bufmgr_unreference_buffer(void *user_data,
++ struct wl_drm_buffer *buffer)
++{
++ struct pipe_resource *resource = buffer->driver_buffer;
++
++ pipe_resource_reference(&resource, NULL);
++}
++
++static struct wayland_drm_callbacks wl_drm_callbacks = {
++ wayland_drm_bufmgr_authenticate,
++ wayland_drm_bufmgr_reference_buffer,
++ wayland_drm_bufmgr_unreference_buffer
++};
++
++static boolean
++wayland_drm_bufmgr_bind_display(struct native_display *ndpy,
++ struct wl_display *wl_dpy)
++{
++ struct wayland_drm_bufmgr *bufmgr;
++
++ bufmgr = wayland_drm_bufmgr(ndpy->wayland_bufmgr);
++
++ if (bufmgr->wl_server_drm)
++ return FALSE;
++
++ bufmgr->wl_server_drm = wayland_drm_init(wl_dpy, bufmgr->device_name,
++ &wl_drm_callbacks, ndpy, 0);
++
++ if (!bufmgr->wl_server_drm)
++ return FALSE;
++
++ return TRUE;
++}
++
++static boolean
++wayland_drm_bufmgr_unbind_display(struct native_display *ndpy,
++ struct wl_display *wl_dpy)
++{
++ struct wayland_drm_bufmgr *bufmgr;
++
++ bufmgr = wayland_drm_bufmgr(ndpy->wayland_bufmgr);
++
++ if (!bufmgr->wl_server_drm)
++ return FALSE;
++
++ wayland_drm_uninit(bufmgr->wl_server_drm);
++ bufmgr->wl_server_drm = NULL;
++
++ return TRUE;
++}
++
++static struct pipe_resource *
++wayland_drm_bufmgr_wl_buffer_get_resource(struct native_display *ndpy,
++ struct wl_buffer *buffer)
++{
++ return wayland_drm_buffer_get_buffer(buffer);
++}
++
++static EGLBoolean
++wayland_drm_bufmgr_query_buffer(struct native_display *ndpy,
++ struct wl_buffer *_buffer,
++ EGLint attribute, EGLint *value)
++{
++ struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) _buffer;
++ struct pipe_resource *resource = buffer->driver_buffer;
++
++ if (!wayland_buffer_is_drm(&buffer->buffer))
++ return EGL_FALSE;
++
++ switch (attribute) {
++ case EGL_TEXTURE_FORMAT:
++ switch (resource->format) {
++ case PIPE_FORMAT_B8G8R8A8_UNORM:
++ *value = EGL_TEXTURE_RGBA;
++ return EGL_TRUE;
++ case PIPE_FORMAT_B8G8R8X8_UNORM:
++ *value = EGL_TEXTURE_RGB;
++ return EGL_TRUE;
++ default:
++ return EGL_FALSE;
++ }
++ case EGL_WIDTH:
++ *value = buffer->buffer.width;
++ return EGL_TRUE;
++ case EGL_HEIGHT:
++ *value = buffer->buffer.height;
++ return EGL_TRUE;
++ default:
++ return EGL_FALSE;
++ }
++}
++
++
++struct native_display_wayland_bufmgr *
++wayland_drm_bufmgr_create(wayland_drm_bufmgr_authenticate_func authenticate,
++ void *user_data, char *device_name)
++{
++ struct wayland_drm_bufmgr *bufmgr;
++
++ bufmgr = calloc(1, sizeof *bufmgr);
++ if (!bufmgr)
++ return NULL;
++
++ bufmgr->user_data = user_data;
++ bufmgr->authenticate = authenticate;
++ bufmgr->device_name = strdup(device_name);
++
++ bufmgr->base.bind_display = wayland_drm_bufmgr_bind_display;
++ bufmgr->base.unbind_display = wayland_drm_bufmgr_unbind_display;
++ bufmgr->base.buffer_get_resource = wayland_drm_bufmgr_wl_buffer_get_resource;
++ bufmgr->base.query_buffer = wayland_drm_bufmgr_query_buffer;
++
++ return &bufmgr->base;
++}
++
++void
++wayland_drm_bufmgr_destroy(struct native_display_wayland_bufmgr *_bufmgr)
++{
++ struct wayland_drm_bufmgr *bufmgr = wayland_drm_bufmgr(_bufmgr);
++
++ if (!bufmgr)
++ return;
++
++ free(bufmgr->device_name);
++ free(bufmgr);
++}
++
++#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.h
+similarity index 59%
+rename from src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h
+rename to src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.h
+index 543dc6f..7bf6513 100644
+--- a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h
++++ b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.h
+@@ -22,26 +22,16 @@
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+-#ifndef _NATIVE_WAYLAND_DRM_BUFMGR_HELPER_H_
+-#define _NATIVE_WAYLAND_DRM_BUFMGR_HELPER_H_
++#ifndef _NATIVE_WAYLAND_DRM_BUFMGR_H_
++#define _NATIVE_WAYLAND_DRM_BUFMGR_H_
+
+-#include "wayland-drm.h"
++typedef int (*wayland_drm_bufmgr_authenticate_func)(void *, uint32_t);
+
+-void
+-egl_g3d_wl_drm_helper_reference_buffer(void *user_data, uint32_t name, int fd,
+- struct wl_drm_buffer *buffer);
++struct native_display_wayland_bufmgr *
++wayland_drm_bufmgr_create(wayland_drm_bufmgr_authenticate_func authenticate,
++ void *user_data, char *device_name);
+
+ void
+-egl_g3d_wl_drm_helper_unreference_buffer(void *user_data,
+- struct wl_drm_buffer *buffer);
+-
+-struct pipe_resource *
+-egl_g3d_wl_drm_common_wl_buffer_get_resource(struct native_display *ndpy,
+- struct wl_buffer *buffer);
+-
+-EGLBoolean
+-egl_g3d_wl_drm_common_query_buffer(struct native_display *ndpy,
+- struct wl_buffer *buffer,
+- EGLint attribute, EGLint *value);
++wayland_drm_bufmgr_destroy(struct native_display_wayland_bufmgr *bufmgr);
+
+-#endif /* _NATIVE_WAYLAND_DRM_BUFMGR_HELPER_H_ */
++#endif /* _NATIVE_WAYLAND_DRM_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
+deleted file mode 100644
+index a9e7342..0000000
+--- a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c
++++ /dev/null
+@@ -1,106 +0,0 @@
+-#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, int fd,
+- struct wl_drm_buffer *buffer)
+-{
+- struct native_display *ndpy = user_data;
+- struct pipe_resource templ;
+- struct winsys_handle wsh;
+- enum pipe_format pf;
+-
+- switch (buffer->format) {
+- case WL_DRM_FORMAT_ARGB8888:
+- pf = PIPE_FORMAT_B8G8R8A8_UNORM;
+- break;
+- case WL_DRM_FORMAT_XRGB8888:
+- pf = PIPE_FORMAT_B8G8R8X8_UNORM;
+- break;
+- default:
+- pf = PIPE_FORMAT_NONE;
+- break;
+- }
+-
+- if (pf == PIPE_FORMAT_NONE)
+- return;
+-
+- memset(&templ, 0, sizeof(templ));
+- templ.target = PIPE_TEXTURE_2D;
+- templ.format = pf;
+- templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+- templ.width0 = buffer->buffer.width;
+- templ.height0 = buffer->buffer.height;
+- templ.depth0 = 1;
+- templ.array_size = 1;
+-
+- memset(&wsh, 0, sizeof(wsh));
+- wsh.handle = name;
+- wsh.stride = buffer->stride[0];
+-
+- buffer->driver_buffer =
+- ndpy->screen->resource_from_handle(ndpy->screen, &templ, &wsh);
+-}
+-
+-void
+-egl_g3d_wl_drm_helper_unreference_buffer(void *user_data,
+- struct wl_drm_buffer *buffer)
+-{
+- struct pipe_resource *resource = buffer->driver_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);
+-}
+-
+-EGLBoolean
+-egl_g3d_wl_drm_common_query_buffer(struct native_display *ndpy,
+- struct wl_buffer *_buffer,
+- EGLint attribute, EGLint *value)
+-{
+- struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) _buffer;
+- struct pipe_resource *resource = buffer->driver_buffer;
+-
+- if (!wayland_buffer_is_drm(&buffer->buffer))
+- return EGL_FALSE;
+-
+- switch (attribute) {
+- case EGL_TEXTURE_FORMAT:
+- switch (resource->format) {
+- case PIPE_FORMAT_B8G8R8A8_UNORM:
+- *value = EGL_TEXTURE_RGBA;
+- return EGL_TRUE;
+- case PIPE_FORMAT_B8G8R8X8_UNORM:
+- *value = EGL_TEXTURE_RGB;
+- return EGL_TRUE;
+- default:
+- return EGL_FALSE;
+- }
+- case EGL_WIDTH:
+- *value = buffer->buffer.width;
+- return EGL_TRUE;
+- case EGL_HEIGHT:
+- *value = buffer->buffer.height;
+- return EGL_TRUE;
+- default:
+- return EGL_FALSE;
+- }
+-}
+-
+-#endif
+diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
+index 03bfdda..88ac490 100644
+--- a/src/gallium/state_trackers/egl/drm/native_drm.c
++++ b/src/gallium/state_trackers/egl/drm/native_drm.c
+@@ -132,6 +132,8 @@ drm_display_destroy(struct native_display *ndpy)
+
+ FREE(drmdpy->device_name);
+
++ wayland_drm_bufmgr_destroy(ndpy->wayland_bufmgr);
++
+ if (drmdpy->own_gbm) {
+ gbm_device_destroy(&drmdpy->gbmdrm->base.base);
+ if (drmdpy->fd >= 0)
+@@ -195,53 +197,6 @@ drm_display_authenticate(void *user_data, uint32_t magic)
+ return drmAuthMagic(drmdpy->fd, magic);
+ }
+
+-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, 0);
+-
+- 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,
+- egl_g3d_wl_drm_common_query_buffer
+-};
+-
+ #endif /* HAVE_WAYLAND_BACKEND */
+
+ static struct native_surface *
+@@ -293,7 +248,8 @@ drm_create_display(struct gbm_gallium_drm_device *gbmdrm, int own_gbm,
+ drmdpy->base.buffer = &drm_display_buffer;
+ #ifdef HAVE_WAYLAND_BACKEND
+ if (drmdpy->device_name)
+- drmdpy->base.wayland_bufmgr = &drm_display_wayland_bufmgr;
++ drmdpy->base.wayland_bufmgr = wayland_drm_bufmgr_create(
++ drm_display_authenticate, drmdpy, drmdpy->device_name);
+ #endif
+ drm_display_init_modeset(&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 16a4251..2c015b2 100644
+--- a/src/gallium/state_trackers/egl/drm/native_drm.h
++++ b/src/gallium/state_trackers/egl/drm/native_drm.h
+@@ -37,7 +37,7 @@
+ #include "common/native_helper.h"
+
+ #ifdef HAVE_WAYLAND_BACKEND
+-#include "common/native_wayland_drm_bufmgr_helper.h"
++#include "common/native_wayland_drm_bufmgr.h"
+ #endif
+
+ #include "gbm_gallium_drmint.h"
+diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c
+index fc8aac7..a4bcdd8 100644
+--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
++++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
+@@ -40,7 +40,7 @@
+ #include "wayland-drm-client-protocol.h"
+ #include "wayland-egl-priv.h"
+
+-#include "common/native_wayland_drm_bufmgr_helper.h"
++#include "common/native_wayland_drm_bufmgr.h"
+
+ #include <xf86drm.h>
+ #include <sys/types.h>
+@@ -53,7 +53,6 @@ struct wayland_drm_display {
+ const 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;
+@@ -77,6 +76,8 @@ wayland_drm_display_destroy(struct native_display *ndpy)
+ if (drmdpy->base.own_dpy)
+ wl_display_disconnect(drmdpy->base.dpy);
+
++ wayland_drm_bufmgr_destroy(ndpy->wayland_bufmgr);
++
+ ndpy_uninit(ndpy);
+
+ if (drmdpy->fd)
+@@ -195,6 +196,24 @@ static const struct wl_registry_listener registry_listener = {
+ registry_handle_global
+ };
+
++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);
++ wl_display_roundtrip(drmdpy->base.dpy);
++ authenticated = drmdpy->authenticated;
++
++ drmdpy->authenticated = current_authenticate;
++
++ return authenticated ? 0 : -1;
++}
++
+ static boolean
+ wayland_drm_display_init_screen(struct native_display *ndpy)
+ {
+@@ -226,6 +245,9 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
+ return FALSE;
+ }
+
++ drmdpy->base.base.wayland_bufmgr = wayland_drm_bufmgr_create(
++ wayland_drm_display_authenticate, drmdpy, drmdpy->device_name);
++
+ return TRUE;
+ }
+
+@@ -235,72 +257,6 @@ static struct native_display_buffer wayland_drm_display_buffer = {
+ drm_display_export_native_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);
+- wl_display_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, 0);
+-
+- 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,
+- egl_g3d_wl_drm_common_query_buffer
+-};
+-
+-
+ struct wayland_display *
+ wayland_create_drm_display(struct wl_display *dpy,
+ const struct native_event_handler *event_handler)
+@@ -322,7 +278,6 @@ wayland_create_drm_display(struct wl_display *dpy,
+ drmdpy->base.base.init_screen = wayland_drm_display_init_screen;
+ 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 053044a..3d08863 100644
+--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
++++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
+@@ -39,7 +39,7 @@
+
+ #include "common/native_helper.h"
+ #ifdef HAVE_WAYLAND_BACKEND
+-#include "common/native_wayland_drm_bufmgr_helper.h"
++#include "common/native_wayland_drm_bufmgr.h"
+ #endif
+
+ #ifdef GLX_DIRECT_RENDERING
+@@ -757,6 +757,8 @@ dri2_display_destroy(struct native_display *ndpy)
+ if (dri2dpy->surfaces)
+ util_hash_table_destroy(dri2dpy->surfaces);
+
++ wayland_drm_bufmgr_destroy(ndpy->wayland_bufmgr);
++
+ if (dri2dpy->xscr)
+ x11_screen_destroy(dri2dpy->xscr);
+ if (dri2dpy->own_dpy)
+@@ -785,6 +787,19 @@ dri2_display_invalidate_buffers(struct x11_screen *xscr, Drawable drawable,
+ &dri2surf->base, dri2surf->server_stamp);
+ }
+
++#ifdef HAVE_WAYLAND_BACKEND
++
++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);
++}
++
++#endif /* HAVE_WAYLAND_BACKEND */
++
+ /**
+ * Initialize DRI2 and pipe screen.
+ */
+@@ -816,6 +831,13 @@ dri2_display_init_screen(struct native_display *ndpy)
+ return FALSE;
+ }
+
++#ifdef HAVE_WAYLAND_BACKEND
++ dri2dpy->base.wayland_bufmgr = wayland_drm_bufmgr_create(
++ dri2_display_authenticate, dri2dpy,
++ x11_screen_get_device_name(dri2dpy->xscr));
++
++#endif
++
+ return TRUE;
+ }
+
+@@ -832,66 +854,6 @@ dri2_display_hash_table_compare(void *key1, void *key2)
+ return ((char *) key1 - (char *) key2);
+ }
+
+-#ifdef HAVE_WAYLAND_BACKEND
+-
+-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);
+-}
+-
+-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, 0);
+-
+- 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,
+- egl_g3d_wl_drm_common_query_buffer
+-};
+-
+-#endif /* HAVE_WAYLAND_BACKEND */
+-
+ struct native_display *
+ x11_create_dri2_display(Display *dpy,
+ const struct native_event_handler *event_handler)
+@@ -936,9 +898,6 @@ x11_create_dri2_display(Display *dpy,
+ dri2dpy->base.copy_to_pixmap = native_display_copy_to_pixmap;
+ 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;
+ }
+--
+1.8.4
+
diff --git a/0002-gallium-egl-Don-t-add-a-listener-for-wl_drm-twice-in.patch b/0002-gallium-egl-Don-t-add-a-listener-for-wl_drm-twice-in.patch
new file mode 100644
index 0000000..cca850a
--- /dev/null
+++ b/0002-gallium-egl-Don-t-add-a-listener-for-wl_drm-twice-in.patch
@@ -0,0 +1,29 @@
+From 38e128d799217a08ea12ddf75a6a7ed440384b5f Mon Sep 17 00:00:00 2001
+From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
+Date: Thu, 18 Jul 2013 15:11:24 +0300
+Subject: [PATCH 2/4] gallium-egl: Don't add a listener for wl_drm twice in
+ wayland platform
+
+A listener is added just after the interface is bound, in
+registry_handle_global().
+
+Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
+---
+ src/gallium/state_trackers/egl/wayland/native_drm.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c
+index a4bcdd8..e1aeeeb 100644
+--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
++++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
+@@ -227,7 +227,6 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
+ if (wayland_roundtrip(&drmdpy->base) < 0 || drmdpy->wl_drm == NULL)
+ return FALSE;
+
+- wl_drm_add_listener(drmdpy->wl_drm, &drm_listener, drmdpy);
+ if (wayland_roundtrip(&drmdpy->base) < 0 || drmdpy->fd == -1)
+ return FALSE;
+
+--
+1.8.4
+
diff --git a/0003-egl-Update-to-Wayland-1.2-server-API.patch b/0003-egl-Update-to-Wayland-1.2-server-API.patch
new file mode 100644
index 0000000..5d768dd
--- /dev/null
+++ b/0003-egl-Update-to-Wayland-1.2-server-API.patch
@@ -0,0 +1,518 @@
+From 29c760d8bb6338679abaf8a30549341bd181cc51 Mon Sep 17 00:00:00 2001
+From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
+Date: Thu, 18 Jul 2013 15:11:25 +0300
+Subject: [PATCH 3/4] egl: Update to Wayland 1.2 server API
+
+Since Wayland 1.2, struct wl_buffer and a few functions are deprecated.
+
+References to wl_buffer are replaced with wl_resource and some getter
+functions and calls to deprecated functions are replaced with the proper
+new API. The latter changes are related to resource versioning.
+
+Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
+---
+ docs/specs/WL_bind_wayland_display.spec | 8 ++-
+ include/EGL/eglmesaext.h | 6 +-
+ src/egl/drivers/dri2/egl_dri2.c | 28 +++++----
+ src/egl/drivers/dri2/egl_dri2.h | 1 -
+ src/egl/main/eglapi.c | 2 +-
+ src/egl/main/eglapi.h | 2 +-
+ src/egl/wayland/wayland-drm/wayland-drm.c | 66 +++++++++++++---------
+ src/egl/wayland/wayland-drm/wayland-drm.h | 13 +++--
+ .../state_trackers/egl/common/egl_g3d_api.c | 2 +-
+ .../state_trackers/egl/common/egl_g3d_image.c | 4 +-
+ .../egl/common/native_wayland_bufmgr.h | 6 +-
+ .../egl/common/native_wayland_drm_bufmgr.c | 25 +++++---
+ src/gbm/backends/dri/gbm_dri.c | 5 +-
+ 13 files changed, 99 insertions(+), 69 deletions(-)
+
+diff --git a/docs/specs/WL_bind_wayland_display.spec b/docs/specs/WL_bind_wayland_display.spec
+index 02bd6ea..8f0083c 100644
+--- a/docs/specs/WL_bind_wayland_display.spec
++++ b/docs/specs/WL_bind_wayland_display.spec
+@@ -17,7 +17,7 @@ Status
+
+ Version
+
+- Version 1, March 1, 2011
++ Version 5, July 16, 2013
+
+ Number
+
+@@ -57,7 +57,7 @@ New Procedures and Functions
+ struct wl_display *display);
+
+ EGLBoolean eglQueryWaylandBufferWL(EGLDisplay dpy,
+- struct wl_buffer *buffer,
++ struct wl_resource *buffer,
+ EGLint attribute, EGLint *value);
+
+ New Tokens
+@@ -173,3 +173,7 @@ Revision History
+ Use EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, and EGL_TEXTURE_RGBA,
+ and just define the new YUV texture formats. Add support for
+ EGL_WIDTH and EGL_HEIGHT in the query attributes (Kristian Høgsberg)
++ Version 5, July 16, 2013
++ Change eglQueryWaylandBufferWL to take a resource pointer to the
++ buffer instead of a pointer to a struct wl_buffer, as the latter has
++ been deprecated. (Ander Conselvan de Oliveira)
+diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
+index d476d18..e0eae28 100644
+--- a/include/EGL/eglmesaext.h
++++ b/include/EGL/eglmesaext.h
+@@ -120,15 +120,15 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) (int fd);
+ #define EGL_TEXTURE_Y_XUXV_WL 0x31D9
+
+ struct wl_display;
+-struct wl_buffer;
++struct wl_resource;
+ #ifdef EGL_EGLEXT_PROTOTYPES
+ EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display);
+ EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display);
+-EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_buffer *buffer, EGLint attribute, EGLint *value);
++EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value);
+ #endif
+ typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display);
+ typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display);
+-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, struct wl_buffer *buffer, EGLint attribute, EGLint *value);
++typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value);
+
+ #endif
+
+diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
+index 52fcb3f..bdbb450 100644
+--- a/src/egl/drivers/dri2/egl_dri2.c
++++ b/src/egl/drivers/dri2/egl_dri2.c
+@@ -41,6 +41,10 @@
+
+ #include "egl_dri2.h"
+
++#ifdef HAVE_WAYLAND_PLATFORM
++#include "wayland-drm.h"
++#endif
++
+ const __DRIuseInvalidateExtension use_invalidate = {
+ { __DRI_USE_INVALIDATE, 1 }
+ };
+@@ -1195,7 +1199,7 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
+ EGLClientBuffer _buffer,
+ const EGLint *attr_list)
+ {
+- struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) _buffer;
++ struct wl_drm_buffer *buffer;
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ const struct wl_drm_components_descriptor *f;
+ __DRIimage *dri_image;
+@@ -1203,7 +1207,8 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
+ EGLint err;
+ int32_t plane;
+
+- if (!wayland_buffer_is_drm(&buffer->buffer))
++ buffer = wayland_drm_buffer_get((struct wl_resource *) _buffer);
++ if (!buffer)
+ return NULL;
+
+ err = _eglParseImageAttribList(&attrs, disp, attr_list);
+@@ -1508,8 +1513,8 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name, int fd,
+
+ if (fd == -1)
+ img = dri2_dpy->image->createImageFromNames(dri2_dpy->dri_screen,
+- buffer->buffer.width,
+- buffer->buffer.height,
++ buffer->width,
++ buffer->height,
+ buffer->format,
+ (int*)&name, 1,
+ buffer->stride,
+@@ -1517,8 +1522,8 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name, int fd,
+ NULL);
+ else
+ img = dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen,
+- buffer->buffer.width,
+- buffer->buffer.height,
++ buffer->width,
++ buffer->height,
+ buffer->format,
+ &fd, 1,
+ buffer->stride,
+@@ -1607,13 +1612,14 @@ dri2_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
+
+ static EGLBoolean
+ dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
+- struct wl_buffer *_buffer,
++ struct wl_resource *buffer_resource,
+ EGLint attribute, EGLint *value)
+ {
+- struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) _buffer;
++ struct wl_drm_buffer *buffer;
+ const struct wl_drm_components_descriptor *format;
+
+- if (!wayland_buffer_is_drm(&buffer->buffer))
++ buffer = wayland_drm_buffer_get(buffer_resource);
++ if (!buffer)
+ return EGL_FALSE;
+
+ format = buffer->driver_format;
+@@ -1622,10 +1628,10 @@ dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
+ *value = format->components;
+ return EGL_TRUE;
+ case EGL_WIDTH:
+- *value = buffer->buffer.width;
++ *value = buffer->width;
+ return EGL_TRUE;
+ case EGL_HEIGHT:
+- *value = buffer->buffer.height;
++ *value = buffer->height;
+ return EGL_TRUE;
+ }
+
+diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
+index 6dfdf94..fba5f81 100644
+--- a/src/egl/drivers/dri2/egl_dri2.h
++++ b/src/egl/drivers/dri2/egl_dri2.h
+@@ -37,7 +37,6 @@
+
+ #ifdef HAVE_WAYLAND_PLATFORM
+ #include <wayland-client.h>
+-#include "wayland-drm.h"
+ #include "wayland-egl-priv.h"
+ #endif
+
+diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
+index 4a9831b..a788295 100644
+--- a/src/egl/main/eglapi.c
++++ b/src/egl/main/eglapi.c
+@@ -1571,7 +1571,7 @@ eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display)
+ }
+
+ EGLBoolean EGLAPIENTRY
+-eglQueryWaylandBufferWL(EGLDisplay dpy,struct wl_buffer *buffer,
++eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer,
+ EGLint attribute, EGLint *value)
+ {
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
+index ee382d0..4a4f976 100644
+--- a/src/egl/main/eglapi.h
++++ b/src/egl/main/eglapi.h
+@@ -123,7 +123,7 @@ typedef EGLBoolean (*ExportDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _
+ struct wl_display;
+ typedef EGLBoolean (*BindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display);
+ typedef EGLBoolean (*UnbindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display);
+-typedef EGLBoolean (*QueryWaylandBufferWL_t)(_EGLDriver *drv, _EGLDisplay *displ, struct wl_buffer *buffer, EGLint attribute, EGLint *value);
++typedef EGLBoolean (*QueryWaylandBufferWL_t)(_EGLDriver *drv, _EGLDisplay *displ, struct wl_resource *buffer, EGLint attribute, EGLint *value);
+ #endif
+
+ typedef EGLBoolean (*PostSubBufferNV_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, EGLint x, EGLint y, EGLint width, EGLint height);
+diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c
+index 7e2073a..d317c5e 100644
+--- a/src/egl/wayland/wayland-drm/wayland-drm.c
++++ b/src/egl/wayland/wayland-drm/wayland-drm.c
+@@ -37,6 +37,8 @@
+ #include "wayland-drm.h"
+ #include "wayland-drm-server-protocol.h"
+
++#define MIN(x,y) (((x)<(y))?(x):(y))
++
+ struct wl_drm {
+ struct wl_display *display;
+
+@@ -86,8 +88,8 @@ create_buffer(struct wl_client *client, struct wl_resource *resource,
+ }
+
+ buffer->drm = drm;
+- buffer->buffer.width = width;
+- buffer->buffer.height = height;
++ buffer->width = width;
++ buffer->height = height;
+ buffer->format = format;
+ buffer->offset[0] = offset0;
+ buffer->stride[0] = stride0;
+@@ -104,16 +106,17 @@ create_buffer(struct wl_client *client, struct wl_resource *resource,
+ return;
+ }
+
+- buffer->buffer.resource.object.id = id;
+- buffer->buffer.resource.object.interface = &wl_buffer_interface;
+- buffer->buffer.resource.object.implementation =
+- (void (**)(void)) &drm_buffer_interface;
+- buffer->buffer.resource.data = buffer;
+-
+- buffer->buffer.resource.destroy = destroy_buffer;
+- buffer->buffer.resource.client = resource->client;
++ buffer->resource =
++ wl_resource_create(client, &wl_buffer_interface, 1, id);
++ if (!buffer->resource) {
++ wl_resource_post_no_memory(resource);
++ free(buffer);
++ return;
++ }
+
+- wl_client_add_resource(resource->client, &buffer->buffer.resource);
++ wl_resource_set_implementation(buffer->resource,
++ (void (**)(void)) &drm_buffer_interface,
++ buffer, destroy_buffer);
+ }
+
+ static void
+@@ -208,8 +211,15 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+ struct wl_resource *resource;
+ uint32_t capabilities;
+
+- resource = wl_client_add_object(client, &wl_drm_interface,
+- &drm_interface, id, data);
++ resource = wl_resource_create(client, &wl_drm_interface,
++ MIN(version, 2), id);
++ if (!resource) {
++ wl_client_post_no_memory(client);
++ return;
++ }
++
++ wl_resource_set_implementation(resource, &drm_interface, data, NULL);
++
+ wl_resource_post_event(resource, WL_DRM_DEVICE, drm->device_name);
+ wl_resource_post_event(resource, WL_DRM_FORMAT,
+ WL_DRM_FORMAT_ARGB8888);
+@@ -232,6 +242,19 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+ wl_resource_post_event(resource, WL_DRM_CAPABILITIES, capabilities);
+ }
+
++struct wl_drm_buffer *
++wayland_drm_buffer_get(struct wl_resource *resource)
++{
++ if (resource == NULL)
++ return NULL;
++
++ if (wl_resource_instance_of(resource, &wl_buffer_interface,
++ &drm_buffer_interface))
++ return wl_resource_get_user_data(resource);
++ else
++ return NULL;
++}
++
+ struct wl_drm *
+ wayland_drm_init(struct wl_display *display, char *device_name,
+ struct wayland_drm_callbacks *callbacks, void *user_data,
+@@ -247,7 +270,7 @@ wayland_drm_init(struct wl_display *display, char *device_name,
+ drm->user_data = user_data;
+ drm->flags = flags;
+
+- wl_display_add_global(display, &wl_drm_interface, drm, bind_drm);
++ wl_global_create(display, &wl_drm_interface, 2, drm, bind_drm);
+
+ return drm;
+ }
+@@ -262,25 +285,14 @@ wayland_drm_uninit(struct wl_drm *drm)
+ free(drm);
+ }
+
+-int
+-wayland_buffer_is_drm(struct wl_buffer *buffer)
+-{
+- return buffer->resource.object.implementation ==
+- (void (**)(void)) &drm_buffer_interface;
+-}
+-
+ uint32_t
+-wayland_drm_buffer_get_format(struct wl_buffer *buffer_base)
++wayland_drm_buffer_get_format(struct wl_drm_buffer *buffer)
+ {
+- struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) buffer_base;
+-
+ return buffer->format;
+ }
+
+ void *
+-wayland_drm_buffer_get_buffer(struct wl_buffer *buffer_base)
++wayland_drm_buffer_get_buffer(struct wl_drm_buffer *buffer)
+ {
+- struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) buffer_base;
+-
+ return buffer->driver_buffer;
+ }
+diff --git a/src/egl/wayland/wayland-drm/wayland-drm.h b/src/egl/wayland/wayland-drm/wayland-drm.h
+index 335073a..ca04882 100644
+--- a/src/egl/wayland/wayland-drm/wayland-drm.h
++++ b/src/egl/wayland/wayland-drm/wayland-drm.h
+@@ -70,8 +70,9 @@ enum wl_drm_format {
+ struct wl_drm;
+
+ struct wl_drm_buffer {
+- struct wl_buffer buffer;
++ struct wl_resource *resource;
+ struct wl_drm *drm;
++ int32_t width, height;
+ uint32_t format;
+ const void *driver_format;
+ int32_t offset[3];
+@@ -90,6 +91,9 @@ struct wayland_drm_callbacks {
+
+ enum { WAYLAND_DRM_PRIME = 0x01 };
+
++struct wl_drm_buffer *
++wayland_drm_buffer_get(struct wl_resource *resource);
++
+ struct wl_drm *
+ wayland_drm_init(struct wl_display *display, char *device_name,
+ struct wayland_drm_callbacks *callbacks, void *user_data,
+@@ -98,13 +102,10 @@ wayland_drm_init(struct wl_display *display, char *device_name,
+ void
+ wayland_drm_uninit(struct wl_drm *drm);
+
+-int
+-wayland_buffer_is_drm(struct wl_buffer *buffer);
+-
+ uint32_t
+-wayland_drm_buffer_get_format(struct wl_buffer *buffer_base);
++wayland_drm_buffer_get_format(struct wl_drm_buffer *buffer);
+
+ void *
+-wayland_drm_buffer_get_buffer(struct wl_buffer *buffer);
++wayland_drm_buffer_get_buffer(struct wl_drm_buffer *buffer);
+
+ #endif
+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 59187a9..46a3245 100644
+--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
++++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+@@ -874,7 +874,7 @@ egl_g3d_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *dpy,
+
+ static EGLBoolean
+ egl_g3d_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *dpy,
+- struct wl_buffer *buffer,
++ struct wl_resource *buffer,
+ EGLint attribute, EGLint *value)
+ {
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+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 aa1980b..c459dc3 100644
+--- a/src/gallium/state_trackers/egl/common/egl_g3d_image.c
++++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
+@@ -183,7 +183,7 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
+ #ifdef EGL_WL_bind_wayland_display
+
+ static struct pipe_resource *
+-egl_g3d_reference_wl_buffer(_EGLDisplay *dpy, struct wl_buffer *buffer,
++egl_g3d_reference_wl_buffer(_EGLDisplay *dpy, struct wl_resource *buffer,
+ _EGLImage *img, const EGLint *attribs)
+ {
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+@@ -253,7 +253,7 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
+ #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);
++ (struct wl_resource *) buffer, &gimg->base, attribs);
+ break;
+ #endif
+ #ifdef EGL_ANDROID_image_native_buffer
+diff --git a/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h b/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h
+index dd27828..eb324bf 100644
+--- a/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h
++++ b/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h
+@@ -27,7 +27,7 @@
+
+ struct native_display;
+ struct wl_display;
+-struct wl_buffer;
++struct wl_resource;
+ struct pipe_resource;
+
+ struct native_display_wayland_bufmgr {
+@@ -38,11 +38,11 @@ struct native_display_wayland_bufmgr {
+ struct wl_display *wl_dpy);
+
+ struct pipe_resource *(*buffer_get_resource)(struct native_display *ndpy,
+- struct wl_buffer *buffer);
++ struct wl_resource *buffer);
+
+
+ boolean (*query_buffer)(struct native_display *ndpy,
+- struct wl_buffer *buffer,
++ struct wl_resource *buffer,
+ int attribute, int *value);
+ };
+
+diff --git a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c
+index 1603a3a..9b69cb9 100644
+--- a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c
++++ b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c
+@@ -70,8 +70,8 @@ wayland_drm_bufmgr_reference_buffer(void *user_data, uint32_t name, int fd,
+ templ.target = PIPE_TEXTURE_2D;
+ templ.format = pf;
+ templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+- templ.width0 = buffer->buffer.width;
+- templ.height0 = buffer->buffer.height;
++ templ.width0 = buffer->width;
++ templ.height0 = buffer->height;
+ templ.depth0 = 1;
+ templ.array_size = 1;
+
+@@ -137,22 +137,29 @@ wayland_drm_bufmgr_unbind_display(struct native_display *ndpy,
+
+ static struct pipe_resource *
+ wayland_drm_bufmgr_wl_buffer_get_resource(struct native_display *ndpy,
+- struct wl_buffer *buffer)
++ struct wl_resource *buffer_resource)
+ {
++ struct wl_drm_buffer *buffer = wayland_drm_buffer_get(buffer_resource);
++
++ if (!buffer)
++ return NULL;
++
+ return wayland_drm_buffer_get_buffer(buffer);
+ }
+
+ static EGLBoolean
+ wayland_drm_bufmgr_query_buffer(struct native_display *ndpy,
+- struct wl_buffer *_buffer,
++ struct wl_resource *buffer_resource,
+ EGLint attribute, EGLint *value)
+ {
+- struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) _buffer;
+- struct pipe_resource *resource = buffer->driver_buffer;
++ struct wl_drm_buffer *buffer = wayland_drm_buffer_get(buffer_resource);
++ struct pipe_resource *resource;
+
+- if (!wayland_buffer_is_drm(&buffer->buffer))
++ if (!buffer)
+ return EGL_FALSE;
+
++ resource = buffer->driver_buffer;
++
+ switch (attribute) {
+ case EGL_TEXTURE_FORMAT:
+ switch (resource->format) {
+@@ -166,10 +173,10 @@ wayland_drm_bufmgr_query_buffer(struct native_display *ndpy,
+ return EGL_FALSE;
+ }
+ case EGL_WIDTH:
+- *value = buffer->buffer.width;
++ *value = buffer->width;
+ return EGL_TRUE;
+ case EGL_HEIGHT:
+- *value = buffer->buffer.height;
++ *value = buffer->height;
+ return EGL_TRUE;
+ default:
+ return EGL_FALSE;
+diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
+index a3a0530..f7da79c 100644
+--- a/src/gbm/backends/dri/gbm_dri.c
++++ b/src/gbm/backends/dri/gbm_dri.c
+@@ -374,9 +374,10 @@ gbm_dri_bo_import(struct gbm_device *gbm,
+ #if HAVE_WAYLAND_PLATFORM
+ case GBM_BO_IMPORT_WL_BUFFER:
+ {
+- struct wl_drm_buffer *wb = (struct wl_drm_buffer *) buffer;
++ struct wl_drm_buffer *wb;
+
+- if (!wayland_buffer_is_drm(buffer))
++ wb = wayland_drm_buffer_get((struct wl_resource *) buffer);
++ if (!wb)
+ return NULL;
+
+ image = wb->driver_buffer;
+--
+1.8.4
+
diff --git a/0004-gallium-egl-Commit-the-rest-of-the-native_wayland_dr.patch b/0004-gallium-egl-Commit-the-rest-of-the-native_wayland_dr.patch
new file mode 100644
index 0000000..d4da213
--- /dev/null
+++ b/0004-gallium-egl-Commit-the-rest-of-the-native_wayland_dr.patch
@@ -0,0 +1,76 @@
+From c5279d643b528690243803c923fd3ff74b1b9dd5 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= <krh at bitplanet.net>
+Date: Wed, 7 Aug 2013 11:19:59 -0700
+Subject: [PATCH 4/4] gallium-egl: Commit the rest of the
+ native_wayland_drm_bufmgr_helper v2 patch
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+I missed Anders v2 on the list which fixed non-wayland compilation:
+
+http://lists.freedesktop.org/archives/mesa-dev/2013-July/042062.html
+
+Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
+---
+ src/gallium/state_trackers/egl/drm/native_drm.c | 2 ++
+ src/gallium/state_trackers/egl/drm/native_drm.h | 4 ----
+ src/gallium/state_trackers/egl/x11/native_dri2.c | 5 ++---
+ 3 files changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
+index 88ac490..c82bbe4 100644
+--- a/src/gallium/state_trackers/egl/drm/native_drm.c
++++ b/src/gallium/state_trackers/egl/drm/native_drm.c
+@@ -132,7 +132,9 @@ drm_display_destroy(struct native_display *ndpy)
+
+ FREE(drmdpy->device_name);
+
++#ifdef HAVE_WAYLAND_BACKEND
+ wayland_drm_bufmgr_destroy(ndpy->wayland_bufmgr);
++#endif
+
+ if (drmdpy->own_gbm) {
+ gbm_device_destroy(&drmdpy->gbmdrm->base.base);
+diff --git a/src/gallium/state_trackers/egl/drm/native_drm.h b/src/gallium/state_trackers/egl/drm/native_drm.h
+index 2c015b2..6a1cd5d 100644
+--- a/src/gallium/state_trackers/egl/drm/native_drm.h
++++ b/src/gallium/state_trackers/egl/drm/native_drm.h
+@@ -67,10 +67,6 @@ 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/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
+index 3d08863..3aa7c17 100644
+--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
++++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
+@@ -60,9 +60,6 @@ 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 {
+@@ -757,7 +754,9 @@ dri2_display_destroy(struct native_display *ndpy)
+ if (dri2dpy->surfaces)
+ util_hash_table_destroy(dri2dpy->surfaces);
+
++#ifdef HAVE_WAYLAND_BACKEND
+ wayland_drm_bufmgr_destroy(ndpy->wayland_bufmgr);
++#endif
+
+ if (dri2dpy->xscr)
+ x11_screen_destroy(dri2dpy->xscr);
+--
+1.8.4
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/Mesa.git/commitdiff/4469c4e7a5e9270740c23fd6ea36d1b064d46614
More information about the pld-cvs-commit
mailing list