---
ui/egl-helpers.c | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 7c530c2825..c11610c083 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -1,6 +1,8 @@
/*
* Copyright (C) 2015-2016 Gerd Hoffmann <kraxel@redhat.com>
*
+ * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -349,11 +351,26 @@ static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
EGLDisplay dpy = EGL_NO_DISPLAY;
/* In practise any EGL 1.5 implementation would support the EXT extension */
- if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
+ if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")
+ && epoxy_has_egl_extension(NULL, "EGL_EXT_platform_device")
+ && (epoxy_has_egl_extension(NULL, "EGL_EXT_device_base")
+ || epoxy_has_egl_extension(NULL, "EGL_EXT_device_enumeration"))) {
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
if (getPlatformDisplayEXT && platform != 0) {
- dpy = getPlatformDisplayEXT(platform, native, NULL);
+ if (platform == EGL_PLATFORM_DEVICE_EXT) {
+ static const int MAX_DEVICES = 4;
+ EGLDeviceEXT eglDevs[MAX_DEVICES];
+ EGLint numDevices;
+
+ PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
+ (PFNEGLQUERYDEVICESEXTPROC)
+ eglGetProcAddress("eglQueryDevicesEXT");
+ eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
+ dpy = getPlatformDisplayEXT(platform, eglDevs[0], 0);