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.
>
> Regards,
> Akihiko Odaki
>
> > + break;
> > + }
> > + }
> > + }
> > +#endif
> > +#else /* VIRGL_VERSION_MAJOR < 1 */
> > memset(&info, 0, sizeof(info));
> > ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
> > #endif
> > @@ -1169,11 +1189,13 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
> > virtio_gpu_3d_cbs.get_egl_display = virgl_get_egl_display;
> > }
> > #endif
> > -#ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE
> > if (qemu_egl_angle_native_device) {
> > +#if defined(VIRGL_RENDERER_NATIVE_SHARE_TEXTURE)
> > + flags |= VIRGL_RENDERER_NATIVE_SHARE_TEXTURE;
> > +#elif defined(VIRGL_RENDERER_D3D11_SHARE_TEXTURE) && defined(WIN32)
> > flags |= VIRGL_RENDERER_D3D11_SHARE_TEXTURE;
> > - }
> > #endif
> > + }
> > #if VIRGL_VERSION_MAJOR >= 1
> > if (virtio_gpu_venus_enabled(g->parent_obj.conf)) {
> > flags |= VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER;
>