grafting
Import native GPU textures (GL framebuffers, Vulkan images, Metal IOSurfaces) into host-owned wgpu textures. This is the core library of the servo-wgpu-interop workspace.
This crate is framework-agnostic — it has no Servo dependency and can be used by any application that needs to import externally-produced GPU content into wgpu.
What it does
A "producer" (Servo, a GL renderer, a video decoder, etc.) renders into a native GPU resource. This crate imports that resource into a wgpu::Texture owned by the host application, enabling zero-copy compositing across API boundaries.
Platform support
| Platform | Import path | Status |
|---|---|---|
| Linux / Android | GL FBO → Vulkan external memory → wgpu | Implemented |
| macOS / iOS | IOSurface → Metal texture → wgpu | Implemented |
| Windows (Vulkan) | GL FBO → Vulkan image (NT handle) → wgpu | Implemented |
| Windows (DX12) | GL FBO → DX12 shared texture → wgpu | Builds, runtime deferred |
Key types
HostWgpuContext— wraps the host'swgpu::Deviceandwgpu::QueueNativeFrame— platform-specific frame produced by the offscreen rendererImportedTexture— the result of importing aNativeFrameinto wgpuImportOptions— controls import behavior (format, usage flags)CapabilityMatrix— runtime query of what the current platform/driver supportsInteropBackend— detected backend (Vulkan, Metal, DX12)FrameProducer/TextureImporter— traits for the produce/import pipelineWgpuTextureImporter— defaultTextureImporterimplementationInteropSynchronizer— trait for cross-API synchronization policies
Modules
raw_gl— surfman-independent GL import functions. UseRawGlFrameProducerfor any GL application without bringing surfman as a dependency (setdefault-features = false).surfman_gl— surfman-backed frame producer (enabled by default via thesurfmanfeature).
Usage
For Servo embedding, pair this crate with servo-wgpu-interop-adapter which handles Servo-specific setup. For standalone GL import, see demo-raw-gl which uses the raw_gl module directly.
Pick exactly one wgpu-* feature; it must match the wgpu your host already
uses, or the imported texture will not share a device.
[]
# Default: wgpu 29, plus the surfman GL producer path.
= "0.5"
# Same, against wgpu 28.
= { = "0.5", = false, = ["wgpu-28", "surfman"] }
# Shared-texture import only (DX12 / Metal / Vulkan DMABUF). No GL, no
# surfman, no glow. This is what wgpu-weld takes.
= { = "0.5", = false, = ["wgpu-29"] }