Long story short: I’m writing to ask if this is a NVIDIA driver error.
Details below:
I’m debugging the following error syndrome:
Unable to create OpenGL context >= 3.0
qemu-system-x86_64: virgl could not be initialized: 22
I can see the failure in glXMakeCurrent() caused the SDL_GL_CreateContext() to give up:
823 if (X11_GL_MakeCurrent(_this, window, context) < 0) {
824 X11_GL_DeleteContext(_this, context);
825 return NULL;
826 }
The error appears to be a GLXBadContextTag according to the following call-stack:
670 if (X11_XGetErrorText(d, errorCode, x11_error_locale, sizeof(x11_error_locale)) == Success) {
(gdb) p errorCode
$11 = 162
(gdb) n
671 x11_error = SDL_iconv_string("UTF-8", "", x11_error_locale, SDL_strlen(x11_error_locale) + 1);
(gdb) n
674 if (x11_error) {
(gdb) p x11_error
$12 = 0x55555a6c8200 "GLXBadContextTag"
(gdb) bt
#0 X11_GL_ErrorHandler (d=<optimized out>, e=<optimized out>) at ./src/video/x11/SDL_x11opengl.c:674
#1 0x00007ffff4c1741b in _XError () at /lib/x86_64-linux-gnu/libX11.so.6
#2 0x00007ffff4c13fc7 in () at /lib/x86_64-linux-gnu/libX11.so.6
#3 0x00007ffff4c153df in _XReply () at /lib/x86_64-linux-gnu/libX11.so.6
#4 0x00007fffec9b9e70 in () at /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
#5 0x00007fffec9bbeb1 in () at /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
#6 0x00007fffeca657e3 in () at /lib/x86_64-linux-gnu/libGLX.so.0
#7 0x00007fffeca67281 in () at /lib/x86_64-linux-gnu/libGLX.so.0
#8 0x00007ffff4e256f3 in X11_GL_MakeCurrent (_this=_this@entry=0x555557478830, window=window@entry=0x5555587dd6b0, context=context@entry=0x555558e1f6a8)
at ./src/video/x11/SDL_x11opengl.c:849
#9 0x00007ffff4e259eb in X11_GL_CreateContext (_this=0x555557478830, window=0x5555587dd6b0) at ./src/video/x11/SDL_x11opengl.c:823
#10 0x00007ffff4dfe370 in SDL_GL_CreateContext_REAL (window=0x5555587dd6b0) at ./src/video/SDL_video.c:4116
#11 0x00007ffff7fa0fc0 in sdl2_gl_create_context (dgc=0x5555574cf330, params=0x7fffffffd730) at ui/sdl2-gl.c:161
#12 0x00007fffeedee0b3 in virgl_create_context (opaque=<optimized out>, scanout_idx=<optimized out>, params=<optimized out>) at hw/display/virtio-gpu-virgl.c:1011
The error code is mysterious. I can see it mentioned in GLX v1.3 spec[1], related to glXMakeCurrent() and glXMakeContextCurrent(). However, in GLX v1.4 spec[2], it appears to go away together with the GLX_CONTEXT_TAG concept and suggests a faulty GLX implementation:
The following error codes may be generated by a faulty GLX implementation,
but would not normally be visible to clients:
GLXBadContextTag A rendering request contains an invalid context tag.
(Context tags are used to identify contexts in the protocol.)
Since I can see libGLX_nvidia.so in the callstack, I wonder if this could be a Nvidia driver error?
I’m currently with 535.230.02, but both 550 && 570 are not working too.
BTW: In my case, both gtk && sdl ui are not working for qemu when virgl is enabled.
[1] https://registry.khronos.org/OpenGL/specs/gl/glxencode1.3.pdf
[2] https://registry.khronos.org/OpenGL/specs/gl/glx1.4.pdf