egl/surfaceless: Don't overwrire disp->Device if using EGL_DEVICE_EXT

Make sure that disp->Device is never overwritten during probe
function calls.

If EGL_DEVICE_EXT is provided, the probing should rather fail
than switch the device being used.

Signed-off-by: Robert Foss <rfoss@kernel.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26131>
This commit is contained in:
Robert Foss
2023-11-09 15:22:28 +01:00
committed by Marge Bot
parent 208894c94f
commit e46e9ee46c
+11 -1
View File
@@ -231,6 +231,10 @@ surfaceless_probe_device(_EGLDisplay *disp, bool swrast, bool zink)
if (!_eglDeviceSupports(dev_list, _EGL_DEVICE_DRM))
goto next;
if (_eglHasAttrib(disp, EGL_DEVICE_EXT) && dev_list != disp->Device) {
goto next;
}
device = _eglDeviceDrm(dev_list);
assert(device);
@@ -286,9 +290,15 @@ static bool
surfaceless_probe_device_sw(_EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct _egl_device *device = _eglFindDevice(dri2_dpy->fd_render_gpu, true);
dri2_dpy->fd_render_gpu = -1;
disp->Device = _eglFindDevice(dri2_dpy->fd_render_gpu, true);
if (_eglHasAttrib(disp, EGL_DEVICE_EXT) && disp->Device != device) {
return false;
}
disp->Device = device;
assert(disp->Device);
dri2_dpy->driver_name = strdup(disp->Options.Zink ? "zink" : "swrast");