diff --git a/hw/xfree86/drivers/video/modesetting/driver.c b/hw/xfree86/drivers/video/modesetting/driver.c index 497ee15a27..3cb358f809 100644 --- a/hw/xfree86/drivers/video/modesetting/driver.c +++ b/hw/xfree86/drivers/video/modesetting/driver.c @@ -40,6 +40,10 @@ #include #include +#ifdef GLAMOR_HAS_EGL +#include +#endif + #include "config/hotplug_priv.h" #include "dix/dix_priv.h" #include "mi/mi_priv.h" @@ -1852,6 +1856,44 @@ CreateWindow_oneshot(WindowPtr pWin) return ret; } +static int +modesetting_get_cursor_interleave(int scrnIndex) +{ +#ifdef GLAMOR_HAS_EGL + const char* renderer = (const char*)glGetString(GL_RENDERER); + if (!renderer) { + /* Something went really wrong */ + xf86DrvMsg(scrnIndex, X_WARNING, + "glGetString(GL_RENDERER) returned NULL, your GL is broken or not initialized\n"); + } + + const char* vendor = (const char*)glGetString(GL_VENDOR); + if (!vendor) { + /* Something went really wrong */ + xf86DrvMsg(scrnIndex, X_WARNING, + "glGetString(GL_VENDOR) returned NULL, your GL is broken or not initialized\n"); + } + +#define CHECK_GL_NAME(name) ((renderer && strstr(renderer, name)) || (vendor && strstr(vendor, name))) + + if (CHECK_GL_NAME("Intel")) { + /* from xf86-video-intel */ + return HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64; + } + if (CHECK_GL_NAME("NVIDIA")) { + /* from xf86-video-{nouveau,nv} */ + return HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32; + } + if (CHECK_GL_NAME("AMD")) { + /* from xf86-video-{amdgpu,ati} */ + return HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; + } + +#undef CHECK_GL_NAME +#endif + return HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED; +} + static Bool ScreenInit(ScreenPtr pScreen, int argc, char **argv) { @@ -1967,17 +2009,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) /* Need to extend HWcursor support to handle mask interleave */ if (!ms->drmmode.sw_cursor) { /* XXX Is there any spec that says we should interleave the cursor bits? XXX */ - int interleave; - if (cursor_dim.width >= 64) - interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64; - else if (cursor_dim.width >= 32) - interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32; - else if (cursor_dim.width >= 16) - interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16; - else if (cursor_dim.width >= 8) - interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8; - else - interleave = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; + int interleave = modesetting_get_cursor_interleave(pScrn->scrnIndex); xf86_cursors_init(pScreen, cursor_dim.width, cursor_dim.height, interleave | diff --git a/hw/xfree86/drivers/video/modesetting/meson.build b/hw/xfree86/drivers/video/modesetting/meson.build index 19cebbedda..58c790a467 100644 --- a/hw/xfree86/drivers/video/modesetting/meson.build +++ b/hw/xfree86/drivers/video/modesetting/meson.build @@ -8,6 +8,12 @@ modesetting_srcs = [ 'vblank.c', ] +if epoxy_dep.found() + egl_dep = epoxy_dep +else + egl_dep = disabler() +endif + shared_module( 'modesetting_drv', modesetting_srcs, @@ -17,6 +23,7 @@ shared_module( c_args: xorg_c_args, dependencies: [ common_dep, + egl_dep, udev_dep, libdrm_dep, gbm_dep, diff --git a/include/meson.build b/include/meson.build index 8b4b87c6c1..687cb0af15 100644 --- a/include/meson.build +++ b/include/meson.build @@ -102,6 +102,7 @@ conf_data.set('CONFIG_WSCONS', host_machine.system() in ['openbsd', 'netbsd'] ? conf_data.set('HAVE_XSHMFENCE', xshmfence_dep.found() ? '1' : false) conf_data.set('WITH_LIBDRM', libdrm_required ? '1' : false) conf_data.set('LIBDRM_HAS_PLANE_SIZE_HINTS', libdrm_required ? libdrm_dep.version().version_compare('>= 2.4.122') : false) +conf_data.set('GLAMOR_HAS_EGL', epoxy_dep.found() ? '1' : false) conf_data.set('GLAMOR_HAS_EGL_QUERY_DMABUF', epoxy_dep.found() and epoxy_dep.version().version_compare('>= 1.4.4') ? '1' : false) conf_data.set('GLAMOR_HAS_EGL_QUERY_DRIVER',