From 1e3165980c352f90d0f1295bfc4fbfa31193b13f Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 12 Oct 2015 12:03:49 +0200 Subject: egl-helpers: add functions for render nodes and dma-buf passing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds helpers to open a drm render node and create a opengl context for it. Also add a helper to export a texture as dma-buf. Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau --- include/ui/egl-helpers.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/ui') diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 8c84398001..03fcf4bba2 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -3,10 +3,23 @@ #include #include +#include extern EGLDisplay *qemu_egl_display; extern EGLConfig qemu_egl_config; +#ifdef CONFIG_OPENGL_DMABUF + +extern int qemu_egl_rn_fd; +extern struct gbm_device *qemu_egl_rn_gbm_dev; +extern EGLContext qemu_egl_rn_ctx; + +int qemu_egl_rendernode_open(void); +int egl_rendernode_init(void); +int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc); + +#endif + EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool gles, bool debug); -- cgit v1.2.3 From 474114b7305cc1be7c2ee8ba5267be159a9d56e3 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 13 Oct 2015 15:39:34 +0200 Subject: spice: add opengl/virgl/dmabuf support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds support for dma-buf passing to spice. This makes virtio-gpu with 3d acceleration work with spice. Workflow: * virglrenderer renders the guest command stream into a texture. * qemu exports the texture as dma-buf and passes on that dma-buf to spice-server. * spice-server passes the dma-buf to spice-client, using unix socket file descriptor passing. * spice-client asks the window systems composer to render the dma-buf to the screen. Requires cutting edge spice (server) and spice-gtk (client) builds, from git master branch. Also requires libvirt managing your qemu instance, and using "virt-viewer --attach $guest". libvirt will connect spice-server and spice-client using unix sockets instead of tcp sockets then, which is required for file descriptor passing. Works for the local case (spice server and client on the same machine) only. Supporting remote too is planned (by feeding the dma-bufs into gpu-assisted video encoder), but not there yet. gl mode is turned off by default, use "-spice gl=on,$otherargs" to enable it. Signed-off-by: Marc-André Lureau Signed-off-by: Gerd Hoffmann --- include/ui/spice-display.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/ui') diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index b25328a6ba..48dc8c4990 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -24,6 +24,14 @@ #include "ui/console.h" #include "sysemu/sysemu.h" +#if defined(CONFIG_OPENGL_DMABUF) +# if SPICE_SERVER_VERSION >= 0x000d00 /* release 0.13.0 */ +# define HAVE_SPICE_GL 1 +# include "ui/egl-helpers.h" +# include "ui/egl-context.h" +# endif +#endif + #define NUM_MEMSLOTS 8 #define MEMSLOT_GENERATION_BITS 8 #define MEMSLOT_SLOT_BITS 8 @@ -50,6 +58,7 @@ enum { QXL_COOKIE_TYPE_IO, QXL_COOKIE_TYPE_RENDER_UPDATE_AREA, QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG, + QXL_COOKIE_TYPE_GL_DRAW_DONE, }; typedef struct QXLCookie { @@ -104,6 +113,12 @@ struct SimpleSpiceDisplay { QEMUCursor *cursor; int mouse_x, mouse_y; QEMUBH *cursor_bh; + +#ifdef HAVE_SPICE_GL + /* opengl rendering */ + QEMUBH *gl_unblock_bh; + int dmabuf_fd; +#endif }; struct SimpleSpiceUpdate { -- cgit v1.2.3 From 8e388e907b853ca42f5c8825042fa17b126d86de Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 19 Feb 2016 07:46:47 +0100 Subject: spice/gl: add unblock timer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure debug aid, print a warning in case unblocking doesn't happen within one second. Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau --- include/ui/spice-display.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/ui') diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 48dc8c4990..69a222b543 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -117,6 +117,7 @@ struct SimpleSpiceDisplay { #ifdef HAVE_SPICE_GL /* opengl rendering */ QEMUBH *gl_unblock_bh; + QEMUTimer *gl_unblock_timer; int dmabuf_fd; #endif }; -- cgit v1.2.3