Skip to main content

Crate wgpu_native_texture_interop

Crate wgpu_native_texture_interop 

Source
Expand description

§wgpu-native-texture-interop

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

PlatformImport pathStatus
Linux / AndroidGL FBO → Vulkan external memory → wgpuImplemented
macOS / iOSIOSurface → Metal texture → wgpuImplemented
Windows (Vulkan)GL FBO → Vulkan image (NT handle) → wgpuImplemented
Windows (DX12)GL FBO → DX12 shared texture → wgpuBuilds, runtime deferred

§Key types

  • HostWgpuContext — wraps the host’s wgpu::Device and wgpu::Queue
  • NativeFrame — platform-specific frame produced by the offscreen renderer
  • ImportedTexture — the result of importing a NativeFrame into wgpu
  • ImportOptions — controls import behavior (format, usage flags)
  • CapabilityMatrix — runtime query of what the current platform/driver supports
  • InteropBackend — detected backend (Vulkan, Metal, DX12)
  • FrameProducer / TextureImporter — traits for the produce/import pipeline
  • WgpuTextureImporter — default TextureImporter implementation
  • InteropSynchronizer — trait for cross-API synchronization policies

§Modules

  • raw_gl — surfman-independent GL import functions. Use RawGlFrameProducer for any GL application without bringing surfman as a dependency (set default-features = false).
  • surfman_gl — surfman-backed frame producer (enabled by default via the surfman feature).

§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.

[dependencies]
# Full (with surfman support):
wgpu-native-texture-interop = "0.1"

# Minimal (raw GL only, no surfman):
wgpu-native-texture-interop = { version = "0.1", default-features = false }

§License

MIT OR Apache-2.0

Modules§

raw_gl
Raw GL-to-wgpu import primitives with no surfman dependency.
surfman_gl

Structs§

CapabilityMatrix
Reports which frame types can be imported on the current device and backend.
Dx12SharedTexture
A frame backed by a D3D12 resource shared via a DXGI NT handle.
GlFramebufferSource
HostWgpuContext
Wraps a wgpu::Device and wgpu::Queue together with the detected backend.
ImplicitOnlySynchronizer
A synchronizer that accepts SyncMechanism::None and SyncMechanism::ImplicitGlFlush and rejects any explicit semaphore or fence mechanism with InteropError::UnsupportedSynchronization.
ImportOptions
Options that control how WgpuTextureImporter processes each frame.
ImportedTexture
A successfully imported wgpu texture, ready for use in a render pipeline.
MetalTextureRef
A frame backed by a MTLTexture from a Metal producer.
NoopSynchronizer
A synchronizer that does nothing. Suitable when the caller manages all synchronization externally (e.g. via a shared queue or explicit barriers).
ProducerCapabilities
The set of NativeFrameKinds a FrameProducer is able to emit.
VulkanExternalImage
Metadata for a Vulkan external image frame. Import not yet implemented.
WgpuTextureImporter
The main entry point for importing frames into wgpu textures.

Enums§

CapabilityStatus
Whether a particular interop capability is available on this device.
InteropBackend
The wgpu graphics backend in use on the host device.
InteropError
Errors that can occur during frame import or synchronization.
NativeFrame
A frame produced by a FrameProducer, ready to be imported by a TextureImporter.
NativeFrameKind
Discriminant for NativeFrame variants, without carrying the frame data.
SyncMechanism
Describes how the producer signals that a frame is ready and how the consumer signals that it has finished reading.
TextureOrigin
Which corner of the texture holds row 0 of the image.
UnsupportedReason
Why a particular interop path is not available.

Traits§

FrameProducer
Produces NativeFrames for a TextureImporter to consume.
GlFramebufferSourceImpl
InteropSynchronizer
Hook points called by WgpuTextureImporter around each frame import.
TextureImporter
Imports a NativeFrame into a wgpu::Texture.