<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - eglQueryDevicesEXT returns 0 devices"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=103575">103575</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>eglQueryDevicesEXT returns 0 devices
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>17.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/Gallium/r600
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Hi-Angel@yandex.ru
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm following this guide
<a href="https://devblogs.nvidia.com/parallelforall/egl-eye-opengl-visualization-without-x-server/">https://devblogs.nvidia.com/parallelforall/egl-eye-opengl-visualization-without-x-server/</a>
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):

<a href="https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_device_enumeration.txt">https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_device_enumeration.txt</a>
<span class="quote">> EGL devices can be enumerated before EGL is initialized.  Use:

>         EGLBoolean eglQueryDevicesEXT(EGLint max_devices,
>                                       EGLDeviceEXT *devices,
>                                       EGLint *num_devices);</span >
[SNIP]
<span class="quote">> 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.</span >

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);
        }</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>