Cross-platform virtual display driver support for Sunshine.
This repository owns Sunshine's dedicated virtual display control protocols,
identity model, EDID generation, Windows UMDF/IddCx driver implementation, and
Linux DRM virtual-display backend.
It is intentionally separate from Sunshine's existing libdisplaydevice
dependency, which remains only a display enumeration/settings library.
The driver is dedicated to Sunshine virtual-display use cases:
- create and remove temporary displays through the control API
- set and query a small permanent-display pool
- preserve stable display identity through
DisplayId - keep lease lifetime separate from display identity through
LeaseId - advertise HDR-capable EDID and IddCx target capabilities
- provide runtime probes that verify the control path and HDR target behavior
- provision a dormant Linux DRM connector pool and lease connectors through a root-owned Unix-domain control broker
The Windows implementation is clean-room: compatibility work happens at the API/behavior level rather than by copying other virtual-display drivers. The Linux kernel subtree is deliberately derived from upstream VKMS and retains its GPL SPDX licensing and provenance.
Initialize the shared dependencies before building the test suite or the optional KWin bridge:
git submodule update --init --recursive
cmake -S . -B cmake-build-tests -G Ninja -DBUILD_TESTS=ON
cmake --build cmake-build-tests --parallel
ctest --test-dir cmake-build-tests --output-on-failureThe test suite uses lizardbyte-common's pinned GoogleTest and shared test helpers.
On Windows, use the MSYS2 UCRT64 shell for Ninja builds. With MSVC, configure
with -G "Visual Studio 17 2022" -A x64, build with --config Release,
and pass -C Release to CTest. Standalone GNU test builds enable coverage automatically.
On Linux, the same build also tests the connector broker, module installer,
kernel-source contract, deterministic HDR EDID, and the public
LinuxControlClient. The linux/vibeshine-drm tree contains the GPL-licensed
out-of-tree DRM module derived from upstream VKMS; its source files retain the
upstream SPDX identifiers. Service and installer assets live under
linux/packaging.
The optional KWin bridge (-DBUILD_VIBESHINE_KWIN_GPU_BRIDGE=ON) requires
libdrm 2.4.127 or newer and the GBM development package.
To build only the Windows driver, CLI, and runtime probe:
cmake -S . -B build-driver -G Ninja -DBUILD_TESTS=OFF -DBUILD_SUNSHINE_VIRTUAL_DISPLAY_DRIVER=ON -DBUILD_VIRTUALDISPLAY_TOOLS=ON -DBUILD_VIRTUALDISPLAY_PROBE=ON
cmake --build build-driver --target SunshineVirtualDisplayDriver virtualdisplay_tools -j 10The Windows driver build requires MSVC and the Windows Driver Kit. Packaging
also requires Inf2Cat.exe from the WDK. Local package builds generate the INF
and catalog files, but do not sign them; sign the driver package according to
your Windows driver distribution policy before installing it outside a test or
developer environment.
To build the release ZIP locally:
cmake -S . -B build-driver -G Ninja -DBUILD_TESTS=OFF -DBUILD_SUNSHINE_VIRTUAL_DISPLAY_DRIVER=ON -DBUILD_VIRTUALDISPLAY_TOOLS=ON -DBUILD_VIRTUALDISPLAY_PROBE=ON -DLIBVIRTUALDISPLAY_PACKAGE_VERSION=0.1.0
cmake --build build-driver --target package -j 10The ZIP contains:
driver/SunshineVirtualDisplayDriver.infdriver/SunshineVirtualDisplayDriver.catdriver/SunshineVirtualDisplayDriver.dlltools/virtualdisplay.exetools/virtualdisplay_broker.exetools/virtualdisplay_probe.exevulkan-layer/VkLayer_sunshine_hdr.dllandvulkan-layer/VkLayer_sunshine_hdr.jsonREADME.mdandLICENSE
Support traces and Event Log capture should follow
docs/support-diagnostics.md.
For C++ integration, consume the source tree and CMake target. The release ZIP is intended for the driver, CLI, and probe tools.
virtualdisplay.exe is the user-facing command line tool. It talks to the
installed driver through the same control interface Sunshine uses.
After extracting the release ZIP, run commands from the extracted top-level directory. Install the driver with:
.\tools\virtualdisplay.exe driver installFor a local developer build, the same command can be run from the build output:
.\build-driver\src\driver\virtualdisplay.exe driver installdriver install self-elevates through the Windows UAC prompt when it is not
already running as administrator. By default it installs
driver\SunshineVirtualDisplayDriver.inf from the same extracted release
directory. To install a different INF:
.\tools\virtualdisplay.exe driver install --inf <path-to-inf>All display management commands assume the driver package has already been
installed, Windows has started the virtual display device, and the broker
service is running. Use virtualdisplay_probe.exe for diagnostics that need to
exercise the installed driver control path directly.
Manage the broker service from the CLI:
.\tools\virtualdisplay.exe broker install
.\tools\virtualdisplay.exe broker start
.\tools\virtualdisplay.exe broker status
.\tools\virtualdisplay.exe broker stop
.\tools\virtualdisplay.exe broker uninstallQuery the current permanent-display state:
.\tools\virtualdisplay.exe status
.\tools\virtualdisplay.exe permanent queryQuery active display identity and profile details:
.\tools\virtualdisplay.exe display queryCreate one permanent display with the default settings:
.\tools\virtualdisplay.exe spawnCreate or update a permanent display with explicit settings:
.\tools\virtualdisplay.exe spawn --width 2560 --height 1440 --refresh 120
.\tools\virtualdisplay.exe permanent set --count 1 --width 3840 --height 2160 --physical-width-mm 700 --physical-height-mm 390 --refresh 144 --name "Desk Display"Create several permanent displays with the same EDID mode/name settings:
.\tools\virtualdisplay.exe permanent set --count 2 --width 1920 --height 1080 --refresh 60 --name "Virtual Display"Remove all permanent displays:
.\tools\virtualdisplay.exe permanent offSupported settings:
--count: permanent display count, from0through the driver's maximum.--width: preferred display width in pixels.--height: preferred display height in pixels.--physical-width-mm: physical panel width advertised in EDID, in millimeters.--physical-height-mm: physical panel height advertised in EDID, in millimeters.--refresh: preferred refresh rate. Values up to1000are treated as Hz, so120means120 Hz; larger values are treated as millihertz.--name: monitor name advertised in EDID, truncated to the protocol limit.
The driver validates modes against the protocol range:
- width:
320through7680 - height:
200through4320 - physical width and height:
10 mmthrough2550 mm - refresh: any positive millihertz value accepted by the protocol; the driver no longer applies a policy refresh-rate ceiling
Vendor Vulkan ICDs (NVIDIA, Intel) only advertise HDR surface formats for
displays driven by their own display pipeline. Indirect (IddCx) displays are
owned by the virtual display adapter, so windowed Vulkan applications never
see VK_COLOR_SPACE_HDR10_ST2084_EXT or
VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT on a virtual display even when
Windows runs it in HDR mode — while the same ICDs present those colorspaces
correctly when asked (verified by reading back DWM's FP16 scRGB composition
through Desktop Duplication). DirectX HDR is unaffected; this gap is specific
to Vulkan surface-format enumeration.
VK_LAYER_SUNSHINE_virtual_hdr is an implicit Vulkan layer that closes the
gap: it appends the two missing HDR format pairs to
vkGetPhysicalDeviceSurfaceFormats(2)KHR results when the surface's monitor
reports HDR support in Windows and the ICD did not already advertise them.
Register it system-wide with:
.\tools\virtualdisplay.exe vulkan-layer install
.\tools\virtualdisplay.exe vulkan-layer status
.\tools\virtualdisplay.exe vulkan-layer uninstallvulkan-layer install self-elevates and registers the manifest from the
vulkan-layer directory of the extracted release (or next to the CLI in a
build tree); pass --json PATH to register a different manifest. Set
The layer only injects HDR formats while Sunshine publishes an active HDR stream
signal; outside an HDR stream it remains loaded but passes results through
unchanged. Set DISABLE_SUNSHINE_VIRTUAL_HDR=1 to disable it per-process, or
SUNSHINE_VHDR_FORCE=1 to inject the formats regardless of the monitor's
reported HDR support while the Sunshine HDR stream signal is active.
Use virtualdisplay_probe.exe for diagnostics and runtime validation rather
than normal display management. Common commands are:
.\tools\virtualdisplay_probe.exe --check
.\tools\virtualdisplay_probe.exe --diagnose
.\tools\virtualdisplay_probe.exe --query-permanent
.\tools\virtualdisplay_probe.exe --self-test-permanent
.\tools\virtualdisplay_probe.exe --self-test-temp 1920 1080 60
.\tools\virtualdisplay_probe.exe --self-test-hdr 1920 1080 60Run .\tools\virtualdisplay_probe.exe --help to list advanced validation and
debug commands.
The C++ API is primarily for source consumers. Link the libvirtualdisplay::driver
CMake target and include headers from src/driver/include. Windows control
device discovery is available through windows_control_client.h; the lower
level protocol types and ControlClient are platform-neutral.
The public C++ control surface is in:
virtual_display/driver/control_protocol.hvirtual_display/driver/control_client.hvirtual_display/driver/windows_control_client.hvirtual_display/driver/linux_control_client.h
On Windows, open the first installed control device, check protocol
compatibility, and construct a ControlClient:
#include "virtual_display/driver/control_client.h"
#include "virtual_display/driver/windows_control_client.h"
namespace vdd = virtual_display::driver;
auto opened = vdd::open_first_control_device();
if (!opened.ok()) {
// opened.status and opened.native_error explain the failure.
return 1;
}
vdd::ControlClient client {*opened.transport};
auto protocol = client.check_protocol_compatible();
if (!protocol.ok()) {
return 1;
}open_first_control_device() enumerates installed virtual display control
devices and opens the first usable one. It fails when the driver is not
installed, the device is not started, or Windows denies access. Keep the opened
transport alive for as long as ControlClient uses it.
API calls return either ControlOperationResult or ControlResult<T>. Check
ok() before using output values. status reports library/protocol failures;
native_error carries the operating-system error code when transport or device
access fails.
Requests in the examples are value-initialized before copying fixed-size display
names. This keeps protocol strings null-terminated when using std::strncpy.
Permanent displays stay present until the count is changed or the driver/device is restarted. Use them for simple desktop setups where a user wants an always-on virtual monitor.
vdd::PermanentDisplayCountRequest request {};
request.display_count = 1;
request.width = 2560;
request.height = 1440;
request.physical_width_mm = 590;
request.physical_height_mm = 330;
request.refresh_rate_millihz = 120'000;
std::strncpy(request.display_name, "Desk Display", sizeof(request.display_name) - 1);
auto result = client.set_permanent_display_count(request);
if (!result.ok()) {
return 1;
}
// result.value reports current_display_count, max_display_count,
// temporary_display_count, width, height, physical size, refresh_rate_millihz,
// and display_name.Query the current permanent-display state:
auto state = client.query_permanent_display_count();
if (!state.ok()) {
return 1;
}Remove all permanent displays:
vdd::PermanentDisplayCountRequest request {};
request.display_count = 0;
auto result = client.set_permanent_display_count(request);Temporary displays are lease-backed. They are useful when an application needs a display only while a session is active. Keep feeding the lease for as long as the display should remain present, then remove the display or release the lease.
vdd::CreateTemporaryDisplayRequest request {};
request.lease_id = 0x1001;
request.display_id = 0x2001;
request.width = 1920;
request.height = 1080;
request.physical_width_mm = 530;
request.physical_height_mm = 300;
request.refresh_rate_millihz = 60'000;
request.requested_timeout_ms = 30'000;
std::strncpy(request.display_name, "Session Display", sizeof(request.display_name) - 1);
auto created = client.create_temporary_display(request);
if (!created.ok()) {
return 1;
}
vdd::LeaseRequest lease {
vdd::kApiNamespaceGuid,
request.lease_id,
request.requested_timeout_ms,
0
};
// Call periodically before remaining_ms reaches zero.
auto fed = client.feed_lease(lease);
if (!fed.ok()) {
return 1;
}
vdd::LeaseDisplayRequest remove {
vdd::kApiNamespaceGuid,
request.lease_id,
request.display_id
};
auto removed = client.remove_temporary_display(remove);
if (!removed.ok()) {
return 1;
}created.value.effective_timeout_ms reports the timeout accepted by the driver.
Call feed_lease() before that timeout expires; applications commonly refresh
at a fraction of the effective timeout. If the lease expires, the driver removes
temporary displays owned by that lease.
Temporary displays retain driver-side identity by default so a caller can reuse
the same DisplayId for a logical display that should keep Windows settings.
Set request.flags |= vdd::kCreateTemporaryDisplayFlagEphemeralIdentity when a
display should not write persistent driver identity state; pair that with a
fresh caller-owned DisplayId when Windows settings retention is not desired.
Release every temporary display owned by a lease:
vdd::LeaseRequest lease {
vdd::kApiNamespaceGuid,
request.lease_id,
0,
0
};
auto released = client.release_lease(lease);
if (!released.ok()) {
return 1;
}- The current protocol version is
3.8.0. Protocol 3.8 adds requested-resolution mode catalogs and an explicit frame transport capability query. The IddCx producer and owner-authenticated frame ring are available only in an explicit experimental build option that defaults off; Windows/WDK/GPU qualification is still required. See the frame transport notes. - Protocol 3.7 adds owned temporary display creation and capability-based lease reclaim without exposing lease IDs through global display-state queries.
- Reclaim rotates only lease ownership and expiry. Connector assignment and the EDID-producing display descriptor remain unchanged, so Windows keeps the same monitor identity and settings contract.
- The Windows driver measures lease expiry with unbiased interrupt time; time spent in system sleep does not consume a temporary display lease.
ControlClient::check_protocol_compatible()should be called before issuing state-changing requests.- IDs are caller-owned. Reuse
DisplayIdfor the same logical display when you want Windows to retain display identity across sessions; use a uniqueLeaseIdfor each active temporary-display owner. - Names are fixed-size protocol strings with a
32byte limit. - Width must be
320through7680and height200through4320, with the total resolution not exceeding7680×4320pixels. Physical width and height must be10through2550millimeters. The refresh rate is given in millihertz and must be non-zero (for example60000for 60 Hz). - Lease timeouts are clamped to the protocol range and reported back as
effective_timeout_ms. - Permanent-display settings are shared by the active permanent pool; setting the same count with new mode/name settings refreshes existing permanent monitors.
kCreateTemporaryDisplayFlagRequestedResolutionOnly opts one temporary monitor
into advertising only its requested width and height. The default flag value is
zero and preserves the complete catalog. The restricted catalog retains existing
same-resolution nominal rates and the descriptor's exact base, 2x and 4x rates;
it does not impose a single refresh rate. A missing or invalid unbound description
retains a nonempty default catalog.
Accepted explicit creates first validate their requested dimensions and refresh,
then carry that exact timing and policy through the temporary record and backend
descriptor. They do not retry as a full-catalog create. The malformed-description
helper fallback is not evidence that Windows will retain the restriction after
unexpected native descriptor loss; that path remains a qualification gate.
Check the actual opened Windows producer with
supports_requested_resolution_catalog(query_protocol_version().value) after
checking that the query succeeded. Protocol 3.7 does not support the new bit;
never silently retry an explicit restricted request with the bit removed and
report it as success. Existing request/result sizes and IOCTL values are unchanged.
QueryDisplayState reports the effective policy with
kDisplayStateFlagRequestedResolutionOnly.
The policy belongs to the temporary display record and is immutable until removal. Secure reclaim changes its lease, not its mode catalog. Changing policy or requested dimensions requires a new monitor lifetime, using the existing proven-owner removal path at a session boundary. Never mutate a peer, shared or permanent display's catalog to satisfy a per-client setting. Producer source support alone does not expose a host setting: consumers must carry a per-client opt-in, verify capability and queried state, and ship a reviewed, trust-qualified Windows producer first.
Both monitor-description callback versions, target-mode callback versions, and the per-monitor default-description callback use the same policy. Portable mode and controller tests do not establish Windows/DXGI enumeration, installed driver trust, or a game's resolution-selection behavior; those need native qualification.