GitHub - fastchain/vgpu3d: Hardware 3D for Windows VMs on QEMU/KVM, using the host's own GPU

GitHub

14 min read Original article β†—

Message from human: I barely understand how any of this graphics stuff works. This entire repository was generated by Claude. I have absolutely no idea what's going on under the hood. But somehow, against all odds, it works.


Contents


πŸ’‘ When it's useful

vgpu3d is a WDDM driver for the Windows 11 guest. It forwards the guest's graphics work to the host's own Vulkan driver through QEMU's virtio-gpu device. The VM gets real GPU acceleration while the GPU stays shared with the host and with other VMs.

βœ… Good fit ❌ Look elsewhere
CAD and 3D tools in a Windows VM (Autodesk Fusion: ~60 fps instead of 1.4 fps on CPU) Competitive gaming at native-GPU frame rates: use GPU passthrough (VFIO)
A smooth, GPU-composited Windows desktop on a Linux workstation Games with kernel anti-cheat (they usually block VMs anyway)
Lighter and older games, emulators, GPU-accelerated apps CUDA workloads (NVIDIA-only, not possible here)
Hosts with only one GPU, or consumer GPUs without SR-IOV Production machines that need signed drivers and Secure Boot
Several Windows VMs sharing one card

Compared with the usual options on KVM:

vgpu3d Display-only virtio / QXL GPU passthrough (VFIO) SR-IOV / NVIDIA vGPU
Host keeps using the GPU βœ… βœ… ❌ dedicated to the VM βœ…
Hardware needed any Venus-capable Vulkan GPU none 2nd GPU + IOMMU data-center GPU, licenses
Windows 3D / compute Vulkan, D3D9–12, GL 4.6, OpenCL 3.0, DirectML ❌ CPU only (WARP) everything, native everything, native
VMs per GPU many – one many
Speed good; CPU-bound on light loads very slow 3D native near native

🧩 Supported APIs and engines

The guest sees one adapter, "vgpu VirtIO GPU 3D (WDDM)", and reports the host GPU by name (e.g. Virtio-GPU Venus (NVIDIA GeForce RTX 4090)) with the host GPU's memory as dedicated video memory. Apps use it automatically, with no per-app setup.

API 64-bit 32-bit Implementation
Vulkan 1.4 βœ… βœ… Mesa Venus ICD β†’ host Vulkan driver; ray tracing (pipelines and ray queries)
Direct3D 12 βœ… βœ… Triton D3D12 DDI + vkd3d-proton (in-process), DXR 1.1 ray tracing, Shader Model 6.6; runs 3DMark Steel Nomad, GravityMark, DirectML
Direct3D 10 / 11 (FL 11_1) βœ… βœ… Triton D3D10/11 DDI + DXVK (in-process)
Direct3D 9 βœ… βœ… Windows' D3D9On12 on our D3D12 driver
OpenGL 4.6 βœ… βœ… Mesa Zink (OpenGL on Vulkan)
Desktop (DWM) βœ… – GPU-composited through D3D11
OpenCL 3.0 βœ… ❌ clvk (OpenCL on Vulkan, clspv compiler built in)
DirectML βœ… – Windows' DirectML.dll on our D3D12

Tested engines and apps: 3DMark (Steel Nomad), Unigine (Heaven, Valley, Superposition), Tellusim (GravityMark), FurMark 2, PassMark PerformanceTest, Autodesk Fusion, Steam client, plus the repository's own D3D9/11/12, Vulkan and OpenGL test programs. Display modes go up to 5120Γ—2160.


πŸ“Š Benchmarks

Host: NVIDIA RTX 4090, Linux, QEMU 11.1. Guest: Windows 11 Pro, 12 vCPUs. Windowed 1080p unless noted.

Benchmark API Result
GravityMark 1.89, 1920Γ—1080 window (release build, mean of 2 runs) Direct3D 12 25105 (~150 fps)
Vulkan 17249 (~103 fps)
OpenGL 12684 (~76 fps)
Direct3D 11 11516 (~69 fps)
GravityMark 1.89, 3840Γ—2160 exclusive fullscreen D3D12 / Vulkan / OpenGL / D3D11 12587 / 5539 / 5295 / 4767 (75 / 33 / 32 / 29 fps)
3DMark Steel Nomad (demo), 4K offscreen Direct3D 12 2969 (~29.7 fps)
3DMark Solar Bay (demo), ray tracing, 1440p offscreen Vulkan 6558 (24.9 fps)
Unigine Superposition 1.1, 1080p Direct3D 11 / OpenGL 69.8 / 56.4 fps
Unigine Heaven 4.0 (5K desktop) Direct3D 11 / OpenGL 82–88 / 67.4 fps
Unigine Heaven 4.0, exclusive fullscreen Direct3D 11, 3840Γ—2160 / 1920Γ—1080 72.0 / 187.2 fps
Unigine Valley 1.0 (5K desktop) OpenGL 67.0 fps
FurMark 2, 1080p preset Vulkan / OpenGL 7882 (130.9 fps) / 7258
PassMark 11.1 3D DX9 / DX10 / DX11 / DX12 37 / 198 / 54 / 27
Autodesk Fusion, 2.5M triangles, 2560Γ—1080 Direct3D 11 66–69 fps
clpeak (OpenCL via clvk) OpenCL 3.0 62–68 TFLOPS fp32, up to 67 TFLOPS fp16, ~600–690 GB/s global memory
DirectML element-wise add, 65536 floats DirectML passes (1.1 ms)

Versus the CPU (no driver, Microsoft Basic Display + WARP):

vgpu3d CPU only
Autodesk Fusion viewport 66–69 fps 1.4 fps (~45–50Γ— slower)
GravityMark (any API) runs refuses to start: no D3D11/12 device, no GL 3+
Unigine Heaven runs aborts (out of memory)

Every frame crosses the VM boundary and goes through D3D/GL β†’ Vulkan translation, so light scenes are CPU-bound and higher desktop resolutions cost more. Heavy GPU scenes scale with the host card.


πŸ–₯️ Prepare the host (step by step)

Full details, with every XML element explained: docs/SETUP.md. Working domain template: docs/examples/WIN11_3D.xml.

1. Check the software. You need QEMU β‰₯ 9.2, libvirt β‰₯ 9 and virglrenderer β‰₯ 1.0 built with Venus:

qemu-system-x86_64 -device virtio-vga-gl,help | grep -E 'blob|hostmem|venus'   # all three listed
ls /usr/libexec/virgl_render_server /usr/lib/*/virgl_render_server 2>/dev/null  # Venus render server

2. Check the GPU. The host Vulkan driver needs 1.3-class features plus dma-buf export (NVIDIA proprietary is tested; AMD RADV and Intel ANV are Venus's main targets):

vulkaninfo | grep -E 'VK_EXT_external_memory_dma_buf|VK_EXT_image_drm_format_modifier|VK_KHR_external_memory_fd'

3. Let QEMU start the Venus render server. In /etc/libvirt/qemu.conf:

sudo systemctl restart libvirtd

4. Give QEMU the render node:

sudo usermod -aG render libvirt-qemu      # "qemu" on Fedora/Arch
ls -l /dev/dri/by-path/                   # pick the renderD* of the GPU to use

5. Configure the VM (start from docs/examples/WIN11_3D.xml). The parts that matter:

<domain type="kvm" xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
  <memoryBacking><source type="memfd"/><access mode="shared"/></memoryBacking>
  <os firmware="efi">
    <firmware>
      <feature enabled="no"  name="enrolled-keys"/>   <!-- Secure Boot capable, not enforced -->
      <feature enabled="yes" name="secure-boot"/>
    </firmware>
  </os>
  <devices>
    <graphics type="spice" autoport="yes"><listen type="address" address="127.0.0.1"/></graphics>
    <graphics type="egl-headless"><gl rendernode="/dev/dri/renderD128"/></graphics>
    <video><model type="virtio" heads="1" primary="yes"><acceleration accel3d="yes"/></model></video>
  </devices>
  <qemu:commandline>
    <qemu:arg value="-global"/><qemu:arg value="virtio-vga-gl.blob=true"/>
    <qemu:arg value="-global"/><qemu:arg value="virtio-vga-gl.hostmem=4G"/>
    <qemu:arg value="-global"/><qemu:arg value="virtio-vga-gl.venus=true"/>
  </qemu:commandline>
</domain>

6. Start it:

sudo virsh define WIN11_3D.xml && sudo virsh start WIN11_3D
sudo tail -f /var/log/libvirt/qemu/WIN11_3D.log     # no "failed to initialize venus renderer"

πŸͺŸ Install on the guest (step by step)

Requirements: Windows 11 x64, Secure Boot not enforced (the driver is test-signed), about 200 MB of free disk space.

Turn off Fast Startup / hibernation in the guest (elevated prompt: powercfg /hibernate off). Fast Startup resumes the guest's graphics driver state from disk, while QEMU and virglrenderer start fresh: host resources the restored driver expects are gone, and allocations fail after such a "shutdown". Use full shutdowns and restarts.

With the installer (recommended)

  1. Copy vgpu3d-setup-<version>.exe into the VM.
  2. Save your work. The display adapter restarts during installation, and apps holding the GPU may close.
  3. Run it and accept the UAC prompt. Setup checks for Windows 11 x64 and the virtio-gpu adapter, then:
    • turns on test signing if it's off. Reboot when asked; installation continues automatically at the next logon;
    • creates a local code-signing certificate and trusts it;
    • signs the driver, builds its catalog and installs it with pnputil.
  4. Reboot if the finish page asks (usually needed only when switching away from Basic Display).
  5. Check: Device Manager β†’ Display adapters shows vgpu VirtIO GPU 3D (WDDM), status OK. The desktop shows a "Test Mode" watermark.

Silent install: vgpu3d-setup-<version>.exe /S (exit code 3010 = reboot needed). Uninstall: Settings β†’ Apps β†’ Installed apps β†’ vgpu3d virtio-gpu 3D driver. This removes the driver (the adapter falls back to Microsoft Basic Display) and the certificate. To turn test signing back off: bcdedit /set testsigning off.

Manually (from the zip)

# elevated PowerShell, inside the unpacked vgpu3d-m1.zip
bcdedit /set testsigning on        # once, then reboot (install.ps1 also offers this)
powershell -ExecutionPolicy Bypass -File .\install.ps1

Verify

Check Expected
vulkaninfo --summary Virtio-GPU Venus (<host GPU>)
dxdiag β†’ Display vgpu adapter, Direct3D acceleration enabled
any OpenGL app renderer zink Vulkan 1.4(Virtio-GPU Venus (<host GPU>))

βš™οΈ How it works

β”Œβ”€β”€ Windows guest ─────────────────────────────────────────────────┐
β”‚                                                                  β”‚
β”‚  D3D12    ──► Triton + vkd3d-proton ────┐                        β”‚
β”‚  D3D9     ──► D3D9On12 ─► D3D12 ─────────                        β”‚
β”‚  D3D10/11 ──► Triton + DXVK ─────────────                        β”‚
β”‚  OpenGL   ──► Mesa Zink ─────────────────                        β”‚
β”‚  OpenCL   ──► clvk ──────────────────────                        β”‚
β”‚  Vulkan   ──► vulkan-1 β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
β”‚                                         β–Ό                        β”‚
β”‚                        Mesa Venus ICD  (vulkan_virtio.dll)       β”‚
β”‚                                         β”‚  D3DKMT                β”‚
β”‚                                         β–Ό                        β”‚
β”‚                       viogpu3d.sys  (WDDM 2 kernel driver)       β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚  virtio-gpu: Venus rings + shared memory
β”Œβ”€β”€ Linux host ───────────────────────────▼────────────────────────┐
β”‚                                                                  β”‚
β”‚                    QEMU  virtio-vga-gl  (blob, hostmem, venus)   β”‚
β”‚                                         β–Ό                        β”‚
β”‚                       virgl_render_server  (Venus decoder)       β”‚
β”‚                                         β–Ό                        β”‚
β”‚                         host Vulkan driver  ─►  host GPU         β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • viogpu3d.sys: a WDDM 2 render and display miniport (GPU virtual memory, monitored fences, residency, mode setting), derived from the virtio-win viogpu3d line.
  • Venus: Mesa's Vulkan-over-virtio driver with a new Windows backend (D3DKMT contexts, shared memory, cross-process sharing). Everything else is built on top of it.
  • D3D10/11/12: a WDDM user-mode driver running DXVK and vkd3d-proton in-process behind Triton's DDI layer.
  • OpenGL: Mesa Zink, registered as the system OpenGL ICD.
  • 32-bit apps: a complete WOW64 set of the user-mode parts on the same kernel driver.
  • Display: frames reach QEMU through a framebuffer copy, which works on every host, including NVIDIA with egl-headless.

Progress log and design notes: docs/STATUS.md.


⚠️ Limitations

  • Test-signed: needs test signing, so Secure Boot must be off (not enforced).
  • OpenCL is 64-bit only (clvk). Do not install Microsoft's OpenCL, OpenGL and Vulkan Compatibility Pack: its Dozen driver and our D3D12 driver call each other, and every Vulkan app deadlocks.
  • No CUDA: it needs NVIDIA's own driver and hardware in the guest.
  • Driver install/update restarts the adapter. Apps using the GPU get a "device removed/lost" error and must recreate their device (many simply exit); DWM and the desktop keep running.
  • Light workloads are CPU-bound, and the desktop costs CPU at very high resolutions.
  • Tested on NVIDIA (RTX 4090) only; AMD and Intel hosts are expected to work but are untested.

Full list and troubleshooting: docs/SETUP.md Β§8–9.


🎞️ Tearing and picture artifacts

Frames travel app β†’ Windows' compositor (DWM) β†’ the driver's framebuffer copy β†’ host (QEMU egl-headless) β†’ SPICE β†’ viewer. What we know about artifacts along that path (measured with the src/umd/tearcheck programs, which alternate solid red and blue frames and check what DWM shows and what the driver hands to the host):

Where Status
Guest framebuffer β†’ host Fixed in 1.0.26313.7767: the next frame overwrote the framebuffer while the host was still reading the previous one (up to ~3 % of frames in fast motion).
Modern apps (flip-model D3D11/D3D12: most games, 3DMark, Unigine) Clean: 0 mixed frames, windowed, borderless and exclusive fullscreen.
Older windowed D3D apps (legacy blt-model swap chains) running uncapped Mostly fixed in 1.0.26313.7767: ~1–2 % of frames mixed (was ~17 %). The copy into DWM's window surface could overlap DWM reading it on the host GPU, because DWM composes outside Windows' GPU scheduler; it now waits while DWM composes, which lowers such apps' uncapped frame rate (test window ~400 β†’ ~120 fps). Clean with vsync on.
Vulkan and OpenGL apps in a window (e.g. GravityMark-Vulkan, FurMark) Fixed in 1.0.26313.15979: they used to end with a GDI blit into the window, which tore in 1–5 % of frames. They now present through a flip-model DXGI swap chain: 0 mixed frames, ~4 % lower GravityMark score. VGPU_WSI_DXGI=0 (environment) or HKLM\SOFTWARE\vgpu WsiDxgi=0 (DWORD) restores the GDI path.
Host side (QEMU readback, SPICE, viewer) Not measurable from the guest. Steel Nomad's frames leave the guest clean, yet patches can show in fast motion in virt-manager's console; turning SPICE streaming and image compression off did not change it.

What helps today

  • Turn vsync on in apps that offer it (blt-model apps are then clean).
  • Prefer fullscreen or borderless modes of modern (flip-model) apps.
  • If patches show in fast motion, try another viewer, e.g. remote-viewer spice://127.0.0.1:5900 instead of virt-manager's built-in console.

The driver cannot see exactly when DWM starts reading a window, so the blt-model fix waits conservatively (from each vsync until DWM's frame is done): hence the residual ~1–2 % and the frame-rate cost for uncapped blt-model apps. Details: docs/STATUS.md.


πŸ”¨ Building from source

Everything cross-compiles on Linux: MinGW-w64 (posix), clang/lld (clang-cl for the kernel driver), meson and ninja, plus the WDK/SDK headers in toolchain/. NSIS (makensis) is needed for the installer.

build/package_kmd3d.sh release     # kernel driver + 64/32-bit UMDs, Venus, Zink -> out/vgpu3d-m1.zip
build/build_installer.sh           # NSIS installer -> out/vgpu3d-setup-<version>.exe
build/build_installer.sh --package # both in one go

The individual builds are build_kmd3d.sh, build_umd.sh [32], build_dxvk.sh [32], build_vkd3d.sh [32], build_triton_venus.sh [32] and build_gl.sh [32]. OpenCL: build_clvk.sh (clvk with an LLVM/clspv cross-build, ~10 min on 32 cores) and build_opencl_loader.sh [32] (Khronos OpenCL.dll).

Path Contents
src/kmd3d/viogpu/ WDDM kernel driver; src/kmd3d-inf/ has the INF and Vulkan ICD manifests
src/umd3d/ D3D10/11/12 user-mode driver backend (Triton DDI β†’ DXVK / vkd3d-proton)
src/installer/ NSIS installer script
src/umd/ guest test programs (d3d9test, d3d11test, d3d12test, blttest, gltest, vkcompute, rttest, dxrtest, …)
patches/ our changes to Mesa, Triton, DXVK, vkd3d-proton and clvk
build/ cross-build, packaging and installer scripts
tools/windows/ guest scripts: install/uninstall, test rounds, benchmark runners
docs/ setup manual, progress log, design notes

πŸ“œ Credits and licences

vgpu3d stands on the work of many projects. Thank you to their authors and contributors. The driver package contains code from the projects in the first table; check each licence before redistributing binaries.

Shipped in the driver package

Component Used for Authors Licence
virtio-win / kvm-guest-drivers-windows Base of the WDDM kernel driver (viogpu3d.sys) and its virtio layer Red Hat, Inc. and contributors BSD-3-Clause
Triton / Neptune (KMD fork) D3D10/11/12 DDI layer, Venus transport for Windows, resolution service (vgpusrv.exe, viogpuap.exe), WDDM 3D groundwork osy / Turing Software LLC and contributors MIT (Mesa side), BSD-3-Clause (kernel side)
Mesa Venus Vulkan driver, Zink OpenGL, Gallium WGL The Mesa contributors (Venus: Google and others; Zink: Collabora and others) MIT (some files other permissive licences, see mesa/licenses)
DXVK (with dxbc-spirv, libdisplay-info) Direct3D 10/11 on Vulkan, in-process Philip Rebohle, Joshua Ashton, Robin Kertels, Jeffrey Ellison and contributors zlib (dxbc-spirv, libdisplay-info: MIT)
vkd3d-proton (with dxil-spirv) Direct3D 12 on Vulkan Hans-Kristian Arntzen, Philip Rebohle, Joshua Ashton (Valve) and contributors; based on Wine's vkd3d (JΓ³zef Kucia and others) LGPL-2.1-or-later (dxil-spirv: MIT)
clvk OpenCL 3.0 on Vulkan KΓ©vin Petit and contributors Apache-2.0
clspv, LLVM OpenCL C β†’ SPIR-V compiler inside clvk Google and contributors; the LLVM project Apache-2.0; Apache-2.0 WITH LLVM-exception
SPIRV-Tools, SPIRV-Headers, SPIRV-LLVM-Translator SPIR-V handling inside clvk/clspv The Khronos Group and contributors Apache-2.0; MIT-style (Khronos); LLVM Release License (NCSA)
OpenCL ICD Loader, OpenCL-Headers OpenCL.dll the installer puts in System32 The Khronos Group Apache-2.0
Vulkan-Headers Vulkan API headers The Khronos Group Apache-2.0 OR MIT
MinGW-w64 runtime, GCC runtime libraries Statically linked C/C++ runtime of the user-mode DLLs and tools The MinGW-w64 project; the GCC project ZPL-2.1 / MIT / public domain (MinGW-w64); GPL-3.0 with the GCC Runtime Library Exception
Inf2Cat.exe and its helper DLLs (Windows Driver Kit) Building the driver catalog inside the guest during installation Microsoft Microsoft WDK licence terms

Used to build, test or run it (not in the package)

Component Used for Authors Licence
QEMU, virglrenderer Host side: virtio-gpu device, Venus and virgl renderers The QEMU and virglrenderer contributors GPL-2.0 (QEMU), MIT (virglrenderer)
Windows SDK and WDK headers/libraries Compiling the kernel and user-mode drivers Microsoft Microsoft SDK/WDK licence terms
LLVM/clang (clang-cl, lld), MinGW-w64 GCC, Meson, Ninja, Python Cross-compilers and build tools Their respective projects Apache-2.0 WITH LLVM-exception; GPL-3.0; Apache-2.0; Apache-2.0; PSF
NSIS The Windows installer NSIS contributors zlib/libpng
RenderDoc Frame-capture debugging Baldur Karlsson and contributors MIT
Yttrium Studied for ideas (scheduler-ordered Venus work, paging node, clock calibration, Fast Startup note); no code copied arehnman and contributors BSD-3-Clause, MPL-2.0 for its viogpu3d changes
VirtualBox Reference only (kept in upstream/vbox); no code used Oracle and contributors GPL-3.0

Our own code (the vgpu changes, the installer, tools and tests) follows the licence of the project it modifies; new files carry an SPDX header (MIT unless stated otherwise). Our patches to Mesa, Triton, DXVK, vkd3d-proton and clvk are in patches/.