wgpu integration for Smithay-based Wayland compositors.
This crate enables wgpu as a "guest renderer" on top of Smithay's Wayland compositor infrastructure. It provides:
- WgpuBridge - Core bridge wrapping wgpu with Vulkan interop for DMA-BUF import
- WgpuRenderer - Full implementation of Smithay's
Renderertrait - Explicit sync - Support for
linux-drm-syncobj-v1protocol (required for NVIDIA)
- Rust 1.92+ (required by wgpu 28)
- Vulkan 1.2+ driver
- Linux with DMA-BUF support
This crate requires Smithay features (backend_vulkan, drm_syncobj) only available in git master,
not in any published crates.io version. Install via git:
[dependencies]
lamco-wgpu = { git = "https://github.com/lamco-admin/lamco-wgpu" }Once Smithay publishes a compatible version, this crate will be available on crates.io.
┌─────────────────────────────────────────────────────────────────────┐
│ SMITHAY HOST LAYER │
│ (Owns Vulkan instance & GPU resources) │
└─────────────────────────────────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
│ lamco-wgpu (this crate) │
└───────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────────────┐
│ WGPU GUEST LAYER │
│ (High-level rendering via shared context) │
└─────────────────────────────────────────────────────────────────────┘
Smithay owns the Vulkan instance and handles low-level GPU resource management. wgpu operates as a "guest" using the shared Vulkan context for high-level rendering.
use lamco_wgpu::{WgpuBridge, WgpuRenderer};
use std::sync::Arc;
// Create bridge (standalone mode)
let bridge = Arc::new(WgpuBridge::new()?);
// Or share Smithay's Vulkan context (production)
let bridge = Arc::new(unsafe {
WgpuBridge::from_smithay_vulkan(
&smithay_instance,
smithay_physical_device,
&smithay_device,
smithay_queue,
queue_family_index,
)?
});
// Create renderer implementing Smithay's Renderer trait
let mut renderer = WgpuRenderer::new(bridge.clone());| Feature | Default | Description |
|---|---|---|
dmabuf |
✓ | DMA-BUF import via raw Vulkan |
explicit-sync |
✓ | Smithay explicit sync integration |
For compositors implementing linux-drm-syncobj-v1 (required for NVIDIA):
use lamco_wgpu::{SyncManager, SyncBridge};
let sync_manager = SyncManager::new(&bridge)?;
let sync_bridge = SyncBridge::new(&sync_manager);
// Before sampling client buffer
if let Some(acquire) = surface.acquire_point() {
sync_bridge.wait_acquire_point(acquire, 5000)?;
}
// Signal release after rendering
let pending = sync_bridge.prepare_release_signal(&queue)?;
queue.submit([encoder.finish()]);
sync_bridge.complete_release_signal(pending, &release_point, &device)?;Release point signaling uses wgpu's add_signal_semaphore() API (wgpu#6813).
GPU-side acquire waiting is not yet possible because wgpu lacks add_wait_semaphore() (wgpu#8996).
Current implementation uses CPU-side waiting via poll() on the exported sync_file.
This crate exists because wgpu does not natively support the low-level Vulkan interop required for Wayland compositors. Relevant upstream issues:
- wgpu#2320 - Texture memory import API (open since 2021)
- wgpu#6813 -
add_signal_semaphore()for external semaphore signaling (merged) - wgpu#8996 -
add_wait_semaphore()for external semaphore waiting (open)
The Smithay maintainers concluded that wgpu is "too abstract for internal compositor work" but suitable as a guest renderer (Smithay#431, Smithay#928). This crate implements that pattern.
This is a foundation release. Working:
- DMA-BUF import (single-plane and multi-planar YUV)
- Smithay Renderer trait implementation
- Explicit sync release signaling
- Shared Vulkan context with Smithay
Not yet production-tested:
- Real compositor integration at scale
- All multi-planar format variants
- DMA-BUF export (scanout)
Developed by Lamco Development as part of the Wayland compositor ecosystem.
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.