Re: [Mesa-dev] [PATCH 4/9] egl/wayland: Add support for render-nodes
On Mon, May 11, 2015 at 10:38 AM, Axel Davy wrote: > Le 11/05/2015 17:42, Matt Turner a écrit : >> >> On Sat, May 9, 2015 at 4:20 AM, Axel Davy wrote: >>> >>> for drmGetNodeTypeFromFd, it looks like a very recent libdrm function, >>> and >>> we would require libdrm 2.4.60, which is quite recent. Currently mesa >>> requires 2.4.38, when libdrm is needed. I guess we cannot require 2.4.60 >>> for >>> now. >> >> Sure you can. libdrm dependencies aren't a problem. >> > As libdrm 2.4.60 is very recent, and I didn't want cause problems > (especially so close to the merge window), > I've pushed the patches without drmGetNodeTypeFromFd. > > The code can be modified later to use it. > > Yours, > > Axel Davy No, really. It's a non-issue. i965 *already requires* 2.4.60. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/9] egl/wayland: Add support for render-nodes
Le 11/05/2015 17:42, Matt Turner a écrit : On Sat, May 9, 2015 at 4:20 AM, Axel Davy wrote: for drmGetNodeTypeFromFd, it looks like a very recent libdrm function, and we would require libdrm 2.4.60, which is quite recent. Currently mesa requires 2.4.38, when libdrm is needed. I guess we cannot require 2.4.60 for now. Sure you can. libdrm dependencies aren't a problem. As libdrm 2.4.60 is very recent, and I didn't want cause problems (especially so close to the merge window), I've pushed the patches without drmGetNodeTypeFromFd. The code can be modified later to use it. Yours, Axel Davy ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/9] egl/wayland: Add support for render-nodes
On Sat, May 9, 2015 at 4:20 AM, Axel Davy wrote: > for drmGetNodeTypeFromFd, it looks like a very recent libdrm function, and > we would require libdrm 2.4.60, which is quite recent. Currently mesa > requires 2.4.38, when libdrm is needed. I guess we cannot require 2.4.60 for > now. Sure you can. libdrm dependencies aren't a problem. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/9] egl/wayland: Add support for render-nodes
On 08/05/2015 18:07, Emil Velikov a wrote : Let's use drmGetNodeTypeFromFd(), rather than hard-coding this ? + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_IMAGE_DRIVER) == 0) + return EGL_TRUE; If memory serves me right__DRI_IMAGE_DRIVER is a cleaned up version of __DRI_DRI2. Afaics the former is never looked up (or used) in the EGL code, unlike the latter. So I'm suspecting that this check is a bit off ? Thanks Emil Thanks for catching for wrong check, I send right away a patch with that fixed for drmGetNodeTypeFromFd, it looks like a very recent libdrm function, and we would require libdrm 2.4.60, which is quite recent. Currently mesa requires 2.4.38, when libdrm is needed. I guess we cannot require 2.4.60 for now. Yours, Axel Davy ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/9] egl/wayland: Add support for render-nodes
On 2 May 2015 at 11:15, Axel Davy wrote: > It is possible the server advertises a render-node. > In that case no authentication is needed, > and Gem names are forbidden. > > Signed-off-by: Axel Davy > --- > diff --git a/src/egl/drivers/dri2/platform_wayland.c > b/src/egl/drivers/dri2/platform_wayland.c > index a5bcf25..79989cb 100644 > --- a/src/egl/drivers/dri2/platform_wayland.c > +++ b/src/egl/drivers/dri2/platform_wayland.c > @@ -800,12 +800,33 @@ bad_format: > return NULL; > } > > +static char > +is_fd_render_node(int fd) > +{ > + struct stat render; > + > + if (fstat(fd, &render)) > + return 0; > + > + if (!S_ISCHR(render.st_mode)) > + return 0; > + > + if (render.st_rdev & 0x80) > + return 1; > + return 0; > +} > + Let's use drmGetNodeTypeFromFd(), rather than hard-coding this ? > +static EGLBoolean > +is_render_node_capable(struct dri2_egl_display *dri2_dpy) > +{ > + const __DRIextension **extensions; > + int i; > + > + /* We cannot use Gem names with render-nodes, only prime fds (dma-buf). > +* The server needs to accept them */ > + if (!(dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME)) > + return EGL_FALSE; > + > + /* Check the __DRIimage api is supported (this is required by our > +* codepath without Gem names) */ > + extensions = dri2_dpy->driver_extensions; > + for (i = 0; extensions[i]; i++) { > + if (strcmp(extensions[i]->name, __DRI_IMAGE_DRIVER) == 0) > + return EGL_TRUE; If memory serves me right__DRI_IMAGE_DRIVER is a cleaned up version of __DRI_DRI2. Afaics the former is never looked up (or used) in the EGL code, unlike the latter. So I'm suspecting that this check is a bit off ? Thanks Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/9] egl/wayland: Add support for render-nodes
On 2 May 2015 at 20:15, Axel Davy wrote: > It is possible the server advertises a render-node. > In that case no authentication is needed, > and Gem names are forbidden. > > Signed-off-by: Axel Davy Reviewed-by: Dave Airlie ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/9] egl/wayland: Add support for render-nodes
It is possible the server advertises a render-node. In that case no authentication is needed, and Gem names are forbidden. Signed-off-by: Axel Davy --- src/egl/drivers/dri2/egl_dri2.h | 1 + src/egl/drivers/dri2/platform_wayland.c | 58 +++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 167b3b1..afa4356 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -198,6 +198,7 @@ struct dri2_egl_display int authenticated; int formats; uint32_t capabilities; + int is_render_node; #endif }; diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index a5bcf25..79989cb 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -800,12 +800,33 @@ bad_format: return NULL; } +static char +is_fd_render_node(int fd) +{ + struct stat render; + + if (fstat(fd, &render)) + return 0; + + if (!S_ISCHR(render.st_mode)) + return 0; + + if (render.st_rdev & 0x80) + return 1; + return 0; +} + static int dri2_wl_authenticate(_EGLDisplay *disp, uint32_t id) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); int ret = 0; + if (dri2_dpy->is_render_node) { + _eglLog(_EGL_WARNING, "wayland-egl: client asks server to " +"authenticate for render-nodes"); + return 0; + } dri2_dpy->authenticated = 0; wl_drm_authenticate(dri2_dpy->wl_drm, id); @@ -847,8 +868,13 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device) return; } - drmGetMagic(dri2_dpy->fd, &magic); - wl_drm_authenticate(dri2_dpy->wl_drm, magic); + if (is_fd_render_node(dri2_dpy->fd)) { + dri2_dpy->is_render_node = 1; + dri2_dpy->authenticated = 1; + } else { + drmGetMagic(dri2_dpy->fd, &magic); + wl_drm_authenticate(dri2_dpy->wl_drm, magic); + } } static void @@ -990,6 +1016,27 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = { .get_sync_values = dri2_fallback_get_sync_values, }; +static EGLBoolean +is_render_node_capable(struct dri2_egl_display *dri2_dpy) +{ + const __DRIextension **extensions; + int i; + + /* We cannot use Gem names with render-nodes, only prime fds (dma-buf). +* The server needs to accept them */ + if (!(dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME)) + return EGL_FALSE; + + /* Check the __DRIimage api is supported (this is required by our +* codepath without Gem names) */ + extensions = dri2_dpy->driver_extensions; + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_IMAGE_DRIVER) == 0) + return EGL_TRUE; + } + return EGL_FALSE; +} + EGLBoolean dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) { @@ -1075,6 +1122,11 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) dri2_dpy->image->createImageFromFds == NULL) dri2_dpy->capabilities &= ~WL_DRM_CAPABILITY_PRIME; + if (dri2_dpy->is_render_node && !is_render_node_capable(dri2_dpy)) { + _eglLog(_EGL_WARNING, "wayland-egl: display is not render-node capable"); + goto cleanup_screen; + } + types = EGL_WINDOW_BIT; for (i = 0; dri2_dpy->driver_configs[i]; i++) { config = dri2_dpy->driver_configs[i]; @@ -1103,6 +1155,8 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) return EGL_TRUE; + cleanup_screen: + dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); cleanup_driver: dlclose(dri2_dpy->driver); cleanup_driver_name: -- 2.3.7 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev