From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366270258608.6883177763488; Thu, 10 Jun 2021 16:04:30 -0700 (PDT) Received: from localhost ([::1]:59810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrTiv-0006jO-2b for importer2@patchew.org; Thu, 10 Jun 2021 19:04:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg1-0007Nn-Jz for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:29 -0400 Received: from mga17.intel.com ([192.55.52.151]:52951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTfz-0006zL-PK for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:29 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:07 -0700 IronPort-SDR: jqdym4baPoj3zUlNG1ycLZgL0bJ5Gj+HIvh+UUBdU5+hen2B/cPhMptmwKl8K4X13Ob7ZGUkdu sh6XiOB2j1VQ== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796180" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796180" IronPort-SDR: yifz6RgAJXtTaknE8cRaMQHOhlB8thqKKzyoSGfnrDhcQU1lJ3ysSQ3thrWkX0iOvPJEKxS6gm IhJWwm6J3h6g== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888351" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 1/8] ui/gtk: Create a common release_dmabuf helper Date: Thu, 10 Jun 2021 15:48:30 -0700 Message-Id: <20210610224837.670192-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since the texture release mechanism is same for both gtk-egl and gtk-glarea, move the helper from gtk-egl to common gtk code so that it can be shared by both gtk backends. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- include/ui/gtk.h | 2 -- ui/gtk-egl.c | 8 -------- ui/gtk.c | 11 ++++++++++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 9516670ebc..e6cbf0507c 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -178,8 +178,6 @@ void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl, uint32_t hot_x, uint32_t hot_y); void gd_egl_cursor_position(DisplayChangeListener *dcl, uint32_t pos_x, uint32_t pos_y); -void gd_egl_release_dmabuf(DisplayChangeListener *dcl, - QemuDmaBuf *dmabuf); void gd_egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); void gtk_egl_init(DisplayGLMode mode); diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 2a2e6d3a17..b671181272 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -249,14 +249,6 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl, vc->gfx.cursor_y =3D pos_y * vc->gfx.scale_y; } =20 -void gd_egl_release_dmabuf(DisplayChangeListener *dcl, - QemuDmaBuf *dmabuf) -{ -#ifdef CONFIG_GBM - egl_dmabuf_release_texture(dmabuf); -#endif -} - void gd_egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { diff --git a/ui/gtk.c b/ui/gtk.c index 98046f577b..6132bab52f 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -575,6 +575,14 @@ static bool gd_has_dmabuf(DisplayChangeListener *dcl) return vc->gfx.has_dmabuf; } =20 +static void gd_gl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ +#ifdef CONFIG_GBM + egl_dmabuf_release_texture(dmabuf); +#endif +} + /** DisplayState Callbacks (opengl version) **/ =20 static const DisplayChangeListenerOps dcl_gl_area_ops =3D { @@ -593,6 +601,7 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = =3D { .dpy_gl_scanout_disable =3D gd_gl_area_scanout_disable, .dpy_gl_update =3D gd_gl_area_scanout_flush, .dpy_gl_scanout_dmabuf =3D gd_gl_area_scanout_dmabuf, + .dpy_gl_release_dmabuf =3D gd_gl_release_dmabuf, .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 @@ -615,8 +624,8 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_gl_scanout_dmabuf =3D gd_egl_scanout_dmabuf, .dpy_gl_cursor_dmabuf =3D gd_egl_cursor_dmabuf, .dpy_gl_cursor_position =3D gd_egl_cursor_position, - .dpy_gl_release_dmabuf =3D gd_egl_release_dmabuf, .dpy_gl_update =3D gd_egl_scanout_flush, + .dpy_gl_release_dmabuf =3D gd_gl_release_dmabuf, .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 --=20 2.30.2 From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366422673652.1728941593469; Thu, 10 Jun 2021 16:07:02 -0700 (PDT) Received: from localhost ([::1]:39874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrTlN-0003pY-Mx for importer2@patchew.org; Thu, 10 Jun 2021 19:07:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg4-0007VY-Kn for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:32 -0400 Received: from mga17.intel.com ([192.55.52.151]:52994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg0-00079b-HC for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:32 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: Xvb0PkUGy9y/SMy7fdSLsUPDyxHp+IL5Rzz1OrDI6V1Ygd8QwnKKiIcwmwxOKTFP4DIbtHtS++ XrQ1joUu3u4g== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796181" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796181" IronPort-SDR: ZJxoHW//EgdQzzg0Jzz0tSbi1kDSNur3HXOM+2WoMy8F5gVzXU6fgBvn2C8hHVmwONXY9jkoDC 73f65vYhLbhg== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888354" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 2/8] ui/egl: Add egl helpers to help with synchronization Date: Thu, 10 Jun 2021 15:48:31 -0700 Message-Id: <20210610224837.670192-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" These egl helpers would be used for creating and waiting on a sync object. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- include/ui/console.h | 2 ++ include/ui/egl-helpers.h | 3 +++ ui/egl-helpers.c | 44 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index b30b63976a..49978fdae3 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -168,6 +168,8 @@ typedef struct QemuDmaBuf { uint64_t modifier; uint32_t texture; bool y0_top; + void *sync; + int fence_fd; } QemuDmaBuf; =20 typedef struct DisplayState DisplayState; diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index f1bf8f97fc..5a7575dc13 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -45,6 +45,9 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *strid= e, EGLint *fourcc, =20 void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf); void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf); +void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf); +void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf); +void egl_dmabuf_wait_sync(QemuDmaBuf *dmabuf); =20 #endif =20 diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 6d0cb2b5cb..47220b66e0 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -76,6 +76,50 @@ void egl_fb_setup_for_tex(egl_fb *fb, int width, int hei= ght, GL_TEXTURE_2D, fb->texture, 0); } =20 +void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf) +{ + EGLSyncKHR sync; + + if (epoxy_has_egl_extension(qemu_egl_display, + "EGL_KHR_fence_sync") && + epoxy_has_egl_extension(qemu_egl_display, + "EGL_ANDROID_native_fence_sync")) { + sync =3D eglCreateSyncKHR(qemu_egl_display, + EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); + if (sync !=3D EGL_NO_SYNC_KHR) { + dmabuf->sync =3D sync; + } + } +} + +void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf) +{ + if (dmabuf->sync) { + dmabuf->fence_fd =3D eglDupNativeFenceFDANDROID(qemu_egl_display, + dmabuf->sync); + eglDestroySyncKHR(qemu_egl_display, dmabuf->sync); + dmabuf->sync =3D NULL; + } +} + +void egl_dmabuf_wait_sync(QemuDmaBuf *dmabuf) +{ + EGLSyncKHR sync; + EGLint attrib_list[] =3D { + EGL_SYNC_NATIVE_FENCE_FD_ANDROID, dmabuf->fence_fd, + EGL_NONE, + }; + + sync =3D eglCreateSyncKHR(qemu_egl_display, + EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list); + if (sync !=3D EGL_NO_SYNC_KHR) { + eglClientWaitSyncKHR(qemu_egl_display, sync, + 0, EGL_FOREVER_KHR); + eglDestroySyncKHR(qemu_egl_display, sync); + dmabuf->fence_fd =3D -1; + } +} + void egl_fb_setup_new_tex(egl_fb *fb, int width, int height) { GLuint texture; --=20 2.30.2 From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366176616991.3470073426588; Thu, 10 Jun 2021 16:02:56 -0700 (PDT) Received: from localhost ([::1]:52130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrThP-0001gB-Ky for importer2@patchew.org; Thu, 10 Jun 2021 19:02:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg3-0007TF-Ph for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:31 -0400 Received: from mga17.intel.com ([192.55.52.151]:52951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg1-0006zL-Vn for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:31 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: N3VQpNG2HHUExoav32NDiJ6+FE8d3TrBFeQtxO2C5JSXMUD5Q3H7QX1rmSauFO3Z1uUQOjL2zj EuEmOjTB7Ijg== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796182" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796182" IronPort-SDR: q40khA96DdrHYPVSl1tvyKLzW+lpTPt9SNJ5p8bf46H3yfbCLj5eOA0jG/Gk8NnEPxKOdy9ab3 M/k6MbcHb3Qw== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888357" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 3/8] ui: Add a helper to wait on a dmabuf sync object Date: Thu, 10 Jun 2021 15:48:32 -0700 Message-Id: <20210610224837.670192-4-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This will be called by virtio-gpu in the subsequent patches. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- include/ui/console.h | 5 +++++ ui/console.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 49978fdae3..a89f739f10 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -242,6 +242,9 @@ typedef struct DisplayChangeListenerOps { /* optional */ void (*dpy_gl_release_dmabuf)(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf); + /* optional */ + void (*dpy_gl_wait_dmabuf)(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf); /* required if GL */ void (*dpy_gl_update)(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); @@ -314,6 +317,8 @@ void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y); void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); +void dpy_gl_wait_dmabuf(QemuConsole *con, + QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con, uint32_t x, uint32_t y, uint32_t w, uint32_t h); =20 diff --git a/ui/console.c b/ui/console.c index 2de5f4105b..b0abfd2246 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1917,6 +1917,16 @@ void dpy_gl_release_dmabuf(QemuConsole *con, } } =20 +void dpy_gl_wait_dmabuf(QemuConsole *con, + QemuDmaBuf *dmabuf) +{ + assert(con->gl); + + if (con->gl->ops->dpy_gl_wait_dmabuf) { + con->gl->ops->dpy_gl_wait_dmabuf(con->gl, dmabuf); + } +} + void dpy_gl_update(QemuConsole *con, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { --=20 2.30.2 From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366524209708.4215889190411; Thu, 10 Jun 2021 16:08:44 -0700 (PDT) Received: from localhost ([::1]:43896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrTn1-0006W0-9L for importer2@patchew.org; Thu, 10 Jun 2021 19:08:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg5-0007Zn-Rp for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:33 -0400 Received: from mga17.intel.com ([192.55.52.151]:53003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg2-0007CA-Hm for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:33 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: RfuMJRJIzVGqMgUBpibiflR/NGwVR59M46w6LaE7KQ4WJe0s6wGg4l3qtG2RKafqdMljUATI0R Dwnv1+0p3+4Q== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796183" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796183" IronPort-SDR: gu80Dd4Xdrez1FmIaKMVRBGmgPv03yN8g/9ZG2ZfzDumtmCWI/sfPXKbvBMH+m3njhQIUE1aSG 60pW8N5c+06g== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888360" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 4/8] ui/gtk: Implement wait_dmabuf function Date: Thu, 10 Jun 2021 15:48:33 -0700 Message-Id: <20210610224837.670192-5-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- ui/gtk.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 6132bab52f..cd884ca26c 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -583,6 +583,19 @@ static void gd_gl_release_dmabuf(DisplayChangeListener= *dcl, #endif } =20 +static void gd_gl_wait_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ +#ifdef CONFIG_GBM + egl_dmabuf_create_fence(dmabuf); + if (dmabuf->fence_fd <=3D 0) { + return; + } + + egl_dmabuf_wait_sync(dmabuf); +#endif +} + /** DisplayState Callbacks (opengl version) **/ =20 static const DisplayChangeListenerOps dcl_gl_area_ops =3D { @@ -602,6 +615,7 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = =3D { .dpy_gl_update =3D gd_gl_area_scanout_flush, .dpy_gl_scanout_dmabuf =3D gd_gl_area_scanout_dmabuf, .dpy_gl_release_dmabuf =3D gd_gl_release_dmabuf, + .dpy_gl_wait_dmabuf =3D gd_gl_wait_dmabuf, .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 @@ -626,6 +640,7 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_gl_cursor_position =3D gd_egl_cursor_position, .dpy_gl_update =3D gd_egl_scanout_flush, .dpy_gl_release_dmabuf =3D gd_gl_release_dmabuf, + .dpy_gl_wait_dmabuf =3D gd_gl_wait_dmabuf, .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 --=20 2.30.2 From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366379137684.2583212169003; Thu, 10 Jun 2021 16:06:19 -0700 (PDT) Received: from localhost ([::1]:36732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrTkg-0001hI-0O for importer2@patchew.org; Thu, 10 Jun 2021 19:06:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg8-0007hD-67 for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:36 -0400 Received: from mga17.intel.com ([192.55.52.151]:52951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg4-0006zL-Rl for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:35 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: PUa9xPidmsk468mSKC5O+5FTzp2t1cFrgUM/eEOdlIt3U0VA0EDOjWLk/jAEHYNYZoMJgXfJn8 hTzLdTK8EPGA== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796184" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796184" IronPort-SDR: g/KtDbhqiSzowI6khzEHpdwPdKj8M10aHPYgGNIENjp4WGDKc8nCKbkR21WNiupyEC+JlZBz7q 2GsM/0Ccvp0g== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888363" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 5/8] ui: Create sync objects only for blobs Date: Thu, 10 Jun 2021 15:48:34 -0700 Message-Id: <20210610224837.670192-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" For now, create sync objects only for dmabufs that are blobs. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- hw/display/virtio-gpu-udmabuf.c | 2 ++ include/ui/console.h | 1 + include/ui/egl-helpers.h | 1 + ui/gtk-egl.c | 10 ++++++++++ ui/gtk-gl-area.c | 8 ++++++++ 5 files changed, 22 insertions(+) diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index 3c01a415e7..33e329e8aa 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -185,6 +185,8 @@ static VGPUDMABuf dmabuf->buf.stride =3D fb->stride; dmabuf->buf.fourcc =3D qemu_pixman_to_drm_format(fb->format); dmabuf->buf.fd =3D res->dmabuf_fd; + dmabuf->buf.blob =3D true; + dmabuf->buf.sync =3D NULL; =20 dmabuf->scanout_id =3D scanout_id; QTAILQ_INSERT_HEAD(&g->dmabuf.bufs, dmabuf, next); diff --git a/include/ui/console.h b/include/ui/console.h index a89f739f10..310d34c67a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -170,6 +170,7 @@ typedef struct QemuDmaBuf { bool y0_top; void *sync; int fence_fd; + bool blob; } QemuDmaBuf; =20 typedef struct DisplayState DisplayState; diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 5a7575dc13..1bc0e31b03 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -19,6 +19,7 @@ typedef struct egl_fb { GLuint texture; GLuint framebuffer; bool delete_texture; + QemuDmaBuf *dmabuf; } egl_fb; =20 void egl_fb_destroy(egl_fb *fb); diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index b671181272..b748f51b0b 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -209,6 +209,8 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { #ifdef CONFIG_GBM + VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + egl_dmabuf_import_texture(dmabuf); if (!dmabuf->texture) { return; @@ -217,6 +219,10 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, gd_egl_scanout_texture(dcl, dmabuf->texture, false, dmabuf->width, dmabuf->height, 0, 0, dmabuf->width, dmabuf->height); + + if (dmabuf->blob) { + vc->gfx.guest_fb.dmabuf =3D dmabuf; + } #endif } =20 @@ -281,6 +287,10 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top); } =20 + if (vc->gfx.guest_fb.dmabuf) { + egl_dmabuf_create_sync(vc->gfx.guest_fb.dmabuf); + } + eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); } =20 diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index dd5783fec7..94f3b87c42 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -71,6 +71,10 @@ void gd_gl_area_draw(VirtualConsole *vc) surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds); } =20 + if (vc->gfx.guest_fb.dmabuf) { + egl_dmabuf_create_sync(vc->gfx.guest_fb.dmabuf); + } + glFlush(); graphic_hw_gl_flushed(vc->gfx.dcl.con); } @@ -231,6 +235,10 @@ void gd_gl_area_scanout_dmabuf(DisplayChangeListener *= dcl, gd_gl_area_scanout_texture(dcl, dmabuf->texture, false, dmabuf->width, dmabuf->height, 0, 0, dmabuf->width, dmabuf->height); + + if (dmabuf->blob) { + vc->gfx.guest_fb.dmabuf =3D dmabuf; + } #endif } =20 --=20 2.30.2 From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366223284774.4792108335967; Thu, 10 Jun 2021 16:03:43 -0700 (PDT) Received: from localhost ([::1]:56808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrTiA-0004jC-3M for importer2@patchew.org; Thu, 10 Jun 2021 19:03:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg6-0007cX-OT for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:34 -0400 Received: from mga17.intel.com ([192.55.52.151]:52994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg4-00079b-W9 for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:34 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: dsijchEd7WJ6Julse8Ao5Sv1/OYJg2As6Sy0l2IxrTv8Cl39d4veHLUZ+6l4FU+0KMcQHr90Zz OKzyPagNF7Rg== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796185" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796185" IronPort-SDR: 03fwPp819v6KHLQlePExZQlQ6IyTqJIB/1i71znIWzCaq2+8rcnu4w1gclXVeeGVGZo5LMgS3C QNhjIAXLoNdg== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888370" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 6/8] ui/gtk-egl: Wait for the draw signal for dmabuf blobs Date: Thu, 10 Jun 2021 15:48:35 -0700 Message-Id: <20210610224837.670192-7-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead of immediately drawing and submitting, queue and wait for the draw signal if the dmabuf submitted is a blob. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- include/ui/gtk.h | 2 ++ ui/gtk-egl.c | 14 ++++++++++++++ ui/gtk.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index e6cbf0507c..34e767a1da 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -178,6 +178,8 @@ void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl, uint32_t hot_x, uint32_t hot_y); void gd_egl_cursor_position(DisplayChangeListener *dcl, uint32_t pos_x, uint32_t pos_y); +void gd_egl_flush(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, uint32_t w, uint32_t h); void gd_egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); void gtk_egl_init(DisplayGLMode mode); diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index b748f51b0b..a5655b6bbc 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -294,6 +294,20 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); } =20 +void gd_egl_flush(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, uint32_t w, uint32_t h) +{ + VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + GtkWidget *area =3D vc->gfx.drawing_area; + + if (vc->gfx.guest_fb.dmabuf) { + gtk_widget_queue_draw_area(area, x, y, w, h); + return; + } + + gd_egl_scanout_flush(&vc->gfx.dcl, x, y, w, h); +} + void gtk_egl_init(DisplayGLMode mode) { GdkDisplay *gdk_display =3D gdk_display_get_default(); diff --git a/ui/gtk.c b/ui/gtk.c index cd884ca26c..af94f12a98 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -638,7 +638,7 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_gl_scanout_dmabuf =3D gd_egl_scanout_dmabuf, .dpy_gl_cursor_dmabuf =3D gd_egl_cursor_dmabuf, .dpy_gl_cursor_position =3D gd_egl_cursor_position, - .dpy_gl_update =3D gd_egl_scanout_flush, + .dpy_gl_update =3D gd_egl_flush, .dpy_gl_release_dmabuf =3D gd_gl_release_dmabuf, .dpy_gl_wait_dmabuf =3D gd_gl_wait_dmabuf, .dpy_has_dmabuf =3D gd_has_dmabuf, --=20 2.30.2 From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366180873979.3105957261475; Thu, 10 Jun 2021 16:03:00 -0700 (PDT) Received: from localhost ([::1]:52616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrThT-0001zM-QR for importer2@patchew.org; Thu, 10 Jun 2021 19:02:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg8-0007hm-DP for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:36 -0400 Received: from mga17.intel.com ([192.55.52.151]:53003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg6-0007CA-7U for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:36 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: pJrEjXBoqu0HzN6itOGIpeF02GMAPRXxmh0KFWmDs+5vwrTJFqzizxijKtgNJEg07Uwcge6yex 4beOsR0ML7hw== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796186" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796186" IronPort-SDR: M7v2seMkRiBr2B3RaJ3ziTPItiPTNWcGPnwDBBkBJv2VG6jLfj98ars5jTKUT+72YrUaqR/dVu 6bT1nGJ6yu/w== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888377" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 7/8] virtio-gpu: Add dmabuf helpers for synchronization Date: Thu, 10 Jun 2021 15:48:36 -0700 Message-Id: <20210610224837.670192-8-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" These helpers will be used in the next subsequent patches to wait until a dmabuf object (via a texture) has been used by the UI to render and submit its buffer. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- hw/display/virtio-gpu-udmabuf.c | 28 ++++++++++++++++++++++++++++ include/hw/virtio/virtio-gpu.h | 2 ++ stubs/virtio-gpu-udmabuf.c | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index 33e329e8aa..8c1b6f8763 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -167,6 +167,34 @@ static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUD= MABuf *dmabuf) g_free(dmabuf); } =20 +static VGPUDMABuf +*virtio_gpu_find_dmabuf(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + VGPUDMABuf *dmabuf, *tmp; + + QTAILQ_FOREACH_SAFE(dmabuf, &g->dmabuf.bufs, next, tmp) { + if (dmabuf->buf.fd =3D=3D res->dmabuf_fd) { + return dmabuf; + } + } + + return NULL; +} + +void virtio_gpu_resource_wait_sync(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + struct virtio_gpu_scanout *scanout; + VGPUDMABuf *dmabuf; + + dmabuf =3D virtio_gpu_find_dmabuf(g, res); + if (dmabuf && dmabuf->buf.sync) { + scanout =3D &g->parent_obj.scanout[dmabuf->scanout_id]; + dpy_gl_wait_dmabuf(scanout->con, &dmabuf->buf); + } +} + static VGPUDMABuf *virtio_gpu_create_dmabuf(VirtIOGPU *g, uint32_t scanout_id, diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index bcf54d970f..9b9b499d06 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -274,6 +274,8 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, uint32_t scanout_id, struct virtio_gpu_simple_resource *res, struct virtio_gpu_framebuffer *fb); +void virtio_gpu_resource_wait_sync(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res); =20 /* virtio-gpu-3d.c */ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, diff --git a/stubs/virtio-gpu-udmabuf.c b/stubs/virtio-gpu-udmabuf.c index 81f661441a..59dab1a66c 100644 --- a/stubs/virtio-gpu-udmabuf.c +++ b/stubs/virtio-gpu-udmabuf.c @@ -25,3 +25,9 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, /* nothing (stub) */ return 0; } + +void virtio_gpu_resource_wait_sync(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + /* nothing (stub) */ +} --=20 2.30.2 From nobody Sat Apr 20 09:29:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623366295675535.3359321960223; Thu, 10 Jun 2021 16:04:55 -0700 (PDT) Received: from localhost ([::1]:60866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrTjJ-0007Q2-PD for importer2@patchew.org; Thu, 10 Jun 2021 19:04:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg9-0007jt-1C for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:37 -0400 Received: from mga17.intel.com ([192.55.52.151]:52994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrTg7-00079b-3w for qemu-devel@nongnu.org; Thu, 10 Jun 2021 19:01:36 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 16:01:08 -0700 IronPort-SDR: 2nMJbFDp29bUxSYeHtodzWdkrSZIGbcIY71rENAVfgbp0OmHkSPeSXdx0WvPweRKrTQ/mBEIo8 AyZ11coo8o9A== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="185796187" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="185796187" IronPort-SDR: J+Qs3t6Qi51b7E8y1zLFWGbfWk4P6AD/BMvr30u8vx33k6WsSZcH9ND1xZfHVwNMbz7BVQYncd xjlOdM1SlHYQ== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="419888380" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v2 8/8] virtio-gpu: Add gl_flushed callback Date: Thu, 10 Jun 2021 15:48:37 -0700 Message-Id: <20210610224837.670192-9-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210610224837.670192-1-vivek.kasireddy@intel.com> References: <20210610224837.670192-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=vivek.kasireddy@intel.com; helo=mga17.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Adding this callback provides a way to determine when the UI has submitted the buffer to the Host windowing system. Making the guest wait for this event will ensure that the dmabuf/buffer updates are synchronized. Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- hw/display/virtio-gpu.c | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 4d549377cb..bd96332973 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -982,7 +982,7 @@ void virtio_gpu_simple_process_cmd(VirtIOGPU *g, cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; break; } - if (!cmd->finished) { + if (!cmd->finished && !(cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_FENCE)) { virtio_gpu_ctrl_response_nodata(g, cmd, cmd->error ? cmd->error : VIRTIO_GPU_RESP_OK_NODATA); } @@ -1040,6 +1040,46 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g) g->processing_cmdq =3D false; } =20 +static void virtio_gpu_signal_fence(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd, + enum virtio_gpu_ctrl_type type) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_flush rf; + + VIRTIO_GPU_FILL_CMD(rf); + virtio_gpu_bswap_32(&rf, sizeof(rf)); + res =3D virtio_gpu_find_check_resource(g, rf.resource_id, true, + __func__, &cmd->error); + if (res) { + virtio_gpu_resource_wait_sync(g, res); + } + virtio_gpu_ctrl_response_nodata(g, cmd, VIRTIO_GPU_RESP_OK_NODATA); +} + +static void virtio_gpu_process_fenceq(VirtIOGPU *g) +{ + struct virtio_gpu_ctrl_command *cmd, *tmp; + + QTAILQ_FOREACH_SAFE(cmd, &g->fenceq, next, tmp) { + trace_virtio_gpu_fence_resp(cmd->cmd_hdr.fence_id); + virtio_gpu_signal_fence(g, cmd, VIRTIO_GPU_RESP_OK_NODATA); + QTAILQ_REMOVE(&g->fenceq, cmd, next); + g_free(cmd); + g->inflight--; + if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { + fprintf(stderr, "inflight: %3d (-)\r", g->inflight); + } + } +} + +static void virtio_gpu_handle_gl_flushed(VirtIOGPUBase *b) +{ + VirtIOGPU *g =3D container_of(b, VirtIOGPU, parent_obj); + + virtio_gpu_process_fenceq(g); +} + static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) { VirtIOGPU *g =3D VIRTIO_GPU(vdev); @@ -1398,10 +1438,12 @@ static void virtio_gpu_class_init(ObjectClass *klas= s, void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); VirtIOGPUClass *vgc =3D VIRTIO_GPU_CLASS(klass); + VirtIOGPUBaseClass *vgbc =3D &vgc->parent; =20 vgc->handle_ctrl =3D virtio_gpu_handle_ctrl; vgc->process_cmd =3D virtio_gpu_simple_process_cmd; vgc->update_cursor_data =3D virtio_gpu_update_cursor_data; + vgbc->gl_flushed =3D virtio_gpu_handle_gl_flushed; =20 vdc->realize =3D virtio_gpu_device_realize; vdc->reset =3D virtio_gpu_reset; --=20 2.30.2