mirror of
https://github.com/utmapp/mesa.git
synced 2026-12-01 07:53:57 -10:00
Introduce the Neptune guest driver: a Mesa-side D3D11.dll/DXGI.dll
implementation that forwards COM calls from a Windows guest (Wine + DXVK,
or native Windows) over virtio-gpu to a host-side virgl_renderer
backend. Designed to give Windows games near-native graphics performance
on Linux/macOS hypervisors without paravirtualizing at the Vulkan level.
Lives entirely under src/virtio/neptune/ alongside Venus, with a single
hook into the Mesa build (top-level meson.build, src/meson.build,
meson.options) and one drm-uapi header sync.
Subsystems
==========
Core driver (src/virtio/neptune/npt_*)
- npt_device / npt_dispatch / npt_cs: command-stream builder, device
singleton with shared guest-id allocator, transport dispatch.
- npt_com / npt_object: hand-written COM wrapper layer with dual
refcount (guest + host), tier-aware widest-vtbl install for
Device5/DeviceContext4/Factory7/Adapter4 aliasing, chained hash
table wrapper cache, real QueryInterface forwarding.
- npt_ring / npt_tls: lock-free per-instance DC+SC ring and
per-thread TLS rings; rotate_slot serialization; Venus-style
drain-on-fresh-TLS for vn_get_target_ring parity.
- npt_resource / npt_d3d_map_ring / npt_shmem_pool: N-slot rename
rings for DYNAMIC buffer + texture Map/Unmap, refcount-based
growable shmem pool, RESOURCE_UPDATE for initial upload, async
shmem destroy via singleton reaper.
- npt_event: Win32 HANDLE/event proxy and signaller threads for
cross-VM event fanout.
- npt_profile / npt_env: NPT_PERF / NPT_DEBUG env-bitmask knobs,
per-frame stutter triage, per-thread submit/reply accounting.
- npt_overrides_*: per-family hand-written overrides for buffer,
context, device, texture, view, fence, query (D3D11) and adapter,
factory, factorymedia, output, swapchain (DXGI).
Generated client proxies (neptune-protocol/)
Auto-generated client-side COM stubs for the full D3D11 + DXGI
interface families (ID3D10Blob, ID3D11Asynchronous through
ID3D11VideoProcessor, IDXGIAdapter through IDXGISwapChainMedia, etc.).
Generator lives out-of-tree at neptune-protocol; this commit pins the
generator's output. Wire-format version is checked at capset
negotiation.
WSI (src/virtio/neptune/nptunix/)
Wine-builtin PE+unixlib helper that lives next to the .dll files and
bridges to native Linux:
- DRI3 1.4 explicit-sync Present path with dmabuf swapchain images,
xshmfence-based GPU-done backpressure, async per-swapchain worker
for Present/poll/xcb.
- virtgpu transport (drmGetDevices2, blob creation, submit_cmd_sync,
sync_file fence) with NPT_DEBUG=force_vtest fallback to
virgl_test_server for development.
- DRM-connector enumeration used to fabricate IDXGIOutput entirely
guest-side (output wrappers are never serialized over the wire).
Performance features
====================
- DXGI Present pacing: guest FIFO_RELAXED + host SyncInterval=0 to
avoid double-pacing; QPC-based present-timing diagnostics.
- Per-instance DC+SC ring + per-thread TLS rings (multi-ring transport
is the default), with seqno-ordered COM_RELEASE batching.
- Sticky SET_REPLY_STREAM + indirect submission for oversize commands,
Venus-style temp pool on the guest decoder.
- Shmem-fresh Map/Unmap directly into shared memory (zero-copy);
standalone-shmem fallback for oversized transfers; create_blob path
for swapchain DMA-BUF images.
- 3-slot texture rename ring with cached row_pitch for async
Map(WRITE_DISCARD); pDstBox sub-region UpdateSubresource;
Map(READ) on textures.
- ID3D11Fence + ID3D11Query shared-memory feedback driven by auto
Begin/End, gated on env.
- Wrapper teardown is leak-safe on host-orphan + multi-wrap OOM; the
npt_device singleton is refcounted via top-level wrapper lifetime.
Build
=====
Enabled with -Dgallium-neptune=true; produces PE-side d3d11.dll +
dxgi.dll plus the nptunix Wine builtin (.so + PE stub). Native
Windows scaffolding is in place but unused; current target is
Wine 11 + DXVK on a Linux/QEMU host.
Assisted-by: Claude:claude-opus-4-7