From nobody Tue Feb 10 21:41:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071239; cv=none; d=zohomail.com; s=zohoarc; b=Q3pVwhzt6E3RfeH3obfuw2dkpVsgpAHftZnWcWBwomn4fM7XuXH0FHiI5d9B/k6WDi1hOH/YE1OIu+LiAGl2aNdqo37sWi5e7hZKxPWugvn32NIysjAEBJBmF6YqEgiNFK5e5z1cVA8olhyC7qONQiuKNQ10D2g2SZFMbPbsvAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f8UvDTsSg5s/5xh4bXNQhmRbd8oCeKhx4pniuOht2/g=; b=az2zu6SyKMhiTZ0NFbTJyEcotgNuT5dlYGKfpSllb34XPDzIqdHaEmYokK+zn5zcCMot8fTh4dzhXp2CRaF0QMr3aK63FKMHjNBA0TrkHsXtUv914H6j7o7D/rEEMqMQ0b6SGQZXwlEKpQIxC9bTRl9q1FRMelwmoMp/tIwJxBk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1640071239536742.6896123306881; Mon, 20 Dec 2021 23:20:39 -0800 (PST) Received: from localhost ([::1]:50288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZRs-0002l3-QG for importer@patchew.org; Tue, 21 Dec 2021 02:20:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAc-00055i-0P for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAa-000250-3C for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-5xpnZumAOj29DB56ZZSznw-1; Tue, 21 Dec 2021 02:02:42 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 614FC2F25; Tue, 21 Dec 2021 07:02:41 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5DF57EDB9; Tue, 21 Dec 2021 07:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f8UvDTsSg5s/5xh4bXNQhmRbd8oCeKhx4pniuOht2/g=; b=cuBD0mNxTOmn7663HPohsBtWHJJ04qC32LG5Sb8myjlB6yMjqxV8dITYVnyFrZfvRgowev 7SKi9f0LhehEvVZg9BVzQb9RfWonhQLTw85UXv+pEF/kTLS5jgd9fkjRKzShPaSbE977K0 exkOh58+6pJ2TDMrS5PmNj4M6vX1ug4= X-MC-Unique: 5xpnZumAOj29DB56ZZSznw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 14/36] ui: simplify gl unblock & flush Date: Tue, 21 Dec 2021 10:58:33 +0400 Message-Id: <20211221065855.142578-15-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071240271100001 From: Marc-Andr=C3=A9 Lureau GraphicHw.gl_flushed was introduced to notify the device (vhost-user-gpu) that the GL resources (the display scanout) are no longer needed. It was decoupled from QEMU own gl-blocking mechanism, but that difference isn't helping. Instead, we can reuse QEMU gl-blocking and notify virtio_gpu_gl_flushed() when unblocking (to unlock vhost-user-gpu). An extra block/unblock is added arount dpy_gl_update() so existing backends that don't block will have the flush event handled. It will also help when there are no backends associated. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/console.h | 2 -- hw/display/vhost-user-gpu.c | 2 +- hw/display/virtio-gpu-base.c | 5 ++++- hw/display/virtio-vga.c | 11 ----------- ui/console.c | 12 +++--------- ui/gtk-egl.c | 2 -- ui/gtk-gl-area.c | 2 -- ui/gtk.c | 1 - ui/sdl2-gl.c | 2 -- ui/spice-display.c | 1 - 10 files changed, 8 insertions(+), 32 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index fb10e6d60cd7..3ff51b492e5b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -391,7 +391,6 @@ typedef struct GraphicHwOps { void (*update_interval)(void *opaque, uint64_t interval); int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); void (*gl_block)(void *opaque, bool block); - void (*gl_flushed)(void *opaque); } GraphicHwOps; =20 QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, @@ -407,7 +406,6 @@ void graphic_hw_update_done(QemuConsole *con); void graphic_hw_invalidate(QemuConsole *con); void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); void graphic_hw_gl_block(QemuConsole *con, bool block); -void graphic_hw_gl_flushed(QemuConsole *con); =20 void qemu_console_early_init(void); =20 diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 49df56cd14e9..09818231bd24 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -254,8 +254,8 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) vhost_user_gpu_unblock(g); break; } - dpy_gl_update(con, m->x, m->y, m->width, m->height); g->backend_blocked =3D true; + dpy_gl_update(con, m->x, m->y, m->width, m->height); break; } case VHOST_USER_GPU_UPDATE: { diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index c8da4806e0bb..fff0fb4a828a 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -117,6 +117,10 @@ virtio_gpu_gl_block(void *opaque, bool block) g->renderer_blocked--; } assert(g->renderer_blocked >=3D 0); + + if (!block && g->renderer_blocked =3D=3D 0) { + virtio_gpu_gl_flushed(g); + } } =20 static int @@ -143,7 +147,6 @@ static const GraphicHwOps virtio_gpu_ops =3D { .text_update =3D virtio_gpu_text_update, .ui_info =3D virtio_gpu_ui_info, .gl_block =3D virtio_gpu_gl_block, - .gl_flushed =3D virtio_gpu_gl_flushed, }; =20 bool diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 9e57f61e9edb..b23a75a04b9d 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -68,16 +68,6 @@ static void virtio_vga_base_gl_block(void *opaque, bool = block) } } =20 -static void virtio_vga_base_gl_flushed(void *opaque) -{ - VirtIOVGABase *vvga =3D opaque; - VirtIOGPUBase *g =3D vvga->vgpu; - - if (g->hw_ops->gl_flushed) { - g->hw_ops->gl_flushed(g); - } -} - static int virtio_vga_base_get_flags(void *opaque) { VirtIOVGABase *vvga =3D opaque; @@ -93,7 +83,6 @@ static const GraphicHwOps virtio_vga_base_ops =3D { .text_update =3D virtio_vga_base_text_update, .ui_info =3D virtio_vga_base_ui_info, .gl_block =3D virtio_vga_base_gl_block, - .gl_flushed =3D virtio_vga_base_gl_flushed, }; =20 static const VMStateDescription vmstate_virtio_vga_base =3D { diff --git a/ui/console.c b/ui/console.c index fcc4fe6a0aa0..6f21007737e5 100644 --- a/ui/console.c +++ b/ui/console.c @@ -267,15 +267,6 @@ void graphic_hw_gl_block(QemuConsole *con, bool block) } } =20 -void graphic_hw_gl_flushed(QemuConsole *con) -{ - assert(con !=3D NULL); - - if (con->hw_ops->gl_flushed) { - con->hw_ops->gl_flushed(con->hw); - } -} - int qemu_console_get_window_id(QemuConsole *con) { return con->window_id; @@ -1894,7 +1885,10 @@ void dpy_gl_update(QemuConsole *con, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { assert(con->gl); + + graphic_hw_gl_block(con, true); con->gl->ops->dpy_gl_update(con->gl, x, y, w, h); + graphic_hw_gl_block(con, false); } =20 /***********************************************************/ diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 45cb67712df0..e891b61048a8 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -119,8 +119,6 @@ void gd_egl_draw(VirtualConsole *vc) =20 glFlush(); } - - graphic_hw_gl_flushed(vc->gfx.dcl.con); } =20 void gd_egl_update(DisplayChangeListener *dcl, diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 01e4e74ee361..f1c7636cba98 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -101,8 +101,6 @@ void gd_gl_area_draw(VirtualConsole *vc) surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh); surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds); } - - graphic_hw_gl_flushed(vc->gfx.dcl.con); } =20 void gd_gl_area_update(DisplayChangeListener *dcl, diff --git a/ui/gtk.c b/ui/gtk.c index 25896023ffe7..077d38145de8 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -593,7 +593,6 @@ void gd_hw_gl_flushed(void *vcon) close(dmabuf->fence_fd); dmabuf->fence_fd =3D -1; graphic_hw_gl_block(vc->gfx.dcl.con, false); - graphic_hw_gl_flushed(vc->gfx.dcl.con); } =20 /** DisplayState Callbacks (opengl version) **/ diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index a21d2deed916..5b950fbbea2f 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -58,7 +58,6 @@ static void sdl2_gl_render_surface(struct sdl2_console *s= con) =20 surface_gl_render_texture(scon->gls, scon->surface); SDL_GL_SwapWindow(scon->real_window); - graphic_hw_gl_flushed(scon->dcl.con); } =20 void sdl2_gl_update(DisplayChangeListener *dcl, @@ -241,5 +240,4 @@ void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top); =20 SDL_GL_SwapWindow(scon->real_window); - graphic_hw_gl_flushed(dcl->con); } diff --git a/ui/spice-display.c b/ui/spice-display.c index 2c204bceee27..ec501f129f07 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -830,7 +830,6 @@ static void qemu_spice_gl_unblock_bh(void *opaque) SimpleSpiceDisplay *ssd =3D opaque; =20 qemu_spice_gl_block(ssd, false); - graphic_hw_gl_flushed(ssd->dcl.con); } =20 static void qemu_spice_gl_block_timer(void *opaque) --=20 2.34.1.8.g35151cf07204