[PATCH RFC 1/7] egl-helpers: store handle to native device

Joelle van Dyne posted 7 patches 3 days, 19 hours ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
[PATCH RFC 1/7] egl-helpers: store handle to native device
Posted by Joelle van Dyne 3 days, 19 hours ago
Make way for other platforms by making the variable more general. Also we
will be using the device in the future so let's save the pointer in the
global instead of just a boolean flag.

Signed-off-by: Joelle van Dyne <j@getutm.app>
---
 include/ui/egl-helpers.h      | 2 +-
 hw/display/virtio-gpu-virgl.c | 2 +-
 ui/egl-helpers.c              | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
index acf993fcf5..c239d32317 100644
--- a/include/ui/egl-helpers.h
+++ b/include/ui/egl-helpers.h
@@ -12,7 +12,7 @@
 extern EGLDisplay *qemu_egl_display;
 extern EGLConfig qemu_egl_config;
 extern DisplayGLMode qemu_egl_mode;
-extern bool qemu_egl_angle_d3d;
+extern void *qemu_egl_angle_native_device;
 
 typedef struct egl_fb {
     int width;
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 07f6355ad6..20c856c04e 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -1152,7 +1152,7 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
     }
 #endif
 #ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE
-    if (qemu_egl_angle_d3d) {
+    if (qemu_egl_angle_native_device) {
         flags |= VIRGL_RENDERER_D3D11_SHARE_TEXTURE;
     }
 #endif
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index e3f2872cc1..57bcf99498 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -28,7 +28,7 @@
 EGLDisplay *qemu_egl_display;
 EGLConfig qemu_egl_config;
 DisplayGLMode qemu_egl_mode;
-bool qemu_egl_angle_d3d;
+void *qemu_egl_angle_native_device;
 
 /* ------------------------------------------------------------------ */
 
@@ -651,7 +651,7 @@ int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode)
         }
 
         trace_egl_init_d3d11_device(device);
-        qemu_egl_angle_d3d = device != NULL;
+        qemu_egl_angle_native_device = d3d11_device;
     }
 #endif
 
-- 
2.41.0
Re: [PATCH RFC 1/7] egl-helpers: store handle to native device
Posted by Akihiko Odaki 2 days, 17 hours ago
On 2025/12/03 13:07, Joelle van Dyne wrote:
> Make way for other platforms by making the variable more general. Also we
> will be using the device in the future so let's save the pointer in the
> global instead of just a boolean flag.
> 
> Signed-off-by: Joelle van Dyne <j@getutm.app>
> ---
>   include/ui/egl-helpers.h      | 2 +-
>   hw/display/virtio-gpu-virgl.c | 2 +-
>   ui/egl-helpers.c              | 4 ++--
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
> index acf993fcf5..c239d32317 100644
> --- a/include/ui/egl-helpers.h
> +++ b/include/ui/egl-helpers.h
> @@ -12,7 +12,7 @@
>   extern EGLDisplay *qemu_egl_display;
>   extern EGLConfig qemu_egl_config;
>   extern DisplayGLMode qemu_egl_mode;
> -extern bool qemu_egl_angle_d3d;
> +extern void *qemu_egl_angle_native_device;

I guess ANGLE will not be relevant for Metal and leaving it will be 
misleading.

Regards,
Akihiko Odaki

>   
>   typedef struct egl_fb {
>       int width;
> diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
> index 07f6355ad6..20c856c04e 100644
> --- a/hw/display/virtio-gpu-virgl.c
> +++ b/hw/display/virtio-gpu-virgl.c
> @@ -1152,7 +1152,7 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
>       }
>   #endif
>   #ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE
> -    if (qemu_egl_angle_d3d) {
> +    if (qemu_egl_angle_native_device) {
>           flags |= VIRGL_RENDERER_D3D11_SHARE_TEXTURE;
>       }
>   #endif
> diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
> index e3f2872cc1..57bcf99498 100644
> --- a/ui/egl-helpers.c
> +++ b/ui/egl-helpers.c
> @@ -28,7 +28,7 @@
>   EGLDisplay *qemu_egl_display;
>   EGLConfig qemu_egl_config;
>   DisplayGLMode qemu_egl_mode;
> -bool qemu_egl_angle_d3d;
> +void *qemu_egl_angle_native_device;
>   
>   /* ------------------------------------------------------------------ */
>   
> @@ -651,7 +651,7 @@ int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode)
>           }
>   
>           trace_egl_init_d3d11_device(device);
> -        qemu_egl_angle_d3d = device != NULL;
> +        qemu_egl_angle_native_device = d3d11_device;
>       }
>   #endif
>