From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645100397412635.6983616003529; Thu, 17 Feb 2022 04:19:57 -0800 (PST) Received: from localhost ([::1]:52118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKflL-0001Vc-Uh for importer@patchew.org; Thu, 17 Feb 2022 07:19:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfRN-00050Q-FJ for qemu-devel@nongnu.org; Thu, 17 Feb 2022 06:59:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfRL-0001BV-RQ for qemu-devel@nongnu.org; Thu, 17 Feb 2022 06:59:17 -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-225-sb5Rtt10NiO_hfdU9p_uLA-1; Thu, 17 Feb 2022 06:59:09 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A5BD1853024; Thu, 17 Feb 2022 11:59:08 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DAED108648D; Thu, 17 Feb 2022 11:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099150; 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=+72i9z7e73MgY074con63qdOaJdfDGS5Fa4BUnZPh50=; b=PmA3iExewrAhG/i20Uxn5ePjpNXyD+K6tiJTPe1iweXknggkWm9yDqacbaRGgcror3d7Or dQvIVlMQCbU9rnYP55QVCJTCRlmoLnnfynlTBHyYP9DvczFEcG1tUvknFJ7hOTUnKee4Nj FT+giqYMmYJif0QVRvKZ0sx4+HIrPyY= X-MC-Unique: sb5Rtt10NiO_hfdU9p_uLA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 01/12] ui/console: fix crash when using gl context with non-gl listeners Date: Thu, 17 Feb 2022 15:58:18 +0400 Message-Id: <20220217115829.2314347-2-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645100398829100001 From: Marc-Andr=C3=A9 Lureau The commit 7cc712e98 ("ui: dispatch GL events to all listener") mechanically replaced the dpy_gl calls with a dispatch loop, using the same pre-conditions. However, it didn't take into account that all listeners do not have to implement the GL callbacks. Add the missing pre-conditions before calling the callbacks. Fix crash when running a GL-enabled VM with "-device virtio-gpu-gl-pci -display egl-headless -vnc :0". Fixes: 7cc712e98 ("ui: dispatch GL events to all listener") Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ui/console.c b/ui/console.c index 40eebb6d2cc2..79a01afd1ea7 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1860,7 +1860,9 @@ void dpy_gl_scanout_disable(QemuConsole *con) con->scanout.kind =3D SCANOUT_NONE; } QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_scanout_disable(dcl); + if (dcl->ops->dpy_gl_scanout_disable) { + dcl->ops->dpy_gl_scanout_disable(dcl); + } } } =20 @@ -1881,10 +1883,12 @@ void dpy_gl_scanout_texture(QemuConsole *con, x, y, width, height }; QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_scanout_texture(dcl, backing_id, - backing_y_0_top, - backing_width, backing_height, - x, y, width, height); + if (dcl->ops->dpy_gl_scanout_texture) { + dcl->ops->dpy_gl_scanout_texture(dcl, backing_id, + backing_y_0_top, + backing_width, backing_height, + x, y, width, height); + } } } =20 @@ -1897,7 +1901,9 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, con->scanout.kind =3D SCANOUT_DMABUF; con->scanout.dmabuf =3D dmabuf; QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); + if (dcl->ops->dpy_gl_scanout_dmabuf) { + dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); + } } } =20 @@ -1951,7 +1957,9 @@ void dpy_gl_update(QemuConsole *con, =20 graphic_hw_gl_block(con, true); QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_update(dcl, x, y, w, h); + if (dcl->ops->dpy_gl_update) { + dcl->ops->dpy_gl_update(dcl, x, y, w, h); + } } graphic_hw_gl_block(con, false); } --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645100726661665.7110909780147; Thu, 17 Feb 2022 04:25:26 -0800 (PST) Received: from localhost ([::1]:58886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKfqf-0006NJ-89 for importer@patchew.org; Thu, 17 Feb 2022 07:25:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfRn-0006Vc-V7 for qemu-devel@nongnu.org; Thu, 17 Feb 2022 06:59:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfRm-0001FG-F0 for qemu-devel@nongnu.org; Thu, 17 Feb 2022 06:59:43 -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-589-r9lW0J1fPEatWSOsSTpzSg-1; Thu, 17 Feb 2022 06:59:39 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 098BF1853028; Thu, 17 Feb 2022 11:59:38 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A79773146; Thu, 17 Feb 2022 11:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099181; 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=Xd1wCtHOUdWyn1wICNVybJ+lJ9wf6hUnyrfwpvgaL18=; b=iH8sBHdpYROy43in0GjTfBq75CZ3PSukMolqPzQCUvBKbwZ/8WyY1ibtsGZGGi7f0lZ48J 5KLAv6p57brLOwsvpZIzdn4ezpZ+bRh9u5Y7fJH8yjAl44zISK6JaJz7WvAgJ98A5mMvZW IE9aUu6YIUfP4T9ckqGtZhIrX2u95A8= X-MC-Unique: r9lW0J1fPEatWSOsSTpzSg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 02/12] ui/console: fix texture leak when calling surface_gl_create_texture() Date: Thu, 17 Feb 2022 15:58:19 +0400 Message-Id: <20220217115829.2314347-3-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645100728136100001 From: Marc-Andr=C3=A9 Lureau Make surface_gl_create_texture() idempotent: if the surface is already bound to a texture, do not create a new one. This fixes texture leaks when there are multiple DBus listeners, for example. Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console-gl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/console-gl.c b/ui/console-gl.c index 7c9894a51d99..8e3c9a3c8c01 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -49,6 +49,10 @@ void surface_gl_create_texture(QemuGLShader *gls, assert(gls); assert(QEMU_IS_ALIGNED(surface_stride(surface), surface_bytes_per_pixe= l(surface))); =20 + if (surface->texture) { + return; + } + switch (surface->format) { case PIXMAN_BE_b8g8r8x8: case PIXMAN_BE_b8g8r8a8: --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645100733474292.0646063782325; Thu, 17 Feb 2022 04:25:33 -0800 (PST) Received: from localhost ([::1]:59168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKfqm-0006ZX-DQ for importer@patchew.org; Thu, 17 Feb 2022 07:25:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfS0-0007FH-Vr for qemu-devel@nongnu.org; Thu, 17 Feb 2022 06:59:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfRz-0001Fz-DJ for qemu-devel@nongnu.org; Thu, 17 Feb 2022 06:59:56 -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-421-yx_nhTttOGWAZkMjR6veag-1; Thu, 17 Feb 2022 06:59:53 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E07241006AA0; Thu, 17 Feb 2022 11:59:52 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id E984F7C0CC; Thu, 17 Feb 2022 11:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099194; 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=z3/fLVN0f8FmK2BpekjUIonMnz89spwYrYp7oriaLhQ=; b=F1Ou7XsapzNfCu6mUHl+vT5b7plFHUz+dZLd90LVXqjrB7Mp5L3TSjQVawuf440Uh6bDbG g/3Al5uxe0Vcc3QgvQosh/cr6awrUKpKwbNlRkrOeV9OXKA6Ran5pCWKGjuje/FzNbrnmy PAlxIdODohl4cGyFFhcuFxaRDcB35uk= X-MC-Unique: yx_nhTttOGWAZkMjR6veag-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 03/12] ui: do not create a surface when resizing a GL scanout Date: Thu, 17 Feb 2022 15:58:20 +0400 Message-Id: <20220217115829.2314347-4-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645100735823100001 From: Marc-Andr=C3=A9 Lureau qemu_console_resize() will create a blank surface and replace the current scanout with it if called while the current scanout is GL (texture or dmabuf). This is not only very costly, but also can produce glitches on the display/listener side. Instead, compare the current console size with the fitting console functions, which also works when the scanout is GL. Note: there might be still an unnecessary surface creation on calling qemu_console_resize() when the size is actually changing, but display backends currently rely on DisplaySurface details during dpy_gfx_switch() to handle various resize aspects. We would need more refactoring to handle resize without DisplaySurface, this is left for a future improvement. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/console.c b/ui/console.c index 79a01afd1ea7..365a2c14b809 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2400,13 +2400,12 @@ static void vc_chr_open(Chardev *chr, =20 void qemu_console_resize(QemuConsole *s, int width, int height) { - DisplaySurface *surface =3D qemu_console_surface(s); + DisplaySurface *surface; =20 assert(s->console_type =3D=3D GRAPHIC_CONSOLE); =20 - if (surface && (surface->flags & QEMU_ALLOCATED_FLAG) && - pixman_image_get_width(surface->image) =3D=3D width && - pixman_image_get_height(surface->image) =3D=3D height) { + if (qemu_console_get_width(s, -1) =3D=3D width && + qemu_console_get_height(s, -1) =3D=3D height) { return; } =20 --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645100973972982.7329498001366; Thu, 17 Feb 2022 04:29:33 -0800 (PST) Received: from localhost ([::1]:37348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKfug-0002fX-5T for importer@patchew.org; Thu, 17 Feb 2022 07:29:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfSX-0007qI-V7 for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:00:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfSW-0001YM-05 for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:00:29 -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-551-bc1lfWf-OX6JfCfGBxy7xg-1; Thu, 17 Feb 2022 07:00:26 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52D43801AC5; Thu, 17 Feb 2022 12:00:25 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D33E66E33; Thu, 17 Feb 2022 11:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099227; 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=q9H2nuo2ugwOgD6+ZO4ABhkAteCErk3GCcKKop4U28c=; b=OcvjaxSNajilteiQDvdhp709oxzIrTzNkpenMsm7prDRhz1/SjAR2chDlhlZHz+LsqAGWj yVyBYE0Gadt1CBtMfws6ocPiBuPT67L9dmiA85InId141g4G1wIWPdgSSskmzTiwErfYgb DkVjompzxe3ZMj0MbReek6ZxSp/6ywQ= X-MC-Unique: bc1lfWf-OX6JfCfGBxy7xg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 04/12] ui/console: move check for compatible GL context Date: Thu, 17 Feb 2022 15:58:21 +0400 Message-Id: <20220217115829.2314347-5-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645100975767100001 From: Marc-Andr=C3=A9 Lureau Move GL context compatibility check in dpy_compatible_with(), and use recommended error reporting. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/ui/console.c b/ui/console.c index 365a2c14b809..57e431d9e609 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1482,6 +1482,12 @@ static bool dpy_compatible_with(QemuConsole *con, =20 flags =3D con->hw_ops->get_flags ? con->hw_ops->get_flags(con->hw) : 0; =20 + if (console_has_gl(con) && con->gl->ops->compatible_dcl !=3D dcl->ops)= { + error_setg(errp, "Display %s is incompatible with the GL context", + dcl->ops->dpy_name); + return false; + } + if (flags & GRAPHIC_FLAGS_GL && !console_has_gl(con)) { error_setg(errp, "The console requires a GL context."); @@ -1509,27 +1515,12 @@ void qemu_console_set_display_gl_ctx(QemuConsole *c= on, DisplayGLCtx *gl) con->gl =3D gl; } =20 -static bool dpy_gl_compatible_with(QemuConsole *con, DisplayChangeListener= *dcl) -{ - if (!con->gl) { - return true; - } - - return con->gl->ops->compatible_dcl =3D=3D dcl->ops; -} - void register_displaychangelistener(DisplayChangeListener *dcl) { QemuConsole *con; =20 assert(!dcl->ds); =20 - if (dcl->con && !dpy_gl_compatible_with(dcl->con, dcl)) { - error_report("Display %s is incompatible with the GL context", - dcl->ops->dpy_name); - exit(1); - } - if (dcl->con) { dpy_compatible_with(dcl->con, dcl, &error_fatal); } --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645100969510522.8684416163311; Thu, 17 Feb 2022 04:29:29 -0800 (PST) Received: from localhost ([::1]:37162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKfua-0002Xb-9q for importer@patchew.org; Thu, 17 Feb 2022 07:29:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfT8-0008Ac-P0 for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfT6-0001e9-Kq for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:06 -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-288-kuqrFFDZO0KAs5_afTb9eQ-1; Thu, 17 Feb 2022 07:01:00 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3AA4344B7; Thu, 17 Feb 2022 12:00:59 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7053B6F12F; Thu, 17 Feb 2022 12:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099264; 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=07fm8LkSpDlrVD4DOtbSfH4o9GmCmMBJi3+LNFNUmSk=; b=C9VAxDLW/JWZZ8N4IbKpWvDb45ueI5AZM5aInh2dXUo+H1+/HkpIAJT3wOEXDr5hcdSGAH Ox6uGKzIf4stVoqWjRs2rv9ZS8I1MM1MZ98j6nA8tyux6TO0wvGJqHcuJnQ390Ugzem019 C/3N+SIGeGSRn/OIPEEizWootSg+ruY= X-MC-Unique: kuqrFFDZO0KAs5_afTb9eQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 05/12] ui/console: move dcl compatiblity check to a callback Date: Thu, 17 Feb 2022 15:58:22 +0400 Message-Id: <20220217115829.2314347-6-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645100972121100001 From: Marc-Andr=C3=A9 Lureau As expected from the "compatible_dcl" comment, a simple comparison of ops isn't enough. The following patch will fix a regression introduced by this limited check by extending the compatibility callback for egl-headless. For now, this patch simply replaces the the "compatible_dcl" ops pointer with a "dpy_gl_ctx_is_compatible_ctx" callback. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 9 ++------- ui/console.c | 3 ++- ui/dbus.c | 9 ++++++++- ui/egl-headless.c | 9 ++++++++- ui/gtk.c | 18 ++++++++++++++++-- ui/sdl2.c | 9 ++++++++- ui/spice-display.c | 9 ++++++++- 7 files changed, 52 insertions(+), 14 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index f590819880b5..18a10c0b7db0 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -282,13 +282,8 @@ struct DisplayChangeListener { }; =20 typedef struct DisplayGLCtxOps { - /* - * We only check if the GLCtx is compatible with a DCL via ops. A natu= ral - * evolution of this would be a callback to check some runtime require= ments - * and allow various DCL kinds. - */ - const DisplayChangeListenerOps *compatible_dcl; - + bool (*dpy_gl_ctx_is_compatible_dcl)(DisplayGLCtx *dgc, + DisplayChangeListener *dcl); QEMUGLContext (*dpy_gl_ctx_create)(DisplayGLCtx *dgc, QEMUGLParams *params); void (*dpy_gl_ctx_destroy)(DisplayGLCtx *dgc, diff --git a/ui/console.c b/ui/console.c index 57e431d9e609..c9318552871b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1482,7 +1482,8 @@ static bool dpy_compatible_with(QemuConsole *con, =20 flags =3D con->hw_ops->get_flags ? con->hw_ops->get_flags(con->hw) : 0; =20 - if (console_has_gl(con) && con->gl->ops->compatible_dcl !=3D dcl->ops)= { + if (console_has_gl(con) && + !con->gl->ops->dpy_gl_ctx_is_compatible_dcl(con->gl, dcl)) { error_setg(errp, "Display %s is incompatible with the GL context", dcl->ops->dpy_name); return false; diff --git a/ui/dbus.c b/ui/dbus.c index 0074424c1fed..f00a44421cf7 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -48,8 +48,15 @@ static QEMUGLContext dbus_create_context(DisplayGLCtx *d= gc, return qemu_egl_create_context(dgc, params); } =20 +static bool +dbus_is_compatible_dcl(DisplayGLCtx *dgc, + DisplayChangeListener *dcl) +{ + return dcl->ops =3D=3D &dbus_gl_dcl_ops; +} + static const DisplayGLCtxOps dbus_gl_ops =3D { - .compatible_dcl =3D &dbus_gl_dcl_ops, + .dpy_gl_ctx_is_compatible_dcl =3D dbus_is_compatible_dcl, .dpy_gl_ctx_create =3D dbus_create_context, .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 94082a9da951..9aff115280bc 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -166,8 +166,15 @@ static const DisplayChangeListenerOps egl_ops =3D { .dpy_gl_update =3D egl_scanout_flush, }; =20 +static bool +egl_is_compatible_dcl(DisplayGLCtx *dgc, + DisplayChangeListener *dcl) +{ + return dcl->ops =3D=3D &egl_ops; +} + static const DisplayGLCtxOps eglctx_ops =3D { - .compatible_dcl =3D &egl_ops, + .dpy_gl_ctx_is_compatible_dcl =3D egl_is_compatible_dcl, .dpy_gl_ctx_create =3D egl_create_context, .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, diff --git a/ui/gtk.c b/ui/gtk.c index a8567b9ddc8f..1b24a67d7964 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -614,8 +614,15 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = =3D { .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 +static bool +gd_gl_area_is_compatible_dcl(DisplayGLCtx *dgc, + DisplayChangeListener *dcl) +{ + return dcl->ops =3D=3D &dcl_gl_area_ops; +} + static const DisplayGLCtxOps gl_area_ctx_ops =3D { - .compatible_dcl =3D &dcl_gl_area_ops, + .dpy_gl_ctx_is_compatible_dcl =3D gd_gl_area_is_compatible_dcl, .dpy_gl_ctx_create =3D gd_gl_area_create_context, .dpy_gl_ctx_destroy =3D gd_gl_area_destroy_context, .dpy_gl_ctx_make_current =3D gd_gl_area_make_current, @@ -641,8 +648,15 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 +static bool +gd_egl_is_compatible_dcl(DisplayGLCtx *dgc, + DisplayChangeListener *dcl) +{ + return dcl->ops =3D=3D &dcl_egl_ops; +} + static const DisplayGLCtxOps egl_ctx_ops =3D { - .compatible_dcl =3D &dcl_egl_ops, + .dpy_gl_ctx_is_compatible_dcl =3D gd_egl_is_compatible_dcl, .dpy_gl_ctx_create =3D gd_egl_create_context, .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, .dpy_gl_ctx_make_current =3D gd_egl_make_current, diff --git a/ui/sdl2.c b/ui/sdl2.c index 46a252d7d9d7..d3741f9b754d 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -788,8 +788,15 @@ static const DisplayChangeListenerOps dcl_gl_ops =3D { .dpy_gl_update =3D sdl2_gl_scanout_flush, }; =20 +static bool +sdl2_gl_is_compatible_dcl(DisplayGLCtx *dgc, + DisplayChangeListener *dcl) +{ + return dcl->ops =3D=3D &dcl_gl_ops; +} + static const DisplayGLCtxOps gl_ctx_ops =3D { - .compatible_dcl =3D &dcl_gl_ops, + .dpy_gl_ctx_is_compatible_dcl =3D sdl2_gl_is_compatible_dcl, .dpy_gl_ctx_create =3D sdl2_gl_create_context, .dpy_gl_ctx_destroy =3D sdl2_gl_destroy_context, .dpy_gl_ctx_make_current =3D sdl2_gl_make_context_current, diff --git a/ui/spice-display.c b/ui/spice-display.c index a3078adf91ec..494168e7fe75 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1125,8 +1125,15 @@ static const DisplayChangeListenerOps display_listen= er_gl_ops =3D { .dpy_gl_update =3D qemu_spice_gl_update, }; =20 +static bool +qemu_spice_is_compatible_dcl(DisplayGLCtx *dgc, + DisplayChangeListener *dcl) +{ + return dcl->ops =3D=3D &display_listener_gl_ops; +} + static const DisplayGLCtxOps gl_ctx_ops =3D { - .compatible_dcl =3D &display_listener_gl_ops, + .dpy_gl_ctx_is_compatible_dcl =3D qemu_spice_is_compatible_dcl, .dpy_gl_ctx_create =3D qemu_spice_gl_create_context, .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645100961201257.81498803476654; Thu, 17 Feb 2022 04:29:21 -0800 (PST) Received: from localhost ([::1]:37104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKfuJ-0002VM-Hr for importer@patchew.org; Thu, 17 Feb 2022 07:29:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTD-0008ES-IV for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTC-0001eu-1D for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:11 -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-518-6Vcv8Q64Pzy6p1QjZgrqzw-1; Thu, 17 Feb 2022 07:01:06 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 706FE1091DA2; Thu, 17 Feb 2022 12:01:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6513327CD2; Thu, 17 Feb 2022 12:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099269; 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=QLkvJRjLKNBuAEw2de7FXHN2e3+VFXy5HXa+jAEnO9Y=; b=bYub0DGcbSfWWpXDrRyoVsiYanYA2WPqq+FKb+d6yya2Q5EWy6dInAAY8AKExHE9trTYuA 6xy8qLr86et44AoxiWTeQjSS5meTbxiJGa/mnyDBN5lcU84dgonEcQ8Yp+7fCnWCBe3On7 Xydn7jpYXEjq2eUJCsG34Yi/3prpehA= X-MC-Unique: 6Vcv8Q64Pzy6p1QjZgrqzw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 06/12] ui/console: egl-headless is compatible with non-gl listeners Date: Thu, 17 Feb 2022 15:58:23 +0400 Message-Id: <20220217115829.2314347-7-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645100961679100001 From: Marc-Andr=C3=A9 Lureau Fix a regression introduced by commit 5e79d516e ("ui: split the GL context in a different object"). Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/egl-headless.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 9aff115280bc..7a30fd977765 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -170,6 +170,14 @@ static bool egl_is_compatible_dcl(DisplayGLCtx *dgc, DisplayChangeListener *dcl) { + if (!dcl->ops->dpy_gl_update) { + /* + * egl-headless is compatible with all 2d listeners, as it blits t= he GL + * updates on the 2d console surface. + */ + return true; + } + return dcl->ops =3D=3D &egl_ops; } =20 --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645101199377918.9547102195105; Thu, 17 Feb 2022 04:33:19 -0800 (PST) Received: from localhost ([::1]:43898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKfyH-0007Vc-Qa for importer@patchew.org; Thu, 17 Feb 2022 07:33:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTJ-0008OF-NU for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTH-0001fJ-Ay for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:17 -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-139-ao7C21CZP-WC7SadAJtx_g-1; Thu, 17 Feb 2022 07:01:11 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F2101876545; Thu, 17 Feb 2022 12:01:10 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 266EB7C0CD; Thu, 17 Feb 2022 12:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099274; 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=yQ+dWvvRK/WAqV3N1iOJs9kcGEkqiUKSdEo65+Rdm2k=; b=Hyqs7F88oOCiVQDlp4MHTZsQIFvE/63xxayybl3AhXOKkC1B48jrEV37njOhEIIRDKzo9v dtOrtHAEganOhhVGe/m8T7d2nrJYzNhljv7J/HG9A10VI+GWovWniiI4vEsylX665n/SPg XwzuxZSmQB70SQjWVHWsiRP79h7Cntc= X-MC-Unique: ao7C21CZP-WC7SadAJtx_g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 07/12] ui/dbus: associate the DBusDisplayConsole listener with the given console Date: Thu, 17 Feb 2022 15:58:24 +0400 Message-Id: <20220217115829.2314347-8-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645101199849100001 From: Marc-Andr=C3=A9 Lureau DBusDisplayConsole is specific to a given QemuConsole. Fixes: commit 142ca628 ("ui: add a D-Bus display backend") Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus.h | 3 +++ ui/dbus-console.c | 27 +++++++++++++-------------- ui/dbus.c | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ui/dbus.h b/ui/dbus.h index 64c77cab4441..5f5c1f759c9b 100644 --- a/ui/dbus.h +++ b/ui/dbus.h @@ -79,6 +79,9 @@ dbus_display_console_new(DBusDisplay *display, QemuConsol= e *con); int dbus_display_console_get_index(DBusDisplayConsole *ddc); =20 + +extern const DisplayChangeListenerOps dbus_console_dcl_ops; + #define DBUS_DISPLAY_TYPE_LISTENER dbus_display_listener_get_type() G_DECLARE_FINAL_TYPE(DBusDisplayListener, dbus_display_listener, diff --git a/ui/dbus-console.c b/ui/dbus-console.c index e062f721d761..898a4ac8a5ba 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -36,7 +36,6 @@ struct _DBusDisplayConsole { DisplayChangeListener dcl; =20 DBusDisplay *display; - QemuConsole *con; GHashTable *listeners; QemuDBusDisplay1Console *iface; =20 @@ -118,7 +117,7 @@ dbus_gl_scanout_update(DisplayChangeListener *dcl, { } =20 -static const DisplayChangeListenerOps dbus_console_dcl_ops =3D { +const DisplayChangeListenerOps dbus_console_dcl_ops =3D { .dpy_name =3D "dbus-console", .dpy_gfx_switch =3D dbus_gfx_switch, .dpy_gfx_update =3D dbus_gfx_update, @@ -191,7 +190,7 @@ dbus_console_set_ui_info(DBusDisplayConsole *ddc, .height =3D arg_height, }; =20 - if (!dpy_ui_info_supported(ddc->con)) { + if (!dpy_ui_info_supported(ddc->dcl.con)) { g_dbus_method_invocation_return_error(invocation, DBUS_DISPLAY_ERROR, DBUS_DISPLAY_ERROR_UNSUPPORT= ED, @@ -199,7 +198,7 @@ dbus_console_set_ui_info(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 - dpy_set_ui_info(ddc->con, &info, false); + dpy_set_ui_info(ddc->dcl.con, &info, false); qemu_dbus_display1_console_complete_set_uiinfo(ddc->iface, invocation); return DBUS_METHOD_INVOCATION_HANDLED; } @@ -335,8 +334,8 @@ dbus_mouse_rel_motion(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 - qemu_input_queue_rel(ddc->con, INPUT_AXIS_X, dx); - qemu_input_queue_rel(ddc->con, INPUT_AXIS_Y, dy); + qemu_input_queue_rel(ddc->dcl.con, INPUT_AXIS_X, dx); + qemu_input_queue_rel(ddc->dcl.con, INPUT_AXIS_Y, dy); qemu_input_event_sync(); =20 qemu_dbus_display1_mouse_complete_rel_motion(ddc->iface_mouse, @@ -362,8 +361,8 @@ dbus_mouse_set_pos(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 - width =3D qemu_console_get_width(ddc->con, 0); - height =3D qemu_console_get_height(ddc->con, 0); + width =3D qemu_console_get_width(ddc->dcl.con, 0); + height =3D qemu_console_get_height(ddc->dcl.con, 0); if (x >=3D width || y >=3D height) { g_dbus_method_invocation_return_error( invocation, DBUS_DISPLAY_ERROR, @@ -371,8 +370,8 @@ dbus_mouse_set_pos(DBusDisplayConsole *ddc, "Invalid mouse position"); return DBUS_METHOD_INVOCATION_HANDLED; } - qemu_input_queue_abs(ddc->con, INPUT_AXIS_X, x, 0, width); - qemu_input_queue_abs(ddc->con, INPUT_AXIS_Y, y, 0, height); + qemu_input_queue_abs(ddc->dcl.con, INPUT_AXIS_X, x, 0, width); + qemu_input_queue_abs(ddc->dcl.con, INPUT_AXIS_Y, y, 0, height); qemu_input_event_sync(); =20 qemu_dbus_display1_mouse_complete_set_abs_position(ddc->iface_mouse, @@ -388,7 +387,7 @@ dbus_mouse_press(DBusDisplayConsole *ddc, { trace_dbus_mouse_press(button); =20 - qemu_input_queue_btn(ddc->con, button, true); + qemu_input_queue_btn(ddc->dcl.con, button, true); qemu_input_event_sync(); =20 qemu_dbus_display1_mouse_complete_press(ddc->iface_mouse, invocation); @@ -403,7 +402,7 @@ dbus_mouse_release(DBusDisplayConsole *ddc, { trace_dbus_mouse_release(button); =20 - qemu_input_queue_btn(ddc->con, button, false); + qemu_input_queue_btn(ddc->dcl.con, button, false); qemu_input_event_sync(); =20 qemu_dbus_display1_mouse_complete_release(ddc->iface_mouse, invocation= ); @@ -424,7 +423,7 @@ dbus_mouse_mode_change(Notifier *notify, void *data) =20 int dbus_display_console_get_index(DBusDisplayConsole *ddc) { - return qemu_console_get_index(ddc->con); + return qemu_console_get_index(ddc->dcl.con); } =20 DBusDisplayConsole * @@ -446,7 +445,7 @@ dbus_display_console_new(DBusDisplay *display, QemuCons= ole *con) "g-object-path", path, NULL); ddc->display =3D display; - ddc->con =3D con; + ddc->dcl.con =3D con; /* handle errors, and skip non graphics? */ qemu_console_fill_device_address( con, device_addr, sizeof(device_addr), NULL); diff --git a/ui/dbus.c b/ui/dbus.c index f00a44421cf7..22c82d2f323a 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -52,7 +52,7 @@ static bool dbus_is_compatible_dcl(DisplayGLCtx *dgc, DisplayChangeListener *dcl) { - return dcl->ops =3D=3D &dbus_gl_dcl_ops; + return dcl->ops =3D=3D &dbus_gl_dcl_ops || dcl->ops =3D=3D &dbus_conso= le_dcl_ops; } =20 static const DisplayGLCtxOps dbus_gl_ops =3D { --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645101185179246.51764814039132; Thu, 17 Feb 2022 04:33:05 -0800 (PST) Received: from localhost ([::1]:43734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKfy3-0007NK-QV for importer@patchew.org; Thu, 17 Feb 2022 07:33:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTO-00007B-6b for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTM-0001ft-Fc for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:21 -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-663-jBWyzkCHOc6XdZWTvZBHWw-1; Thu, 17 Feb 2022 07:01:16 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 946BA100C610; Thu, 17 Feb 2022 12:01:15 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E6DC282F1; Thu, 17 Feb 2022 12:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099279; 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=EY4+5g50jkPLK/EDKB7YrCc9M6uS2Kt2HNutgNeuJd0=; b=JIbcvfkXdbxA4r1McsI4Fw/xsnrx3v3R7lVN98g40HnCis5U+Wy6TSbfbqWPquMidIZ+9Q /kfQ8b5J5jjDTECyZWGgz9sJHa+yHrWJCnqTKealVzpY+GqA5DEGePWZsXSBlpQjcSpxIB 5d3i0sDfYGDeF1rvd2V5DLB+kmO6jno= X-MC-Unique: jBWyzkCHOc6XdZWTvZBHWw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 08/12] ui/console: move console compatibility check to dcl_display_console() Date: Thu, 17 Feb 2022 15:58:25 +0400 Message-Id: <20220217115829.2314347-9-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645101186204100001 From: Marc-Andr=C3=A9 Lureau The current checks are done at registration time only. However, if a DCL has no specific console specified, it may be switched dynamically with console_select() later on. Let's move the checks when displaychangelistener_display_console() is called, which includes registration time and remains fatal if the specified console is incompatible. Note: we may want to display the compatibility error to the DCL, this is left for a future improvement. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ui/console.c b/ui/console.c index c9318552871b..d3ecbb215736 100644 --- a/ui/console.c +++ b/ui/console.c @@ -148,6 +148,8 @@ static DisplayState *get_alloc_displaystate(void); static void text_console_update_cursor_timer(void); static void text_console_update_cursor(void *opaque); static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl); +static bool console_compatible_with(QemuConsole *con, + DisplayChangeListener *dcl, Error **er= rp); =20 static void gui_update(void *opaque) { @@ -1057,13 +1059,14 @@ static void console_putchar(QemuConsole *s, int ch) } =20 static void displaychangelistener_display_console(DisplayChangeListener *d= cl, - QemuConsole *con) + QemuConsole *con, + Error **errp) { static const char nodev[] =3D "This VM has no graphic display device."; static DisplaySurface *dummy; =20 - if (!con) { + if (!con || !console_compatible_with(con, dcl, errp)) { if (!dcl->ops->dpy_gfx_switch) { return; } @@ -1114,7 +1117,7 @@ void console_select(unsigned int index) if (dcl->con !=3D NULL) { continue; } - displaychangelistener_display_console(dcl, s); + displaychangelistener_display_console(dcl, s, NULL); } } if (ds->have_text) { @@ -1475,8 +1478,8 @@ static bool displaychangelistener_has_dmabuf(DisplayC= hangeListener *dcl) return false; } =20 -static bool dpy_compatible_with(QemuConsole *con, - DisplayChangeListener *dcl, Error **errp) +static bool console_compatible_with(QemuConsole *con, + DisplayChangeListener *dcl, Error **er= rp) { int flags; =20 @@ -1522,10 +1525,6 @@ void register_displaychangelistener(DisplayChangeLis= tener *dcl) =20 assert(!dcl->ds); =20 - if (dcl->con) { - dpy_compatible_with(dcl->con, dcl, &error_fatal); - } - trace_displaychangelistener_register(dcl, dcl->ops->dpy_name); dcl->ds =3D get_alloc_displaystate(); QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next); @@ -1536,7 +1535,7 @@ void register_displaychangelistener(DisplayChangeList= ener *dcl) } else { con =3D active_console; } - displaychangelistener_display_console(dcl, con); + displaychangelistener_display_console(dcl, con, dcl->con ? &error_fata= l : NULL); text_console_update_cursor(NULL); } =20 --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645100033566558.7042993357052; Thu, 17 Feb 2022 04:13:53 -0800 (PST) Received: from localhost ([::1]:40768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKffT-0001xA-IU for importer@patchew.org; Thu, 17 Feb 2022 07:13:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTf-0000BV-Ms for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTV-0001g6-Ls for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:39 -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-563-TLe_ED54PyeTMLpWNH8xpA-1; Thu, 17 Feb 2022 07:01:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C1481091DA1; Thu, 17 Feb 2022 12:01:20 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 350ED2AA97; Thu, 17 Feb 2022 12:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099284; 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=yyXhf8G9dzE4M0R0S2f9nB5x+AV4ZbUq+v95MQcfIwg=; b=iiyDHYksdOHE6jXyl9a4TdKsngMCWW+g4i1lQQMZyC0WziOp+/QsvYS+eqktpxNcCrSjHT jeBVh3BmEg6pN4W2A9WnRnLbb9FZn8zHEVlFA4X2iwFCHoUdzZyj5eI2bI7j9bBTQ8TN32 7uNyCfeMJ0OcbLnvh09FUgYuSK9VZHU= X-MC-Unique: TLe_ED54PyeTMLpWNH8xpA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 09/12] ui/shader: fix potential leak of shader on error Date: Thu, 17 Feb 2022 15:58:26 +0400 Message-Id: <20220217115829.2314347-10-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645100035917100001 From: Marc-Andr=C3=A9 Lureau Value of 0 for program and shaders are silently ignored and indicate error. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/shader.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/shader.c b/ui/shader.c index e8b8d321b7c7..4c80fc831f68 100644 --- a/ui/shader.c +++ b/ui/shader.c @@ -130,15 +130,17 @@ static GLuint qemu_gl_create_link_program(GLuint vert= , GLuint frag) static GLuint qemu_gl_create_compile_link_program(const GLchar *vert_src, const GLchar *frag_src) { - GLuint vert_shader, frag_shader, program; + GLuint vert_shader, frag_shader, program =3D 0; =20 vert_shader =3D qemu_gl_create_compile_shader(GL_VERTEX_SHADER, vert_s= rc); frag_shader =3D qemu_gl_create_compile_shader(GL_FRAGMENT_SHADER, frag= _src); if (!vert_shader || !frag_shader) { - return 0; + goto end; } =20 program =3D qemu_gl_create_link_program(vert_shader, frag_shader); + +end: glDeleteShader(vert_shader); glDeleteShader(frag_shader); =20 --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645101405100981.2645757052542; Thu, 17 Feb 2022 04:36:45 -0800 (PST) Received: from localhost ([::1]:50092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKg1a-0003Mb-Dh for importer@patchew.org; Thu, 17 Feb 2022 07:36:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTp-0000C7-Ep for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTd-0001hW-84 for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:40 -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-617-6X58ORZGO32woW8v9KrjFw-1; Thu, 17 Feb 2022 07:01:26 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F00971091DA1; Thu, 17 Feb 2022 12:01:25 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9A066E1BA; Thu, 17 Feb 2022 12:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099288; 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=WeVsYHrLE4GY7K03Sx9GvPRisdrpjFTU0ZZb4a2/Jkk=; b=Ef3ydjDUyJi6EY1y4NXUGAAa/zDSRy7MXApGG6fkOiGf08uqipgniZfXWgTmiKqlwJK7Dp TUF9a/r63tdyzq4T/LEQey69bFv1PIih/YGOh/aOn5iyTEq2tNN3oqusqSwwqDGN2r3v7D rn8nloBiC3t+wN/P3LngM80mYNrfYOw= X-MC-Unique: 6X58ORZGO32woW8v9KrjFw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 10/12] ui/shader: free associated programs Date: Thu, 17 Feb 2022 15:58:27 +0400 Message-Id: <20220217115829.2314347-11-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645101406400100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/shader.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/shader.c b/ui/shader.c index 4c80fc831f68..ab448c41d4c6 100644 --- a/ui/shader.c +++ b/ui/shader.c @@ -172,5 +172,8 @@ void qemu_gl_fini_shader(QemuGLShader *gls) if (!gls) { return; } + glDeleteProgram(gls->texture_blit_prog); + glDeleteProgram(gls->texture_blit_flip_prog); + glDeleteProgram(gls->texture_blit_vao); g_free(gls); } --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645102253174292.8379654593439; Thu, 17 Feb 2022 04:50:53 -0800 (PST) Received: from localhost ([::1]:55424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKgFH-0007Uo-0o for importer@patchew.org; Thu, 17 Feb 2022 07:50:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTp-0000C8-Ez for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfTe-0001hg-6I for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:01:40 -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-355-X9uuJghvPMGWR8IAKHCEUQ-1; Thu, 17 Feb 2022 07:01:32 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FF691883620; Thu, 17 Feb 2022 12:01:31 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03AD06E1B8; Thu, 17 Feb 2022 12:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099295; 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=KdfW8EWn9HAFN9rtDr4m2Xs1y65Nmx5hvt7SEdnLv88=; b=OMhG9Gh4s7XW3pEI7j/KT5QwOgiM+hJwdSc7HGXncBjCxzMf2PPpATw//1ZlgvZdtOpVaM sE4iHjq+tFOxYNIzSIuigxiUbNkSxguk5UrI+GXAOQ2E5dWv33/HUPxgwvger+K/AWqrRg 34BAZKNucjRX4oAeYfO+uJvcKt+H85M= X-MC-Unique: X9uuJghvPMGWR8IAKHCEUQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 11/12] ui/console: add a dpy_gfx_switch callback helper Date: Thu, 17 Feb 2022 15:58:28 +0400 Message-Id: <20220217115829.2314347-12-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645102254693100001 From: Marc-Andr=C3=A9 Lureau Slight code improvement. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ui/console.c b/ui/console.c index d3ecbb215736..102fcf0a5068 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1058,6 +1058,15 @@ static void console_putchar(QemuConsole *s, int ch) } } =20 +static void displaychangelistener_gfx_switch(DisplayChangeListener *dcl, + struct DisplaySurface *new_su= rface) +{ + if (dcl->ops->dpy_gfx_switch) { + dcl->ops->dpy_gfx_switch(dcl, new_surface); + } +} + + static void displaychangelistener_display_console(DisplayChangeListener *d= cl, QemuConsole *con, Error **errp) @@ -1067,13 +1076,10 @@ static void displaychangelistener_display_console(D= isplayChangeListener *dcl, static DisplaySurface *dummy; =20 if (!con || !console_compatible_with(con, dcl, errp)) { - if (!dcl->ops->dpy_gfx_switch) { - return; - } if (!dummy) { dummy =3D qemu_create_placeholder_surface(640, 480, nodev); } - dcl->ops->dpy_gfx_switch(dcl, dummy); + displaychangelistener_gfx_switch(dcl, dummy); return; } =20 @@ -1091,9 +1097,8 @@ static void displaychangelistener_display_console(Dis= playChangeListener *dcl, con->scanout.texture.y, con->scanout.texture.width, con->scanout.texture.height); - } else if (con->scanout.kind =3D=3D SCANOUT_SURFACE && - dcl->ops->dpy_gfx_switch) { - dcl->ops->dpy_gfx_switch(dcl, con->surface); + } else if (con->scanout.kind =3D=3D SCANOUT_SURFACE) { + displaychangelistener_gfx_switch(dcl, con->surface); } =20 dcl->ops->dpy_gfx_update(dcl, 0, 0, @@ -1677,9 +1682,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, if (con !=3D (dcl->con ? dcl->con : active_console)) { continue; } - if (dcl->ops->dpy_gfx_switch) { - dcl->ops->dpy_gfx_switch(dcl, surface); - } + displaychangelistener_gfx_switch(dcl, surface); } qemu_free_displaysurface(old_surface); } --=20 2.34.1.428.gdcc0cd074f0c From nobody Mon May 20 14:38:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164510290471791.61932317376682; Thu, 17 Feb 2022 05:01:44 -0800 (PST) Received: from localhost ([::1]:35874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKgPo-0005nh-QZ for importer@patchew.org; Thu, 17 Feb 2022 08:01:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfUH-0000TZ-Pr for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:02:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKfUE-0001qh-V1 for qemu-devel@nongnu.org; Thu, 17 Feb 2022 07:02:16 -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-371-g_WWAkXVNpa8nJ2VuIYTsg-1; Thu, 17 Feb 2022 07:02:10 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D553A344AF; Thu, 17 Feb 2022 12:02:09 +0000 (UTC) Received: from localhost (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C10B6E1E3; Thu, 17 Feb 2022 12:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645099333; 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=wDtTxFL4F7lhqGLAAYPwbVV5bgNCFBgMT5QwhR/w63o=; b=gJuCLQ+jUbd6ttRPimrU/njQb5i7yqQAmtPJvL85uY7v7SjEpV4J4lfW8baWMI9ieSxUGW XkvmZtG7NfbC3Ennb5z7RuK2di+KqQNF9+X66CLIYCE8wtej//D6/51lU993ujMaHw0W61 Rtd1EAEuCd0IWmEAaeByh23gCbdo9Ec= X-MC-Unique: g_WWAkXVNpa8nJ2VuIYTsg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 12/12] ui/dbus: fix texture sharing Date: Thu, 17 Feb 2022 15:58:29 +0400 Message-Id: <20220217115829.2314347-13-marcandre.lureau@redhat.com> In-Reply-To: <20220217115829.2314347-1-marcandre.lureau@redhat.com> References: <20220217115829.2314347-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.083, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com, akihiko.odaki@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645102921287100001 From: Marc-Andr=C3=A9 Lureau The DBus listener naively create, update and destroy textures without taking into account other listeners. The texture were shared, but texture update was unnecessarily duplicated. Teach DisplayGLCtx to do optionally shared texture handling. This is only implemented for DBus display at this point, however the same infrastructure could potentially be used for egl-headless & VNC listeners for example, or other future combinations. Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 10 ++++++++++ ui/console.c | 26 ++++++++++++++++++++++++++ ui/dbus-listener.c | 11 ----------- ui/dbus.c | 24 ++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 18a10c0b7db0..0f84861933e1 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -290,10 +290,20 @@ typedef struct DisplayGLCtxOps { QEMUGLContext ctx); int (*dpy_gl_ctx_make_current)(DisplayGLCtx *dgc, QEMUGLContext ctx); + void (*dpy_gl_ctx_create_texture)(DisplayGLCtx *dgc, + DisplaySurface *surface); + void (*dpy_gl_ctx_destroy_texture)(DisplayGLCtx *dgc, + DisplaySurface *surface); + void (*dpy_gl_ctx_update_texture)(DisplayGLCtx *dgc, + DisplaySurface *surface, + int x, int y, int w, int h); } DisplayGLCtxOps; =20 struct DisplayGLCtx { const DisplayGLCtxOps *ops; +#ifdef CONFIG_OPENGL + QemuGLShader *gls; /* optional shared shader */ +#endif }; =20 DisplayState *init_displaystate(void); diff --git a/ui/console.c b/ui/console.c index 102fcf0a5068..b9188559fb12 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1066,6 +1066,27 @@ static void displaychangelistener_gfx_switch(Display= ChangeListener *dcl, } } =20 +static void dpy_gfx_create_texture(QemuConsole *con, DisplaySurface *surfa= ce) +{ + if (con->gl && con->gl->ops->dpy_gl_ctx_create_texture) { + con->gl->ops->dpy_gl_ctx_create_texture(con->gl, surface); + } +} + +static void dpy_gfx_destroy_texture(QemuConsole *con, DisplaySurface *surf= ace) +{ + if (con->gl && con->gl->ops->dpy_gl_ctx_destroy_texture) { + con->gl->ops->dpy_gl_ctx_destroy_texture(con->gl, surface); + } +} + +static void dpy_gfx_update_texture(QemuConsole *con, DisplaySurface *surfa= ce, + int x, int y, int w, int h) +{ + if (con->gl && con->gl->ops->dpy_gl_ctx_update_texture) { + con->gl->ops->dpy_gl_ctx_update_texture(con->gl, surface, x, y, w,= h); + } +} =20 static void displaychangelistener_display_console(DisplayChangeListener *d= cl, QemuConsole *con, @@ -1078,6 +1099,7 @@ static void displaychangelistener_display_console(Dis= playChangeListener *dcl, if (!con || !console_compatible_with(con, dcl, errp)) { if (!dummy) { dummy =3D qemu_create_placeholder_surface(640, 480, nodev); + dpy_gfx_create_texture(con, dummy); } displaychangelistener_gfx_switch(dcl, dummy); return; @@ -1098,6 +1120,7 @@ static void displaychangelistener_display_console(Dis= playChangeListener *dcl, con->scanout.texture.width, con->scanout.texture.height); } else if (con->scanout.kind =3D=3D SCANOUT_SURFACE) { + dpy_gfx_create_texture(con, con->surface); displaychangelistener_gfx_switch(dcl, con->surface); } =20 @@ -1634,6 +1657,7 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, i= nt w, int h) if (!qemu_console_is_visible(con)) { return; } + dpy_gfx_update_texture(con, con->surface, x, y, w, h); QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D (dcl->con ? dcl->con : active_console)) { continue; @@ -1678,12 +1702,14 @@ void dpy_gfx_replace_surface(QemuConsole *con, =20 con->scanout.kind =3D SCANOUT_SURFACE; con->surface =3D surface; + dpy_gfx_create_texture(con, surface); QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D (dcl->con ? dcl->con : active_console)) { continue; } displaychangelistener_gfx_switch(dcl, surface); } + dpy_gfx_destroy_texture(con, old_surface); qemu_free_displaysurface(old_surface); } =20 diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 81c119b13a2c..a287edd2fc15 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -42,7 +42,6 @@ struct _DBusDisplayListener { =20 DisplayChangeListener dcl; DisplaySurface *ds; - QemuGLShader *gls; int gl_updates; }; =20 @@ -240,10 +239,6 @@ static void dbus_gl_gfx_update(DisplayChangeListener *= dcl, { DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); =20 - if (ddl->ds) { - surface_gl_update_texture(ddl->gls, ddl->ds, x, y, w, h); - } - ddl->gl_updates++; } =20 @@ -285,15 +280,11 @@ static void dbus_gl_gfx_switch(DisplayChangeListener = *dcl, { DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); =20 - if (ddl->ds) { - surface_gl_destroy_texture(ddl->gls, ddl->ds); - } ddl->ds =3D new_surface; if (ddl->ds) { int width =3D surface_width(ddl->ds); int height =3D surface_height(ddl->ds); =20 - surface_gl_create_texture(ddl->gls, ddl->ds); /* TODO: lazy send dmabuf (there are unnecessary sent otherwise) */ dbus_scanout_texture(&ddl->dcl, ddl->ds->texture, false, width, height, 0, 0, width, height); @@ -403,7 +394,6 @@ dbus_display_listener_dispose(GObject *object) g_clear_object(&ddl->conn); g_clear_pointer(&ddl->bus_name, g_free); g_clear_object(&ddl->proxy); - g_clear_pointer(&ddl->gls, qemu_gl_fini_shader); =20 G_OBJECT_CLASS(dbus_display_listener_parent_class)->dispose(object); } @@ -414,7 +404,6 @@ dbus_display_listener_constructed(GObject *object) DBusDisplayListener *ddl =3D DBUS_DISPLAY_LISTENER(object); =20 if (display_opengl) { - ddl->gls =3D qemu_gl_init_shader(); ddl->dcl.ops =3D &dbus_gl_dcl_ops; } else { ddl->dcl.ops =3D &dbus_dcl_ops; diff --git a/ui/dbus.c b/ui/dbus.c index 22c82d2f323a..8e2e4c9cad28 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -55,11 +55,33 @@ dbus_is_compatible_dcl(DisplayGLCtx *dgc, return dcl->ops =3D=3D &dbus_gl_dcl_ops || dcl->ops =3D=3D &dbus_conso= le_dcl_ops; } =20 +static void +dbus_create_texture(DisplayGLCtx *ctx, DisplaySurface *surface) +{ + surface_gl_create_texture(ctx->gls, surface); +} + +static void +dbus_destroy_texture(DisplayGLCtx *ctx, DisplaySurface *surface) +{ + surface_gl_destroy_texture(ctx->gls, surface); +} + +static void +dbus_update_texture(DisplayGLCtx *ctx, DisplaySurface *surface, + int x, int y, int w, int h) +{ + surface_gl_update_texture(ctx->gls, surface, x, y, w, h); +} + static const DisplayGLCtxOps dbus_gl_ops =3D { .dpy_gl_ctx_is_compatible_dcl =3D dbus_is_compatible_dcl, .dpy_gl_ctx_create =3D dbus_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_create_texture =3D dbus_create_texture, + .dpy_gl_ctx_destroy_texture =3D dbus_destroy_texture, + .dpy_gl_ctx_update_texture =3D dbus_update_texture, }; =20 static NotifierList dbus_display_notifiers =3D @@ -90,6 +112,7 @@ dbus_display_init(Object *o) g_autoptr(GDBusObjectSkeleton) vm =3D NULL; =20 dd->glctx.ops =3D &dbus_gl_ops; + dd->glctx.gls =3D qemu_gl_init_shader(); dd->iface =3D qemu_dbus_display1_vm_skeleton_new(); dd->consoles =3D g_ptr_array_new_with_free_func(g_object_unref); =20 @@ -126,6 +149,7 @@ dbus_display_finalize(Object *o) g_clear_object(&dd->iface); g_free(dd->dbus_addr); g_free(dd->audiodev); + g_clear_pointer(&dd->glctx.gls, qemu_gl_fini_shader); dbus_display =3D NULL; } =20 --=20 2.34.1.428.gdcc0cd074f0c