Couldn't find current GLX or EGL context (AMD/nVidia graphics)

I’m having a bunch of programs reporting an error along these lines. I have a Legion 5 Pro laptop with a 5800H and RTX3070, with the hybrid graphics in effect. The closed source nVidia drivers are installed and nouveau is blacklisted.

xrandr --listproviders shows :

Providers: number : 2
Provider 0: id: 0x53 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 1 associated providers: 1 name:AMD Radeon Graphics @ pci:0000:06:00.0
Provider 1: id: 0x1f8 cap: 0x2, Sink Output crtcs: 4 outputs: 6 associated providers: 1 name:NVIDIA-G0

Blender, and various Steam games work just fine. I cannot fathom what’s going on to cause this breakage and how to start troubleshooting it.

I wondered if anyone might have some suggestions to help me sort this out.

I have a Legion 5 (Ryzen + RTX3070), I tend to run on the AMD iGPU and switch to the RTX in the bios.

What does inxi -G show?

Also, I had to exclude the nVidia drivers from dracut else things just did not work and if I tried to use the dGPU, it would use the llvmpipe render, not the nVidia one.

Am at work, though, no access to my computer till I get home.

I actually went on a bit of a test drive using EndeavourOS live, Garuda, and both of these Arch-based distributions had the same issue in their live environments (with the proprietary nVidia drivers loaded). Pop_OS, curiously, it all worked. Speculatively, I copied the /usr/share/X11/xorg.conf.d/* configuration from Pop_OS live session into my installed EndeavourOS, just in case something was misconfigured, but it hasn’t helped.

I’ve also tried with and without the nVidia beta drivers. I settled back on 525 because 530 made things quite sluggish, particularly on the external display.

Graphics:
  Device-1: NVIDIA GA104M [GeForce RTX 3070 Mobile / Max-Q] driver: nvidia
    v: 525.89.02
  Device-2: AMD Cezanne [Radeon Vega Series / Radeon Mobile Series]
    driver: amdgpu v: kernel
  Display: x11 server: X.Org v: 21.1.7 driver: X: loaded: amdgpu,nvidia
    unloaded: modesetting dri: radeonsi gpu: amdgpu,nvidia,nvidia-nvswitch
    resolution: 1: 2560x1440~60Hz 2: 2560x1600~60Hz
  API: OpenGL v: 4.6 Mesa 22.3.6 renderer: AMD Radeon Graphics (renoir LLVM
    15.0.7 DRM 3.49 6.2.6-arch1-1)

And if you reboot to the RTX card, what does inxi show? I don’t have an external monitor, so can’t help with that.

When I get home, will share mine and what I did to remove from dracut.

Not-hybrid, I get :

Graphics:
  Device-1: NVIDIA GA104M [GeForce RTX 3070 Mobile / Max-Q] driver: nvidia
    v: 525.89.02
  Display: x11 server: X.Org v: 21.1.7 driver: X: loaded: nvidia
    unloaded: modesetting gpu: nvidia,nvidia-nvswitch resolution:
    1: 2560x1440~60Hz 2: 2560x1600~60Hz
  API: OpenGL v: 4.6.0 NVIDIA 525.89.02 renderer: NVIDIA GeForce RTX 3070
    Laptop GPU/PCIe/SSE2

and the errors still exist. Very strange indeed.

Changing to the LTS kernel (6.1.19) also doesn’t help, in hybrid or full-discrete graphics modes.

AMD

Graphics:
  Device-1: NVIDIA GA104M [GeForce RTX 3070 Mobile / Max-Q] driver: nvidia
    v: 525.89.02
  Device-2: AMD Cezanne [Radeon Vega Series / Radeon Mobile Series]
    driver: amdgpu v: kernel
  Device-3: Bison Integrated Camera type: USB driver: uvcvideo
  Display: wayland server: X.Org v: 22.1.8 with: Xwayland v: 22.1.8
    compositor: kwin_wayland driver: X: loaded: amdgpu,nvidia
    unloaded: modesetting dri: radeonsi gpu: amdgpu
    resolution: 1920x1080~144Hz
  API: OpenGL v: 4.6 Mesa 22.3.6 renderer: AMD Radeon Graphics (renoir LLVM
    15.0.7 DRM 3.49 6.2.6-arch1-1)

nVidia:

Graphics:
  Device-1: NVIDIA GA104M [GeForce RTX 3070 Mobile / Max-Q] driver: nvidia
    v: 525.89.02
  Device-2: Bison Integrated Camera type: USB driver: uvcvideo
  Display: wayland server: X.Org v: 22.1.8 with: Xwayland v: 22.1.8
    compositor: kwin_wayland driver: X: loaded: nvidia unloaded: modesetting
    gpu: nvidia,nvidia-nvswitch resolution: 1920x1080~144Hz
  API: OpenGL v: 4.6.0 NVIDIA 525.89.02 renderer: NVIDIA GeForce RTX 3070
    Laptop GPU/PCIe/SSE2

The file to omit from dracut:

➑ 19:21 in /etc/dracut.conf.d ξ‚’ ➜  cat nvidia.conf         
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       β”‚ File: nvidia.conf
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   β”‚ # Omit the nvidia driver from the ramdisk, to avoid needing to regenerate
   2   β”‚ # the ramdisk on updates.
   3   β”‚ omit_drivers+=" nvidia nvidia-drm nvidia-modeset nvidia-uvm "
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
➑ 19:21 in /etc/dracut.conf.d ξ‚’ ➜  

What do you have in grub?? or are you using systemd boot? Mine (I use grub purely for wayland):

GRUB_CMDLINE_LINUX_DEFAULT="nvidia-drm.modeset=1 nohpet quiet resume=UUID=9d4e515c-9542-43fb-8175-1b1f8f27b762 loglevel=3 nowatchdog nvme_load=YES"

Using systemd boot and tried with those drivers omitted; didn’t seem to make much of a difference. I guess it might be worth a shot with Wayland.

Kernel commandline is :

nvidia-drm.modeset=1 modprobe.blacklist=nouveau nvme_load=YES splash quiet systemd.show_status=false rw rd.luks.uuid=46e70949-4648-4ab8-ae26-cca23e4dd836 root=/dev/mapper/luks-46e70949-4648-4ab8-ae26-cca23e4dd836

EDIT : Nope - Wayland also shows the same problem.

So grub makes no difference as you are using systemd. This is a fairly old install, I have grub and refind (for emergencies, after last August’s grub problem). Have you made the changes in the systemd boot files?

Not used systemd boot yet, so haven’t read up on it. I did convert to dracut though.

Would be nice to see the exact error messages presented. What desktop are you running?

@philstopford
What does this show when rendering on AMD and then also on Nvidia?

glxinfo | grep -i opengl

KDE Plasma. Sorry - I thought I’d pasted the error messages, but clearly I haven’t. Not terribly helpful.

No matter whether with hybrid or discrete, I get :

../libepoxy/src/dispatch_common.c:872: epoxy_get_proc_address: Assertion 0 && β€œCouldn’t find current GLX or EGL context.\n”’ failed.`

Now, oddly, it’s not a universal issue. Blender, various Steam (Proton or native GL) games seem to run. X-Plane 12’s installer won’t start anymore in hybrid mode (but will start in discrete graphics mode), but X-Plane 12 will come up in both.

nVidia-only reports:

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce RTX 3070 Laptop GPU/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 525.89.02
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 525.89.02
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 525.89.02
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

Hybrid reports:

OpenGL vendor string: AMD
OpenGL renderer string: AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.2.6-arch1-1)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 22.3.6
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 22.3.6
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 22.3.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

What is an easy way to replicate at my end?

Trying to find out. Currently, the simplest case I found doesn’t crash at launch, but shows the same error when the application is quit. That’s the example at https://github.com/agrechnev/gtkmm-fun/tree/master/glarea0

If you build that and run it, when you quit, you might see :

glarea0: ../libepoxy/src/dispatch_common.c:872: epoxy_get_proc_address: Assertion `0 && "Couldn't find current GLX or EGL context.\n"' failed.
Aborted (core dumped)

My actual examples are more complex binaries :

https://github.com/philstopford/Variance_GPL/releases/download/5.0.0/Variance500.Gtk.zip
or
https://github.com/philstopford/Quilt_GPL/releases/download/4.0.0/Quilt400.Gtk.zip

These should launch without issue using OpenGL via AMD when in hybrid mode (prime-run will probably not work with them), and on the RTX in non-hybrid mode. For me, under my current set-up, I cannot get them to launch without crashing on hybrid or RTX-only.

What are these for? Not familiar with what it is you are trying to do. :thinking:

The first is a test application using GTK’s GLArea. The others are essentially pre-built tools that I have easily available to demonstrate the failure to launch (you’d launch using the .Gtk file in either of those example packages. I don’t have other conveniently available examples right now.

Here’s a test binary that comes from the Eto.Veldrid project on GitHub that exhibits the same failure : https://drive.google.com/file/d/1w5Z_YPbixBF8NgORI0DTykU208ezCu7r/view?usp=share_link. Run TestEtoVeldrid.Gtk and it should fail in the way described. I just can’t see why it fails on Endeavour and co, but Pop_OS works fine. I assume a misconfiguration somewhere.

Turns out also to be an issue with pure AMD graphics - I borrowed a ThinkPad L14 Gen3 AMD machine from someone else and set up Endeavour OS on it. The same problem is seen there - that makes me very puzzled.

I really don’t understand what you are doing? You would have to show me or explain it. I’m not going to just run some files i know nothing about.

Edit: I also don’t have a hybrid laptop system.

I didn’t expect you to be happy running random code, but that’s really what I have as test cases and you asked for an easy way to replicate.

GTKmm is a basic GTK based example that has an OpenGL viewport within a frame. It’s a single code file and some glsl shader code. It’s trivially built with cmake/make and the resulting binary throws that error when you close the tool down. The error looks similar to what I see when launching the other tools.

The bigger tools, and the TestEtoVeldrid.Gtk package, all use an open source library called Veldrid to bring up an OpenGL viewport, usually via GTK#. The code is all open on GitHub so can be built from scratch, but even that doesn’t necessarily help. They also use glsl shaders.

At heart, something across all Arch systems I’ve tried seems to struggle to bring up OpenGL in some form for some cases, with these common error messages :

…/libepoxy/src/dispatch_common.c:872: epoxy_get_proc_address: Assertion` 0 && β€œCouldn’t find current GLX or EGL context.\n”’ failed.

For now, I begin to think there’s a defect in a library somewhere (mesa?) that isn’t present in the current libraries on Pop_OS. I’m not sure how to find out where and, assuming I can find something, how to report it. Such is life, I will probably advise folks affected to avoid Arch for now until either some upstream fix addresses the problem or I can isolate it and make a report somewhere.

Actually i just wanted to know what you were trying to do. This really doesn’t help me understand that. :man_shrugging: