On 12/24/25 16:56, Joelle van Dyne wrote:
On Tue, Dec 23, 2025 at 10:29 PM Akihiko Odaki
<[email protected]> wrote:
On 2025/12/20 1:16, Joelle van Dyne wrote:
On Wed, Dec 3, 2025 at 10:41 PM Akihiko Odaki
<[email protected]> wrote:
On 2025/12/03 13:07, Joelle van Dyne wrote:
In order to support native texture scanout beyond D3D, we make this more
generic allowing for multiple native texture handle types.
Signed-off-by: Joelle van Dyne <[email protected]>
---
include/ui/console.h | 22 +++++++++++++++++++---
include/ui/gtk.h | 4 ++--
include/ui/sdl2.h | 2 +-
hw/display/virtio-gpu-virgl.c | 10 +++++++---
ui/console.c | 8 ++++----
ui/dbus-console.c | 2 +-
ui/dbus-listener.c | 8 ++++----
ui/egl-headless.c | 2 +-
ui/gtk-egl.c | 2 +-
ui/gtk-gl-area.c | 2 +-
ui/sdl2-gl.c | 2 +-
ui/spice-display.c | 2 +-
12 files changed, 43 insertions(+), 23 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 98feaa58bd..25e45295d4 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -131,6 +131,22 @@ struct QemuConsoleClass {
ObjectClass parent_class;
};
+typedef enum ScanoutTextureNativeType {
+ SCANOUT_TEXTURE_NATIVE_TYPE_NONE,
+ SCANOUT_TEXTURE_NATIVE_TYPE_D3D,
+} ScanoutTextureNativeType;
+
+typedef struct ScanoutTextureNative {
+ ScanoutTextureNativeType type;
+ union {
+ void *d3d_tex2d;
+ } u;> +} ScanoutTextureNative;
Instead, I suggest:
typedef struct ScanoutTextureNative {
ScanoutTextureNativeType type;
void *handle;
} ScanoutTextureNative;
...to align with the definition of struct
virgl_renderer_resource_info_ext and
virgl_renderer_create_handle_for_scanout(), which do not add a field for
each type (except the one for the backward compatibility).
I've updated virglrenderer to use a union as well. Since we are
passing ScanoutTextureNative around byval and it can grow with
additional platform support, I think it would be better to keep it as
a union.
I don't think using a union for virglrenderer is a good idea because
adding another member to the union can change its size and cause an ABI
breakage. Sticking to void * is the safest choice. We rely on void * to
represent platform-specific types anyway so there is practically no type
safetey here, unfortunately.
That's fair, we can use a struct in virglrenderer. However, in QEMU if
we are passing byval and a struct (once increased in size) could lead
to needless copying.
What I suggest for virlgrenderer is basically as folllows:
struct virgl_renderer_resource_info_ext {
int version;
struct virgl_renderer_resource_info base;
bool has_dmabuf_export;
int planes;
uint64_t modifiers;
void *d3d_tex2d;
union {
/* this is for backwards compatibility */
void *d3d_tex2d;
void *native_handle;
};
enum virgl_renderer_native_handle_type native_type;
};
For QEMU:
typedef struct ScanoutTextureNative {
enum virgl_renderer_native_handle_type type;
void *handle;
} ScanoutTextureNative;
... and you'll get the stable ABI for virglrenderer and zero-copy with
handle.
Regards,
Akihiko Odaki