C API reference¶
The reference for include/sona.h and the optional modules' headers (sona_body.h, sona_track.h, sona_npc.h, sona_xr.h, sona_editor.h, sona_xsdk.h), version 1.1 (SONA_VERSION_MAJOR 1, SONA_VERSION_MINOR 1), SONA_ABI 1. Every public function is listed once, under the part of the header that declares it, with its signature, its parameters, what it returns and its rules. Where this page and the header differ, the header wins. The same entries, with every struct and constant, are in api/api.json for tools.
Conventions are the web SDK's: metres, Y up, left-handed, avatars face -Z at turn 0 and stand about 1.8 m tall. Matrices are row-major and row-vector (v' = v * M).
The reference by area¶
- Constants
- Results and errors
- Handles
- Host services
- HTTP
- Asset sources
- The context
- Events
- Avatars
- Game features
- Animation layers
- Clips
- The frame
- Crowds
- The data API
- Drawing with the SDK's backends
- Item previews
- Rendering quality
- 2D outputs
- Camera helpers
- Manifests
- Credit
- The offline catalogue
- Stock clips and the idle
- Inverse kinematics
- Imported clips
- Headless rendering and video out
- Skeleton maps and VRM export
- 3D print export
- Other players' avatars by id
- State, network sync, replays
- Art styles
- Player screens
- Picking
- Hair and cloth sway
- Custom items
- Lip sync and voice mouths
- Making avatars in code
- Content filters
- Lighting and shadows
- Loading placeholders
- Overlays
- Props
- Ragdolls
- Two-avatar interactions
- Text to emote
- Award items
- Body tracking module
- Player editor module
- NPC kit module
- Face tracking module
- XR body module
- Xbox 360 homebrew module
- Types
- Index of functions
Version¶
This page is version 1.1.0 of the library: sona_version() returns "1.1.0", and SONA_ABI is 1. 1.1 keeps every
1.0 call, struct and layout: a 1.0 host builds against the 1.1 header unchanged and draws the same, but for these:
- Pictures. A new renderer starts with the web's quality defaults: 4 samples on a hardware GPU (1 on a software rasteriser), mip chains and coverage-preserving mips.
sona_renderer_set_qualitywithmsaa1 andflags0 draws without them. - GL state. With multisampling, GL and GLES also change the renderbuffer binding in
sona_drawandsona_snapshot.
Within 1.x nothing breaks for two minor versions (the stable ABI). The changelog lists every addition.
Rules every function follows¶
- One owner thread. All calls on one
sona_ctx, and on its avatars and renderers, come from one thread at a time. The only exceptions aresona_completeandsona_http_done, which a source or an HTTP layer may call from any thread. - Completed exactly once. Every
sona_requestand everysona_http_replyis completed exactly once, and stays valid until then: aftercancel(which only asks), and aftersona_close. A source must complete every read it accepted, also aftercancel, and the host must not unload a source's code until its reads are complete. - Callbacks run on the owner thread. The core calls a source's
readand an HTTP layer'ssendonly on the owner thread, insidesona_openorsona_update, so engines can start their own main-thread requests from them. - No blocking I/O. Work that needs bytes returns
SONA_PENDINGor moves an avatar through its states. Results arrive throughsona_updateandsona_poll_event. - No allocation per frame. After the first frames,
sona_update,sona_poseandsona_drawdo not allocate. Memory comes from the config's allocator and is counted against the budget. - Pointer lifetime. Pointers handed out (
sona_pose_data, event strings, clip info) stay valid until the nextsona_updateon that ctx, unless a function says otherwise. - Explicit padding. Every public struct has explicit padding, so each field sits at its natural alignment on every ABI.
sona_struct_sizeandsona_struct_offsetlet a binding check its mirror of every struct when it loads.
Threading and memory¶
- The owner thread calls everything. Inside
sona_updatethe core drains completed reads, commits finished jobs, runs build steps insidebuild_budget_ms, advances clocks and poses due avatars.sona_drawandsona_snapshotfold the palettes with their own view. - The device's queue. On Vulkan,
sona_snapshotandsona_item_preview_snapshotsubmit on theVkQueuethe host passed and wait for it. Vulkan requires the host to keep every other thread off that queue during those calls. - A loaded catalogue never changes, so any thread may read it at once, with no ctx.
- Jobs are: decode an asset, decode a clip, bake a face sheet, build an avatar, CPU-skin a mesh slice. With workers (the core's threads or the host's
sona_jobs) they run there and are committed on the owner thread in the nextsona_update. Withworker_threads = 0(WASM, a single-threaded Xbox 360 host) they run inside the build budget. - Decoded shared data (assets, clips, textures) is immutable once committed and reference counted. Per-avatar data belongs to the avatar.
- The idle chooser's randomness comes from
config.seed. A fixed seed makes every run repeatable. - Every allocation goes through the config's allocator.
sona_statsreports bytes incpu_mbandgpu_mb. Eviction is idle first, oldest first. An Xbox 360 host setsbudget.total(for example a budget of 96 MiB) and the caps; nothing in the core assumes a heap bigger than the budget.
Left out on purpose¶
- No glTF export, for size only. The data API hands out every mesh, material and texture.
- No pointer controls, badge element, or resize and visibility observers: those are the web's DOM pieces. Wire input to
sona_camera_orbit. - No origin check: native apps have no origin. The licence file and the native check replace it. The WASM build keeps the web's origin check through the bridge.
- No offline gate use. Local sources are the offline path.
- No "do not clear" draw flag.
- The web's
samples()andbenchmark()live in sona-bench.
This page as Markdown · All the docs as one file (llms-full.txt)