Hi Josh, > It looks like the virtio-gpu flush should be fenced, but on the host side the > received flush cmd doesn't have the fence flag set, and no fence_id. So, > I have to reply right away instead of waiting for scanout to complete. > Is that expected? then what's the right way to vsync the guest? You have not described how you are rendering the frame in the Guest; are you using Virgl or software renderer (llvmpipe?) or any other mechanism? Regardless, a fence is added to virtio-gpu resource_flush only for Guest blobs (i.e, when blob=true and the scanout buffer is allocated by the Guest) at the moment. And, with Qemu GTK UI, the guest updates are synchronized with GTK's draw (Xorg based compositors) or render events (Wayland compositors), which align with Host's vsync event. All of the above only happens when launching the VM with blob=true (zero-copy) to prevent the Host and Guest from using Guest's scanout buffer at the same time. For blob=false, since a copy of the scanout buffer is made on the Host during virtio_gpu_cmd_transfer_to_host_2d (into a pixman image), it did not make sense to add a fence to synchronize access. > At the moment, I'm queueing up the resources for scanout, but guest is > flushing faster than host vsync. I briefly looked at qemu implementation, > but don't understand it yet. A high level breakdown of what should be > happening would be extremely helpful! With Qemu GTK UI, the pipeline is blocked (renderer_blocked=true) after resource_flush and the response to the Guest is deferred (the cmd is put on a fenceq) until the GPU Blit (from the scanout buffer to a Host allocated EGL backbuffer) is complete. This Blit itself is tracked with a EGL Sync object (or a fence derived from it) and once the Blit is complete (which indicates that the Host is done and the EGL fence is signaled), the pipeline is unblocked and the response to resource_flush is sent to the Guest. This response includes the fence_id that the Guest embedded in resource_flush. If virgl=true (which means blob=false at the moment), then things work very differently. AFAIU, the backing for most resources including the scanout are allocated on the Host in this case. On a different note, please use text instead of HTML when sending emails to mailing lists. Thanks, Vivek > Thanks, > Josh