Commit 2f113d68 authored by Kristian Høgsberg's avatar Kristian Høgsberg Committed by Keith Packard

xwayland: Add glamor and DRI3 support

Reviewed-by: Axel Davy's avatarAxel Davy <axel.davy@ens.fr>
Signed-off-by: Kristian H. Kristensen's avatarKristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent fd16555c
...@@ -810,7 +810,7 @@ LIBDMX="dmx >= 1.0.99.1" ...@@ -810,7 +810,7 @@ LIBDMX="dmx >= 1.0.99.1"
LIBDRI="dri >= 7.8.0" LIBDRI="dri >= 7.8.0"
LIBDRM="libdrm >= 2.3.0" LIBDRM="libdrm >= 2.3.0"
LIBEGL="egl" LIBEGL="egl"
LIBGBM="gbm >= 9" LIBGBM="gbm >= 10.2.0"
LIBGL="gl >= 7.1.0" LIBGL="gl >= 7.1.0"
LIBXEXT="xext >= 1.0.99.4" LIBXEXT="xext >= 1.0.99.4"
LIBXFONT="xfont >= 1.4.2" LIBXFONT="xfont >= 1.4.2"
...@@ -2459,6 +2459,10 @@ if test "x$XWAYLAND" = xyes; then ...@@ -2459,6 +2459,10 @@ if test "x$XWAYLAND" = xyes; then
XWAYLAND_SYS_LIBS="$XWAYLANDMODULES_LIBS $GLX_SYS_LIBS" XWAYLAND_SYS_LIBS="$XWAYLANDMODULES_LIBS $GLX_SYS_LIBS"
AC_SUBST([XWAYLAND_LIBS]) AC_SUBST([XWAYLAND_LIBS])
AC_SUBST([XWAYLAND_SYS_LIBS]) AC_SUBST([XWAYLAND_SYS_LIBS])
WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client`
AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],,
[${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH])
fi fi
......
bin_PROGRAMS = Xwayland bin_PROGRAMS = Xwayland
Xwayland_CFLAGS = \ Xwayland_CFLAGS = \
-I$(top_srcdir)/glamor \
-I$(top_srcdir)/dri3 \ -I$(top_srcdir)/dri3 \
-DHAVE_DIX_CONFIG_H \ -DHAVE_DIX_CONFIG_H \
$(XWAYLANDMODULES_CFLAGS) \ $(XWAYLANDMODULES_CFLAGS) \
$(DIX_CFLAGS) $(DIX_CFLAGS) \
$(GLAMOR_CFLAGS) \
$(GBM_CFLAGS)
Xwayland_SOURCES = \ Xwayland_SOURCES = \
xwayland.c \ xwayland.c \
...@@ -19,6 +22,7 @@ Xwayland_SOURCES = \ ...@@ -19,6 +22,7 @@ Xwayland_SOURCES = \
$(top_srcdir)/mi/miinitext.c $(top_srcdir)/mi/miinitext.c
Xwayland_LDADD = \ Xwayland_LDADD = \
$(glamor_lib) \
$(XWAYLAND_LIBS) \ $(XWAYLAND_LIBS) \
$(XWAYLAND_SYS_LIBS) \ $(XWAYLAND_SYS_LIBS) \
$(XSERVER_SYS_LIBS) $(XSERVER_SYS_LIBS)
...@@ -26,5 +30,30 @@ Xwayland_DEPENDENCIES = $(XWAYLAND_LIBS) ...@@ -26,5 +30,30 @@ Xwayland_DEPENDENCIES = $(XWAYLAND_LIBS)
Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
if GLAMOR_EGL
Xwayland_SOURCES += xwayland-glamor.c
nodist_Xwayland_SOURCES = \
drm-client-protocol.h \
drm-protocol.c
CLEANFILES = $(nodist_Xwayland_SOURCES)
EXTRA_DIST = drm.xml
xwayland-glamor.c : $(nodist_Xwayland_SOURCES)
glamor_lib = $(top_builddir)/glamor/libglamor.la
Xwayland_LDADD += $(GLAMOR_LIBS) $(GBM_LIBS) -lEGL -lGL
endif
relink: relink:
$(AM_V_at)rm -f Xwayland$(EXEEXT) && $(MAKE) Xwayland$(EXEEXT) $(AM_V_at)rm -f Xwayland$(EXEEXT) && $(MAKE) Xwayland$(EXEEXT)
%-protocol.c : %.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
%-client-protocol.h : %.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="drm">
<copyright>
Copyright © 2008-2011 Kristian Høgsberg
Copyright © 2010-2011 Intel Corporation
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that\n the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<!-- drm support. This object is created by the server and published
using the display's global event. -->
<interface name="wl_drm" version="2">
<enum name="error">
<entry name="authenticate_fail" value="0"/>
<entry name="invalid_format" value="1"/>
<entry name="invalid_name" value="2"/>
</enum>
<enum name="format">
<!-- The drm format codes match the #defines in drm_fourcc.h.
The formats actually supported by the compositor will be
reported by the format event. -->
<entry name="c8" value="0x20203843"/>
<entry name="rgb332" value="0x38424752"/>
<entry name="bgr233" value="0x38524742"/>
<entry name="xrgb4444" value="0x32315258"/>
<entry name="xbgr4444" value="0x32314258"/>
<entry name="rgbx4444" value="0x32315852"/>
<entry name="bgrx4444" value="0x32315842"/>
<entry name="argb4444" value="0x32315241"/>
<entry name="abgr4444" value="0x32314241"/>
<entry name="rgba4444" value="0x32314152"/>
<entry name="bgra4444" value="0x32314142"/>
<entry name="xrgb1555" value="0x35315258"/>
<entry name="xbgr1555" value="0x35314258"/>
<entry name="rgbx5551" value="0x35315852"/>
<entry name="bgrx5551" value="0x35315842"/>
<entry name="argb1555" value="0x35315241"/>
<entry name="abgr1555" value="0x35314241"/>
<entry name="rgba5551" value="0x35314152"/>
<entry name="bgra5551" value="0x35314142"/>
<entry name="rgb565" value="0x36314752"/>
<entry name="bgr565" value="0x36314742"/>
<entry name="rgb888" value="0x34324752"/>
<entry name="bgr888" value="0x34324742"/>
<entry name="xrgb8888" value="0x34325258"/>
<entry name="xbgr8888" value="0x34324258"/>
<entry name="rgbx8888" value="0x34325852"/>
<entry name="bgrx8888" value="0x34325842"/>
<entry name="argb8888" value="0x34325241"/>
<entry name="abgr8888" value="0x34324241"/>
<entry name="rgba8888" value="0x34324152"/>
<entry name="bgra8888" value="0x34324142"/>
<entry name="xrgb2101010" value="0x30335258"/>
<entry name="xbgr2101010" value="0x30334258"/>
<entry name="rgbx1010102" value="0x30335852"/>
<entry name="bgrx1010102" value="0x30335842"/>
<entry name="argb2101010" value="0x30335241"/>
<entry name="abgr2101010" value="0x30334241"/>
<entry name="rgba1010102" value="0x30334152"/>
<entry name="bgra1010102" value="0x30334142"/>
<entry name="yuyv" value="0x56595559"/>
<entry name="yvyu" value="0x55595659"/>
<entry name="uyvy" value="0x59565955"/>
<entry name="vyuy" value="0x59555956"/>
<entry name="ayuv" value="0x56555941"/>
<entry name="nv12" value="0x3231564e"/>
<entry name="nv21" value="0x3132564e"/>
<entry name="nv16" value="0x3631564e"/>
<entry name="nv61" value="0x3136564e"/>
<entry name="yuv410" value="0x39565559"/>
<entry name="yvu410" value="0x39555659"/>
<entry name="yuv411" value="0x31315559"/>
<entry name="yvu411" value="0x31315659"/>
<entry name="yuv420" value="0x32315559"/>
<entry name="yvu420" value="0x32315659"/>
<entry name="yuv422" value="0x36315559"/>
<entry name="yvu422" value="0x36315659"/>
<entry name="yuv444" value="0x34325559"/>
<entry name="yvu444" value="0x34325659"/>
</enum>
<!-- Call this request with the magic received from drmGetMagic().
It will be passed on to the drmAuthMagic() or
DRIAuthConnection() call. This authentication must be
completed before create_buffer could be used. -->
<request name="authenticate">
<arg name="id" type="uint"/>
</request>
<!-- Create a wayland buffer for the named DRM buffer. The DRM
surface must have a name using the flink ioctl -->
<request name="create_buffer">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="uint"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="stride" type="uint"/>
<arg name="format" type="uint"/>
</request>
<!-- Create a wayland buffer for the named DRM buffer. The DRM
surface must have a name using the flink ioctl -->
<request name="create_planar_buffer">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="uint"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="format" type="uint"/>
<arg name="offset0" type="int"/>
<arg name="stride0" type="int"/>
<arg name="offset1" type="int"/>
<arg name="stride1" type="int"/>
<arg name="offset2" type="int"/>
<arg name="stride2" type="int"/>
</request>
<!-- Create a wayland buffer for the prime fd. Use for regular and planar
buffers. Pass 0 for offset and stride for unused planes. -->
<request name="create_prime_buffer" since="2">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="fd"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="format" type="uint"/>
<arg name="offset0" type="int"/>
<arg name="stride0" type="int"/>
<arg name="offset1" type="int"/>
<arg name="stride1" type="int"/>
<arg name="offset2" type="int"/>
<arg name="stride2" type="int"/>
</request>
<!-- Notification of the path of the drm device which is used by
the server. The client should use this device for creating
local buffers. Only buffers created from this device should
be be passed to the server using this drm object's
create_buffer request. -->
<event name="device">
<arg name="name" type="string"/>
</event>
<event name="format">
<arg name="format" type="uint"/>
</event>
<!-- Raised if the authenticate request succeeded -->
<event name="authenticated"/>
<enum name="capability" since="2">
<description summary="wl_drm capability bitmask">
Bitmask of capabilities.
</description>
<entry name="prime" value="1" summary="wl_drm prime available"/>
</enum>
<event name="capabilities">
<arg name="value" type="uint"/>
</event>
</interface>
</protocol>
This diff is collapsed.
...@@ -337,7 +337,13 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen) ...@@ -337,7 +337,13 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window); pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window);
buffer = xwl_shm_pixmap_get_wl_buffer(pixmap); #if GLAMOR_HAS_GBM
if (xwl_screen->glamor)
buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
#endif
if (!xwl_screen->glamor)
buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
wl_surface_attach(xwl_window->surface, buffer, 0, 0); wl_surface_attach(xwl_window->surface, buffer, 0, 0);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
box = &RegionRects(region)[i]; box = &RegionRects(region)[i];
...@@ -373,6 +379,12 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id, ...@@ -373,6 +379,12 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
xwl_output_create(xwl_screen, id); xwl_output_create(xwl_screen, id);
xwl_screen->expecting_event++; xwl_screen->expecting_event++;
} }
#ifdef GLAMOR_HAS_GBM
else if (xwl_screen->glamor &&
strcmp(interface, "wl_drm") == 0 && version >= 2) {
xwl_screen_init_glamor(xwl_screen, id, version);
}
#endif
} }
static void static void
...@@ -495,6 +507,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) ...@@ -495,6 +507,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen); dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen);
xwl_screen->screen = pScreen; xwl_screen->screen = pScreen;
#ifdef GLAMOR_HAS_GBM
xwl_screen->glamor = 1;
#endif
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-rootless") == 0) { if (strcmp(argv[i], "-rootless") == 0) {
xwl_screen->rootless = 1; xwl_screen->rootless = 1;
...@@ -514,6 +530,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) ...@@ -514,6 +530,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
atoi(argv[i + 1]); atoi(argv[i + 1]);
i++; i++;
} }
else if (strcmp(argv[i], "-shm") == 0) {
xwl_screen->glamor = 0;
}
} }
if (xwl_screen->listen_fd_count > 0) { if (xwl_screen->listen_fd_count > 0) {
...@@ -591,10 +610,19 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) ...@@ -591,10 +610,19 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
if (!xwl_screen_init_cursor(xwl_screen)) if (!xwl_screen_init_cursor(xwl_screen))
return FALSE; return FALSE;
xwl_screen->CreateScreenResources = pScreen->CreateScreenResources; #ifdef GLAMOR_HAS_GBM
pScreen->CreateScreenResources = xwl_shm_create_screen_resources; if (xwl_screen->glamor && !xwl_glamor_init(xwl_screen)) {
pScreen->CreatePixmap = xwl_shm_create_pixmap; ErrorF("Failed to initialize glamor, falling back to sw\n");
pScreen->DestroyPixmap = xwl_shm_destroy_pixmap; xwl_screen->glamor = 0;
}
#endif
if (!xwl_screen->glamor) {
xwl_screen->CreateScreenResources = pScreen->CreateScreenResources;
pScreen->CreateScreenResources = xwl_shm_create_screen_resources;
pScreen->CreatePixmap = xwl_shm_create_pixmap;
pScreen->DestroyPixmap = xwl_shm_destroy_pixmap;
}
xwl_screen->RealizeWindow = pScreen->RealizeWindow; xwl_screen->RealizeWindow = pScreen->RealizeWindow;
pScreen->RealizeWindow = xwl_realize_window; pScreen->RealizeWindow = xwl_realize_window;
......
...@@ -55,6 +55,7 @@ struct xwl_screen { ...@@ -55,6 +55,7 @@ struct xwl_screen {
int listen_fds[5]; int listen_fds[5];
int listen_fd_count; int listen_fd_count;
int rootless; int rootless;
int glamor;
CreateScreenResourcesProcPtr CreateScreenResources; CreateScreenResourcesProcPtr CreateScreenResources;
CloseScreenProcPtr CloseScreen; CloseScreenProcPtr CloseScreen;
...@@ -83,6 +84,16 @@ struct xwl_screen { ...@@ -83,6 +84,16 @@ struct xwl_screen {
#define XWL_FORMAT_RGB565 (1 << 2) #define XWL_FORMAT_RGB565 (1 << 2)
int prepare_read; int prepare_read;
char *device_name;
int drm_fd;
int fd_render_node;
struct wl_drm *drm;
uint32_t formats;
uint32_t capabilities;
void *egl_display, *egl_context;
struct gbm_device *gbm;
struct glamor_context *glamor_ctx;
}; };
struct xwl_window { struct xwl_window {
...@@ -161,4 +172,10 @@ Bool xwl_shm_destroy_pixmap(PixmapPtr pixmap); ...@@ -161,4 +172,10 @@ Bool xwl_shm_destroy_pixmap(PixmapPtr pixmap);
struct wl_buffer *xwl_shm_pixmap_get_wl_buffer(PixmapPtr pixmap); struct wl_buffer *xwl_shm_pixmap_get_wl_buffer(PixmapPtr pixmap);
Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
uint32_t id, uint32_t version);
struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment