From nobody Tue Feb 10 17:08:29 2026 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.zohomail.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508239119239969.6566792800488; Tue, 17 Oct 2017 04:18:39 -0700 (PDT) Received: from localhost ([::1]:37789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4PtL-0000ep-Eb for importer@patchew.org; Tue, 17 Oct 2017 07:18:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Pou-0005KT-DF for qemu-devel@nongnu.org; Tue, 17 Oct 2017 07:14:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Poq-0001u5-Re for qemu-devel@nongnu.org; Tue, 17 Oct 2017 07:14:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4Poq-0001tG-K0 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 07:13:56 -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 BFD8CC0587E9 for ; Tue, 17 Oct 2017 11:13:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CBFB77FEE; Tue, 17 Oct 2017 11:13:55 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EE5CB40574; Tue, 17 Oct 2017 13:13:50 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BFD8CC0587E9 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 13:13:50 +0200 Message-Id: <20171017111350.8176-7-kraxel@redhat.com> In-Reply-To: <20171017111350.8176-1-kraxel@redhat.com> References: <20171017111350.8176-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.32]); Tue, 17 Oct 2017 11:13:55 +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] [PULL 6/6] egl-headless: add dmabuf support 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" Add support for the new dmabuf interface. Signed-off-by: Gerd Hoffmann Message-id: 20171010135453.6704-7-kraxel@redhat.com --- ui/egl-headless.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 12ad64e995..5d50226869 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -4,13 +4,18 @@ #include "ui/console.h" #include "ui/egl-helpers.h" #include "ui/egl-context.h" +#include "ui/shader.h" =20 typedef struct egl_dpy { DisplayChangeListener dcl; DisplaySurface *ds; + QemuGLShader *gls; egl_fb guest_fb; + egl_fb cursor_fb; egl_fb blit_fb; bool y_0_top; + uint32_t pos_x; + uint32_t pos_y; } egl_dpy; =20 /* ------------------------------------------------------------------ */ @@ -65,6 +70,43 @@ static void egl_scanout_texture(DisplayChangeListener *d= cl, } } =20 +static void egl_scanout_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + egl_dmabuf_import_texture(dmabuf); + if (!dmabuf->texture) { + return; + } + + egl_scanout_texture(dcl, dmabuf->texture, + false, dmabuf->width, dmabuf->height, + 0, 0, dmabuf->width, dmabuf->height); +} + +static void egl_cursor_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf, + uint32_t pos_x, uint32_t pos_y) +{ + egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); + + edpy->pos_x =3D pos_x; + edpy->pos_y =3D pos_y; + + egl_dmabuf_import_texture(dmabuf); + if (!dmabuf->texture) { + return; + } + + egl_fb_setup_for_tex(&edpy->cursor_fb, dmabuf->width, dmabuf->height, + dmabuf->texture, false); +} + +static void egl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + egl_dmabuf_release_texture(dmabuf); +} + static void egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) @@ -78,9 +120,18 @@ static void egl_scanout_flush(DisplayChangeListener *dc= l, assert(surface_height(edpy->ds) =3D=3D edpy->guest_fb.height); assert(surface_format(edpy->ds) =3D=3D PIXMAN_x8r8g8b8); =20 - egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top); + if (edpy->cursor_fb.texture) { + /* have cursor -> render using textures */ + egl_texture_blit(edpy->gls, &edpy->blit_fb, &edpy->guest_fb, + !edpy->y_0_top); + egl_texture_blend(edpy->gls, &edpy->blit_fb, &edpy->cursor_fb, + !edpy->y_0_top, edpy->pos_x, edpy->pos_y); + } else { + /* no cursor -> use simple framebuffer blit */ + egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top); + } + egl_fb_read(surface_data(edpy->ds), &edpy->blit_fb); - dpy_gfx_update(edpy->dcl.con, x, y, w, h); } =20 @@ -97,6 +148,9 @@ static const DisplayChangeListenerOps egl_ops =3D { =20 .dpy_gl_scanout_disable =3D egl_scanout_disable, .dpy_gl_scanout_texture =3D egl_scanout_texture, + .dpy_gl_scanout_dmabuf =3D egl_scanout_dmabuf, + .dpy_gl_cursor_dmabuf =3D egl_cursor_dmabuf, + .dpy_gl_release_dmabuf =3D egl_release_dmabuf, .dpy_gl_update =3D egl_scanout_flush, }; =20 @@ -120,6 +174,7 @@ void egl_headless_init(void) edpy =3D g_new0(egl_dpy, 1); edpy->dcl.con =3D con; edpy->dcl.ops =3D &egl_ops; + edpy->gls =3D qemu_gl_init_shader(); register_displaychangelistener(&edpy->dcl); } } --=20 2.9.3