summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c10
-rw-r--r--src/egl/wayland/wayland-drm/wayland-drm.c20
-rw-r--r--src/egl/wayland/wayland-drm/wayland-drm.h2
-rw-r--r--src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr.c11
-rw-r--r--src/gbm/backends/dri/gbm_dri.c5
-rw-r--r--src/gbm/backends/dri/gbm_driint.h2
6 files changed, 35 insertions, 15 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 04ab5649e52..18ecdc8df38 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1212,7 +1212,8 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
EGLint err;
int32_t plane;
- buffer = wayland_drm_buffer_get((struct wl_resource *) _buffer);
+ buffer = wayland_drm_buffer_get(dri2_dpy->wl_server_drm,
+ (struct wl_resource *) _buffer);
if (!buffer)
return NULL;
@@ -1852,6 +1853,10 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
if (!dri2_dpy->wl_server_drm)
return EGL_FALSE;
+ /* We have to share the wl_drm instance with gbm, so gbm can convert
+ * wl_buffers to gbm bos. */
+ dri2_dpy->gbm_dri->wl_drm = dri2_dpy->wl_server_drm;
+
return EGL_TRUE;
}
@@ -1877,10 +1882,11 @@ dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
struct wl_resource *buffer_resource,
EGLint attribute, EGLint *value)
{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct wl_drm_buffer *buffer;
const struct wl_drm_components_descriptor *format;
- buffer = wayland_drm_buffer_get(buffer_resource);
+ buffer = wayland_drm_buffer_get(dri2_dpy->wl_server_drm, buffer_resource);
if (!buffer)
return EGL_FALSE;
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c
index d317c5e1c46..7b614b71b5c 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -47,6 +47,8 @@ struct wl_drm {
uint32_t flags;
struct wayland_drm_callbacks *callbacks;
+
+ struct wl_buffer_interface buffer_interface;
};
static void
@@ -65,10 +67,6 @@ buffer_destroy(struct wl_client *client, struct wl_resource *resource)
wl_resource_destroy(resource);
}
-const static struct wl_buffer_interface drm_buffer_interface = {
- buffer_destroy
-};
-
static void
create_buffer(struct wl_client *client, struct wl_resource *resource,
uint32_t id, uint32_t name, int fd,
@@ -115,7 +113,7 @@ create_buffer(struct wl_client *client, struct wl_resource *resource,
}
wl_resource_set_implementation(buffer->resource,
- (void (**)(void)) &drm_buffer_interface,
+ (void (**)(void)) &drm->buffer_interface,
buffer, destroy_buffer);
}
@@ -243,15 +241,17 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
}
struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_resource *resource)
+wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
{
+ struct wl_drm_buffer *buffer;
+
if (resource == NULL)
return NULL;
- if (wl_resource_instance_of(resource, &wl_buffer_interface,
- &drm_buffer_interface))
+ if (wl_resource_instance_of(resource, &wl_buffer_interface,
+ &drm->buffer_interface))
return wl_resource_get_user_data(resource);
- else
+ else
return NULL;
}
@@ -270,6 +270,8 @@ wayland_drm_init(struct wl_display *display, char *device_name,
drm->user_data = user_data;
drm->flags = flags;
+ drm->buffer_interface.destroy = buffer_destroy;
+
wl_global_create(display, &wl_drm_interface, 2, drm, bind_drm);
return drm;
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.h b/src/egl/wayland/wayland-drm/wayland-drm.h
index ca0488285bc..7892d561f3c 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.h
+++ b/src/egl/wayland/wayland-drm/wayland-drm.h
@@ -92,7 +92,7 @@ struct wayland_drm_callbacks {
enum { WAYLAND_DRM_PRIME = 0x01 };
struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_resource *resource);
+wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
struct wl_drm *
wayland_drm_init(struct wl_display *display, char *device_name,
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 3fd5fa2dbda..f9acb2afd6a 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
@@ -139,7 +139,11 @@ static struct pipe_resource *
wayland_drm_bufmgr_wl_buffer_get_resource(struct native_display *ndpy,
struct wl_resource *buffer_resource)
{
- struct wl_drm_buffer *buffer = wayland_drm_buffer_get(buffer_resource);
+ struct wayland_drm_bufmgr *bufmgr;
+ struct wl_drm_buffer *buffer;
+
+ bufmgr = wayland_drm_bufmgr(ndpy->wayland_bufmgr);
+ buffer = wayland_drm_buffer_get(bufmgr->wl_server_drm, buffer_resource);
if (!buffer)
return NULL;
@@ -152,9 +156,12 @@ wayland_drm_bufmgr_query_buffer(struct native_display *ndpy,
struct wl_resource *buffer_resource,
int attribute, int *value)
{
- struct wl_drm_buffer *buffer = wayland_drm_buffer_get(buffer_resource);
+ struct wayland_drm_bufmgr *bufmgr;
+ struct wl_drm_buffer *buffer;
struct pipe_resource *resource;
+ bufmgr = wayland_drm_bufmgr(ndpy->wayland_bufmgr);
+ buffer = wayland_drm_buffer_get(bufmgr->wl_server_drm, buffer_resource);
if (!buffer)
return FALSE;
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index f7da79cac14..24ed2f1c6ab 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -376,7 +376,10 @@ gbm_dri_bo_import(struct gbm_device *gbm,
{
struct wl_drm_buffer *wb;
- wb = wayland_drm_buffer_get((struct wl_resource *) buffer);
+ if (!dri->wl_drm)
+ return NULL;
+
+ wb = wayland_drm_buffer_get(dri->wl_drm, (struct wl_resource *) buffer);
if (!wb)
return NULL;
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index 18fc3c0919e..90d764fb44f 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -66,6 +66,8 @@ struct gbm_dri_device {
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *data);
+
+ struct wl_drm *wl_drm;
};
struct gbm_dri_bo {