From nobody Tue Feb 10 20:47:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686053400; cv=none; d=zohomail.com; s=zohoarc; b=L5f8Xd7S4dcobgm5fA1g2niO4/h3yfwdUTka0yYWCBPaqBTsMtWW+PK9wvPlvrqUI6UaNLqMkpupsso5py4OtJxXoV3pYEbvkrJr6iSO6+XvTDfA+JQXjWZJ6sbTSmslUlys2UP25oD2wClY2qk3Yq5bP/qjmIq4JU1DcZipve0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686053400; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ebTz4S7vJuC4skd6EZ33Pz47IQvc6cbAAwkkCzCwaY0=; b=VO5XbEt+HzwQQ4TXwnYeHDiMJ+UOGw1LArNgruRquwS8LChoIKmE4JryFWR+CondZlw1ZfusMR/M96Y4p2ithl7Rxmrmvg92JLRvK7PZ/5LQ+VtBePzPPa508/0vh99TMs/zOWohK2Na0vdzYSZBByhZdS+4LP9vvlauJ2uNSTg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686053400455597.7226668441326; Tue, 6 Jun 2023 05:10:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VKX-0001Kj-KZ; Tue, 06 Jun 2023 07:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VKL-0000ds-54 for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:58:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VKH-0005uz-5I for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:58:15 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-104-q-gBLuMmO3Sn9hrZSMra7w-1; Tue, 06 Jun 2023 07:58:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E710C1C01E99 for ; Tue, 6 Jun 2023 11:58:09 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6B00140E956; Tue, 6 Jun 2023 11:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052691; 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=ebTz4S7vJuC4skd6EZ33Pz47IQvc6cbAAwkkCzCwaY0=; b=CPu5eoPKaQhcdfstrGG6yujlp1w9xcx2hXHwWCT78v0EL5JnvOdmrLldOr1xYggcK5YY6H aeIZQ21olq9CE7XutJtBfy+3cMShXysxkgxGCkxhyhuJdpP8pDZ+QQPOxJosTca5b9C4Lj lv9t28w2yjplPpTPDfqbHaITf2Y3YZA= X-MC-Unique: q-gBLuMmO3Sn9hrZSMra7w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eric Blake , Markus Armbruster Subject: [PATCH 12/21] ui: add egl-headless support on win32 Date: Tue, 6 Jun 2023 15:56:49 +0400 Message-Id: <20230606115658.677673-13-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686053402402100003 From: Marc-Andr=C3=A9 Lureau Make GBM optional for EGL code, and enable the build for win32. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi/ui.json | 5 ++--- include/ui/egl-helpers.h | 7 ++++++- ui/egl-headless.c | 20 +++++++++++++------- ui/egl-helpers.c | 38 +++++++++++++++++++++++++++++++------- ui/meson.build | 6 +++--- 5 files changed, 55 insertions(+), 21 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index 2755395483..bb06fb6039 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1484,8 +1484,7 @@ { 'name': 'none' }, { 'name': 'gtk', 'if': 'CONFIG_GTK' }, { 'name': 'sdl', 'if': 'CONFIG_SDL' }, - { 'name': 'egl-headless', - 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }, + { 'name': 'egl-headless', 'if': 'CONFIG_OPENGL' }, { 'name': 'curses', 'if': 'CONFIG_CURSES' }, { 'name': 'cocoa', 'if': 'CONFIG_COCOA' }, { 'name': 'spice-app', 'if': 'CONFIG_SPICE' }, @@ -1525,7 +1524,7 @@ 'cocoa': { 'type': 'DisplayCocoa', 'if': 'CONFIG_COCOA' }, 'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' }, 'egl-headless': { 'type': 'DisplayEGLHeadless', - 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }, + 'if': 'CONFIG_OPENGL' }, 'dbus': { 'type': 'DisplayDBus', 'if': 'CONFIG_DBUS_DISPLAY' }, 'sdl': { 'type': 'DisplaySDL', 'if': 'CONFIG_SDL' } } diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 2cf6633ad2..6c4eb5dd70 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -36,11 +36,12 @@ void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, e= gl_fb *src, bool flip); void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool f= lip, int x, int y, double scale_x, double scale_y); =20 +extern EGLContext qemu_egl_rn_ctx; + #ifdef CONFIG_GBM =20 extern int qemu_egl_rn_fd; extern struct gbm_device *qemu_egl_rn_gbm_dev; -extern EGLContext qemu_egl_rn_ctx; =20 int egl_rendernode_init(const char *rendernode, DisplayGLMode mode); int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc, @@ -62,6 +63,10 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, Dis= playGLMode mode); =20 #endif =20 +#ifdef WIN32 +int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode); +#endif + EGLContext qemu_egl_init_ctx(void); bool qemu_egl_has_dmabuf(void); =20 diff --git a/ui/egl-headless.c b/ui/egl-headless.c index ef70e6a18e..e4177206f2 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -79,6 +79,8 @@ static void egl_scanout_texture(DisplayChangeListener *dc= l, } } =20 +#ifdef CONFIG_GBM + static void egl_scanout_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { @@ -110,6 +112,14 @@ static void egl_cursor_dmabuf(DisplayChangeListener *d= cl, } } =20 +static void egl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + egl_dmabuf_release_texture(dmabuf); +} + +#endif + static void egl_cursor_position(DisplayChangeListener *dcl, uint32_t pos_x, uint32_t pos_y) { @@ -119,12 +129,6 @@ static void egl_cursor_position(DisplayChangeListener = *dcl, edpy->pos_y =3D pos_y; } =20 -static void egl_release_dmabuf(DisplayChangeListener *dcl, - QemuDmaBuf *dmabuf) -{ - egl_dmabuf_release_texture(dmabuf); -} - static void egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) @@ -160,10 +164,12 @@ static const DisplayChangeListenerOps egl_ops =3D { =20 .dpy_gl_scanout_disable =3D egl_scanout_disable, .dpy_gl_scanout_texture =3D egl_scanout_texture, +#ifdef CONFIG_GBM .dpy_gl_scanout_dmabuf =3D egl_scanout_dmabuf, .dpy_gl_cursor_dmabuf =3D egl_cursor_dmabuf, - .dpy_gl_cursor_position =3D egl_cursor_position, .dpy_gl_release_dmabuf =3D egl_release_dmabuf, +#endif + .dpy_gl_cursor_position =3D egl_cursor_position, .dpy_gl_update =3D egl_scanout_flush, }; =20 diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 3c94b3f216..4b29dda7ed 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -199,11 +199,12 @@ void egl_texture_blend(QemuGLShader *gls, egl_fb *dst= , egl_fb *src, bool flip, =20 /* ---------------------------------------------------------------------- = */ =20 +EGLContext qemu_egl_rn_ctx; + #ifdef CONFIG_GBM =20 int qemu_egl_rn_fd; struct gbm_device *qemu_egl_rn_gbm_dev; -EGLContext qemu_egl_rn_ctx; =20 int egl_rendernode_init(const char *rendernode, DisplayGLMode mode) { @@ -400,7 +401,7 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, E= GLNativeWindowType win) =20 /* ---------------------------------------------------------------------- = */ =20 -#if defined(CONFIG_X11) || defined(CONFIG_GBM) +#if defined(CONFIG_X11) || defined(CONFIG_GBM) || defined(WIN32) =20 /* * Taken from glamor_egl.h from the Xorg xserver, which is MIT licensed @@ -510,6 +511,9 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, return 0; } =20 +#endif + +#if defined(CONFIG_X11) || defined(CONFIG_GBM) int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode) { #ifdef EGL_KHR_platform_x11 @@ -527,7 +531,14 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, D= isplayGLMode mode) return qemu_egl_init_dpy(dpy, 0, mode); #endif } +#endif + =20 +#ifdef WIN32 +int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode) +{ + return qemu_egl_init_dpy(dpy, 0, mode); +} #endif =20 bool qemu_egl_has_dmabuf(void) @@ -579,15 +590,28 @@ bool egl_init(const char *rendernode, DisplayGLMode m= ode, Error **errp) return false; } =20 -#ifdef CONFIG_GBM +#ifdef WIN32 + if (qemu_egl_init_dpy_win32(EGL_DEFAULT_DISPLAY, mode) < 0) { + error_setg(errp, "egl: init failed"); + return false; + } + qemu_egl_rn_ctx =3D qemu_egl_init_ctx(); + if (!qemu_egl_rn_ctx) { + error_setg(errp, "egl: egl_init_ctx failed"); + return false; + } +#elif defined(CONFIG_GBM) if (egl_rendernode_init(rendernode, mode) < 0) { error_setg(errp, "egl: render node init failed"); return false; } +#endif + + if (!qemu_egl_rn_ctx) { + error_setg(errp, "egl: not available on this platform"); + return false; + } + display_opengl =3D 1; return true; -#else - error_setg(errp, "egl: not available on this platform"); - return false; -#endif } diff --git a/ui/meson.build b/ui/meson.build index d0dd65880c..fad6033439 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -65,10 +65,10 @@ if opengl.found() ui_modules +=3D {'opengl' : opengl_ss} endif =20 -if opengl.found() and gbm.found() +if opengl.found() egl_headless_ss =3D ss.source_set() - egl_headless_ss.add(when: [opengl, gbm, pixman], - if_true: files('egl-headless.c')) + egl_headless_ss.add(when: [opengl, pixman], + if_true: [files('egl-headless.c'), gbm]) ui_modules +=3D {'egl-headless' : egl_headless_ss} endif =20 --=20 2.40.1