Fake vblank synchonization of page flips on virtual DRM devices
While virtual DRM devices like virtio_gpu or bochsdrmfb advertise 60Hz modes, page flips happen quicker than that and complete once the data reached the host, with no relation to when it's actually displayed. The missing delay leads to excessive frame rates in VMs when something is being continuously updated, like wayland clients using frame callbacks for animations or vsync.
If a page flip completes quicker than a vblank interval for the configured refresh rate, override the presentation timestamp with the minimum expected interval to limit the frame rate.
Tested in a QEMU+KVM VM with VGA
(bochs
driver), QXL
and virtio_gpu
(no virgl). While playing a YT video in FF, CPU use is reduced from 65% to
45% and the system is much more reponsive, while rendering a smooth 60fps.
Previously animations in FF were smooth, but it took several seconds before
it reacted to input.
When using virgl with virtio_gpu
, FPS is already ~59 before this patch,
so it doesn't make a difference. That case should probably be detected and
m_fakeVblankWait
set to false in that case, also for VRR displays.
I don't think it's possible to just call GLPlatform::instance()->isVirgl();
during DrmOutput
construction, what's the best way for that?
Should it ignore VRR capable connectors as well? I don't think that's
supported for any of the named drivers currently.