Native runtime
ComingThe 0x native runtime runs games compiled to WebAssembly in a sandbox, with direct GPU access through wgpu (Vulkan, DX12, Metal, GL), hardware ray queries and mesh shaders.
The 0x native runtime, sg-runtime, runs games that are delivered over HTTP like web games
but execute natively: the game is a WebAssembly module (a guest) running in a wasmtime
sandbox, and it draws with wgpu on the player's GPU. The runtime exposes features stock
browser WebGPU does not have: hardware ray queries and mesh shaders.
Preview
The runtime is not in the 0x app download yet, and it is not a public production release: an
external security audit and production signing roots are still to come. The SDK crates
(sg-guest, sg-abi) are not published on a package registry yet. This section documents the
API as it stands so you can plan a port, and it will grow into the release documentation.
#The pieces
| Piece | What it is |
|---|---|
sg-runtime | The host. It fetches the game's manifest, pulls the module and assets through a content-addressed cache, shows the player what the game asks for, and runs the module with only the sg host API available. |
sg-guest | The Rust guest SDK. A wgpu custom backend (so ordinary wgpu code runs unchanged on the host GPU), safe wrappers for the rest of the sg API (clock, input, HTTP fetch, TCP, key/value storage, audio, workers, WebRTC data channels, display), and log integration. |
sg-abi | The ABI shared by host and guest: the GPU wire format, input event records and key codes, display and HDR constants. |
sg_platform_v1 | An optional second import module with 0x platform services (identity, ownership, stats, achievements, leaderboards, cloud saves, lobbies, P2P, trusted UI), the same services Steamworks games get. See permissions. |
#A game's shape
- A game is a
cdylibbuilt forwasm32-unknown-unknown. - It exports
sg_init() -> i32(0 for success) andsg_frame(t: f64, dt: f64). Worker instances of the same module exportsg_worker_init() -> i32andsg_worker_tick(t: f64) -> i32. - It imports only from module
sg(andsg_platform_v1if it asked for platform services). A module that imports anything else, WASI included, is rejected before it starts. - It is described by a
manifest.json: the entry module and assets, each named by SHA-256, and the permissions it requests.
#Sandbox guarantees
| Hostile behaviour | What the runtime does |
|---|---|
Imports outside sg (and sg_platform_v1 when granted), WASI included | Rejected before instantiation. |
| Pointers outside guest memory | The call traps with the bad pointer and length. |
| Forged GPU handles | The call traps ("invalid handle"). |
| Endless loops | sg_init gets 10 s of guest time and each sg_frame 4 s; past that the guest is interrupted. |
| Memory bombs | Linear memory is capped (512 MiB by default, up to 4096 MiB if the manifest asks and the player grants it); memory.grow past the cap fails. |
| Invalid shaders and descriptors | A validation error goes to the game's wgpu error scopes, as in WebGPU, and the game keeps running. |
| Out-of-range audio values (NaN, infinities) | Clamped; a forged voice returns 0. |
| Undeclared network destinations or platform domains | Denied: the call traps. |
#In this section
- Quickstart: a minimal guest in Rust, built, packaged and run.
- Permissions and grants: the manifest, what a game may ask for, and what the player approves.
- Swarm assets: how a native game's files come from the player swarm.
- Graphics: wgpu backends, GPU limits, ray queries and mesh shaders, HDR and presentation.
- The sg ABI: every host function, conventions, and versioning.
- Rust API reference: the generated rustdoc for
sg-guestandsg-abi.
