Streaming

The resource interface of the asynchronous asset source. A resource may be pending at any time (natively while read and decoded; in the browser while read from installed packs, decoded and uploaded, never while downloaded); neither scene construction nor gameplay may assume synchronous visual availability. Asset source; index.

Pending policy by class

First version: no visual substitute, partial material or uninitialized data is drawn. A ready dependency may be shared with another complete object; that does not make an incomplete object ready.

Asset classWhile pendingReadiness/lifetime rule
Static mesh, BSP visual batch, terrain visual patchRetain an available spatial parent during refinementPublish a representation when its geometry, program and required image data are resident. Gameplay collision and heights are pinned separately.
Character, equipment, attachmentsIncomplete visual unit absentPublish coherent mesh/material/skeleton/animation dependencies; independently transformed ready attachments still need their parent's valid pose. Bound the actor startup set separately from world entry; a crowd cannot extend that gate indefinitely.
Textures, masks, lightmaps, terrain layers, cubemapsRetain a valid material representationEligible opaque textures can refine from their authored mip tail. Masks preserve coverage, and terrain layers publish together in their authored order.
Procedural texture, water/portal/material render targetDependent draw absentSource inputs and a completed valid render result are required; pending is not a black/white texture. An already published valid revision may stay resident until replaced atomically.
Particles and effect visualsAffected draw absentSimulation/event time continues under existing gameplay rules; late residency does not replay historical spawn/audio events or stall combat.
Sky and time-of-day/environment dataEntry/loading gateWorld entry waits for the level's sky/time data; never publish an incoherent destination environment.
UI bitmaps, bitmap fonts and TrueFont facesDependent UI content absent; startup gate for essential UIA loading/error interface remains operable using its already resident startup set. Keep face bytes alive for the FreeType face lifetime. Fonts use the source on every backend.
Music/ambient audio, sound samplesSilence for the unavailable stream/voiceMusic and ambience progressively feed decoded pages; do not preload entire tracks or replay missed one-shots. Audio buffering has its own bounded accounting.
Collision, terrain heights, BSP topology, zones, water volumesSimulation cannot enter the uncovered areaPinned together for the active simulation area plus a movement margin; never evicted while required.

Gameplay and destination gate

Pin collision, lossless terrain heights, BSP, zones and water volumes, including dependencies, for every active simulation area plus a movement margin. Readiness is a complete set, not the render camera's frustum. Pinning precedes movement and includes boats, fast movement and server teleports. A missing destination enters a controlled loading state: continue pumping frames, input/cancellation and network state, but do not advance local simulation into missing collision or fabricate a landing height. Server packet order/authoritative state still follows the networking contract.

World entry also waits for level tables, sky/time-of-day data and essential UI. Prefetch known destinations before committing the transition. Keep the current pinned set until the destination set can be installed coherently; account for the overlap. Actor visual startup admission is separately bounded and cannot depend on all nearby players becoming drawable. Failure of a pinned dependency leaves a loading/error state with cancellation/retry, rather than silently treating it as empty space.

The movement margin is not an invented radius: determine it from maximum supported movement during measured read/decode/publication latency and the simulation's collision-query reach, then test boundary crossings at that speed under load. Teleports are discontinuous and always use destination readiness, not an extrapolated margin. If a newly required pinned set does not fit the configured budget, report the shortfall/hold loading; do not evict active collision to make it fit.

Source and scene interface

These are semantic obligations, not a claim that the current Resources implements this API. The concurrent assets/src/asset_source.rs source owns asynchronous native file work; format loaders own decoding. The scene consumes resource handles through the following boundary. The source's first implementation exposes byte ranges; GPU residency remains the renderer's responsibility.

The asset source provides request(key, generation, offset, size) and poll(request): Status (Pending, Resident(Lease), Failed, Cancelled), with Lease holding shared immutable bytes, generation checked by the caller before publication, and Request::cancel() dropping that consumer. Matching ranges share work; explicit Limits { requests, bytes } account for queued, in-flight and leased source bytes. This byte adapter's Resident corresponds to Ready(lease) below, not GPU drawable readiness. Dependency closures, object decoding/readiness, gameplay pin sets and GPU residency still need their integration layers. Adapter queue defaults are engineering controls, not measured residency profiles.

  1. Request an opaque asset/object key and its precomputed dependency closure with priority and an owning load generation. Repeated requests share work and immutable results. Native local files and the browser's installed packs implement the same availability semantics; the scene does not perform filesystem, HTTP, asset-offset or GPU-device operations.
  2. Poll/callback delivers a discriminated result: Pending, Ready(lease), Failed(error) or Cancelled. Ready carries a complete immutable result and its ownership; other states carry no usable data. Cancellation is request-and-poll, removes that consumer's interest and suppresses stale-generation publication. Shared work continues while another consumer needs it. No future wait, join or synchronous I/O on the application/GPU frame path or browser main thread; shutdown drains asynchronously.
  3. A lease keeps CPU data/dependencies alive; explicit pin leases prevent gameplay eviction. The renderer separately requests upload, reports visual readiness and retires GPU handles after completion. The scene observes drawable only when both source dependencies and renderer publication are ready. Releasing the last scene lease makes a resource eviction-eligible; it does not immediately free in-flight storage.
  4. Each published snapshot is immutable for the frame/submission. Request, cancellation, release and pin changes take effect at publication boundaries. An old loading generation cannot install geometry/collision into a new world. Failures identify the asset/chunk and reason; malformed or digest-mismatched data is failed, not a perpetual pending item.
  5. Pack indexes locate files and objects; precomputed dependency closures let an object load be one batched set of reads. Deduplicate requests and coalesce adjacent ranges. Bound in-flight count and bytes, decode working sets, completed-but-unconsumed results and upload staging. Packs are verified at install; a pack missing or invalid at runtime (browser storage eviction) is a reported failure that returns the player to the install, never an in-game download. Install and hosting rules follow the web plan.

Scheduling order is essential UI/current interaction, visible, nearby by distance/view, then movement/destination prefetch. Cancellation removes unwanted speculative work. GPU uploads occur on the GPU-owning application thread and consume a per-frame byte/time allowance; backpressure must propagate through decode to fetch before a queue exceeds its cap. A single item larger than a cap needs an explicit bounded chunk path or a reported admission failure, never an exemption that makes the cap meaningless.

Budgets and eviction

No residency or movement-margin number is set by this document. A host's recorded scenarios (crowds, effects, dense scenery, water, interiors) and their transitions set its native and browser profiles, measured from installed packs in the browser.

AccountRequired measurement and resulting limit
Pinned gameplay and transition overlapLive bytes per class/region and dependency closure, old+new peak, maximum query/movement reach; sets pin admission and movement margin.
CPU/Wasm assetsAsset tables, encoded/decoded objects, audio/font storage, decode scratch and shared ownership; sets resident decoded/encoded and worker working-set caps. Wasm32 address-space growth to 4 GiB is not a usable-memory budget. Measured so far: web memory.
Pack readsOPFS read copies into Wasm, decoded-block cache, reads queued/in flight and their latency; sets read caps and prefetch reach. Install download memory is measured separately, outside play.
GPU resident resourcesActual buffers/textures/array-page occupancy plus graph targets, histories, UI and native RT structures; sets an asset-residency cap after non-asset reservations. Metal's allocation counter is device-wide for this process, not an asset-only ledger.
Staging/publicationPeak staging/row padding, completed decode backlog, bytes uploaded/frame, upload duration and frame-time tails; sets bounded queue depth and upload allowance.
Browser storageInstall size against quota, persistence grant, interrupted installs and eviction. The install is complete or absent, not a capped cache.

Use the performance method: process footprint already includes mapped GPU memory and must not be added to Metal currentAllocatedSize. Existing counters cannot attribute all accounts above; instrument those gaps before selecting limits. Report peaks and tails, not just steady-state averages.

Evict only unreferenced, unpinned resources, preferring least recently used outside the active/prefetch region. Stop admitting speculative work before reaching a cap; never borrow indefinitely from the pinned or frame-target reserve. Retiring GPU resources and array layers remain charged until completion. Count dependency sharing once in byte totals and retain shared dependencies until their final lease releases. Log eviction/reload churn, rejected admissions and pin pressure; Recorded scenarios decide hysteresis and cache sizing. Fade-in and sparse residency remain open.

Shared shader ABI and validation

Residency/texture/instance GPU tables obey the Slang spike: 16-byte vector/array records with shared MSL/WGSL offsets, declaration-order group-0 bindings verified by reflection, and explicit counts instead of Metal structured-buffer GetDimensions. Check new groups explicitly. Shader selection through residency flags must not put implicit-derivative samples under varying branches; take gradients first and use SampleGrad where needed. These are upload/publication requirements even though the asset source itself has no GPU API.

  • Source tests use delayed completion, shared requests, cancellation at every stage, failed digests, stale load generations, over-budget objects and held leases. Assert bounded counters and that no partially ready object is published. Test native and browser sources with the same state/lifetime cases.
  • Gameplay tests delay each pinned class separately during entry, boundary crossing, boat travel and teleport; simulation must stay behind the readiness gate and old collision must survive until coherent transition. Test failure, retry and shutdown without blocking a frame.
  • Metal and browser replays verify every pending-policy row, transparent/terrain completeness, font lifetime, storage eviction (reinstall before Play), device loss and GPU retirement. Record install size/time, login/world-entry latency, missing-object time, account peaks and frame p50/p95/p99.
  • Run heavy measurements through the shared build slot, in its exclusive mode for GPU/display. This document performs source review only; the source integration, numeric profiles, margin and throttled-browser acceptance remain implementation/measurement gates.