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
This directory contains a copy of the installed kernel headers required by several drivers to communicate with the kernel. Whenever one of those driver needs new definitions for new kernel APIs, these files should be updated. These files in upstream Mesa should only be updated once the changes have landed in the drm-next branch of the drm repository. The drm repository is currently located at: * https://gitlab.freedesktop.org/drm/kernel * git url: https://gitlab.freedesktop.org/drm/kernel.git Tagged Linux kernel releases can also be used. When using the drm repository, it is recommended that the headers are generated using a *merge commit* in the drm-next branch. After checking out the commit in the drm (or tagged Linux release) tree, the drm-uapi files can be generated by running this from the drm tree: $ make headers_install INSTALL_HDR_PATH=/path/to/install This will generate files under /path/to/install/include/drm which can be copied into the Mesa include/drm-uapi directory. It is not required to copy/update all kernel header files. The commit message for the Mesa drm-uapi update should include the full commit version of the drm kernel tree. An easy way to generate this is with the following command in the drm tree: $ git log -1 --pretty=short --no-decorate Which would produce output similar to this to include in the Mesa commit: commit a78313bb206e0c456a989f380c4cbd8af8af7c76 Merge: 365aa9f57399 79655e867ad6 Author: Dave Airlie <[email protected]> Merge tag 'drm-intel-gt-next-2024-06-12' of https://gitlab.freedesktop.org/drm/i915/kernel into drm-next