diff --git a/glamor/glamor_egl_stubs.c b/glamor/glamor_egl_stubs.c deleted file mode 100644 index 91ab9a7ae..000000000 --- a/glamor/glamor_egl_stubs.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/** @file glamor_egl_stubs.c - * - * Stubbed out glamor_egl.c functions for servers other than Xorg. - */ - -#include "dix-config.h" - -#include "glamor.h" - -void -glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx) -{ -} - -int -glamor_egl_fd_name_from_pixmap(ScreenPtr screen, - PixmapPtr pixmap, - CARD16 *stride, CARD32 *size) -{ - return -1; -} - - -int -glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds, - uint32_t *offsets, uint32_t *strides, - uint64_t *modifier) -{ - return 0; -} - -int -glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, - CARD16 *stride, CARD32 *size) -{ - return -1; -} diff --git a/glamor/meson.build b/glamor/meson.build index d4cb1859a..2ae522aec 100644 --- a/glamor/meson.build +++ b/glamor/meson.build @@ -51,12 +51,6 @@ glamor = static_library('glamor', ], ) -glamor_egl_stubs = static_library('glamor_egl_stubs', - 'glamor_egl_stubs.c', - include_directories: inc, - dependencies: common_dep, -) - if build_xorg install_data('glamor.h', install_dir: xorgsdkdir) endif diff --git a/hw/kdrive/ephyr/ephyr_glamor.c b/hw/kdrive/ephyr/ephyr_glamor.c index 724611d69..772b73052 100644 --- a/hw/kdrive/ephyr/ephyr_glamor.c +++ b/hw/kdrive/ephyr/ephyr_glamor.c @@ -25,14 +25,18 @@ * * Glamor support and EGL setup. */ +#define MESA_EGL_NO_X11_HEADERS +#define EGL_NO_X11 #include #include #include #include #include +#include "glamor_context.h" #include "glamor_egl.h" #include "glamor_priv.h" +#include "ephyr.h" #include "ephyr_glamor.h" #include "os.h" @@ -69,6 +73,64 @@ struct ephyr_glamor { GLuint vao, vbo; }; +static void +glamor_egl_make_current(struct glamor_context *glamor_ctx) +{ + /* There's only a single global dispatch table in Mesa. EGL, GLX, + * and AIGLX's direct dispatch table manipulation don't talk to + * each other. We need to set the context to NULL first to avoid + * EGL's no-op context change fast path when switching back to + * EGL. + */ + eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE, + EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (!eglMakeCurrent(glamor_ctx->display, + glamor_ctx->surface, glamor_ctx->surface, + glamor_ctx->ctx)) { + FatalError("Failed to make EGL context current\n"); + } +} + +void +glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx) +{ + KdScreenPriv(screen); + KdScreenInfo *kd_screen = pScreenPriv->screen; + EphyrScrPriv *scrpriv = kd_screen->driver; + struct ephyr_glamor *ephyr_glamor = scrpriv->glamor; + + glamor_enable_dri3(screen); + glamor_ctx->display = ephyr_glamor->dpy; + glamor_ctx->ctx = ephyr_glamor->ctx; + glamor_ctx->surface = ephyr_glamor->egl_win; + glamor_ctx->make_current = glamor_egl_make_current; +} + +int +glamor_egl_fd_name_from_pixmap(ScreenPtr screen, + PixmapPtr pixmap, + CARD16 *stride, CARD32 *size) +{ + return -1; +} + + +int +glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds, + uint32_t *offsets, uint32_t *strides, + uint64_t *modifier) +{ + return 0; +} + +int +glamor_egl_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, + CARD16 *stride, CARD32 *size) +{ + return -1; +} + static GLuint ephyr_glamor_build_glsl_prog(GLuint vs, GLuint fs) { diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 1dc14be38..5baa3e781 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -43,6 +43,8 @@ #include #include +#define X_INCLUDE_STRING_H +#include #include #include #include @@ -55,8 +57,11 @@ #include #include #ifdef GLAMOR +#include +#include #include #include "glamor.h" +#include "glamor_glx_provider.h" #include "ephyr_glamor.h" #endif #include "ephyrlog.h" @@ -83,6 +88,7 @@ struct EphyrHostXVars { long damage_debug_msec; Bool size_set_from_configure; + char *glvnd_vendor; }; /* memset ( missing> ) instead of below */ @@ -1551,12 +1557,50 @@ out: } #ifdef GLAMOR + +#ifndef GLX_EXTENSIONS +#define GLX_EXTENSIONS 3 +#endif + +#ifndef GLX_VENDOR_NAMES_EXT +#define GLX_VENDOR_NAMES_EXT 0x20F6 +#endif + +/** + * Exchange a protocol request for glXQueryServerString. + */ +static char * +__glXQueryServerString(CARD32 name) +{ + xcb_glx_query_server_string_cookie_t cookie; + xcb_glx_query_server_string_reply_t *reply; + uint32_t len; + char *str; + char *buf; + + cookie = xcb_glx_query_server_string(HostX.conn, HostX.screen, name); + reply = xcb_glx_query_server_string_reply(HostX.conn, cookie, NULL); + str = xcb_glx_query_server_string_string(reply); + + /* The spec doesn't mention this, but the Xorg server replies with + * a string already terminated with '\0'. */ + len = xcb_glx_query_server_string_string_length(reply); + buf = xnfalloc(len); + memcpy(buf, str, len); + free(reply); + + return buf; +} + Bool ephyr_glamor_init(ScreenPtr screen) { KdScreenPriv(screen); KdScreenInfo *kd_screen = pScreenPriv->screen; EphyrScrPriv *scrpriv = kd_screen->driver; + char *hostx_glx_exts = NULL; + char *glvnd_vendors = NULL; + _Xstrtokparams saveptr; scrpriv->glamor = ephyr_glamor_screen_init(scrpriv->win, scrpriv->vid); ephyr_glamor_set_window_size(scrpriv->glamor, @@ -1566,6 +1610,18 @@ ephyr_glamor_init(ScreenPtr screen) FatalError("Failed to initialize glamor\n"); return FALSE; } + hostx_glx_exts = __glXQueryServerString(GLX_EXTENSIONS); + if (epoxy_extension_in_string(hostx_glx_exts,"GLX_EXT_libglvnd")) + glvnd_vendors = __glXQueryServerString(GLX_VENDOR_NAMES_EXT); + + if (glvnd_vendors) { + HostX.glvnd_vendor = _XStrtok(glvnd_vendors, " ", saveptr); + glamor_set_glvnd_vendor(screen, HostX.glvnd_vendor); + free(glvnd_vendors); + } + free(hostx_glx_exts); + + GlxPushProvider(&glamor_provider); return TRUE; } diff --git a/hw/kdrive/ephyr/meson.build b/hw/kdrive/ephyr/meson.build index dff1dfb68..148b82cef 100644 --- a/hw/kdrive/ephyr/meson.build +++ b/hw/kdrive/ephyr/meson.build @@ -28,8 +28,8 @@ if build_glamor srcs += 'ephyr_glamor_xv.c' endif xephyr_glamor += glamor - xephyr_glamor += glamor_egl_stubs xephyr_dep += epoxy_dep + xephyr_dep += dependency('xcb-glx') endif if build_xv