egl/x11: Handle both depth 30 formats for eglCreateImage(). (v4)
authorMario Kleiner <mario.kleiner.de@gmail.com>
Wed, 13 Jun 2018 04:04:13 +0000 (06:04 +0200)
committerEric Engestrom <eric.engestrom@intel.com>
Wed, 1 Aug 2018 11:55:37 +0000 (12:55 +0100)
commit61a02729f749add535ad9d18c62f65641e428cfb
tree7647daf589e4c81349f6a01e362e23f08a31f805
parent753f603b52db5eb38e27e1842fa43299a348998b
egl/x11: Handle both depth 30 formats for eglCreateImage(). (v4)

We need to distinguish if the backing storage of a pixmap
is XRGB2101010 or XBGR2101010, as different gpu hw supports
different formats. NVidia hw prefers XBGR, whereas AMD and
Intel are happy with XRGB.

Use the red channel mask of the first depth 30 visual of
the x-screen to distinguish which hw format to choose.

This fixes desktop composition of color depth 30 windows
when the X11 compositor uses EGL.

v2: Switch from using the visual of the root window to simply
    using the first depth 30 visual for the x-screen, as testing
    shows that each driver only exports either xrgb ordering or
    xbgr ordering for the channel masks of its depth 30 visuals,
    so this should be unambiguous and avoid trouble if X ever
    supports depth 30 pixmaps on screens with a non-depth 30 root
    window visual. This per Michels suggestion.

v3: No change to v2, but spent some time testing this more on
    AMD hw, with my software hacked up to intentionally choose
    pixel formats/visual with the non-preferred xBGR2101010
    ordering on the ati-ddx, also with a standard non-OpenGL
    X-Window with depth 30 visual, to make sure that things show
    up properly with the right colors on the screen when going
    through EGL+OpenGL based compositing on KDE-5. Iow. to confirm
    that my explanation to the v2 patch on the mailing list of why
    it should work and the actual practice agree (or possibly that
    i am good at fooling myself during testing ;).

v4: Drop the local `red_mask` and just `return visual->red_mask`/
    `return 0`, as suggested by Eric Engestrom.

    Rebased onto current master, to take the cleanup via the new
    function dri2_format_for_depth() into account.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/platform_x11.c
src/egl/drivers/dri2/platform_x11_dri3.c
src/egl/drivers/dri2/platform_x11_dri3.h