Skip to content

Fix error handling in eglQueryDevicesEXT

Libglvnd's current implementation of eglQueryDevicesEXT is set up such that it will return success (and zero devices) even if every vendor's eglQueryDevicesEXT implementation fails. That's definitely not the behavior we'd want.

With these changes, libglvnd's eglQueryDevicesEXT will return success if it got at least one EGLDeviceEXT handle. Otherwise, it'll return failure, and will hand back the first error code that it got from a vendor library.

That should be consistent with existing driver behavior. In both Mesa and NVIDIA, if the driver fails to initialize a particular device, then it'll still return handles for any other devices that it finds.

I also reworked it to avoid some unnecessary work. Previously, libglvnd would call the vendor's eglQueryDevicesEXT to get a device count, then malloc a local EGLDeviceEXT array, call the vendor's eglQueryDevicesEXT again with that buffer, and then copy the handles to the application's buffer. Now, it'll just pass the pass the application's buffer through to the vendor, which avoids both the malloc and the extra eglQueryDevicesEXT call, and lets it stop early if it runs out of room in the buffer.

Merge request reports