Skip to content

Linux: DMA-BUF import for NativeSurface, and a GL backend without Vulkan #23

Open

Description

@kitlangton

Two optional Linux items for the native surface and renderer:

  • DMA-BUF import for NativeSurface: zero-copy frames from VA-API video decode, PipeWire screen capture or camera, the way macOS imports CVPixelBuffer/IOSurface. wgpu needs Vulkan external-memory interop for this.
  • A GL backend without Vulkan: for machines and VMs with only GL (older Intel, some VMs, software rendering). Check what wgpu's GLES backend can do with Rune's shaders and the features it requires, and what degrades.

Low priority; filed so it isn't lost.

Activity

  1. edwardmanhattan commented on Nov 12, 2026

    @edwardmanhattan

    +1 from a map consumer. MapLibre Native renders on its own thread at 1920×1080 RGBA; today we read each frame back to the CPU and hand it to rune::Pixels, which uploads dirty rows. That is ~8.29 MB down and ~8.29 MB up per frame at 30 fps (~250 MB/s each way) plus the readback latency, for a surface Rune then composites. A DMA-BUF import (Vulkan external memory + modifier) would remove both copies and let the map keep its own device. The macOS CVPixelBuffer path is the shape we would want on Linux. Use case is a wall display with a live chart overlay, so latency and power both matter.

  2. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    Thanks for filing this. Here's where the two items stand on dev today.

    DMA-BUF import: partly there. NativeSurface::push_dmabuf landed in #862 (importer shutdown was fixed in #1620). Right now it is narrower than what this issue describes (crates/rune-media/src/native_surface/linux.rs):

    • It accepts only single-plane DRM_FORMAT_ARGB8888 with DRM_FORMAT_MOD_LINEAR. Multi-plane NV12/P010 (what VA-API decode and most cameras produce) and tiled modifiers are rejected.
    • It isn't zero-copy yet. Each pushed frame gets one GPU copy into a texture Rune owns, then that texture is drawn. There's no CPU round trip, but it isn't a direct sample of the producer's buffer.

    What's still open for this item: YUV/multi-plane formats, non-linear modifiers, and sampling the imported image directly. @edwardmanhattan, a MapLibre producer that can render ARGB8888 into linear dmabufs on the GPU that native_surface::linux::import_target() names should already avoid both CPU copies with push_dmabuf.

    GL backend without Vulkan: not started. On Linux, crates/rune/Cargo.toml enables only wgpu's vulkan feature. GL is used only for WebGL2 on the web. Today a machine without a Vulkan driver relies on the CPU renderer for opaque windows; transparent windows currently fail to open there (#2151). What's still needed: enable gles on Linux, check which of Rune's shaders and required features GLES can handle, and document what degrades.

  3. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    I looked into making a first step here and stopped short of a PR. Both remaining pieces need testing on real Linux GPUs, and I couldn't do that.

    • GL backend: enabling wgpu's gles feature on Linux is one line in crates/rune/Cargo.toml, but adapter enumeration uses wgpu::Backends::all() (render/device.rs, rune-gpu/src/pick.rs), so GL adapters would also appear on machines where Vulkan works. Adapter preference, the Vulkan driver-loading path (render/vulkan_icd.rs) and the CpuFirst software-GPU check would all need to account for that. The main work is then checking Rune's shaders and the features and limits it requests (render/device.rs) on GLES drivers such as Mesa iris, llvmpipe and virgl, and documenting what degrades.
    • DMA-BUF: NV12/P010, tiled modifiers and direct sampling need multi-plane Vulkan import with YCbCr conversion in native_surface/linux.rs, plus a real VA-API or PipeWire producer to test against.

    The narrower crash where a transparent window fails to open without a Vulkan driver is tracked in #2151, and it can be fixed separately from the GL backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions