Skip to content

Commit 0905367

Browse files
Volker Rümelinkraxel
authored andcommitted
ui/gtk-gl-area: create the requested GL context version
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent e561b3b commit 0905367

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

ui/gtk-gl-area.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,32 @@ void gd_gl_area_switch(DisplayChangeListener *dcl,
170170
}
171171
}
172172

173+
static int gd_cmp_gl_context_version(int major, int minor, QEMUGLParams *params)
174+
{
175+
if (major > params->major_ver) {
176+
return 1;
177+
}
178+
if (major < params->major_ver) {
179+
return -1;
180+
}
181+
if (minor > params->minor_ver) {
182+
return 1;
183+
}
184+
if (minor < params->minor_ver) {
185+
return -1;
186+
}
187+
return 0;
188+
}
189+
173190
QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
174191
QEMUGLParams *params)
175192
{
176193
VirtualConsole *vc = container_of(dgc, VirtualConsole, gfx.dgc);
177194
GdkWindow *window;
178195
GdkGLContext *ctx;
179196
GError *err = NULL;
197+
int major, minor;
180198

181-
gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
182199
window = gtk_widget_get_window(vc->gfx.drawing_area);
183200
ctx = gdk_window_create_gl_context(window, &err);
184201
if (err) {
@@ -196,6 +213,18 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
196213
g_clear_object(&ctx);
197214
return NULL;
198215
}
216+
217+
gdk_gl_context_make_current(ctx);
218+
gdk_gl_context_get_version(ctx, &major, &minor);
219+
gdk_gl_context_clear_current();
220+
gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
221+
222+
if (gd_cmp_gl_context_version(major, minor, params) == -1) {
223+
/* created ctx version < requested version */
224+
g_clear_object(&ctx);
225+
}
226+
227+
trace_gd_gl_area_create_context(ctx, params->major_ver, params->minor_ver);
199228
return ctx;
200229
}
201230

ui/trace-events

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ gd_key_event(const char *tab, int gdk_keycode, int qkeycode, const char *action)
2626
gd_grab(const char *tab, const char *device, const char *reason) "tab=%s, dev=%s, reason=%s"
2727
gd_ungrab(const char *tab, const char *device) "tab=%s, dev=%s"
2828
gd_keymap_windowing(const char *name) "backend=%s"
29+
gd_gl_area_create_context(void *ctx, int major, int minor) "ctx=%p, major=%d, minor=%d"
2930
gd_gl_area_destroy_context(void *ctx, void *current_ctx) "ctx=%p, current_ctx=%p"
3031

3132
# vnc-auth-sasl.c

0 commit comments

Comments
 (0)