Skip to content

eglinfo: fix crash

Alba Mendez requested to merge mildsunrise/mesa-demos:fix-eglinfo into main

Commit db46c142 (which builds on 1bf0690e) transitioned eglinfo to using glad2 to load EGL functions. It has been crashing since.

This seems to be because we're not using glad2 correctly. gladLoaderLoadEGL needs an initialized display (it will try the passed one, the current one, and the default one, in that order) or it will otherwise silently refuse to load EGL functions above v1.0. Trying to call eglGetPlatformDisplay (EGL v1.5) then results in a crash.

Even if we correctly initialize glad2 by passing an initialized display, this is not enough because glad2 is conservative and will only load eglGetPlatformDisplay if Mesa reports EGL v1.5+. This is not always the case; Mesa may report v1.4 even when eglGetPlatformDisplay is exposed.

So, I suggest changing the eglGetPlatformDisplay call into an eglGetPlatformDisplayEXT one. This makes it consistent with the rest of the code (which is only using eglGetPlatformDisplayEXT) and also improves compatibility with non-Mesa EGL implementations.

Merge request reports