[Mesa-dev] [PATCH 7/9] egl: keep the software device at the end of the list

Marek Olšák maraeo at gmail.com
Tue May 7 22:29:25 UTC 2019


On Mon, May 6, 2019 at 11:02 AM Emil Velikov <emil.l.velikov at gmail.com>
wrote:

> From: Emil Velikov <emil.velikov at collabora.com>
>
> By default, the user is likely to pick the first device so it should
> not be the least performant (aka software) one.
>
> Suggested-by: Marek Olšák <maraeo at gmail.com>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/egl/main/egldevice.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c
> index c5c9a21273a..328d9ea08c5 100644
> --- a/src/egl/main/egldevice.c
> +++ b/src/egl/main/egldevice.c
> @@ -293,13 +293,26 @@ _eglQueryDevicesEXT(EGLint max_devices,
>        goto out;
>     }
>
> +   /* Push the first device (the software one) to the end of the list.
> +    * Sending it to the user only if they've requested the full list.
> +    *
> +    * By default, the user is likely to pick the first device so having
> the
> +    * software (aka least performant) one is not a good idea.
> +    */
>     *num_devices = MIN2(num_devs, max_devices);
>
> -   for (i = 0, dev = devs; i < *num_devices; i++) {
> +   for (i = 0, dev = devs->Next; dev && i < max_devices; i++) {
>        devices[i] = dev;
>        dev = dev->Next;
>     }
>
> +   /* User requested the full device list, add the sofware device. */
> +   if (max_devices >= num_devs) {
> +      /* The first device is always software */
>

Oh BTW, the comment here is not congruent with the code.

Marek


> +      assert(_eglDeviceSupports(devs, _EGL_DEVICE_SOFTWARE));
> +      devices[num_devs - 1] = devs;
> +   }
> +
>  out:
>     mtx_unlock(_eglGlobal.Mutex);
>
> --
> 2.21.0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190507/9f6f42e5/attachment.html>


More information about the mesa-dev mailing list