Disable scanouts referencing a resource being unreferenced.
The scanout disable callbacks may change the current GL context, so
restore the renderer context before detaching and unreferencing the
resource.
Fixes: 9d9e152136bd ("virtio-gpu: add 3d mode and virgl rendering support.")
Signed-off-by: Marc-André Lureau <[email protected]>
---
hw/display/virtio-gpu-virgl.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 118419171ff0..cf624761610a 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -431,6 +431,7 @@ virtio_gpu_virgl_resource_unref(VirtIOGPU *g,
{
struct iovec *res_iovs = NULL;
int num_iovs = 0;
+ int i;
#if VIRGL_VERSION_MAJOR >= 1
int ret;
@@ -443,6 +444,13 @@ virtio_gpu_virgl_resource_unref(VirtIOGPU *g,
}
#endif
+ for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
+ if (g->parent_obj.scanout[i].resource_id == res->base.resource_id) {
+ virtio_gpu_disable_scanout(g, i);
+ }
+ }
+
+ virgl_renderer_force_ctx_0();
virgl_renderer_resource_detach_iov(res->base.resource_id,
&res_iovs,
&num_iovs);
--
2.55.0.543.g5ebe2ebe4ea8