Glitcher API
WebAssembly Interface Types for Glitcher Engine render node plugins.
Overview
This crate provides the WIT-generated Rust types that define the contract between the Glitcher Engine host and WASM plugins. Plugins act as "Definition Providers" - they supply node metadata and WGSL shader source code.
Architecture
WASM Plugin (Guest) Glitcher Engine (Host)
┌─────────────────┐ ┌─────────────────────┐
│ get-manifest() │────WIT──>│ Load metadata │
│ get-shader() │────WIT──>│ Compile WGSL │
└─────────────────┘ │ Execute on GPU │
└─────────────────────┘
Usage
For Plugin Authors (Guest)
use *;
generate!;
;
For Host Implementation
use *;
use *;
// Load and instantiate WASM plugin
let module = from_file?;
let instance = linker.instantiate?;
// Call WIT functions
let get_manifest = instance
.?;
let manifest = get_manifest.call?;
// Validate and use manifest
assert_eq!;
Type System
All types are strongly typed through WIT, eliminating string-based parsing:
- [
ParamType]: WGSL-compatible parameter types (f32, vec3, mat4, etc.) - [
WidgetConfig]: UI widget configurations (slider, color-picker, etc.) - [
ExecutionModel]: Fragment shader or compute shader - [
NodeManifest]: Complete node definition
Memory Layout
The host calculates GPU buffer layouts using std140 rules based on [ParamType].
Plugins don't need to worry about alignment or padding.
Binding Conventions
Shaders must follow these binding group conventions:
- Group 0: System globals (time, resolution, mouse) - Host-managed
- Group 1: Node parameters - Single uniform buffer at binding 0
- Group 2: Textures - Bindings match [
TexturePort::binding_slot]
API Versioning
The [NodeManifest::api_version] field ensures compatibility:
- Current version: 1
- Host rejects plugins with mismatched versions
- Breaking changes increment the version number