SYSTEMS EXPLAINED

How Groot & Ube work

Follow a frame from window events to GPU presentation, then explore how Ube compiles code and keeps memory lifetimes predictable.

01 · GROOT ENGINE

One frame, from input to pixels

Game logic and engine packages run in the Ube guest. The native Rust host owns platform access, GPU work, and presentation.

UBE / WASM COMPONENTGame state & ECSGroot packagesRender data & frame arena
WASI 0.2 · Component Modeltyped imports / buffers ⇄
NATIVE RUST HOSTwinit events & inputWasmtime runtimewgpu encode & present

Events: The native host pumps window events and updates keyboard, mouse, and timing state.

UBE · WASI 0.2
while game.is_running {
    game.begin_frame()       // refresh frame and input state
    update_game_state()      // Ube simulation and ECS
    arena {                  // frame scratch lifetime
        build_render_data()
        game.present()       // submit and present
    }
}

02 · UBE COMPILER

Source becomes a WebAssembly component

Ube checks types and ownership before emitting WebAssembly. With the wasi2 target, component interfaces define the host capabilities the guest can use.

STEP 01.ube source
STEP 02Lexer & parser
STEP 03Type + ownership checks
STEP 04Wasm emitter
STEP 05WASI 0.2 component

The compiler performs these stages at build time. At runtime, Wasmtime instantiates the component and connects its declared imports to the Groot host.

03 · MEMORY & OWNERSHIP

Memory follows the lifetime of the data

Choose values for short-lived calculations, arenas for scoped temporary allocations, and pools for objects that persist across frames.

TIER 01

Stack values

Numbers, booleans, fixed arrays, and plain value structs live in locals and are copied as values.

UBE · WASI 0.2
let mut scratch = []f32{}
arena {
    scratch.push(1.0)         // temporary region allocation
}                            // region is reclaimed together

let original = "owned value"
let next = move original    // ownership transfers

fn inspect(view values: []f32) {
    // read-only; the view cannot escape
}
move

Transfers ownership of an affine value. The old binding cannot be read until reassigned.

view

Passes read-only access for the call. A view cannot be returned or stored beyond its allowed scope.

arena

Groups temporary allocations under one lifetime, with bulk reclamation when the scope ends.

04 · DRAW DATA

Instancing packs per-object data together

Groot’s 3D instance path sends one model transform and one RGBA tint for each instance.

MODEL MATRIX · 16 FLOATS
12345678910111213141516
+
RGBA TINT · 4 FLOATS
RGBA
=20 floats
per instance