qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH] Use EGL device extension in display initialization.


From: Eugene Huang
Subject: RE: [PATCH] Use EGL device extension in display initialization.
Date: Thu, 26 Aug 2021 18:00:50 +0000

Hi,

 

Sorry for the delay. Finally got git send-email working and resubmitted the patch on Aug. 24:

https://lists.nongnu.org/archive/html/qemu-devel/2021-08/msg04112.html

https://lists.nongnu.org/archive/html/qemu-devel/2021-08/msg04113.html

 

If anything is still incorrect, please advise.

 

Regards,

Eugene Huang

 

From: Marc-André Lureau <marcandre.lureau@gmail.com>
Sent: Wednesday, August 11, 2021 3:43 AM
To: Eugene Huang <eugeneh@nvidia.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] Use EGL device extension in display initialization.

 

External email: Use caution opening links or attachments

 

Hi

 

On Wed, Aug 11, 2021 at 11:58 AM Eugene Huang <eugeneh@nvidia.com> wrote:

Hi,

 

I have had some hard time to set up git send-email. I am not even sure if it is doable here. I read that attachments can be used a last resort for first timers. Here are the attachments. Hope it works.

 

 

Unfortunately, the patches still fail to apply.

 

Thanks,

Eugene

 

From: Marc-André Lureau <marcandre.lureau@gmail.com>
Sent: Friday, August 6, 2021 12:25 AM
To: Eugene Huang <eugeneh@nvidia.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] Use EGL device extension in display initialization.

 

External email: Use caution opening links or attachments

 

Hi

 

On Fri, Aug 6, 2021 at 2:28 AM Eugene Huang <eugeneh@nvidia.com> wrote:

This patch enables running generic EGL devices such as Nvidia’s in headless mode. It assumes single device. More work is needed to support multiple devices.

 

Signed-off-by: Eugene Huang <eugeneh@nvidia.com>

 

Thanks for the patch. It isn't correctly formatted and git apply fails  (https://patchew.org/QEMU/BYAPR12MB319275649A1403C254A9EA43D9F29@BYAPR12MB3192.namprd12.prod.outlook.com/). Please use git send-email.

 

---

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);

 

Given that the function has a lengthy comment to explain it, and this is quite archaic stuff, I think you should update the comments with your additions.

 

+            } else {

+                dpy = getPlatformDisplayEXT(platform, native, NULL);

+            }

         }

     }

@@ -386,6 +403,17 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,

         EGL_ALPHA_SIZE, 0,

         EGL_NONE,

     };

+

+    static const EGLint conf_att_pbuffer[] = {

+        EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,

+        EGL_RED_SIZE, 8,

+        EGL_GREEN_SIZE, 8,

+        EGL_BLUE_SIZE, 8,

+        EGL_DEPTH_SIZE, 1,

+        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,

+        EGL_NONE

+    };

+

     EGLint major, minor;

     EGLBoolean b;

     EGLint n;

@@ -411,8 +439,8 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,

     }

     b = eglChooseConfig(qemu_egl_display,

-                        gles ? conf_att_gles : conf_att_core,

-                        &qemu_egl_config, 1, &n);

+        gles ? conf_att_gles : (platform == EGL_PLATFORM_DEVICE_EXT ? conf_att_pbuffer : conf_att_core),

+        &qemu_egl_config, 1, &n);

     if (b == EGL_FALSE || n != 1) {

         error_report("egl: eglChooseConfig failed (%s mode)",

                      gles ? "gles" : "core");

@@ -434,6 +462,11 @@ int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode)

 int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)

{

+    // Try EGL Device Extension

+    if (qemu_egl_init_dpy(dpy, EGL_PLATFORM_DEVICE_EXT, mode) == 0) {

+        return 0;

+    }

+

#ifdef EGL_MESA_platform_gbm

     return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA, mode);

#else

--

2.17.1

 


thanks

 

--

Marc-André Lureau



--

Marc-André Lureau


reply via email to

[Prev in Thread] Current Thread [Next in Thread]