debian/changelog | 7 debian/patches/egl-platform-mir.patch | 1027 ---------------------------------- 2 files changed, 35 insertions(+), 999 deletions(-)
New commits: commit f779852d44bc2a151afa9c380ef0a65603dda6af Author: Maarten Lankhorst <maarten.lankho...@canonical.com> Date: Wed Feb 12 14:43:02 2014 +0100 add changelog entry diff --git a/debian/changelog b/debian/changelog index c732663..bc14cca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +mesa (10.1.0~rc1-1ubuntu1) UNRELEASED; urgency=low + + * First mesa 10.1 release candidate. + * Refresh egl-platform-mir.patch and drop upstreamed bits. + + -- Maarten Lankhorst <maarten.lankho...@ubuntu.com> Wed, 12 Feb 2014 14:42:42 +0100 + mesa (10.1.0~rc1-1) experimental; urgency=low * New upstream release. commit 24233eadced0de9d8a828f802c8e29ffc804f024 Author: Maarten Lankhorst <maarten.lankho...@canonical.com> Date: Wed Feb 12 13:46:56 2014 +0100 refresh egl-platform-mir patch diff --git a/debian/patches/egl-platform-mir.patch b/debian/patches/egl-platform-mir.patch index 8a7617b..5369db8 100644 --- a/debian/patches/egl-platform-mir.patch +++ b/debian/patches/egl-platform-mir.patch @@ -1,6 +1,6 @@ --- a/configure.ac +++ b/configure.ac -@@ -1428,7 +1428,9 @@ +@@ -1468,7 +1468,9 @@ android|fbdev|gdi|null) ;; @@ -11,7 +11,7 @@ *) AC_MSG_ERROR([EGL platform '$plat' does not exist]) ;; -@@ -1457,6 +1459,7 @@ +@@ -1497,6 +1499,7 @@ AM_CONDITIONAL(HAVE_EGL_PLATFORM_DRM, echo "$egl_platforms" | grep 'drm' >/dev/null 2>&1) AM_CONDITIONAL(HAVE_EGL_PLATFORM_FBDEV, echo "$egl_platforms" | grep 'fbdev' >/dev/null 2>&1) AM_CONDITIONAL(HAVE_EGL_PLATFORM_NULL, echo "$egl_platforms" | grep 'null' >/dev/null 2>&1) @@ -37,7 +37,7 @@ #ifdef MESA_EGL_NO_X11_HEADERS --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h -@@ -819,10 +819,12 @@ +@@ -826,10 +826,12 @@ unsigned int pitch; unsigned int cpp; unsigned int flags; @@ -53,7 +53,7 @@ --- a/src/egl/drivers/dri2/Makefile.am +++ b/src/egl/drivers/dri2/Makefile.am -@@ -63,3 +63,9 @@ +@@ -64,3 +64,9 @@ libegl_dri2_la_SOURCES += platform_drm.c AM_CFLAGS += -DHAVE_DRM_PLATFORM endif @@ -65,7 +65,7 @@ +endif --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c -@@ -632,6 +632,12 @@ +@@ -639,6 +639,12 @@ return EGL_TRUE; return dri2_initialize_wayland(drv, disp); #endif @@ -103,7 +103,7 @@ int (*authenticate) (_EGLDisplay *disp, uint32_t id); }; -@@ -183,7 +192,9 @@ +@@ -182,7 +191,9 @@ struct gbm_dri_surface *gbm_surf; #endif @@ -114,7 +114,7 @@ __DRIbuffer *dri_buffers[__DRI_BUFFER_COUNT]; struct { #ifdef HAVE_WAYLAND_PLATFORM -@@ -205,6 +216,10 @@ +@@ -204,6 +215,10 @@ /* EGL-owned buffers */ __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT]; #endif @@ -125,19 +125,17 @@ }; -@@ -266,6 +281,9 @@ +@@ -271,4 +286,7 @@ EGLBoolean dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp); +EGLBoolean +dri2_initialize_mir(_EGLDriver *drv, _EGLDisplay *disp); + - char * - dri2_get_driver_for_fd(int fd); - char * + #endif /* EGL_DRI2_INCLUDED */ --- /dev/null +++ b/src/egl/drivers/dri2/platform_mir.c -@@ -0,0 +1,435 @@ +@@ -0,0 +1,436 @@ +/* + * Copyright © 2012 Canonical, Inc + * @@ -168,6 +166,7 @@ +#include <mir_toolkit/mesa/native_display.h> + +#include "egl_dri2.h" ++#include "loader.h" + +#include <stdlib.h> +#include <string.h> @@ -344,7 +343,7 @@ + struct gbm_dri_surface *surf = malloc(sizeof *surf); + + dri2_surf->gbm_surf = surf; -+ surf->base.gbm = &dri2_dpy->gbm_dri->base; ++ surf->base.gbm = &dri2_dpy->gbm_dri->base.base; + surf->base.width = dri2_surf->base.Width; + surf->base.height = dri2_surf->base.Height; + surf->base.format = GBM_FORMAT_ARGB8888; @@ -516,7 +515,7 @@ + dri2_dpy->mir_disp = disp->PlatformDisplay; + dri2_dpy->mir_disp->display_get_platform(dri2_dpy->mir_disp, &platform); + dri2_dpy->fd = platform.fd[0]; -+ dri2_dpy->device_name = dri2_get_device_name_for_fd(dri2_dpy->fd); ++ dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd); + + /* + * At the moment, a pointer to gbm_device is the first and only @@ -700,7 +699,7 @@ + _EGLDriver *Driver[_EGL_NUM_PLATFORMS]; } _EGLModule; - static _EGL_DECLARE_MUTEX(_eglModuleMutex); + static _EGLMutex _eglModuleMutex = _EGL_MUTEX_INITIALIZER; @@ -134,7 +134,6 @@ #endif @@ -831,16 +830,7 @@ --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c -@@ -44,6 +44,8 @@ - #include "gbm_driint.h" - - #include "gbmint.h" -+#include <xf86drm.h> -+ - - /* For importing wl_buffer */ - #if HAVE_WAYLAND_PLATFORM -@@ -132,7 +134,7 @@ +@@ -133,7 +133,7 @@ }; static const __DRIdri2LoaderExtension dri2_loader_extension = { @@ -849,7 +839,7 @@ dri_get_buffers, dri_flush_front_buffer, dri_get_buffers_with_format, -@@ -327,9 +329,11 @@ +@@ -329,9 +329,11 @@ switch (format) { case GBM_BO_FORMAT_XRGB8888: case GBM_FORMAT_XRGB8888: @@ -861,7 +851,7 @@ if (usage & GBM_BO_USE_SCANOUT) return 0; break; -@@ -394,6 +398,9 @@ +@@ -396,6 +398,9 @@ case __DRI_IMAGE_FORMAT_ABGR8888: ret = GBM_FORMAT_ABGR8888; break; @@ -871,7 +861,7 @@ default: ret = 0; break; -@@ -402,6 +409,41 @@ +@@ -404,6 +409,41 @@ return ret; } @@ -913,7 +903,7 @@ static struct gbm_bo * gbm_dri_bo_import(struct gbm_device *gbm, uint32_t type, void *buffer, uint32_t usage) -@@ -585,30 +627,7 @@ +@@ -587,30 +627,7 @@ bo->base.base.height = height; bo->base.base.format = format; @@ -947,7 +937,7 @@ dri_use |= __DRI_IMAGE_USE_SCANOUT; --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c -@@ -791,24 +791,36 @@ +@@ -781,24 +781,36 @@ */ if (rb->mt && rb->mt->region && @@ -996,7 +986,7 @@ --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c -@@ -1021,7 +1021,7 @@ +@@ -1009,7 +1009,7 @@ struct intel_renderbuffer *rb, const char *buffer_name); @@ -1005,7 +995,7 @@ intel_update_image_buffers(struct brw_context *brw, __DRIdrawable *drawable); static void -@@ -1094,9 +1094,8 @@ +@@ -1082,9 +1082,8 @@ if (unlikely(INTEL_DEBUG & DEBUG_DRI)) fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable); @@ -1017,7 +1007,7 @@ intel_update_dri2_buffers(brw, drawable); driUpdateFramebufferSize(&brw->ctx, drawable); -@@ -1268,13 +1267,15 @@ +@@ -1256,13 +1255,15 @@ if (num_samples == 0) { if (rb->mt && rb->mt->region && @@ -1035,7 +1025,7 @@ return; } -@@ -1286,13 +1287,24 @@ +@@ -1274,13 +1275,24 @@ } intel_miptree_release(&rb->mt); @@ -1067,7 +1057,7 @@ if (!region) return; -@@ -1347,7 +1359,7 @@ +@@ -1346,7 +1358,7 @@ region); } @@ -1076,7 +1066,7 @@ intel_update_image_buffers(struct brw_context *brw, __DRIdrawable *drawable) { struct gl_framebuffer *fb = drawable->driverPrivate; -@@ -1366,7 +1378,7 @@ +@@ -1365,7 +1377,7 @@ else if (front_rb) format = intel_rb_format(front_rb); else @@ -1085,7 +1075,7 @@ if ((brw->is_front_buffer_rendering || brw->is_front_buffer_reading || !back_rb) && front_rb) buffer_mask |= __DRI_IMAGE_BUFFER_FRONT; -@@ -1374,12 +1386,13 @@ +@@ -1373,12 +1385,13 @@ if (back_rb) buffer_mask |= __DRI_IMAGE_BUFFER_BACK; @@ -1105,7 +1095,7 @@ if (images.image_mask & __DRI_IMAGE_BUFFER_FRONT) { drawable->w = images.front->width; -@@ -1399,4 +1412,5 @@ +@@ -1398,4 +1411,5 @@ images.back, __DRI_IMAGE_BUFFER_BACK); } commit 935dd4354ce49d0c23194032a09b56b700005863 Author: Maarten Lankhorst <maarten.lankho...@canonical.com> Date: Wed Feb 12 13:43:39 2014 +0100 kill off upstreamed parts of the mir patch first before refreshing diff --git a/debian/patches/egl-platform-mir.patch b/debian/patches/egl-platform-mir.patch index 00d6b7f..8a7617b 100644 --- a/debian/patches/egl-platform-mir.patch +++ b/debian/patches/egl-platform-mir.patch @@ -829,874 +829,6 @@ } ---- a/src/gallium/drivers/freedreno/freedreno_screen.c -+++ b/src/gallium/drivers/freedreno/freedreno_screen.c -@@ -359,6 +359,11 @@ - struct fd_screen *screen = fd_screen(pscreen); - struct fd_bo *bo; - -+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) { -+ DBG("Attempt to import unsupported handle type %d", whandle->type); -+ return NULL; -+ } -+ - bo = fd_bo_from_name(screen->dev, whandle->handle); - if (!bo) { - DBG("ref name 0x%08x failed", whandle->handle); ---- a/src/gallium/drivers/nouveau/nouveau_screen.c -+++ b/src/gallium/drivers/nouveau/nouveau_screen.c -@@ -85,8 +85,19 @@ - struct nouveau_device *dev = nouveau_screen(pscreen)->device; - struct nouveau_bo *bo = 0; - int ret; -+ -+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED && -+ whandle->type != DRM_API_HANDLE_TYPE_FD) { -+ debug_printf("%s: attempt to import unsupported handle type %d\n", -+ __FUNCTION__, whandle->type); -+ return NULL; -+ } -+ -+ if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) -+ ret = nouveau_bo_name_ref(dev, whandle->handle, &bo); -+ else -+ ret = nouveau_bo_prime_handle_ref(dev, whandle->handle, &bo); - -- ret = nouveau_bo_name_ref(dev, whandle->handle, &bo); - if (ret) { - debug_printf("%s: ref name 0x%08x failed with %d\n", - __FUNCTION__, whandle->handle, ret); -@@ -111,6 +122,8 @@ - } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { - whandle->handle = bo->handle; - return TRUE; -+ } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { -+ return nouveau_bo_set_prime(bo, &whandle->handle) == 0; - } else { - return FALSE; - } ---- a/src/gallium/include/state_tracker/drm_driver.h -+++ b/src/gallium/include/state_tracker/drm_driver.h -@@ -10,6 +10,8 @@ - - #define DRM_API_HANDLE_TYPE_SHARED 0 - #define DRM_API_HANDLE_TYPE_KMS 1 -+#define DRM_API_HANDLE_TYPE_FD 2 -+ - - /** - * For use with pipe_screen::{texture_from_handle|texture_get_handle}. -@@ -17,9 +19,10 @@ - struct winsys_handle - { - /** -- * Unused for texture_from_handle, always -- * DRM_API_HANDLE_TYPE_SHARED. Input to texture_get_handle, -- * use TEXTURE_USAGE to select handle for kms or ipc. -+ * Input for texture_from_handle, valid values are -+ * DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD. -+ * Input to texture_get_handle, -+ * to select handle for kms, flink, or prime. - */ - unsigned type; - /** -@@ -42,6 +45,8 @@ - enum drm_conf { - /* How many frames to allow before throttling. Or -1 to indicate any number */ - DRM_CONF_THROTTLE, /* DRM_CONF_INT. */ -+ /* Can this driver, running on this kernel, import and export dma-buf fds? */ -+ DRM_CONF_SHARE_FD, /* DRM_CONF_BOOL. */ - DRM_CONF_MAX - }; - ---- a/src/gallium/state_trackers/dri/drm/dri2.c -+++ b/src/gallium/state_trackers/dri/drm/dri2.c -@@ -33,6 +33,9 @@ - #include "util/u_format.h" - #include "util/u_debug.h" - #include "state_tracker/drm_driver.h" -+#include "state_tracker/st_texture.h" -+#include "state_tracker/st_context.h" -+#include "main/texobj.h" - - #include "dri_screen.h" - #include "dri_context.h" -@@ -262,7 +265,13 @@ - - templ.format = format; - templ.bind = bind; -- whandle.handle = buf->name; -+ if (buf->name != 0) { -+ whandle.type = DRM_API_HANDLE_TYPE_SHARED; -+ whandle.handle = buf->name; -+ } else { -+ whandle.type = DRM_API_HANDLE_TYPE_FD; -+ whandle.handle = buf->fd; -+ } - whandle.stride = buf->pitch; - - drawable->textures[statt] = -@@ -526,14 +535,14 @@ - } - - static __DRIimage * --dri2_create_image_from_name(__DRIscreen *_screen, -- int width, int height, int format, -- int name, int pitch, void *loaderPrivate) -+dri2_create_image_from_winsys(__DRIscreen *_screen, -+ int width, int height, int format, -+ struct winsys_handle *whandle, int pitch, -+ void *loaderPrivate) - { - struct dri_screen *screen = dri_screen(_screen); - __DRIimage *img; - struct pipe_resource templ; -- struct winsys_handle whandle; - unsigned tex_usage; - enum pipe_format pf; - -@@ -573,12 +582,10 @@ - templ.depth0 = 1; - templ.array_size = 1; - -- memset(&whandle, 0, sizeof(whandle)); -- whandle.handle = name; -- whandle.stride = pitch * util_format_get_blocksize(pf); -+ whandle->stride = pitch * util_format_get_blocksize(pf); - - img->texture = screen->base.screen->resource_from_handle(screen->base.screen, -- &templ, &whandle); -+ &templ, whandle); - if (!img->texture) { - FREE(img); - return NULL; -@@ -593,6 +600,39 @@ - } - - static __DRIimage * -+dri2_create_image_from_name(__DRIscreen *_screen, -+ int width, int height, int format, -+ int name, int pitch, void *loaderPrivate) -+{ -+ struct winsys_handle whandle; -+ -+ memset(&whandle, 0, sizeof(whandle)); -+ whandle.type = DRM_API_HANDLE_TYPE_SHARED; -+ whandle.handle = name; -+ -+ return dri2_create_image_from_winsys(_screen, width, height, format, -+ &whandle, pitch, loaderPrivate); -+} -+ -+static __DRIimage * -+dri2_create_image_from_fd(__DRIscreen *_screen, -+ int width, int height, int format, -+ int fd, int pitch, void *loaderPrivate) -+{ -+ struct winsys_handle whandle; -+ -+ if (fd < 0) -+ return NULL; -+ -+ memset(&whandle, 0, sizeof(whandle)); -+ whandle.type = DRM_API_HANDLE_TYPE_FD; -+ whandle.handle = (unsigned)fd; -+ -+ return dri2_create_image_from_winsys(_screen, width, height, format, -+ &whandle, pitch, loaderPrivate); -+} -+ -+static __DRIimage * - dri2_create_image_from_renderbuffer(__DRIcontext *context, - int renderbuffer, void *loaderPrivate) - { -@@ -686,6 +726,7 @@ - - switch (attrib) { - case __DRI_IMAGE_ATTRIB_STRIDE: -+ whandle.type = DRM_API_HANDLE_TYPE_KMS; - image->texture->screen->resource_get_handle(image->texture->screen, - image->texture, &whandle); - *value = whandle.stride; -@@ -702,6 +743,12 @@ - image->texture, &whandle); - *value = whandle.handle; - return GL_TRUE; -+ case __DRI_IMAGE_ATTRIB_FD: -+ whandle.type= DRM_API_HANDLE_TYPE_FD; -+ image->texture->screen->resource_get_handle(image->texture->screen, -+ image->texture, &whandle); -+ *value = whandle.handle; -+ return GL_TRUE; - case __DRI_IMAGE_ATTRIB_FORMAT: - *value = image->dri_format; - return GL_TRUE; -@@ -825,6 +872,122 @@ - return img; - } - -+static __DRIimage * -+dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture, -+ int depth, int level, unsigned *error, -+ void *loaderPrivate) -+{ -+ __DRIimage *img; -+ struct gl_context *ctx = ((struct st_context *)dri_context(context)->st)->ctx; -+ struct gl_texture_object *obj; -+ struct pipe_resource *tex; -+ GLuint face = 0; -+ -+ obj = _mesa_lookup_texture(ctx, texture); -+ if (!obj || obj->Target != target) { -+ *error = __DRI_IMAGE_ERROR_BAD_PARAMETER; -+ return NULL; -+ } -+ -+ tex = st_get_texobj_resource(obj); -+ if (!tex) { -+ *error = __DRI_IMAGE_ERROR_BAD_PARAMETER; -+ return NULL; -+ } -+ -+ if (target == GL_TEXTURE_CUBE_MAP) -+ face = depth; -+ -+ _mesa_test_texobj_completeness(ctx, obj); -+ if (!obj->_BaseComplete || (level > 0 && !obj->_MipmapComplete)) { -+ *error = __DRI_IMAGE_ERROR_BAD_PARAMETER; -+ return NULL; -+ } -+ -+ if (level < obj->BaseLevel || level > obj->_MaxLevel) { -+ *error = __DRI_IMAGE_ERROR_BAD_MATCH; -+ return NULL; -+ } -+ -+ if (target == GL_TEXTURE_3D && obj->Image[face][level]->Depth < depth) { -+ *error = __DRI_IMAGE_ERROR_BAD_MATCH; -+ return NULL; -+ } -+ -+ img = CALLOC_STRUCT(__DRIimageRec); -+ if (!img) { -+ *error = __DRI_IMAGE_ERROR_BAD_ALLOC; -+ return NULL; -+ } -+ -+ img->level = level; -+ img->layer = depth; -+ img->dri_format = driGLFormatToImageFormat(obj->Image[face][level]->TexFormat); -+ -+ img->loader_private = loaderPrivate; -+ -+ if (img->dri_format == __DRI_IMAGE_FORMAT_NONE) { -+ *error = __DRI_IMAGE_ERROR_BAD_PARAMETER; -+ free(img); -+ return NULL; -+ } -+ -+ pipe_resource_reference(&img->texture, tex); -+ -+ *error = __DRI_IMAGE_ERROR_SUCCESS; -+ return img; -+} -+ -+static __DRIimage * -+dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc, -+ int *fds, int num_fds, int *strides, int *offsets, -+ void *loaderPrivate) -+{ -+ __DRIimage *img; -+ int format, stride, dri_components; -+ -+ if (num_fds != 1) -+ return NULL; -+ if (offsets[0] != 0) -+ return NULL; -+ -+ switch(fourcc) { -+ case __DRI_IMAGE_FOURCC_RGB565: -+ format = __DRI_IMAGE_FORMAT_RGB565; -+ dri_components = __DRI_IMAGE_COMPONENTS_RGB; -+ break; -+ case __DRI_IMAGE_FOURCC_ARGB8888: -+ format = __DRI_IMAGE_FORMAT_ARGB8888; -+ dri_components = __DRI_IMAGE_COMPONENTS_RGBA; -+ break; -+ case __DRI_IMAGE_FOURCC_XRGB8888: -+ format = __DRI_IMAGE_FORMAT_XRGB8888; -+ dri_components = __DRI_IMAGE_COMPONENTS_RGB; -+ break; -+ case __DRI_IMAGE_FOURCC_ABGR8888: -+ format = __DRI_IMAGE_FORMAT_ABGR8888; -+ dri_components = __DRI_IMAGE_COMPONENTS_RGBA; -+ break; -+ case __DRI_IMAGE_FOURCC_XBGR8888: -+ format = __DRI_IMAGE_FORMAT_XBGR8888; -+ dri_components = __DRI_IMAGE_COMPONENTS_RGB; -+ break; -+ default: -+ return NULL; -+ } -+ -+ /* Strides are in bytes not pixels. */ -+ stride = strides[0] /4; -+ -+ img = dri2_create_image_from_fd(screen, width, height, format, -+ fds[0], stride, loaderPrivate); -+ if (img == NULL) -+ return NULL; -+ -+ img->dri_components = dri_components; -+ return img; -+} -+ - static void - dri2_destroy_image(__DRIimage *img) - { -@@ -833,7 +996,7 @@ - } - - static struct __DRIimageExtensionRec dri2ImageExtension = { -- { __DRI_IMAGE, 5 }, -+ { __DRI_IMAGE, 6 }, - dri2_create_image_from_name, - dri2_create_image_from_renderbuffer, - dri2_destroy_image, -@@ -843,6 +1006,7 @@ - dri2_validate_usage, - dri2_from_names, - dri2_from_planar, -+ dri2_create_from_texture, - }; - - /* -@@ -870,6 +1034,7 @@ - struct dri_screen *screen; - struct pipe_screen *pscreen; - const struct drm_conf_ret *throttle_ret = NULL; -+ const struct drm_conf_ret *dmabuf_ret = NULL; - - screen = CALLOC_STRUCT(dri_screen); - if (!screen) -@@ -881,14 +1046,21 @@ - sPriv->driverPrivate = (void *)screen; - - pscreen = driver_descriptor.create_screen(screen->fd); -- if (driver_descriptor.configuration) -+ if (driver_descriptor.configuration) { - throttle_ret = driver_descriptor.configuration(DRM_CONF_THROTTLE); -+ dmabuf_ret = driver_descriptor.configuration(DRM_CONF_SHARE_FD); -+ } - - if (throttle_ret && throttle_ret->val.val_int != -1) { - screen->throttling_enabled = TRUE; - screen->default_throttle_frames = throttle_ret->val.val_int; - } - -+ if (dmabuf_ret && dmabuf_ret->val.val_bool) { -+ dri2ImageExtension.base.version = 7; -+ dri2ImageExtension.createImageFromFds = dri2_from_fds; -+ } -+ - sPriv->extensions = dri_screen_extensions; - - /* dri_init_screen_helper checks pscreen for us */ ---- a/src/gallium/state_trackers/egl/common/native_helper.c -+++ b/src/gallium/state_trackers/egl/common/native_helper.c -@@ -427,6 +427,7 @@ - - memset(&wsh, 0, sizeof(wsh)); - wsh.handle = nbuf->u.drm.name; -+ wsh.type = DRM_API_HANDLE_TYPE_SHARED; - wsh.stride = nbuf->u.drm.stride; - - res = screen->resource_from_handle(screen, &nbuf->u.drm.templ, &wsh); ---- a/src/gallium/state_trackers/egl/x11/native_dri2.c -+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c -@@ -173,6 +173,7 @@ - } - - memset(&whandle, 0, sizeof(whandle)); -+ whandle.type = DRM_API_HANDLE_TYPE_SHARED; - whandle.stride = xbuf->pitch; - whandle.handle = xbuf->name; - dri2surf->textures[natt] = dri2dpy->base.screen->resource_from_handle( ---- a/src/gallium/targets/dri-ilo/target.c -+++ b/src/gallium/targets/dri-ilo/target.c -@@ -24,4 +24,21 @@ - return screen; - } - --DRM_DRIVER_DESCRIPTOR("i965", "i915", create_screen, NULL) -+ -+static const struct drm_conf_ret share_fd_ret = { -+ .type = DRM_CONF_BOOL, -+ .val.val_int = true, -+}; -+ -+static const struct drm_conf_ret *drm_configuration(enum drm_conf conf) -+{ -+ switch (conf) { -+ case DRM_CONF_SHARE_FD: -+ return &share_fd_ret; -+ default: -+ break; -+ } -+ return NULL; -+} -+ -+DRM_DRIVER_DESCRIPTOR("i965", "i915", create_screen, drm_configuration) ---- a/src/gallium/targets/dri-nouveau/target.c -+++ b/src/gallium/targets/dri-nouveau/target.c -@@ -17,4 +17,20 @@ - return screen; - } - --DRM_DRIVER_DESCRIPTOR("nouveau", "nouveau", create_screen, NULL) -+static const struct drm_conf_ret share_fd_ret = { -+ .type = DRM_CONF_BOOL, -+ .val.val_int = true, -+}; -+ -+static const struct drm_conf_ret *drm_configuration(enum drm_conf conf) -+{ -+ switch (conf) { -+ case DRM_CONF_SHARE_FD: -+ return &share_fd_ret; -+ default: -+ break; -+ } -+ return NULL; -+} -+ -+DRM_DRIVER_DESCRIPTOR("nouveau", "nouveau", create_screen, drm_configuration) ---- a/src/gallium/targets/dri-vmwgfx/target.c -+++ b/src/gallium/targets/dri-vmwgfx/target.c -@@ -31,11 +31,24 @@ - .val.val_int = 2, - }; - -+/* Technically this requires kernel support that is not yet -+ * widespread. -+ * -+ * We could check for support in create_screen and return the correct -+ * value, but for now just return true in all cases. -+ */ -+static const struct drm_conf_ret share_fd_ret = { -+ .type = DRM_CONF_BOOL, -+ .val.val_int = true, -+}; -+ - static const struct drm_conf_ret *drm_configuration(enum drm_conf conf) - { - switch (conf) { - case DRM_CONF_THROTTLE: - return &throttle_ret; -+ case DRM_CONF_SHARE_FD: -+ return &share_fd_ret; - default: - break; - } ---- a/src/gallium/winsys/i915/drm/i915_drm_buffer.c -+++ b/src/gallium/winsys/i915/drm/i915_drm_buffer.c -@@ -95,9 +95,13 @@ - unsigned *stride) - { - struct i915_drm_winsys *idws = i915_drm_winsys(iws); -- struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer); -+ struct i915_drm_buffer *buf; - uint32_t tile = 0, swizzle = 0; - -+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) -+ return NULL; -+ -+ buf = CALLOC_STRUCT(i915_drm_buffer); - if (!buf) - return NULL; - ---- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c -+++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c -@@ -257,7 +257,6 @@ - name, gem_name); - } - break; --#if 0 - case DRM_API_HANDLE_TYPE_FD: - { - const int fd = (int) handle->handle; -@@ -265,7 +264,6 @@ - fd, height * handle->stride); - } - break; --#endif - default: - bo = NULL; - break; ---- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c -+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c -@@ -40,6 +40,7 @@ - #include <sys/ioctl.h> - #include <xf86drm.h> - #include <errno.h> -+#include <fcntl.h> - - /* - * this are copy from radeon_drm, once an updated libdrm is released -@@ -114,7 +115,9 @@ - /* Winsys. */ - struct radeon_drm_winsys *rws; - -- /* List of buffer handles and its mutex. */ -+ /* List of buffer GEM names. Protected by bo_handles_mutex. */ -+ struct util_hash_table *bo_names; -+ /* List of buffer handles. Protectded by bo_handles_mutex. */ - struct util_hash_table *bo_handles; - pipe_mutex bo_handles_mutex; - pipe_mutex bo_va_mutex; -@@ -370,12 +373,13 @@ - - memset(&args, 0, sizeof(args)); - -+ pipe_mutex_lock(bo->mgr->bo_handles_mutex); -+ util_hash_table_remove(bo->mgr->bo_handles, (void*)(uintptr_t)bo->handle); - if (bo->name) { -- pipe_mutex_lock(bo->mgr->bo_handles_mutex); -- util_hash_table_remove(bo->mgr->bo_handles, -+ util_hash_table_remove(bo->mgr->bo_names, - (void*)(uintptr_t)bo->name); -- pipe_mutex_unlock(bo->mgr->bo_handles_mutex); - } -+ pipe_mutex_unlock(bo->mgr->bo_handles_mutex); - - if (bo->ptr) - os_munmap(bo->ptr, bo->base.size); -@@ -660,6 +664,7 @@ - static void radeon_bomgr_destroy(struct pb_manager *_mgr) - { - struct radeon_bomgr *mgr = radeon_bomgr(_mgr); -+ util_hash_table_destroy(mgr->bo_names); - util_hash_table_destroy(mgr->bo_handles); - pipe_mutex_destroy(mgr->bo_handles_mutex); - pipe_mutex_destroy(mgr->bo_va_mutex); -@@ -692,6 +697,7 @@ - mgr->base.is_buffer_busy = radeon_bomgr_is_buffer_busy; - - mgr->rws = rws; -+ mgr->bo_names = util_hash_table_create(handle_hash, handle_compare); - mgr->bo_handles = util_hash_table_create(handle_hash, handle_compare); - pipe_mutex_init(mgr->bo_handles_mutex); - pipe_mutex_init(mgr->bo_va_mutex); -@@ -841,6 +847,7 @@ - enum radeon_bo_domain domain) - { - struct radeon_drm_winsys *ws = radeon_drm_winsys(rws); -+ struct radeon_bomgr *mgr = radeon_bomgr(ws->kman); - struct radeon_bo_desc desc; - struct pb_manager *provider; - struct pb_buffer *buffer; -@@ -862,6 +869,10 @@ - if (!buffer) - return NULL; - -+ pipe_mutex_lock(mgr->bo_handles_mutex); -+ util_hash_table_set(mgr->bo_handles, (void*)(uintptr_t)get_radeon_bo(buffer)->handle, buffer); -+ pipe_mutex_unlock(mgr->bo_handles_mutex); -+ - return (struct pb_buffer*)buffer; - } - -@@ -872,10 +883,10 @@ - struct radeon_drm_winsys *ws = radeon_drm_winsys(rws); - struct radeon_bo *bo; - struct radeon_bomgr *mgr = radeon_bomgr(ws->kman); -- struct drm_gem_open open_arg = {}; -+ struct drm_radeon_gem_busy args; - int r; -- -- memset(&open_arg, 0, sizeof(open_arg)); -+ unsigned handle; -+ uint64_t size; - - /* We must maintain a list of pairs <handle, bo>, so that we always return - * the same BO for one particular handle. If we didn't do that and created -@@ -885,8 +896,20 @@ - * The list of pairs is guarded by a mutex, of course. */ - pipe_mutex_lock(mgr->bo_handles_mutex); - -- /* First check if there already is an existing bo for the handle. */ -- bo = util_hash_table_get(mgr->bo_handles, (void*)(uintptr_t)whandle->handle); -+ if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { -+ /* First check if there already is an existing bo for the handle. */ -+ bo = util_hash_table_get(mgr->bo_names, (void*)(uintptr_t)whandle->handle); -+ } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { -+ /* We must first get the GEM handle, as fds are unreliable keys */ -+ r = drmPrimeFDToHandle(ws->fd, whandle->handle, &handle); -+ if (r) -+ goto fail; -+ bo = util_hash_table_get(mgr->bo_handles, (void*)(uintptr_t)handle); -+ } else { -+ /* Unknown handle type */ -+ goto fail; -+ } -+ - if (bo) { - /* Increase the refcount. */ - struct pb_buffer *b = NULL; -@@ -900,27 +923,48 @@ - goto fail; - } - -- /* Open the BO. */ -- open_arg.name = whandle->handle; -- if (drmIoctl(ws->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) { -- FREE(bo); -- goto fail; -+ if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { -+ struct drm_gem_open open_arg = {}; -+ memset(&open_arg, 0, sizeof(open_arg)); -+ /* Open the BO. */ -+ open_arg.name = whandle->handle; -+ if (drmIoctl(ws->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) { -+ FREE(bo); -+ goto fail; -+ } -+ handle = open_arg.handle; -+ size = open_arg.size; -+ bo->name = whandle->handle; -+ } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { -+ size = lseek(whandle->handle, 0, SEEK_END); -+ /* -+ * Could check errno to determine whether the kernel is new enough, but -+ * it doesn't really matter why this failed, just that it failed. -+ */ -+ if (size == (off_t)-1) { -+ FREE(bo); -+ goto fail; -+ } -+ lseek(whandle->handle, 0, SEEK_SET); - } -- bo->handle = open_arg.handle; -- bo->name = whandle->handle; -+ -+ bo->handle = handle; - - /* Initialize it. */ - pipe_reference_init(&bo->base.reference, 1); - bo->base.alignment = 0; - bo->base.usage = PB_USAGE_GPU_WRITE | PB_USAGE_GPU_READ; -- bo->base.size = open_arg.size; -+ bo->base.size = (unsigned) size; - bo->base.vtbl = &radeon_bo_vtbl; - bo->mgr = mgr; - bo->rws = mgr->rws; - bo->va = 0; - pipe_mutex_init(bo->map_mutex); - -- util_hash_table_set(mgr->bo_handles, (void*)(uintptr_t)whandle->handle, bo); -+ if (bo->name) -+ util_hash_table_set(mgr->bo_names, (void*)(uintptr_t)bo->name, bo); -+ -+ util_hash_table_set(mgr->bo_handles, (void*)(uintptr_t)bo->handle, bo); - - done: - pipe_mutex_unlock(mgr->bo_handles_mutex); -@@ -931,7 +975,7 @@ - if (mgr->va && !bo->va) { - struct drm_radeon_gem_va va; - -- bo->va_size = ((bo->base.size + 4095) & ~4095); -+ bo->va_size = ((size + 4095) & ~4095); - bo->va = radeon_bomgr_find_va(mgr, bo->va_size, 1 << 20); - - va.handle = bo->handle; -@@ -955,8 +999,27 @@ - } - } - -- ws->allocated_vram += align(open_arg.size, 4096); -- bo->initial_domain = RADEON_DOMAIN_VRAM; -+ memset(&args, 0, sizeof(args)); -+ -+ args.handle = bo->handle; -+ r = drmCommandWriteRead(bo->rws->fd, DRM_RADEON_GEM_BUSY, &args, sizeof(args)); -+ /* We don't mind if the bo is busy; we're just after the memory domain */ -+ if (r && r != -EBUSY) { -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1wda6f-0005nw...@moszumanska.debian.org