I'm following this guide
https://devblogs.nvidia.com/parallelforall/egl-eye-opengl-visualization-without-x-server/
to choose a GPU through native means of EGL.
Using eglQueryDevicesEXT() in both modes, i.e. with "devices" array to get
descriptions, as well as by passing 0 as "devices", results in 0 as a number of
supported devices. Specification says that I should've get at least 1 (and I
actually have two, r600g-managed, cards):
https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_device_enumeration.txt
> EGL devices can be enumerated before EGL is initialized. Use:
>
> EGLBoolean eglQueryDevicesEXT(EGLint max_devices,
> EGLDeviceEXT *devices,
> EGLint *num_devices);
[SNIP]
> If <devices> is NULL, then <max_devices> will be ignored, no devices will be
> returned in <devices>, and <num_devices> will be set to the number of
> supported devices in the system. All implementations must support at least
> one device.
>
> On failure, EGL_FALSE is returned.
Below is the modified code I'm using:
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
EGLint numDevices;
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)
eglGetProcAddress("eglQueryDevicesEXT");
if (eglQueryDevicesEXT(2, 0, &numDevices) == EGL_FALSE) {
puts("error in eglQueryDevicesEXT");
return 1;
}
printf("Detected %d devices\n", numDevices);
}