From 59527150640e1f62cbc69aa5a28494ce8b119fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 20 Mar 2023 12:55:48 -0400 Subject: [PATCH] egl: reorder code in _eglQueryDevicesEXT, add *swrast variable This is a preparation for the next commit. No change in behavior. Reviewed-by: Yogesh Mohan Marimuthu Part-of: --- src/egl/main/egldevice.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c index 68c272d282d..66f17db0522 100644 --- a/src/egl/main/egldevice.c +++ b/src/egl/main/egldevice.c @@ -306,7 +306,7 @@ _eglQueryDevicesEXT(EGLint max_devices, _EGLDevice **devices, EGLint *num_devices) { - _EGLDevice *dev, *devs; + _EGLDevice *dev, *devs, *swrast; int i = 0, num_devs; if ((devices && max_devices <= 0) || !num_devices) @@ -316,6 +316,10 @@ _eglQueryDevicesEXT(EGLint max_devices, num_devs = _eglRefreshDeviceList(); devs = _eglGlobal.DeviceList; + swrast = devs; + + /* The first device is swrast. Start with the non-swrast device. */ + devs = devs->Next; /* bail early if we only care about the count */ if (!devices) { @@ -323,23 +327,22 @@ _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. + *num_devices = MIN2(num_devs, max_devices); + + /* Add non-swrast devices first and add swrast last. * * 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->Next; dev && i < max_devices; i++) { + for (i = 0, dev = devs; 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) { - assert(_eglDeviceSupports(devs, _EGL_DEVICE_SOFTWARE)); - devices[num_devs - 1] = devs; + assert(_eglDeviceSupports(swrast, _EGL_DEVICE_SOFTWARE)); + devices[num_devs - 1] = swrast; } out: