virtio-gpu refresh rate option

slonkazoid via posted 1 patch 3 weeks, 3 days ago
Failed in applying to current master (apply log)
hw/display/virtio-gpu-base.c | 1 +
include/hw/virtio/virtio-gpu.h | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
virtio-gpu refresh rate option
Posted by slonkazoid via 3 weeks, 3 days ago
currently, the virtio-gpu module does not set a refresh rate, making it 
default to 75Hz in the qemu edid generation logic. i wrote a sloppy 
patch that adds a `refresh_rate` option to virtio-gpu, which propagates 
to all the devices based on it (i was interested in virtio-vga-gl). it's 
not of much use by itself but when combined with something like Sunshine 
or looking-glass, it can provide *far* smoother guest graphics than the 
inbuilt display devices. i have done a bare minimum amount of manual 
testing (virtio-vga-gl with venus XOR amdgpu drm native context 
streaming video games) and it functions as intended, and should not 
break the code path to fetch the refresh rate from the active display 
device (?), however, i have never contributed to QEMU before and i don't 
know the customs concerning testing, documentation, etc. if there's more 
i should do, please tell me! if this is something that would benefit 
QEMU, feel free to merge it. it's not a copyrightable change anyways.

 From bf599519fcf0fb03bffc2ce82051c91472591f26 Mon Sep 17 00:00:00 2001
From: slonkazoid <slonkazoid@slonk.ing> <mailto:slonkazoid@slonk.ing 
<mailto:slonkazoid@slonk.ing>>
Date: Tue, 21 Oct 2025 12:35:57 +0300
Subject: [PATCH] add a refresh_rate option to virtio-gpu

Signed-off-by: slonkazoid <slonkazoid@slonk.ing> 
<mailto:slonkazoid@slonk.ing <mailto:slonkazoid@slonk.ing>>
hw/display/virtio-gpu-base.c | 1 +
include/hw/virtio/virtio-gpu.h | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 7269477a1c..8e3ae958bf 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -232,6 +232,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,

g->req_state[0].width = g->conf.xres;
g->req_state[0].height = g->conf.yres;
+ g->req_state[0].refresh_rate = g->conf.refresh_rate;

g->hw_ops = &virtio_gpu_ops;
for (i = 0; i < g->conf.max_outputs; i++) {
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 9f16f89a36..8831514bb3 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -128,6 +128,7 @@ struct virtio_gpu_base_conf {
uint32_t flags;
uint32_t xres;
uint32_t yres;
+ uint32_t refresh_rate;
uint64_t hostmem;
VirtIOGPUOutputList *outputs;
};
@@ -173,7 +174,8 @@ struct VirtIOGPUBaseClass {
DEFINE_PROP_BIT("edid", _state, _conf.flags, \
VIRTIO_GPU_FLAG_EDID_ENABLED, true), \
DEFINE_PROP_UINT32("xres", _state, _conf.xres, 1280), \
- DEFINE_PROP_UINT32("yres", _state, _conf.yres, 800)
+ DEFINE_PROP_UINT32("yres", _state, _conf.yres, 800), \
+ DEFINE_PROP_UINT32("refresh_rate", _state, _conf.refresh_rate, 60000)

typedef struct VGPUDMABuf {
QemuDmaBuf *buf;
--
2.51.0