All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	xen-devel@lists.xenproject.org,
	"Akihiko Odaki" <akihiko.odaki@gmail.com>,
	"Hongren (Zenithal) Zheng" <i@zenithal.me>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Canokeys.org" <contact@canokeys.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Paul Durrant" <paul@xen.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Volker Rümelin" <vr_qemu@t-online.de>
Subject: [PULL 02/16] ui/gtk-gl-area: create the requested GL context version
Date: Mon, 13 Jun 2022 13:36:41 +0200	[thread overview]
Message-ID: <20220613113655.3693872-3-kraxel@redhat.com> (raw)
In-Reply-To: <20220613113655.3693872-1-kraxel@redhat.com>

From: Volker Rümelin <vr_qemu@t-online.de>

Since about 2018 virglrenderer (commit fa835b0f88 "vrend: don't
hardcode context version") tries to open the highest available GL
context version. This is done by creating the known GL context
versions from the highest to the lowest until (*create_gl_context)
returns a context != NULL.

This does not work properly with
the current QEMU gd_gl_area_create_context() function, because
gdk_gl_context_realize() on Wayland creates a version 3.0 legacy
context if the requested GL context version can't be created.

In order for virglrenderer to find the highest available GL
context version, return NULL if the created context version is
lower than the requested version.

This fixes the following error:
QEMU started with -device virtio-vga-gl -display gtk,gl=on.
Under Wayland, the guest window remains black and the following
information can be seen on the host.

gl_version 30 - compat profile
(qemu:5978): Gdk-WARNING **: 16:19:01.533:
  gdk_gl_context_set_required_version
  - GL context versions less than 3.2 are not supported.

(qemu:5978): Gdk-WARNING **: 16:19:01.537:
  gdk_gl_context_set_required_version -
  GL context versions less than 3.2 are not supported.

(qemu:5978): Gdk-WARNING **: 16:19:01.554:
  gdk_gl_context_set_required_version -
  GL context versions less than 3.2 are not supported.
vrend_renderer_fill_caps: Entering with stale GL error: 1282

To reproduce this error, an OpenGL driver is required on the host
that doesn't have the latest OpenGL extensions fully implemented.
An example for this is the Intel i965 driver on a Haswell processor.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20220605085131.7711-2-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk-gl-area.c | 31 ++++++++++++++++++++++++++++++-
 ui/trace-events  |  1 +
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 0e20ea031d34..2e0129c28cd4 100644
--- a/ui/gtk-gl-area.c
+++ b/ui/gtk-gl-area.c
@@ -170,6 +170,23 @@ void gd_gl_area_switch(DisplayChangeListener *dcl,
     }
 }
 
+static int gd_cmp_gl_context_version(int major, int minor, QEMUGLParams *params)
+{
+    if (major > params->major_ver) {
+        return 1;
+    }
+    if (major < params->major_ver) {
+        return -1;
+    }
+    if (minor > params->minor_ver) {
+        return 1;
+    }
+    if (minor < params->minor_ver) {
+        return -1;
+    }
+    return 0;
+}
+
 QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
                                         QEMUGLParams *params)
 {
@@ -177,8 +194,8 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
     GdkWindow *window;
     GdkGLContext *ctx;
     GError *err = NULL;
+    int major, minor;
 
-    gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
     window = gtk_widget_get_window(vc->gfx.drawing_area);
     ctx = gdk_window_create_gl_context(window, &err);
     if (err) {
@@ -196,6 +213,18 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
         g_clear_object(&ctx);
         return NULL;
     }
+
+    gdk_gl_context_make_current(ctx);
+    gdk_gl_context_get_version(ctx, &major, &minor);
+    gdk_gl_context_clear_current();
+    gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
+
+    if (gd_cmp_gl_context_version(major, minor, params) == -1) {
+        /* created ctx version < requested version */
+        g_clear_object(&ctx);
+    }
+
+    trace_gd_gl_area_create_context(ctx, params->major_ver, params->minor_ver);
     return ctx;
 }
 
diff --git a/ui/trace-events b/ui/trace-events
index 1040ba0f88c7..a922f00e10b4 100644
--- a/ui/trace-events
+++ b/ui/trace-events
@@ -26,6 +26,7 @@ gd_key_event(const char *tab, int gdk_keycode, int qkeycode, const char *action)
 gd_grab(const char *tab, const char *device, const char *reason) "tab=%s, dev=%s, reason=%s"
 gd_ungrab(const char *tab, const char *device) "tab=%s, dev=%s"
 gd_keymap_windowing(const char *name) "backend=%s"
+gd_gl_area_create_context(void *ctx, int major, int minor) "ctx=%p, major=%d, minor=%d"
 gd_gl_area_destroy_context(void *ctx, void *current_ctx) "ctx=%p, current_ctx=%p"
 
 # vnc-auth-sasl.c
-- 
2.36.1



  parent reply	other threads:[~2022-06-13 11:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 11:36 [PULL 00/16] Kraxel 20220613 patches Gerd Hoffmann
2022-06-13 11:36 ` [PULL 01/16] ui/gtk-gl-area: implement GL context destruction Gerd Hoffmann
2022-06-13 11:36 ` Gerd Hoffmann [this message]
2022-06-13 11:36 ` [PULL 03/16] ui/cocoa: Fix poweroff request code Gerd Hoffmann
2022-06-13 11:36 ` [PULL 04/16] hw/usb: Add CanoKey Implementation Gerd Hoffmann
2022-06-13 11:36 ` [PULL 05/16] hw/usb/canokey: Add trace events Gerd Hoffmann
2022-06-13 11:36 ` [PULL 06/16] meson: Add CanoKey Gerd Hoffmann
2022-06-13 11:36 ` [PULL 07/16] docs: Add CanoKey documentation Gerd Hoffmann
2022-06-13 11:36 ` [PULL 08/16] docs/system/devices/usb: Add CanoKey to USB devices examples Gerd Hoffmann
2022-06-13 11:36 ` [PULL 09/16] MAINTAINERS: add myself as CanoKey maintainer Gerd Hoffmann
2022-06-13 11:36 ` [PULL 10/16] hw/usb/hcd-ehci: fix writeback order Gerd Hoffmann
2022-06-13 11:36 ` [PULL 11/16] usbredir: avoid queuing hello packet on snapshot restore Gerd Hoffmann
2022-06-13 11:36 ` [PULL 12/16] virtio-gpu: update done only on the scanout associated with rect Gerd Hoffmann
2022-06-13 11:36 ` [PULL 13/16] ui/console: Do not return a value with ui_info Gerd Hoffmann
2022-06-13 11:36 ` [PULL 14/16] ui: Deliver refresh rate via QemuUIInfo Gerd Hoffmann
2022-06-13 11:36 ` [PULL 15/16] virtio-gpu: Respect UI refresh rate for EDID Gerd Hoffmann
2022-06-13 11:36 ` [PULL 16/16] ui: move 'pc-bios/keymaps' to 'ui/keymaps' Gerd Hoffmann
2022-06-13 15:52 ` [PULL 00/16] Kraxel 20220613 patches Richard Henderson
2022-06-13 15:54   ` Richard Henderson
2022-06-14  9:40   ` Gerd Hoffmann
2022-06-14  9:51     ` Daniel P. Berrangé
2022-06-14 12:14       ` Gerd Hoffmann
2022-06-14 12:16   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220613113655.3693872-3-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=akihiko.odaki@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=anthony.perard@citrix.com \
    --cc=contact@canokeys.org \
    --cc=f4bug@amsat.org \
    --cc=i@zenithal.me \
    --cc=mst@redhat.com \
    --cc=paul@xen.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=vr_qemu@t-online.de \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.