eglQueryDevicesEXT doesn't update as new devices are added
If a graphics device appears after the first call to eglQueryDevicesEXT, it won't appear in the list of devices returned by eglQueryDevicesEXT in subsequent calls. This could e.g.: occur if you start sway with nouveau
disabled, and then run modprobe nouveau
later (and suddenly nvidia cards will appear in /dev/dri/)
(by the way, I encountered this while working on GPU hotplugging support for wlroots: https://github.com/neon64/wlroots/issues/2)
It appears this may be to do with this line in libglvnd: https://gitlab.freedesktop.org/glvnd/libglvnd/-/blob/master/src/EGL/libeglmapping.c#L354 (which is called by https://gitlab.freedesktop.org/glvnd/libglvnd/-/blob/master/src/EGL/libegl.c#L962), where the list of egl devices is only initialised once in the library, assuming it will never change throughout the lifetime of the application.
Also referring to #210 (closed)
On a closer look, this isn't as broken as I thought. Libglvnd does initialize the device list before it tries to look up the vendor which owns an EGLDeviceEXT handle. So, as long as the device that the vendor returns from eglQueryDisplayAttribEXT is also returned from eglQueryDevicesEXT, it'll work. In practice, that's probably a safe assumption.
It appears like this isn't a safe assumption, because in this case the device returned from eglQueryDisplayAttribEXT doesn't appear in eglQueryDevicesEXT, so wlroots gets a BAD_DEVICE_EXT
error from device pointer that isn't actually invalid.