# gfx-rs/wgpu-native architecture

> Architecture diagram of the GitHub repository gfx-rs/wgpu-native, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gfx-rs/wgpu-native
- Repository: https://github.com/gfx-rs/wgpu-native

## Overview

wgpu-native is a Rust implementation of the native WebGPU C API, built on wgpu-core. A C application calls the exported API to create an instance, obtain an adapter and device, create resources and encode rendering or compute work, then submit it through a queue. The Rust layer translates C descriptors and values before delegating to wgpu-core. The README establishes the core dependency and header-based bindings; sampled excerpts show API dispatch and conversion helpers, but do not expose the full backend or resource flow.

Main entry points: [`src/lib.rs`](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs) (WebGPU entry points), [`ffi/wgpu.h`](https://github.com/gfx-rs/wgpu-native/blob/trunk/ffi/wgpu.h) (Native API header), [`src/conv.rs`](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/conv.rs) (C/Rust conversion), [`src/utils.rs`](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/utils.rs) (FFI utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["C API"]
  node_header["Native API header<br/>[wgpu.h]"]
  node_entry["WebGPU entry points<br/>[lib.rs]"]
end

subgraph group_runtime["Rust Runtime"]
  node_instance["Instance and device<br/>[lib.rs]"]
  node_resources["GPU resources<br/>[lib.rs]"]
  node_commands["Render and compute<br/>[lib.rs]"]
  node_queue["Queue operations<br/>[lib.rs]"]
  node_core["wgpu-core"]
end

subgraph group_support["Runtime Support"]
  node_conversion["C/Rust conversion<br/>[conv.rs]"]
  node_utilities["FFI utilities<br/>[utils.rs]"]
  node_logging["Logging callbacks<br/>[logging.rs]"]
  node_stubs["Unimplemented API<br/>[unimplemented.rs]"]
end

node_client(("C application"))

node_client -->|"uses contract"| node_header
node_client -->|"calls"| node_entry
node_header -->|"defines bindings"| node_entry
node_entry -->|"maps values"| node_conversion
node_conversion -->|"uses helpers"| node_utilities
node_entry -->|"handles requests"| node_instance
node_entry -->|"handles requests"| node_resources
node_entry -->|"handles requests"| node_commands
node_entry -.->|"handles requests"| node_queue
node_entry -.->|"delegates to"| node_core
node_logging -->|"formats callbacks"| node_utilities

click node_header "https://github.com/gfx-rs/wgpu-native/blob/trunk/ffi/wgpu.h"
click node_entry "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs"
click node_instance "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs"
click node_resources "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs"
click node_commands "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs"
click node_queue "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs"
click node_conversion "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/conv.rs"
click node_utilities "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/utils.rs"
click node_logging "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/logging.rs"
click node_stubs "https://github.com/gfx-rs/wgpu-native/blob/trunk/src/unimplemented.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_header,node_entry toneBlue
class node_instance,node_resources,node_commands,node_queue,node_core toneAmber
class node_conversion,node_utilities,node_logging,node_stubs toneMint
class node_client toneIndigo
```

## Components

### C API

- [Native API header](https://github.com/gfx-rs/wgpu-native/blob/trunk/ffi/wgpu.h): `ffi/wgpu.h`
- [WebGPU entry points](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs): `src/lib.rs`

### Rust Runtime

- [Instance and device](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs): `src/lib.rs`
- [GPU resources](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs): `src/lib.rs`
- [Render and compute](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs): `src/lib.rs`
- [Queue operations](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/lib.rs): `src/lib.rs`
- **wgpu-core**

### Runtime Support

- [C/Rust conversion](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/conv.rs): `src/conv.rs`
- [FFI utilities](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/utils.rs): `src/utils.rs`
- [Logging callbacks](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/logging.rs): `src/logging.rs`
- [Unimplemented API](https://github.com/gfx-rs/wgpu-native/blob/trunk/src/unimplemented.rs): `src/unimplemented.rs`

### Other components

- **C application**

## Connections

- C application → Native API header: uses contract (evidence: `README.md`)
- C application → WebGPU entry points: calls (evidence: `README.md`)
- Native API header → WebGPU entry points: defines bindings (evidence: `README.md`)
- WebGPU entry points → C/Rust conversion: maps values (evidence: `src/lib.rs`)
- C/Rust conversion → FFI utilities: uses helpers (evidence: `src/conv.rs`)
- WebGPU entry points → Instance and device: handles requests (evidence: `src/lib.rs`)
- WebGPU entry points → GPU resources: handles requests (evidence: `src/lib.rs`)
- WebGPU entry points → Render and compute: handles requests (evidence: `src/lib.rs`)
- WebGPU entry points → Queue operations: handles requests (evidence: `src/lib.rs`)
- WebGPU entry points → wgpu-core: delegates to
- Logging callbacks → FFI utilities: formats callbacks (evidence: `src/logging.rs`)
