From nobody Sat Apr 27 18:36:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493981406497825.9812464006565; Fri, 5 May 2017 03:50:06 -0700 (PDT) Received: from localhost ([::1]:46222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aoH-0003nQ-3E for importer@patchew.org; Fri, 05 May 2017 06:50:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aff-0004gR-B5 for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6afc-00088c-IB for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45450) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6afc-000884-Ah for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48C21804EE for ; Fri, 5 May 2017 10:41:07 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id A15D260BEF; Fri, 5 May 2017 10:41:04 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 8E15080AF2; Fri, 5 May 2017 12:41:03 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 48C21804EE Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 48C21804EE From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 12:40:56 +0200 Message-Id: <20170505104101.30589-2-kraxel@redhat.com> In-Reply-To: <20170505104101.30589-1-kraxel@redhat.com> References: <20170505104101.30589-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 05 May 2017 10:41:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/6] virtio-gpu: move virtio_gpu_gl_block X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move to virtio-gpu-3d.c where all the other virgl code lives too. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/virtio/virtio-gpu.h | 1 + hw/display/virtio-gpu-3d.c | 16 ++++++++++++++++ hw/display/virtio-gpu.c | 18 ++---------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index f3ffdceca4..83f474ffc3 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -169,6 +169,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd); void virtio_gpu_virgl_fence_poll(VirtIOGPU *g); void virtio_gpu_virgl_reset(VirtIOGPU *g); +void virtio_gpu_gl_block(void *opaque, bool block); int virtio_gpu_virgl_init(VirtIOGPU *g); =20 #endif diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index f49b7fe8cd..8c106a662d 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -600,6 +600,22 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g) } } =20 +void virtio_gpu_gl_block(void *opaque, bool block) +{ + VirtIOGPU *g =3D opaque; + + if (block) { + g->renderer_blocked++; + } else { + g->renderer_blocked--; + } + assert(g->renderer_blocked >=3D 0); + + if (g->renderer_blocked =3D=3D 0) { + virtio_gpu_process_cmdq(g); + } +} + int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index e1056f34df..cfb5dfa336 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -929,28 +929,14 @@ static int virtio_gpu_ui_info(void *opaque, uint32_t = idx, QemuUIInfo *info) return 0; } =20 -static void virtio_gpu_gl_block(void *opaque, bool block) -{ - VirtIOGPU *g =3D opaque; - - if (block) { - g->renderer_blocked++; - } else { - g->renderer_blocked--; - } - assert(g->renderer_blocked >=3D 0); - - if (g->renderer_blocked =3D=3D 0) { - virtio_gpu_process_cmdq(g); - } -} - const GraphicHwOps virtio_gpu_ops =3D { .invalidate =3D virtio_gpu_invalidate_display, .gfx_update =3D virtio_gpu_update_display, .text_update =3D virtio_gpu_text_update, .ui_info =3D virtio_gpu_ui_info, +#ifdef CONFIG_VIRGL .gl_block =3D virtio_gpu_gl_block, +#endif }; =20 static const VMStateDescription vmstate_virtio_gpu_scanout =3D { --=20 2.9.3 From nobody Sat Apr 27 18:36:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493981079982161.22621449320877; Fri, 5 May 2017 03:44:39 -0700 (PDT) Received: from localhost ([::1]:46196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aj0-0007lX-LA for importer@patchew.org; Fri, 05 May 2017 06:44:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aff-0004gV-Bi for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6afc-00088V-Gy for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37682) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6afc-00087z-83 for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22E8BC04B941 for ; Fri, 5 May 2017 10:41:07 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EC7317114; Fri, 5 May 2017 10:41:04 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id A001F80DDC; Fri, 5 May 2017 12:41:03 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 22E8BC04B941 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 22E8BC04B941 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 12:40:57 +0200 Message-Id: <20170505104101.30589-3-kraxel@redhat.com> In-Reply-To: <20170505104101.30589-1-kraxel@redhat.com> References: <20170505104101.30589-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 05 May 2017 10:41:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/6] egl-helpers: drop support for gles and debug logging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Leftover from the early opengl days. Unused now, so delete the dead code. Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/ui/egl-helpers.h | 2 +- ui/egl-helpers.c | 52 +++++---------------------------------------= ---- ui/gtk-egl.c | 2 +- 3 files changed, 7 insertions(+), 49 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 88a13e827b..fec7da14a5 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -21,7 +21,7 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *strid= e, EGLint *fourcc); =20 EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool gles, bool debug); +int qemu_egl_init_dpy(EGLNativeDisplayType dpy); EGLContext qemu_egl_init_ctx(void); =20 #endif /* EGL_HELPERS_H */ diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index b7b6b2e3cc..a3d7c3d7f5 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -26,18 +26,6 @@ EGLConfig qemu_egl_config; =20 /* ---------------------------------------------------------------------- = */ =20 -static bool egl_gles; -static int egl_debug; - -#define egl_dbg(_x ...) \ - do { \ - if (egl_debug) { \ - fprintf(stderr, "egl: " _x); \ - } \ - } while (0); - -/* ---------------------------------------------------------------------- = */ - #ifdef CONFIG_OPENGL_DMABUF =20 int qemu_egl_rn_fd; @@ -105,7 +93,7 @@ int egl_rendernode_init(const char *rendernode) goto err; } =20 - qemu_egl_init_dpy((EGLNativeDisplayType)qemu_egl_rn_gbm_dev, false, fa= lse); + qemu_egl_init_dpy((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); =20 if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { @@ -171,8 +159,6 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, W= indow win) EGLSurface esurface; EGLBoolean b; =20 - egl_dbg("eglCreateWindowSurface (x11 win id 0x%lx) ...\n", - (unsigned long) win); esurface =3D eglCreateWindowSurface(qemu_egl_display, qemu_egl_config, (EGLNativeWindowType)win, NULL); @@ -242,7 +228,7 @@ static EGLDisplay qemu_egl_get_display(void *native) return dpy; } =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool gles, bool debug) +int qemu_egl_init_dpy(EGLNativeDisplayType dpy) { static const EGLint conf_att_gl[] =3D { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, @@ -253,56 +239,34 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool = gles, bool debug) EGL_ALPHA_SIZE, 0, EGL_NONE, }; - static const EGLint conf_att_gles[] =3D { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 5, - EGL_BLUE_SIZE, 5, - EGL_ALPHA_SIZE, 0, - EGL_NONE, - }; EGLint major, minor; EGLBoolean b; EGLint n; =20 - if (debug) { - egl_debug =3D 1; - setenv("EGL_LOG_LEVEL", "debug", true); - setenv("LIBGL_DEBUG", "verbose", true); - } - - egl_dbg("qemu_egl_get_display (dpy %p) ...\n", dpy); qemu_egl_display =3D qemu_egl_get_display(dpy); if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { error_report("egl: eglGetDisplay failed"); return -1; } =20 - egl_dbg("eglInitialize ...\n"); b =3D eglInitialize(qemu_egl_display, &major, &minor); if (b =3D=3D EGL_FALSE) { error_report("egl: eglInitialize failed"); return -1; } =20 - egl_dbg("eglBindAPI ...\n"); - b =3D eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API); + b =3D eglBindAPI(EGL_OPENGL_API); if (b =3D=3D EGL_FALSE) { error_report("egl: eglBindAPI failed"); return -1; } =20 - egl_dbg("eglChooseConfig ...\n"); - b =3D eglChooseConfig(qemu_egl_display, - gles ? conf_att_gles : conf_att_gl, + b =3D eglChooseConfig(qemu_egl_display, conf_att_gl, &qemu_egl_config, 1, &n); if (b =3D=3D EGL_FALSE || n !=3D 1) { error_report("egl: eglChooseConfig failed"); return -1; } - - egl_gles =3D gles; return 0; } =20 @@ -311,17 +275,11 @@ EGLContext qemu_egl_init_ctx(void) static const EGLint ctx_att_gl[] =3D { EGL_NONE }; - static const EGLint ctx_att_gles[] =3D { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - EGLContext ectx; EGLBoolean b; =20 - egl_dbg("eglCreateContext ...\n"); ectx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, EGL_NO_CO= NTEXT, - egl_gles ? ctx_att_gles : ctx_att_gl); + ctx_att_gl); if (ectx =3D=3D EGL_NO_CONTEXT) { error_report("egl: eglCreateContext failed"); return NULL; diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index d53288f027..89492c0e02 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -246,7 +246,7 @@ void gtk_egl_init(void) GdkDisplay *gdk_display =3D gdk_display_get_default(); Display *x11_display =3D gdk_x11_display_get_xdisplay(gdk_display); =20 - if (qemu_egl_init_dpy(x11_display, false, false) < 0) { + if (qemu_egl_init_dpy(x11_display) < 0) { return; } =20 --=20 2.9.3 From nobody Sat Apr 27 18:36:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493981612594916.7966211406786; Fri, 5 May 2017 03:53:32 -0700 (PDT) Received: from localhost ([::1]:46240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6arX-0006rF-5n for importer@patchew.org; Fri, 05 May 2017 06:53:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aff-0004gS-B9 for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6afc-00088h-Ih for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6afc-000882-AM for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:08 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BD2480466 for ; Fri, 5 May 2017 10:41:07 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5EE881B50; Fri, 5 May 2017 10:41:04 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id B28AC80DE9; Fri, 5 May 2017 12:41:03 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3BD2480466 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3BD2480466 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 12:40:58 +0200 Message-Id: <20170505104101.30589-4-kraxel@redhat.com> In-Reply-To: <20170505104101.30589-1-kraxel@redhat.com> References: <20170505104101.30589-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 05 May 2017 10:41:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/6] egl-helpers: fix display init for x11 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When running on gtk we need X11 platform not mesa platform. Create separate functions for mesa and x11 so we can keep the egl #ifdef mess local to egl-helpers.c Fixes: 0ea1523fb6703aa0dcd65e66b59e96fec028e60a Signed-off-by: Gerd Hoffmann --- include/ui/egl-helpers.h | 3 ++- ui/egl-helpers.c | 34 ++++++++++++++++++++++++++-------- ui/gtk-egl.c | 2 +- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index fec7da14a5..c785d60e91 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -21,7 +21,8 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *strid= e, EGLint *fourcc); =20 EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy); +int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy); +int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy); EGLContext qemu_egl_init_ctx(void); =20 #endif /* EGL_HELPERS_H */ diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index a3d7c3d7f5..ec2e325e21 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -93,7 +93,7 @@ int egl_rendernode_init(const char *rendernode) goto err; } =20 - qemu_egl_init_dpy((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); + qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); =20 if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { @@ -206,20 +206,19 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx,= Window win) * platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't s= eem * like mesa will be able to advertise these (even though it can do EGL 1.= 5). */ -static EGLDisplay qemu_egl_get_display(void *native) +static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native, + EGLenum platform) { EGLDisplay dpy =3D EGL_NO_DISPLAY; =20 -#ifdef EGL_MESA_platform_gbm /* In practise any EGL 1.5 implementation would support the EXT extens= ion */ if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) { PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =3D (void *) eglGetProcAddress("eglGetPlatformDisplayEXT"); - if (getPlatformDisplayEXT) { - dpy =3D getPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, native, N= ULL); + if (getPlatformDisplayEXT && platform !=3D 0) { + dpy =3D getPlatformDisplayEXT(platform, native, NULL); } } -#endif =20 if (dpy =3D=3D EGL_NO_DISPLAY) { /* fallback */ @@ -228,7 +227,8 @@ static EGLDisplay qemu_egl_get_display(void *native) return dpy; } =20 -int qemu_egl_init_dpy(EGLNativeDisplayType dpy) +static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, + EGLenum platform) { static const EGLint conf_att_gl[] =3D { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, @@ -243,7 +243,7 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy) EGLBoolean b; EGLint n; =20 - qemu_egl_display =3D qemu_egl_get_display(dpy); + qemu_egl_display =3D qemu_egl_get_display(dpy, platform); if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { error_report("egl: eglGetDisplay failed"); return -1; @@ -270,6 +270,24 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy) return 0; } =20 +int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy) +{ +#ifdef EGL_KHR_platform_x11 + return qemu_egl_init_dpy(dpy, EGL_PLATFORM_X11_KHR); +#else + return qemu_egl_init_dpy(dpy, 0); +#endif +} + +int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy) +{ +#ifdef EGL_MESA_platform_gbm + return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA); +#else + return qemu_egl_init_dpy(dpy, 0); +#endif +} + EGLContext qemu_egl_init_ctx(void) { static const EGLint ctx_att_gl[] =3D { diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 89492c0e02..cf48cca259 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -246,7 +246,7 @@ void gtk_egl_init(void) GdkDisplay *gdk_display =3D gdk_display_get_default(); Display *x11_display =3D gdk_x11_display_get_xdisplay(gdk_display); =20 - if (qemu_egl_init_dpy(x11_display) < 0) { + if (qemu_egl_init_dpy_x11(x11_display) < 0) { return; } =20 --=20 2.9.3 From nobody Sat Apr 27 18:36:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493981283083841.669120276086; Fri, 5 May 2017 03:48:03 -0700 (PDT) Received: from localhost ([::1]:46215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6amH-00025S-Mc for importer@patchew.org; Fri, 05 May 2017 06:48:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aff-0004gU-Ba for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6afc-000889-6g for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36518) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6afc-00087q-0h for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B034E80C04 for ; Fri, 5 May 2017 10:41:06 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id A79FF1715F; Fri, 5 May 2017 10:41:04 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id C2D1A80E0E; Fri, 5 May 2017 12:41:03 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B034E80C04 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B034E80C04 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 12:40:59 +0200 Message-Id: <20170505104101.30589-5-kraxel@redhat.com> In-Reply-To: <20170505104101.30589-1-kraxel@redhat.com> References: <20170505104101.30589-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 05 May 2017 10:41:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/6] egl-helpers: add missing error check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Code didn't check for qemu_egl_init_dpy_mesa() failures, add it. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/egl-helpers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index ec2e325e21..b50225158b 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -80,6 +80,7 @@ static int qemu_egl_rendernode_open(const char *rendernod= e) int egl_rendernode_init(const char *rendernode) { qemu_egl_rn_fd =3D -1; + int rc; =20 qemu_egl_rn_fd =3D qemu_egl_rendernode_open(rendernode); if (qemu_egl_rn_fd =3D=3D -1) { @@ -93,7 +94,11 @@ int egl_rendernode_init(const char *rendernode) goto err; } =20 - qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); + rc =3D qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_de= v); + if (rc !=3D 0) { + /* qemu_egl_init_dpy_mesa reports error */ + goto err; + } =20 if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { --=20 2.9.3 From nobody Sat Apr 27 18:36:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493981154215484.6503797551421; Fri, 5 May 2017 03:45:54 -0700 (PDT) Received: from localhost ([::1]:46209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6akC-0000My-R4 for importer@patchew.org; Fri, 05 May 2017 06:45:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aff-0004gb-CF for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6afd-00088w-6m for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6afd-00088K-0o for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F121261D38 for ; Fri, 5 May 2017 10:41:07 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id A65421715F; Fri, 5 May 2017 10:41:07 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id D57CA80E25; Fri, 5 May 2017 12:41:03 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F121261D38 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F121261D38 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 12:41:00 +0200 Message-Id: <20170505104101.30589-6-kraxel@redhat.com> In-Reply-To: <20170505104101.30589-1-kraxel@redhat.com> References: <20170505104101.30589-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 05 May 2017 10:41:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/6] egl: explicitly ask for core context X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann --- ui/egl-context.c | 7 ++++--- ui/egl-helpers.c | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/egl-context.c b/ui/egl-context.c index 3a02b68d1a..2161969abe 100644 --- a/ui/egl-context.c +++ b/ui/egl-context.c @@ -7,9 +7,10 @@ QEMUGLContext qemu_egl_create_context(DisplayChangeListene= r *dcl, { EGLContext ctx; EGLint ctx_att[] =3D { - EGL_CONTEXT_CLIENT_VERSION, params->major_ver, - EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver, - EGL_NONE + EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BI= T, + EGL_CONTEXT_CLIENT_VERSION, params->major_ver, + EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver, + EGL_NONE }; =20 ctx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index b50225158b..4a4d3370ee 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -296,6 +296,7 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy) EGLContext qemu_egl_init_ctx(void) { static const EGLint ctx_att_gl[] =3D { + EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_B= IT, EGL_NONE }; EGLContext ectx; --=20 2.9.3 From nobody Sat Apr 27 18:36:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493981527300540.9192851442709; Fri, 5 May 2017 03:52:07 -0700 (PDT) Received: from localhost ([::1]:46234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aqC-0005QJ-8Z for importer@patchew.org; Fri, 05 May 2017 06:52:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6aff-0004gW-Bz for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6afd-00089A-Ox for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48428) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6afd-00088l-Fb for qemu-devel@nongnu.org; Fri, 05 May 2017 06:41:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67CA43B70D for ; Fri, 5 May 2017 10:41:08 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDC894F6DC; Fri, 5 May 2017 10:41:07 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id EA55780E55; Fri, 5 May 2017 12:41:03 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67CA43B70D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 67CA43B70D From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 12:41:01 +0200 Message-Id: <20170505104101.30589-7-kraxel@redhat.com> In-Reply-To: <20170505104101.30589-1-kraxel@redhat.com> References: <20170505104101.30589-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 05 May 2017 10:41:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 6/6] opengl: add egl-headless display X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add egl-headless user interface. It doesn't provide a real user interface, it only provides opengl support using drm render nodes. It will copy back the bits rendered by the guest using virgl back to a DisplaySurface and kick the usual display update code paths, so spice and vnc and screendump can pick it up. Use it this way: qemu -display egl-headless -vnc $display qemu -display egl-headless -spice gl=3Doff,$args Note that you should prefer native spice opengl support (-spice gl=3Don) if possible because that delivers better performance. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 3 + ui/egl-headless.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ vl.c | 16 ++++++ ui/Makefile.objs | 1 + 4 files changed, 178 insertions(+) create mode 100644 ui/egl-headless.c diff --git a/include/ui/console.h b/include/ui/console.h index d759338816..7262bef6d3 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -527,4 +527,7 @@ static inline void early_gtk_display_init(int opengl) } #endif =20 +/* egl-headless.c */ +void egl_headless_init(void); + #endif diff --git a/ui/egl-headless.c b/ui/egl-headless.c new file mode 100644 index 0000000000..d8d800f8a6 --- /dev/null +++ b/ui/egl-headless.c @@ -0,0 +1,158 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "ui/console.h" +#include "ui/egl-helpers.h" +#include "ui/egl-context.h" + +typedef struct egl_dpy { + DisplayChangeListener dcl; + DisplaySurface *ds; + int width, height; + GLuint texture; + GLuint framebuffer; + GLuint blit_texture; + GLuint blit_framebuffer; + bool y_0_top; +} egl_dpy; + +static void egl_refresh(DisplayChangeListener *dcl) +{ + graphic_hw_update(dcl->con); +} + +static void egl_gfx_update(DisplayChangeListener *dcl, + int x, int y, int w, int h) +{ +} + +static void egl_gfx_switch(DisplayChangeListener *dcl, + struct DisplaySurface *new_surface) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->ds =3D new_surface; +} + +static void egl_scanout_disable(DisplayChangeListener *dcl) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->texture =3D 0; + /* XXX: delete framebuffers here ??? */ +} + +static void egl_scanout_texture(DisplayChangeListener *dcl, + uint32_t backing_id, + bool backing_y_0_top, + uint32_t backing_width, + uint32_t backing_height, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->texture =3D backing_id; + edpy->y_0_top =3D backing_y_0_top; + + /* source framebuffer */ + if (!edpy->framebuffer) { + glGenFramebuffers(1, &edpy->framebuffer); + } + glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->framebuffer); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, edpy->texture, 0); + + /* dest framebuffer */ + if (!edpy->blit_framebuffer) { + glGenFramebuffers(1, &edpy->blit_framebuffer); + glGenTextures(1, &edpy->blit_texture); + edpy->width =3D 0; + edpy->height =3D 0; + } + if (edpy->width !=3D backing_width || edpy->height !=3D backing_height= ) { + edpy->width =3D backing_width; + edpy->height =3D backing_height; + glBindTexture(GL_TEXTURE_2D, edpy->blit_texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, + edpy->width, edpy->height, + 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); + glBindFramebuffer(GL_FRAMEBUFFER_EXT, edpy->blit_framebuffer); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0= _EXT, + GL_TEXTURE_2D, edpy->blit_texture, 0); + } +} + +static void egl_scanout_flush(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + GLuint y1, y2; + + if (!edpy->texture || !edpy->ds) { + return; + } + assert(surface_width(edpy->ds) =3D=3D edpy->width); + assert(surface_height(edpy->ds) =3D=3D edpy->height); + assert(surface_format(edpy->ds) =3D=3D PIXMAN_x8r8g8b8); + + /* blit framebuffer, flip if needed */ + glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->framebuffer); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, edpy->blit_framebuffer); + glViewport(0, 0, edpy->width, edpy->height); + y1 =3D edpy->y_0_top ? edpy->height : 0; + y2 =3D edpy->y_0_top ? 0 : edpy->height; + glBlitFramebuffer(0, y1, edpy->width, y2, + 0, 0, edpy->width, edpy->height, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + + /* read pixels to surface */ + glBindFramebuffer(GL_READ_FRAMEBUFFER, edpy->blit_framebuffer); + glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); + glReadPixels(0, 0, edpy->width, edpy->height, + GL_BGRA, GL_UNSIGNED_BYTE, surface_data(edpy->ds)); + + /* notify about updates */ + dpy_gfx_update(edpy->dcl.con, x, y, w, h); +} + +static const DisplayChangeListenerOps egl_ops =3D { + .dpy_name =3D "egl-headless", + .dpy_refresh =3D egl_refresh, + .dpy_gfx_update =3D egl_gfx_update, + .dpy_gfx_switch =3D egl_gfx_switch, + + .dpy_gl_ctx_create =3D qemu_egl_create_context, + .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, + .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, + .dpy_gl_ctx_get_current =3D qemu_egl_get_current_context, + + .dpy_gl_scanout_disable =3D egl_scanout_disable, + .dpy_gl_scanout_texture =3D egl_scanout_texture, + .dpy_gl_update =3D egl_scanout_flush, +}; + +void egl_headless_init(void) +{ + QemuConsole *con; + egl_dpy *edpy; + int idx; + + if (egl_rendernode_init(NULL) < 0) { + error_report("egl: render node init failed"); + exit(1); + } + + for (idx =3D 0;; idx++) { + con =3D qemu_console_lookup_by_index(idx); + if (!con || !qemu_console_is_graphic(con)) { + break; + } + + edpy =3D g_new0(egl_dpy, 1); + edpy->dcl.con =3D con; + edpy->dcl.ops =3D &egl_ops; + register_displaychangelistener(&edpy->dcl); + } +} diff --git a/vl.c b/vl.c index f46e070e0d..4e76e0ceb4 100644 --- a/vl.c +++ b/vl.c @@ -2050,6 +2050,7 @@ typedef enum DisplayType { DT_SDL, DT_COCOA, DT_GTK, + DT_EGL, DT_NONE, } DisplayType; =20 @@ -2127,6 +2128,15 @@ static DisplayType select_display(const char *p) error_report("VNC requires a display argument vnc=3D"= ); exit(1); } + } else if (strstart(p, "egl-headless", &opts)) { +#ifdef CONFIG_OPENGL + request_opengl =3D 1; + display_opengl =3D 1; + display =3D DT_EGL; +#else + fprintf(stderr, "egl support is disabled\n"); + exit(1); +#endif } else if (strstart(p, "curses", &opts)) { #ifdef CONFIG_CURSES display =3D DT_CURSES; @@ -4662,6 +4672,12 @@ int main(int argc, char **argv, char **envp) qemu_spice_display_init(); } =20 +#ifdef CONFIG_OPENGL + if (display_type =3D=3D DT_EGL) { + egl_headless_init(); + } +#endif + if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { exit(1); } diff --git a/ui/Makefile.objs b/ui/Makefile.objs index 27566b32f1..aac6ae8bef 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -33,6 +33,7 @@ common-obj-y +=3D shader.o common-obj-y +=3D console-gl.o common-obj-y +=3D egl-helpers.o common-obj-y +=3D egl-context.o +common-obj-y +=3D egl-headless.o ifeq ($(CONFIG_GTK_GL),y) common-obj-$(CONFIG_GTK) +=3D gtk-gl-area.o else --=20 2.9.3