Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wjp/xserver
  • DemiMarie/xserver
  • metux/xserver
  • alanc/xserver
  • uvas/xserver
  • cl91/xserver
  • heymiaoO/xserver
  • oreaus/xserver
  • stapelberg/xserver
  • PaulKocialkowski/xserver
  • CendioOssman/xserver
  • wiz/xserver
  • maos20008/xserver
  • dougvj/xserver
  • mgorse1/xserver
  • gldrk/xserver
  • TMR5454/xserver
  • Kyawswat/xserver
  • hexiaodong/xserver
  • gilvbp/xserver
  • vliaskov/xserver
  • aarondill/xserver
  • zzyiwei/xserver
  • kleinerm/xserver
  • jcherry/xserver
  • jcristau/xserver
  • nathankidd/xserver
  • jexposit/xserver
  • refi_64/xserver
  • kbrenneman/xserver
  • kupper.pa/xserver
  • LickmeDown/xserver
  • zboszor/xserver
  • jadahl/xserver
  • shadeslayer/xserver
  • mherrb/xserver
  • Julia/xserver
  • twaik/xserver
  • fvalasiad/xserver
  • zzxyb/xserver
  • HermannSW/xserver
  • erwinou/xserver
  • ekurzinger/xserver
  • nacho.resa/xserver
  • agoins/xserver
  • NSUTanghaixiang/xserver
  • huxd1532/xserver
  • keithp/xserver
  • vinilokorlok/xserver
  • bbeckett/xserver
  • dslater38/xserver
  • zzag/xserver
  • emersion/xserver
  • djlucas/xserver
  • ccullumbine2018/xserver
  • daniels/xserver
  • llandwerlin/xserver
  • doraskayo/xserver
  • afett/xserver
  • XDXTHX/xserver
  • xexaxo/xserver
  • ecurtin/xserver
  • rbernon/xserver
  • pekdon/xserver
  • karolherbst/xserver
  • russellcnv/xserver
  • mbiebl/xserver
  • orbea/xserver
  • vsyrjala/xserver
  • lyudess/xserver
  • manu/xserver
  • lucmann/xserver
  • tholin/xserver
  • yarivb/xserver
  • tmlind/xserver
  • chema/xserver
  • J-Bu/xserver
  • chenhuacai/xserver
  • E5ten/xserver
  • haagch/xserver
  • whot/xserver
  • strassek/xserver
  • mntmn/xserver
  • liyi42/xserver
  • YusufKhan-gamedev/xserver
  • iv-m/xserver
  • vanvugt/xserver
  • Rui511/xserver
  • catap/xserver
  • tjbp/xserver
  • webi123/xserver
  • noblock/xserver
  • freemangordon/xserver
  • xdandys/xserver
  • jbeich/xserver
  • zeising/xserver
  • romangg/xserver
  • pq/xserver
  • azhadchenko/xserver
  • Emantor/xserver
  • xorg/xserver
  • carlosg/xserver
  • kwg/xserver
  • pichika/xserver
  • klniu/xserver
  • TAAPArthur/xserver
  • sjoerd/xserver
  • Sjecai2/xserver
  • jturney/xserver
  • pkubaj/xserver
  • os369510/xserver
  • Zamundaaa/xserver
  • Gorg/xserver
  • lkundrak/xserver
  • niveditharau/xserver
  • ForTheReallys/xserver
  • jmonteiro/xserver
  • jocelyn/xserver
  • ThatMG393/xserver
  • fweimer/xserver
  • mlankhorst/xserver
  • marv/xserver
  • dbn/xserver
  • mattrope/xserver
  • coypoop/xserver
  • mwyraz/xserver
  • frog/xserver
  • 3v1n0/xserver
  • awilfox/xserver
  • muesli4/xserver
  • rarbab/xserver
  • yshui/xserver
  • jannau/xserver
  • mikeroyal/xserver
  • andrebsguedes/xserver
  • JeffyCN/xserver
  • ipominov/xserver
  • gtrentalancia/xserver
  • josch/xserver
  • lucyllewy/xserver
  • tomty89/xserver
  • qarmin/xserver
  • tagr/xserver
  • zwenna/xserver
  • bkylerussell/xserver
  • mupuf/xserver
  • zubzub/xserver
  • galaxytgtabiday/xserver
  • OlCe/xserver
  • ashafer/xserver
  • dengbo/xserver
  • valpackett/xserver
  • andreyknyazev077/xserver
  • antonovitch/xserver
  • contactshashanksharma/xserver-fork-shashank
  • akihiko.odaki/xserver
  • sknsean/xserver
  • rnpnr/xserver
  • hitong602/xserver
  • halfline/xserver
  • ismailsiege/xserver
  • dongwonk/xserver
  • Fatton1/xserver
  • GermanAizek/xserver
  • daenzer/xserver
  • FeepingCreature/xserver
  • mvlad/xserver
  • puleglot/xserver
  • smelenius/xserver
  • sewn/xserver
  • kaichuan.hsieh/xserver
  • SimonPilkington/xserver
  • adamdruppe/xserver
  • floppym/xserver
  • trevdave/xserver
  • luke-jr/xserver
  • headrush/xserver
  • davidriley/xserver
  • heitbaum/xserver
  • mrisaacb/xserver
  • goosen78/xserver
  • Ma/xserver
  • gmbr3/xserver
  • tsutsui/xserver
  • sherrodejjohnson/xserver
  • hassoon1986/xserver
  • lanodan/xserver
  • ydc-dadada/xserver
  • wengxt/xserver
  • icenowy/xserver
  • denisfa/xserver
  • StarsGreen/xserver
  • adamjrichter/xserver
  • bigon/xserver
  • djacewicz/xserver
  • davidre/xserver
  • kylin0061/xserver
  • arrowd/xserver
  • p12tic/xserver
  • ernstp/xserver
  • bbrezillon/xserver
  • penguin42/xserver
  • anarsoul/xserver
  • marvinjr35/xserver
  • gerddie/xserver
  • xry111/xserver
  • psyruss85/xserver
  • volkanorhan/xserver
  • luporl/xserver
  • cbur201592/xserver
  • bphaslett/xserver
  • guillem/xserver
  • haihao/xserver
  • peterh/xserver
  • miztake/xserver
  • zaps166/xserver
  • lostgoat/xserver
  • vfjpl/xserver
  • bentiss/xserver
  • rilian-la-te/xserver
  • wujiangGitHub/xserver
  • cubanismo/xserver
  • arichardson/xserver
  • schreibemirhalt/xserver
  • jsg/xserver
  • karlosrangel337/xserver
  • knisht/xserver
  • manuelcrack642/xserver
  • ross/xserver
  • topimiettinen/xserver
  • davidedmundson/xserver
  • DPA/xserver
  • dkorkmazturk/xserver
  • karamjameelmoore/xserver
  • lihongtao/xserver
  • sthibaul/xserver
  • RyzenDew/xserver
  • christian-rauch/xserver
  • Vivek/xserver
  • peigongdsd/xserver
  • peng.jin/xserver
  • alagner/xserver
  • mehdigh419/xserver
  • dixler/xserver
  • BBaoVanC/xserver
  • Drakulix/xserver
  • Acidburn0zzz/xserver
  • bafanahub/xserver
  • benpicco/xserver
  • yangxiaojuan-loongson/xserver
  • kaocher82/xserver
  • pepp/xserver
  • luyn/xserver
  • cgzones/xserver
  • 1740301466jxz/xserver
  • ids1024/xserver
  • svalaskevicius/xserver
  • ZhiJie.Zhang/xserver
  • chengbo7135/xserver
  • eschwartz/xserver
  • jayantpranjal0/xserver
  • hmazlan/xserver
  • kerneltoast/xserver
  • Michaelypk/xserver
  • dottedmag/xserver
  • aplattner/xserver
  • sergiomb/xserver
  • looi/xserver
  • robclark/xserver
  • tzimmermann/xserver
  • vitoux.pascal/xserver
  • aditj/xserver
  • kennylevinsen/xserver
  • Kishore409/xserver
  • Daasin/xserver
  • dirbaio/xserver
  • xinbowang/xserver
  • mwei/xserver
  • SpikyCaterpillar1/xserver
  • devin11911191/xserver
  • alex-tu-cc/xserver
  • kaniini/xserver
  • jcourreges/xserver
  • n3rdopolis/xserver
  • zagursky/xserver
  • thesamesam/xserver
  • anholt/xserver
  • themaister/xserver
  • jrtc27/xserver
  • JoseExposito/xserver
  • Hi-Angel/xserver
  • City-busz/xserver
  • ydirson/xserver
  • dawnhan/xserver
  • avolkov/xserver
  • meMuszr/xserver
  • dk/xserver
  • cooperch/xserver
  • Tuetuopay/xserver
  • gabifalk/xserver
  • jeremyhu/xserver
  • road2react/xserver
  • 1480c1/xserver
  • Spintzyk/xserver
  • MisterDA/xserver
  • starnight/xserver
  • abono/xserver
  • ajax/xserver
  • dougg3/xserver
  • chenx_dust/xserver
  • EXtremeExploit/xserver
  • jwrdegoede/xserver
  • acelan/xserver
  • airlied/xserver
  • justazarsky/xserver
  • sri-ka1ki/xserver
  • rgfernandes/xserver
  • lynxeye/xserver
  • tintou/xserver
  • mattst88/xserver
  • rmader/xserver
  • linkmauve/xserver
  • kamarul6401/xserver
  • andy-zetier/xserver
  • gsittyz/xserver
  • bernhardu/xserver
  • causztic/xserver
  • cpmichael/modesetting
  • ryanneph/xserver
  • zhangyaning/xserver
  • olv/xserver
  • hongaoo/xserver
  • LiChenG-P/xserver
  • Ivaniku/x-taylan
  • dkg/xserver
  • ofourdan/xserver
  • mahkoh/xserver
  • AkiSakurai/xserver
  • msizanoen1/xserver
339 results
Show changes
Commits on Source (11)
  • Aaron Plattner's avatar
    xfree86: NUL-terminate strings in hwEnableIO · 72c5d153
    Aaron Plattner authored
    The Linux version of xf86EnableIO calls a helper function called hwEnableIO().
    Except on Alpha, this function reads /proc/ioports looking for the 'keyboard'
    and 'timer' ports, extracts the port ranges, and enables access to them. It does
    this by reading 4 bytes from the string for the start port number and 4 bytes
    for the last port number, passing those to atoi(). However, it doesn't add a
    fifth byte for a NUL terminator, so some implementations of atoi() read past the
    end of this string, triggering an AddressSanitizer error:
    
      ==1383==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff71fd5b74 at pc 0x7fe1be0de3e0 bp 0x7fff71fd5ae0 sp 0x7fff71fd5288
      READ of size 5 at 0x7fff71fd5b74 thread T0
          #0 0x7fe1be0de3df in __interceptor_atoi /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cpp:520
          #1 0x564971adcc45 in hwEnableIO ../hw/xfree86/os-support/linux/lnx_video.c:138
          #2 0x564971adce87 in xf86EnableIO ../hw/xfree86/os-support/linux/lnx_video.c:174
          #3 0x5649719f6a30 in InitOutput ../hw/xfree86/common/xf86Init.c:439
          #4 0x564971585924 in dix_main ../dix/main.c:190
          #5 0x564971b6246e in main ../dix/stubmain.c:34
          #6 0x7fe1bdab6b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
          #7 0x564971490e9d in _start (/home/aaron/git/x/xserver/build.asan/hw/xfree86/Xorg+0xb2e9d)
    
      Address 0x7fff71fd5b74 is located in stack of thread T0 at offset 100 in frame
          #0 0x564971adc96a in hwEnableIO ../hw/xfree86/os-support/linux/lnx_video.c:118
    
        This frame has 3 object(s):
          [32, 40) 'n' (line 120)
          [64, 72) 'buf' (line 122)
          [96, 100) 'target' (line 122) <== Memory access at offset 100 overflows this variable
      HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
            (longjmp and C++ exceptions *are* supported)
      SUMMARY: AddressSanitizer: stack-buffer-overflow /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cpp:520 in __interceptor_atoi
      Shadow bytes around the buggy address:
        0x10006e3f2b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x10006e3f2b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x10006e3f2b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x10006e3f2b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x10006e3f2b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      =>0x10006e3f2b60: 00 00 f1 f1 f1 f1 00 f2 f2 f2 00 f2 f2 f2[04]f3
        0x10006e3f2b70: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x10006e3f2b80: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
        0x10006e3f2b90: f1 f1 f8 f2 00 f2 f2 f2 f8 f3 f3 f3 00 00 00 00
        0x10006e3f2ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
        0x10006e3f2bb0: f1 f1 00 f3 f3 f3 00 00 00 00 00 00 00 00 00 00
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07
        Heap left redzone:       fa
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack after return:      f5
        Stack use after scope:   f8
        Global redzone:          f9
        Global init order:       f6
        Poisoned by user:        f7
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
        Shadow gap:              cc
      ==1383==ABORTING
    
    Fix this by NUL-terminating the string.
    
    Fixes: #1193 (comment 1053306)
    
    
    Signed-off-by: Aaron Plattner's avatarAaron Plattner <aplattner@nvidia.com>
    72c5d153
  • Olivier Fourdan's avatar
    xwayland: Fix leak of xwl_screen on init · 138d4eba
    Olivier Fourdan authored
    
    On screen init, if any of the private type registration fails we would
    return FALSE without actually freeing the xwl_screen we just allocated.
    
    This is not a serious leak as failure at that point would lead to the
    premature termination of Xwayland at startup, but covscan complains and
    it's easy enough to fix.
    
    Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
    Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: default avatarMichel Dänzer <mdaenzer@redhat.com>
    138d4eba
  • Olivier Fourdan's avatar
    xwayland: Fix memory allocation test · c01ac52b
    Olivier Fourdan authored
    
    Due to a typo in tablet_pad_group(), we would allocate a variable
    ("group") and test another one ("pad") for allocation success.
    
    Spotted by covscan.
    
    Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
    Fixes: commit 8475e636 - "xwayland: add tablet pad support"
    Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: default avatarMichel Dänzer <mdaenzer@redhat.com>
    c01ac52b
  • Olivier Fourdan's avatar
    glamor: Fix leak in glamor_build_program() · 2906ee5e
    Olivier Fourdan authored
    
    Fix the possible leak of `vs_prog_string` and `fs_prog_string` in case
    of failure, as reported by covscan.
    
    Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
    Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: default avatarMichel Dänzer <mdaenzer@redhat.com>
    2906ee5e
  • Adam Jackson's avatar
    ephyr/glamor: Port to EGL · 07fa12ad
    Adam Jackson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    There's no real benefit to using GLX, and the other DDXes are using EGL
    already, so let's converge on EGL so we can concentrate the fixes in one
    place.
    
    We go to some effort to avoid being the thing that requires libX11 here.
    We prefer EGL_EXT_platform_xcb over _x11, and if forced to use the
    latter we'll ask the dynamic linker for XGetXCBConnection and
    XOpenDisplay rather than link against xlib stuff ourselves. Xephyr is
    now a pure XCB application if it can be.
    
    Reviewed-by: Emma Anholt's avatarEmma Anholt <emma@anholt.net>
    07fa12ad
  • Adam Jackson's avatar
    glamor: Don't open-code epoxy_glsl_version() · ea92cd22
    Adam Jackson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    Reviewed-by: Emma Anholt's avatarEmma Anholt <emma@anholt.net>
    ea92cd22
  • Adam Jackson's avatar
    ephyr: Don't open-code glamor_compile_glsl_prog · 22772f00
    Adam Jackson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    Reviewed-by: Emma Anholt's avatarEmma Anholt <emma@anholt.net>
    22772f00
  • Adam Jackson's avatar
    wayland/streams: Don't open-code glamor_compile_glsl_prog · abda3f42
    Adam Jackson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    Reviewed-by: Emma Anholt's avatarEmma Anholt <emma@anholt.net>
    abda3f42
  • Adam Jackson's avatar
    glamor: Require EGL_KHR_no_config_context · 7d5b4c54
    Adam Jackson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    This is not actually a change for xwayland with gbm, or for xfree86 with
    big-GL, but we do change them as well to use EGL_NO_CONFIG_KHR
    explicitly.
    
    Reviewed-by: Emma Anholt's avatarEmma Anholt <emma@anholt.net>
    7d5b4c54
  • Adam Jackson's avatar
    glamor: Assume EGL in glamor_context · ecdf2103
    Adam Jackson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    Reviewed-by: Emma Anholt's avatarEmma Anholt <emma@anholt.net>
    ecdf2103
  • Patrik Jakobsson's avatar
    modesetting: Fix dirty updates for sw rotation · db9e9d45
    Patrik Jakobsson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
    
    Rotation is broken for all drm drivers not providing hardware rotation
    support. Drivers that give direct access to vram and not needing dirty
    updates still work but only by accident. The problem is caused by
    modesetting not sending the correct fb_id to drmModeDirtyFB() and
    passing the damage rects in the rotated state and not as the crtc
    expects them. This patch takes care of both problems.
    
    Signed-off-by: default avatarPatrik Jakobsson <pjakobsson@suse.de>
    db9e9d45
Showing
with 483 additions and 237 deletions
......@@ -2192,9 +2192,6 @@ if test "$KDRIVE" = yes; then
if test "x$DRI" = xyes && test "x$GLX" = xyes; then
XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS $LIBDRM xcb-glx xcb-xf86dri > 1.6"
fi
if test "x$GLAMOR" = xyes; then
XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS x11-xcb"
fi
if test "x$XEPHYR" = xauto; then
PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [XEPHYR="yes"], [XEPHYR="no"])
......
......@@ -13,7 +13,6 @@ libglamor_la_SOURCES = \
glamor_debug.h \
glamor_font.c \
glamor_font.h \
glamor_glx.c \
glamor_composite_glyphs.c \
glamor_image.c \
glamor_lines.c \
......
......@@ -618,10 +618,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
{
glamor_screen_private *glamor_priv;
int gl_version;
int glsl_major, glsl_minor;
int max_viewport_size[2];
const char *shading_version_string;
int shading_version_offset;
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
......@@ -670,9 +667,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
* register correct close screen function. */
if (flags & GLAMOR_USE_EGL_SCREEN) {
glamor_egl_screen_init(screen, &glamor_priv->ctx);
} else {
if (!glamor_glx_screen_init(&glamor_priv->ctx))
goto fail;
}
glamor_make_current(glamor_priv);
......@@ -686,29 +680,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->is_core_profile =
gl_version >= 31 && !epoxy_has_gl_extension("GL_ARB_compatibility");
shading_version_string = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
if (!shading_version_string) {
LogMessage(X_WARNING,
"glamor%d: Failed to get GLSL version\n",
screen->myNum);
goto fail;
}
shading_version_offset = 0;
if (strncmp("OpenGL ES GLSL ES ", shading_version_string, 18) == 0)
shading_version_offset = 18;
if (sscanf(shading_version_string + shading_version_offset,
"%i.%i",
&glsl_major,
&glsl_minor) != 2) {
LogMessage(X_WARNING,
"glamor%d: Failed to parse GLSL version string %s\n",
screen->myNum, shading_version_string);
goto fail;
}
glamor_priv->glsl_version = glsl_major * 100 + glsl_minor;
glamor_priv->glsl_version = epoxy_glsl_version();
if (glamor_priv->is_gles) {
/* Force us back to the base version of our programs on an ES
......
......@@ -21,29 +21,26 @@
* IN THE SOFTWARE.
*/
#ifndef GLAMOR_CONTEXT_H
#define GLAMOR_CONTEXT_H
#include <epoxy/egl.h>
/**
* @file glamor_context.h
*
* This is the struct of state required for context switching in
* glamor. It has to use types that don't require including either
* server headers or Xlib headers, since it will be included by both
* the server and the GLX (xlib) code.
* glamor. Initially this was abstracted away from EGL, and
* presumably it would need to be again if someone wanted to use
* glamor with WGL/CGL.
*/
struct glamor_context {
/** Either an EGLDisplay or an Xlib Display */
void *display;
/** Either a GLXContext or an EGLContext. */
void *ctx;
/** The EGLSurface we should MakeCurrent to */
void *drawable;
/** The GLXDrawable we should MakeCurrent to */
uint32_t drawable_xid;
EGLDisplay display;
EGLContext ctx;
EGLSurface surface;
void (*make_current)(struct glamor_context *glamor_ctx);
};
Bool glamor_glx_screen_init(struct glamor_context *glamor_ctx);
#endif
......@@ -933,8 +933,6 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
{
struct glamor_egl_screen_private *glamor_egl;
const GLubyte *renderer;
EGLConfig egl_config;
int n;
glamor_egl = calloc(sizeof(*glamor_egl), 1);
if (glamor_egl == NULL)
......@@ -977,6 +975,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
}
GLAMOR_CHECK_EGL_EXTENSION(KHR_surfaceless_context);
GLAMOR_CHECK_EGL_EXTENSION(KHR_no_config_context);
if (eglBindAPI(EGL_OPENGL_API)) {
static const EGLint config_attribs_core[] = {
......@@ -993,12 +992,13 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
};
glamor_egl->context = eglCreateContext(glamor_egl->display,
NULL, EGL_NO_CONTEXT,
EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT,
config_attribs_core);
if (glamor_egl->context == EGL_NO_CONTEXT)
glamor_egl->context = eglCreateContext(glamor_egl->display,
NULL, EGL_NO_CONTEXT,
EGL_NO_CONFIG_KHR,
EGL_NO_CONTEXT,
config_attribs);
}
......@@ -1029,14 +1029,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
goto error;
}
if (!eglChooseConfig(glamor_egl->display, NULL, &egl_config, 1, &n)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"glamor: No acceptable EGL configs found\n");
goto error;
}
glamor_egl->context = eglCreateContext(glamor_egl->display,
egl_config, EGL_NO_CONTEXT,
EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT,
config_attribs);
if (glamor_egl->context == EGL_NO_CONTEXT) {
......
/*
* 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.
*/
#include <epoxy/glx.h>
#include "glamor_context.h"
/**
* @file glamor_glx.c
*
* GLX context management for glamor.
*
* This has to be kept separate from the server sources because of
* Xlib's conflicting definition of CARD32 and similar typedefs.
*/
static void
glamor_glx_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
* GLX's no-op context change fast path when switching back to
* GLX.
*/
glXMakeCurrent(glamor_ctx->display, None, None);
glXMakeCurrent(glamor_ctx->display, glamor_ctx->drawable_xid,
glamor_ctx->ctx);
}
Bool
glamor_glx_screen_init(struct glamor_context *glamor_ctx)
{
glamor_ctx->ctx = glXGetCurrentContext();
if (!glamor_ctx->ctx)
return False;
glamor_ctx->display = glXGetCurrentDisplay();
if (!glamor_ctx->display)
return False;
glamor_ctx->drawable_xid = glXGetCurrentDrawable();
glamor_ctx->make_current = glamor_glx_make_current;
return True;
}
......@@ -383,6 +383,8 @@ fail:
glDeleteProgram(prog->prog);
prog->prog = 0;
}
free(vs_prog_string);
free(fs_prog_string);
free(version_string);
free(fs_vars);
free(vs_vars);
......
......@@ -4,7 +4,6 @@ srcs_glamor = [
'glamor_core.c',
'glamor_dash.c',
'glamor_font.c',
'glamor_glx.c',
'glamor_composite_glyphs.c',
'glamor_image.c',
'glamor_lines.c',
......
......@@ -41,8 +41,8 @@ GLAMOR_XV_SRCS = ephyr_glamor_xv.c
endif
GLAMOR_SRCS = \
ephyr_glamor_glx.c \
ephyr_glamor_glx.h \
ephyr_glamor.c \
ephyr_glamor.h \
$(GLAMOR_XV_SRCS) \
$()
endif
......
......@@ -39,7 +39,7 @@
#ifdef GLAMOR
#include "glamor.h"
#endif
#include "ephyr_glamor_glx.h"
#include "ephyr_glamor.h"
#include "glx_extinit.h"
#include "xkbsrv.h"
......@@ -1171,9 +1171,6 @@ ephyrXcbProcessEvents(Bool queued_only)
}
if (xev) {
if (ephyr_glamor)
ephyr_glamor_process_event(xev);
free(xev);
}
}
......
......@@ -71,6 +71,7 @@ typedef struct _ephyrScrPriv {
xcb_window_t win;
xcb_window_t win_pre_existing; /* Set via -parent option like xnest */
xcb_window_t peer_win; /* Used for GL; should be at most one */
xcb_visualid_t vid;
xcb_image_t *ximg;
Bool win_explicit_position;
int win_x, win_y;
......@@ -87,10 +88,6 @@ typedef struct _ephyrScrPriv {
ScreenBlockHandlerProcPtr BlockHandler;
/**
* Per-screen Xlib-using state for glamor (private to
* ephyr_glamor_glx.c)
*/
struct ephyr_glamor *glamor;
} EphyrScrPriv;
......
......@@ -21,25 +21,20 @@
* IN THE SOFTWARE.
*/
/** @file ephyr_glamor_glx.c
/** @file ephyr_glamor.c
*
* Separate file for hiding Xlib and GLX-using parts of xephyr from
* the rest of the server-struct-aware build.
* Glamor support and EGL setup.
*/
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#undef Xcalloc
#undef Xrealloc
#undef Xfree
#include <X11/Xlib-xcb.h>
#include <stdint.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <pixman.h>
#include <epoxy/glx.h>
#include "ephyr_glamor_glx.h"
#include "glamor_egl.h"
#include "glamor_priv.h"
#include "ephyr_glamor.h"
#include "os.h"
#include <X11/Xproto.h>
/* until we need geometry shaders GL3.1 should suffice. */
/* Xephyr has its own copy of this for build reasons */
......@@ -47,15 +42,8 @@
#define GLAMOR_GL_CORE_VER_MINOR 1
/** @{
*
* global state for Xephyr with glamor.
*
* Xephyr can render with multiple windows, but all the windows have
* to be on the same X connection and all have to have the same
* visual.
* global state for Xephyr with glamor, all of which is arguably a bug.
*/
static Display *dpy;
static XVisualInfo *visual_info;
static GLXFBConfig fb_config;
Bool ephyr_glamor_gles2;
Bool ephyr_glamor_skip_present;
/** @} */
......@@ -64,9 +52,10 @@ Bool ephyr_glamor_skip_present;
* Per-screen state for Xephyr with glamor.
*/
struct ephyr_glamor {
GLXContext ctx;
Window win;
GLXWindow glx_win;
EGLDisplay dpy;
EGLContext ctx;
xcb_window_t win;
EGLSurface egl_win;
GLuint tex;
......@@ -80,37 +69,6 @@ struct ephyr_glamor {
GLuint vao, vbo;
};
static GLint
ephyr_glamor_compile_glsl_prog(GLenum type, const char *source)
{
GLint ok;
GLint prog;
prog = glCreateShader(type);
glShaderSource(prog, 1, (const GLchar **) &source, NULL);
glCompileShader(prog);
glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
if (!ok) {
GLchar *info;
GLint size;
glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
info = malloc(size);
if (info) {
glGetShaderInfoLog(prog, size, NULL, info);
ErrorF("Failed to compile %s: %s\n",
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
ErrorF("Program source:\n%s", source);
free(info);
}
else
ErrorF("Failed to get shader compilation info.\n");
FatalError("GLSL compile failure\n");
}
return prog;
}
static GLuint
ephyr_glamor_build_glsl_prog(GLuint vs, GLuint fs)
{
......@@ -167,8 +125,8 @@ ephyr_glamor_setup_texturing_shader(struct ephyr_glamor *glamor)
GLuint fs, vs, prog;
vs = ephyr_glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
fs = ephyr_glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_source);
vs = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_source);
fs = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_source);
prog = ephyr_glamor_build_glsl_prog(vs, fs);
glamor->texture_shader = prog;
......@@ -178,16 +136,86 @@ ephyr_glamor_setup_texturing_shader(struct ephyr_glamor *glamor)
assert(glamor->texture_shader_texcoord_loc != -1);
}
#ifndef EGL_PLATFORM_XCB_EXT
#define EGL_PLATFORM_XCB_EXT 0x31DC
#endif
#include <dlfcn.h>
#ifndef RTLD_DEFAULT
#define RTLD_DEFAULT NULL
#endif
/* (loud booing)
*
* keeping this as a static variable is bad form, we _could_ have zaphod heads
* on different displays (for example). but other bits of Xephyr are already
* broken for that case, and fixing that would entail fixing the rest of the
* contortions with hostx.c anyway, so this works for now.
*/
static EGLDisplay edpy = EGL_NO_DISPLAY;
xcb_connection_t *
ephyr_glamor_connect(void)
{
dpy = XOpenDisplay(NULL);
if (!dpy)
return NULL;
int major = 0, minor = 0;
/*
* Try pure xcb first. If that doesn't work but we can find XOpenDisplay,
* fall back to xlib. This lets us potentially not load libX11 at all, if
* the EGL is also pure xcb.
*/
if (epoxy_has_egl_extension(EGL_NO_DISPLAY, "EGL_EXT_platform_xcb")) {
xcb_connection_t *conn = xcb_connect(NULL, NULL);
EGLDisplay dpy = glamor_egl_get_display(EGL_PLATFORM_XCB_EXT, conn);
if (dpy == EGL_NO_DISPLAY) {
xcb_disconnect(conn);
return NULL;
}
edpy = dpy;
eglInitialize(dpy, &major, &minor);
return conn;
}
if (epoxy_has_egl_extension(EGL_NO_DISPLAY, "EGL_EXT_platform_x11") ||
epoxy_has_egl_extension(EGL_NO_DISPLAY, "EGL_KHR_platform_x11)")) {
void *lib = NULL;
xcb_connection_t *ret = NULL;
void *(*x_open_display)(void *) =
(void *) dlsym(RTLD_DEFAULT, "XOpenDisplay");
xcb_connection_t *(*x_get_xcb_connection)(void *) =
(void *) dlsym(RTLD_DEFAULT, "XGetXCBConnection");
if (x_open_display == NULL)
return NULL;
if (x_get_xcb_connection == NULL) {
lib = dlopen("libX11-xcb.so.1", RTLD_LOCAL | RTLD_LAZY);
x_get_xcb_connection =
(void *) dlsym(lib, "XGetXCBConnection");
}
if (x_get_xcb_connection == NULL)
goto out;
XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
void *xdpy = x_open_display(NULL);
EGLDisplay dpy = glamor_egl_get_display(EGL_PLATFORM_X11_KHR, xdpy);
if (dpy == EGL_NO_DISPLAY)
goto out;
return XGetXCBConnection(dpy);
edpy = dpy;
eglInitialize(dpy, &major, &minor);
ret = x_get_xcb_connection(xdpy);
out:
if (lib)
dlclose(lib);
return ret;
}
return NULL;
}
void
......@@ -221,7 +249,7 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
if (ephyr_glamor_skip_present)
return;
glXMakeCurrent(dpy, glamor->glx_win, glamor->ctx);
eglMakeCurrent(glamor->dpy, glamor->egl_win, glamor->egl_win, glamor->ctx);
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &old_vao);
glBindVertexArray(glamor->vao);
......@@ -238,53 +266,12 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
glBindVertexArray(old_vao);
glXSwapBuffers(dpy, glamor->glx_win);
}
/**
* Xlib-based handling of xcb events for glamor.
*
* We need to let the Xlib event filtering run on the event so that
* Mesa's dri2_glx.c userspace event mangling gets run, and we
* correctly get our invalidate events propagated into the driver.
*/
void
ephyr_glamor_process_event(xcb_generic_event_t *xev)
{
uint32_t response_type = xev->response_type & 0x7f;
/* Note the types on wire_to_event: there's an Xlib XEvent (with
* the broken types) that it returns, and a protocol xEvent that
* it inspects.
*/
Bool (*wire_to_event)(Display *dpy, XEvent *ret, xEvent *event);
XLockDisplay(dpy);
/* Set the event handler to NULL to get access to the current one. */
wire_to_event = XESetWireToEvent(dpy, response_type, NULL);
if (wire_to_event) {
XEvent processed_event;
/* OK they had an event handler. Plug it back in, and call
* through to it.
*/
XESetWireToEvent(dpy, response_type, wire_to_event);
xev->sequence = LastKnownRequestProcessed(dpy);
wire_to_event(dpy, &processed_event, (xEvent *)xev);
}
XUnlockDisplay(dpy);
}
static int
ephyr_glx_error_handler(Display * _dpy, XErrorEvent * ev)
{
return 0;
eglSwapBuffers(glamor->dpy, glamor->egl_win);
}
struct ephyr_glamor *
ephyr_glamor_glx_screen_init(xcb_window_t win)
ephyr_glamor_screen_init(xcb_window_t win, xcb_visualid_t vid)
{
int (*oldErrorHandler) (Display *, XErrorEvent *);
static const float position[] = {
-1, -1,
1, -1,
......@@ -297,9 +284,9 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
};
GLint old_vao;
GLXContext ctx;
EGLContext ctx;
struct ephyr_glamor *glamor;
GLXWindow glx_win;
EGLSurface egl_win;
glamor = calloc(1, sizeof(struct ephyr_glamor));
if (!glamor) {
......@@ -307,56 +294,49 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
return NULL;
}
glx_win = glXCreateWindow(dpy, fb_config, win, NULL);
if (ephyr_glamor_gles2) {
static const int context_attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES_PROFILE_BIT_EXT,
0,
};
if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
"GLX_EXT_create_context_es2_profile")) {
ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
context_attribs);
} else {
FatalError("Xephyr -glamor_gles2 requires "
"GLX_EXT_create_context_es2_profile\n");
}
} else {
if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
"GLX_ARB_create_context")) {
static const int context_attribs[] = {
GLX_CONTEXT_PROFILE_MASK_ARB,
GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
GLX_CONTEXT_MAJOR_VERSION_ARB,
GLAMOR_GL_CORE_VER_MAJOR,
GLX_CONTEXT_MINOR_VERSION_ARB,
GLAMOR_GL_CORE_VER_MINOR,
0,
};
oldErrorHandler = XSetErrorHandler(ephyr_glx_error_handler);
ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
context_attribs);
XSync(dpy, False);
XSetErrorHandler(oldErrorHandler);
} else {
ctx = NULL;
}
const EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NATIVE_VISUAL_ID, vid,
EGL_NONE,
};
EGLConfig config = EGL_NO_CONFIG_KHR;
int num_configs = 0;
/* (loud booing (see above)) */
glamor->dpy = edpy;
eglChooseConfig(glamor->dpy, config_attribs, &config, 1, &num_configs);
if (num_configs != 1)
FatalError("Unable to find an EGLConfig for vid %#x\n", vid);
egl_win = eglCreatePlatformWindowSurfaceEXT(glamor->dpy, config,
&win, NULL);
if (ephyr_glamor_gles2)
eglBindAPI(EGL_OPENGL_ES_API);
else
eglBindAPI(EGL_OPENGL_API);
EGLint context_attribs[5];
int i = 0;
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
context_attribs[i++] = ephyr_glamor_gles2 ? 2 : 3;
context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION;
context_attribs[i++] = ephyr_glamor_gles2 ? 0 : 1;
context_attribs[i++] = EGL_NONE;
ctx = eglCreateContext(glamor->dpy, EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT,
context_attribs);
if (!ctx)
ctx = glXCreateContext(dpy, visual_info, NULL, True);
}
if (ctx == NULL)
FatalError("glXCreateContext failed\n");
FatalError("eglCreateContext failed\n");
if (!glXMakeCurrent(dpy, glx_win, ctx))
FatalError("glXMakeCurrent failed\n");
if (!eglMakeCurrent(glamor->dpy, egl_win, egl_win, ctx))
FatalError("eglMakeCurrent failed\n");
glamor->ctx = ctx;
glamor->win = win;
glamor->glx_win = glx_win;
glamor->egl_win = egl_win;
ephyr_glamor_setup_texturing_shader(glamor);
glGenVertexArrays(1, &glamor->vao);
......@@ -375,48 +355,17 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
}
void
ephyr_glamor_glx_screen_fini(struct ephyr_glamor *glamor)
ephyr_glamor_screen_fini(struct ephyr_glamor *glamor)
{
glXMakeCurrent(dpy, None, NULL);
glXDestroyContext(dpy, glamor->ctx);
glXDestroyWindow(dpy, glamor->glx_win);
eglMakeCurrent(glamor->dpy,
EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
eglDestroyContext(glamor->dpy, glamor->ctx);
eglDestroySurface(glamor->dpy, glamor->egl_win);
free(glamor);
}
xcb_visualtype_t *
ephyr_glamor_get_visual(void)
{
xcb_screen_t *xscreen =
xcb_aux_get_screen(XGetXCBConnection(dpy), DefaultScreen(dpy));
int attribs[] = {
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER, 1,
None
};
int event_base = 0, error_base = 0, nelements;
GLXFBConfig *fbconfigs;
if (!glXQueryExtension (dpy, &error_base, &event_base))
FatalError("Couldn't find GLX extension\n");
fbconfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &nelements);
if (!nelements)
FatalError("Couldn't choose an FBConfig\n");
fb_config = fbconfigs[0];
free(fbconfigs);
visual_info = glXGetVisualFromFBConfig(dpy, fb_config);
if (visual_info == NULL)
FatalError("Couldn't get RGB visual\n");
return xcb_aux_find_visual_by_id(xscreen, visual_info->visualid);
}
void
ephyr_glamor_set_window_size(struct ephyr_glamor *glamor,
unsigned width, unsigned height)
......
......@@ -21,13 +21,6 @@
* IN THE SOFTWARE.
*/
/**
* ephyr_glamor_glx.h
*
* Prototypes exposed by ephyr_glamor_glx.c, without including any
* server headers.
*/
#include <xcb/xcb.h>
#include "dix-config.h"
......@@ -40,14 +33,11 @@ ephyr_glamor_connect(void);
void
ephyr_glamor_set_texture(struct ephyr_glamor *ephyr_glamor, uint32_t tex);
xcb_visualtype_t *
ephyr_glamor_get_visual(void);
struct ephyr_glamor *
ephyr_glamor_glx_screen_init(xcb_window_t win);
ephyr_glamor_screen_init(xcb_window_t win, xcb_visualid_t vid);
void
ephyr_glamor_glx_screen_fini(struct ephyr_glamor *glamor);
ephyr_glamor_screen_fini(struct ephyr_glamor *glamor);
#ifdef GLAMOR
void
......@@ -58,9 +48,6 @@ void
ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
struct pixman_region16 *damage);
void
ephyr_glamor_process_event(xcb_generic_event_t *xev);
#else /* !GLAMOR */
static inline void
......@@ -75,9 +62,4 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
{
}
static inline void
ephyr_glamor_process_event(xcb_generic_event_t *xev)
{
}
#endif /* !GLAMOR */
......@@ -57,7 +57,7 @@
#ifdef GLAMOR
#include <epoxy/gl.h>
#include "glamor.h"
#include "ephyr_glamor_glx.h"
#include "ephyr_glamor.h"
#endif
#include "ephyrlog.h"
#include "ephyr.h"
......@@ -556,21 +556,7 @@ hostx_init(void)
HostX.winroot = xscreen->root;
HostX.gc = xcb_generate_id(HostX.conn);
HostX.depth = xscreen->root_depth;
#ifdef GLAMOR
if (ephyr_glamor) {
HostX.visual = ephyr_glamor_get_visual();
if (HostX.visual->visual_id != xscreen->root_visual) {
attrs[1] = xcb_generate_id(HostX.conn);
attr_mask |= XCB_CW_COLORMAP;
xcb_create_colormap(HostX.conn,
XCB_COLORMAP_ALLOC_NONE,
attrs[1],
HostX.winroot,
HostX.visual->visual_id);
}
} else
#endif
HostX.visual = xcb_aux_find_visual_by_id(xscreen,xscreen->root_visual);
HostX.visual = xcb_aux_find_visual_by_id(xscreen, xscreen->root_visual);
xcb_create_gc(HostX.conn, HostX.gc, HostX.winroot, 0, NULL);
cookie_WINDOW_STATE = xcb_intern_atom(HostX.conn, FALSE,
......@@ -586,6 +572,7 @@ hostx_init(void)
EphyrScrPriv *scrpriv = screen->driver;
scrpriv->win = xcb_generate_id(HostX.conn);
scrpriv->vid = xscreen->root_visual;
scrpriv->server_depth = HostX.depth;
scrpriv->ximg = NULL;
scrpriv->win_x = 0;
......@@ -1570,11 +1557,11 @@ ephyr_glamor_init(ScreenPtr screen)
KdScreenInfo *kd_screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = kd_screen->driver;
scrpriv->glamor = ephyr_glamor_glx_screen_init(scrpriv->win);
scrpriv->glamor = ephyr_glamor_screen_init(scrpriv->win, scrpriv->vid);
ephyr_glamor_set_window_size(scrpriv->glamor,
scrpriv->win_width, scrpriv->win_height);
if (!glamor_init(screen, 0)) {
if (!glamor_init(screen, GLAMOR_USE_EGL_SCREEN)) {
FatalError("Failed to initialize glamor\n");
return FALSE;
}
......@@ -1660,7 +1647,7 @@ ephyr_glamor_fini(ScreenPtr screen)
EphyrScrPriv *scrpriv = kd_screen->driver;
glamor_fini(screen);
ephyr_glamor_glx_screen_fini(scrpriv->glamor);
ephyr_glamor_screen_fini(scrpriv->glamor);
scrpriv->glamor = NULL;
}
#endif
......@@ -23,13 +23,12 @@ xephyr_dep = [
xephyr_glamor = []
if build_glamor
srcs += 'ephyr_glamor_glx.c'
srcs += 'ephyr_glamor.c'
if build_xv
srcs += 'ephyr_glamor_xv.c'
endif
xephyr_glamor += glamor
xephyr_glamor += glamor_egl_stubs
xephyr_dep += dependency('x11-xcb')
xephyr_dep += epoxy_dep
endif
......
......@@ -515,9 +515,41 @@ GetRec(ScrnInfoPtr pScrn)
return TRUE;
}
static void
rotate_clip(PixmapPtr pixmap, BoxPtr rect, drmModeClip *clip, Rotation rotation)
{
int w = pixmap->drawable.width;
int h = pixmap->drawable.height;
if (rotation == RR_Rotate_90) {
/* Rotate 90 degrees counter clockwise */
clip->x1 = rect->y1;
clip->x2 = rect->y2;
clip->y1 = w - rect->x2;
clip->y2 = w - rect->x1;
} else if (rotation == RR_Rotate_180) {
/* Rotate 180 degrees */
clip->x1 = w - rect->x2;
clip->x2 = w - rect->x1;
clip->y1 = h - rect->y2;
clip->y2 = h - rect->y1;
} else if (rotation == RR_Rotate_270) {
/* Rotate 90 degrees clockwise */
clip->x1 = h - rect->y2;
clip->x2 = h - rect->y1;
clip->y1 = rect->x1;
clip->y2 = rect->x2;
} else {
clip->x1 = rect->x1;
clip->x2 = rect->x2;
clip->y1 = rect->y1;
clip->y2 = rect->y2;
}
}
static int
dispatch_dirty_region(ScrnInfoPtr scrn,
PixmapPtr pixmap, DamagePtr damage, int fb_id)
dispatch_dirty_region(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
PixmapPtr pixmap, DamagePtr damage, int fb_id)
{
modesettingPtr ms = modesettingPTR(scrn);
RegionPtr dirty = DamageRegion(damage);
......@@ -532,13 +564,9 @@ dispatch_dirty_region(ScrnInfoPtr scrn,
if (!clip)
return -ENOMEM;
/* XXX no need for copy? */
for (i = 0; i < num_cliprects; i++, rect++) {
clip[i].x1 = rect->x1;
clip[i].y1 = rect->y1;
clip[i].x2 = rect->x2;
clip[i].y2 = rect->y2;
}
/* Rotate and copy rects into clips */
for (i = 0; i < num_cliprects; i++, rect++)
rotate_clip(pixmap, rect, &clip[i], crtc->rotation);
/* TODO query connector property to see if this is needed */
ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
......@@ -561,20 +589,31 @@ static void
dispatch_dirty(ScreenPtr pScreen)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
modesettingPtr ms = modesettingPTR(scrn);
PixmapPtr pixmap = pScreen->GetScreenPixmap(pScreen);
int fb_id = ms->drmmode.fb_id;
int ret;
uint32_t fb_id;
int ret, c, x, y ;
ret = dispatch_dirty_region(scrn, pixmap, ms->damage, fb_id);
if (ret == -EINVAL || ret == -ENOSYS) {
ms->dirty_enabled = FALSE;
DamageUnregister(ms->damage);
DamageDestroy(ms->damage);
ms->damage = NULL;
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"Disabling kernel dirty updates, not required.\n");
return;
for (c = 0; c < xf86_config->num_crtc; c++) {
xf86CrtcPtr crtc = xf86_config->crtc[c];
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
if (!drmmode_crtc)
continue;
drmmode_crtc_get_fb_id(crtc, &fb_id, &x, &y);
ret = dispatch_dirty_region(scrn, crtc, pixmap, ms->damage, fb_id);
if (ret == -EINVAL || ret == -ENOSYS) {
ms->dirty_enabled = FALSE;
DamageUnregister(ms->damage);
DamageDestroy(ms->damage);
ms->damage = NULL;
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"Disabling kernel dirty updates, not required.\n");
return;
}
}
}
......@@ -586,7 +625,7 @@ dispatch_dirty_pixmap(ScrnInfoPtr scrn, xf86CrtcPtr crtc, PixmapPtr ppix)
DamagePtr damage = ppriv->secondary_damage;
int fb_id = ppriv->fb_id;
dispatch_dirty_region(scrn, ppix, damage, fb_id);
dispatch_dirty_region(scrn, crtc, ppix, damage, fb_id);
}
static void
......
......@@ -627,7 +627,7 @@ drmmode_crtc_can_test_mode(xf86CrtcPtr crtc)
return ms->atomic_modeset;
}
static Bool
Bool
drmmode_crtc_get_fb_id(xf86CrtcPtr crtc, uint32_t *fb_id, int *x, int *y)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
......
......@@ -311,6 +311,8 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
int drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, uint32_t flags, void *data);
Bool drmmode_crtc_get_fb_id(xf86CrtcPtr crtc, uint32_t *fb_id, int *x, int *y);
void drmmode_set_dpms(ScrnInfoPtr scrn, int PowerManagementMode, int flags);
void drmmode_crtc_set_vrr(xf86CrtcPtr crtc, Bool enabled);
......
......@@ -119,7 +119,7 @@ hwEnableIO(void)
short i;
size_t n=0;
int begin, end;
char *buf=NULL, target[4];
char *buf=NULL, target[5];
FILE *fp;
if (ioperm(0, 1024, 1)) {
......@@ -129,6 +129,8 @@ hwEnableIO(void)
}
#if !defined(__alpha__)
target[4] = '\0';
/* trap access to the keyboard controller(s) and timer chip(s) */
fp = fopen("/proc/ioports", "r");
while (getline(&buf, &n, fp) != -1) {
......
......@@ -99,37 +99,6 @@ xwl_eglstream_get(struct xwl_screen *xwl_screen)
&xwl_eglstream_private_key);
}
static GLint
xwl_eglstream_compile_glsl_prog(GLenum type, const char *source)
{
GLint ok;
GLint prog;
prog = glCreateShader(type);
glShaderSource(prog, 1, (const GLchar **) &source, NULL);
glCompileShader(prog);
glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
if (!ok) {
GLchar *info;
GLint size;
glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
info = malloc(size);
if (info) {
glGetShaderInfoLog(prog, size, NULL, info);
ErrorF("Failed to compile %s: %s\n",
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
ErrorF("Program source:\n%s", source);
free(info);
}
else
ErrorF("Failed to get shader compilation info.\n");
FatalError("GLSL compile failure\n");
}
return prog;
}
static GLuint
xwl_eglstream_build_glsl_prog(GLuint vs, GLuint fs)
{
......@@ -775,8 +744,8 @@ xwl_eglstream_init_shaders(struct xwl_screen *xwl_screen)
0, 0,
};
vs = xwl_eglstream_compile_glsl_prog(GL_VERTEX_SHADER, blit_vs_src);
fs = xwl_eglstream_compile_glsl_prog(GL_FRAGMENT_SHADER, blit_fs_src);
vs = glamor_compile_glsl_prog(GL_VERTEX_SHADER, blit_vs_src);
fs = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, blit_fs_src);
xwl_eglstream->blit_prog = xwl_eglstream_build_glsl_prog(vs, fs);
glDeleteShader(vs);
......@@ -1020,8 +989,10 @@ xwl_glamor_eglstream_init_egl(struct xwl_screen *xwl_screen)
#endif
eglBindAPI(EGL_OPENGL_API);
xwl_screen->egl_context = eglCreateContext(
xwl_screen->egl_display, config, EGL_NO_CONTEXT, attrib_list);
xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
EGL_NO_CONFIG_KHR,
EGL_NO_CONTEXT,
attrib_list);
if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
ErrorF("Failed to create main EGL context: 0x%x\n", eglGetError());
goto error;
......