On 2025/12/20 1:26, Joelle van Dyne wrote:
On Wed, Dec 3, 2025 at 11:13 PM Akihiko Odaki
<[email protected]> wrote:

On 2025/12/03 13:07, Joelle van Dyne wrote:
In order to support additional native texture types, we need to update the
defines in virglrenderer. The changes are backwards compatible and so
builds should work with either the new version or the old version.

Signed-off-by: Joelle van Dyne <[email protected]>
---
   hw/display/virtio-gpu-virgl.c | 28 +++++++++++++++++++++++++---
   1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index d0e6ad4b17..36c670f988 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -24,6 +24,8 @@

   #include <virglrenderer.h>

+#define SUPPORTED_VIRGL_INFO_EXT_VERSION (1)

This naming is a bit confusing because version 0 is also supported.

+
   struct virtio_gpu_virgl_resource {
       struct virtio_gpu_simple_resource base;
       MemoryRegion *mr;
@@ -441,12 +443,30 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
           memset(&ext, 0, sizeof(ext));
           ret = virgl_renderer_resource_get_info_ext(ss.resource_id, &ext);
           info = ext.base;
+        /* fallback to older version */
           native = (ScanoutTextureNative){
               .type = ext.d3d_tex2d ? SCANOUT_TEXTURE_NATIVE_TYPE_D3D :
                                       SCANOUT_TEXTURE_NATIVE_TYPE_NONE,
               .u.d3d_tex2d = ext.d3d_tex2d,
           };
-#else
+#if VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION >= 
SUPPORTED_VIRGL_INFO_EXT_VERSION
+        if (ext.version >= VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION) {
+            switch (ext.native_type) {
+            case VIRGL_NATIVE_HANDLE_NONE:
+            case VIRGL_NATIVE_HANDLE_D3D_TEX2D: {
+                /* already handled above */
+                break;
+            }
+            default: {
+                qemu_log_mask(LOG_GUEST_ERROR,
+                            "%s: unsupported native texture type %d\n",
+                            __func__, ext.native_type);

It is not an error condition; the d3d_tex2d field is an optional hint
that allows zero-copy inter-process sharing and the tex_id field is used
if it is missing or inter-process sharing is unnecessary. It should be
fine to dismiss the native handle unless the semantic changes.
When VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION >= 1, the semantic
changed to always have a ext.native_type. In case of missing
d3d_tex2d, ext.native_type will be VIRGL_NATIVE_HANDLE_NONE. The
default case is if virglrenderer introduces a new native type that is
unknown at the time QEMU is built. This is why the struct version is
bumped.

What I am saying is that having a new native type that is unknown is fine and hence no need to log an error. QEMU will simply use the OpenGL texture in such a case.

Regards,
Akihiko Odaki

Reply via email to