Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lamco-wgpu

CI License

wgpu integration for Smithay-based Wayland compositors.

Overview

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 Renderer trait
  • Explicit sync bridge - Signals wgpu semaphores for Smithay's linux-drm-syncobj-v1 release points (required for NVIDIA). The protocol itself is implemented by Smithay, not this crate; this crate only bridges Smithay's syncobj release points to wgpu's semaphore API.

Requirements

  • Rust 1.92+ (required by wgpu 28)
  • Vulkan 1.2+ driver
  • Linux with DMA-BUF support

Installation

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.

Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                        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.

Quick Start

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());

Features

Feature Default Description
dmabuf ✓ DMA-BUF import via raw Vulkan
explicit-sync ✓ Smithay explicit sync integration

Explicit Sync

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)?;

Semaphore Limitations

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.

wgpu Ecosystem Context

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.

Status

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

Not currently possible:

  • DMA-BUF export (scanout) — Smithay does not currently expose a trait for this, so it is not something this crate can provide regardless of test coverage.

About

Developed by Lamco Development as part of the Wayland compositor ecosystem.

License

Licensed under either of:

at your option.

Contribution

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.

Links

About

wgpu integration for Smithay-based Wayland compositors

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages