code wiki / (root) / nx_enginelab.nx

nx_enginelab.nx

buildroot/runtime/nx_enginelab.nx

25925 B534 linesdepth 10pulls 47 transitivereach 0 importersview sourcekind tooltopic enginelab
docsdependenciesstructsconstsfunctions

about

nx_enginelab.nx -- THE DRIVER: attach the sovereign engine instrument to a REAL renderer. WHAT WAS MISSING AND WHY IT MATTERED. nx_enginelab_lib (the spine), nx_enginelab_store (EL1 persistence), nx_enginelab_golden (the O3DE class) and nx_enginelab_analysis (replay, shader binding, sampling, call tree) are roughly 69 KB of gate-proven library. The gate that proves them says so in its own verdict: every tooth asserts an arithmetic property "on fixtures whose answers are known by construction". That is a proof about the INSTRUMENT and it is worth having -- but until this file existed NOTHING drove the instrument over a real frame, so the estate owned a profiler that had never profiled anything. A measurement capability with no driver is BUILT-AND-UNWIRED, and a green gate makes that invisible: the gate passes exactly as well with zero real subjects as with a thousand. THE SUBJECT, AND WHY THIS ONE. nx_wasm_craft is the estate real renderer -- a per-pixel integer DDA raycast over a voxel world plus a skinned-mesh character composite -- and it is the ONE render path reachable natively with no browser (nx_world_snap already drives it that way, which is the standing evidence that init_impl_v / tick_impl / render_impl compose outside a page). Attaching here therefore needs no GUI, no capture harness and no second copy of the engine. WHAT THIS DRIVER MEASURES, AND WHAT IT REFUSES TO. It owns the call sites it wraps: the arena allocation, init, and per frame a tick zone and a render zone. Everything derived from those is a real observation of a real frame. It does NOT own the inside of render_impl, so: - THE DRAW CLASS IS UNMEASURABLE HERE AND SAYS SO BY NAME. The engine emits no draw stream -- there is no el_draw call anywhere in nx_wasm_craft -- so draws, redundant binds, pipeline state hashes, capture diff and replay divergence have NO SUBJECT. This driver reports draws=0 with the reason attached and the exact emission site the engine lane owes. It does NOT reconstruct the engine visibility test from outside: mob_draw culls on 200 < vz < 40*256, and copying that predicate here would be a duplicate ruler that drifts silently the day the engine changes it. A NAMED ABSENCE IS A BUILD CONTRACT; A RECONSTRUCTED NUMBER IS A LIE WITH A DENOMINATOR. - THE BOUND VERDICT ABSTAINS. This renderer is a CPU integer raycaster; nothing is submitted to a GPU queue, so el_bound_verdict correctly returns UNKNOWN. Manufacturing a GPU signal to make the verdict decide would be the acquit-on-no-evidence defect the spine exists to prevent. What it CAN answer, and nothing else in this estate could before: how long a real frame costs, how that cost splits between simulation and rasterisation, what the cost per RAY is, whether the pacing stutters, and whether two independent runs of the same seed produce the same pixels. RAYS ARE THE UNIT OF WORK, AND THE COUNT IS ENGINE-OWNED. wc_rw/wc_rh are the engine own single owner of the written extent (its source says so), so rays-per-frame is READ from the engine rather than recomputed here. ns-per-ray is the figure that survives a resolution change; a bare frame time does not.

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_enginelab_lib.nx nx_enginelab_store.nx nx_enginelab_golden.nx nx_wasm_craft.nx nx_enginelab.nx

imports: nx_syscalls.nxnx_enginelab_lib.nxnx_enginelab_store.nxnx_enginelab_golden.nxnx_wasm_craft.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_exit eld_usage eld_puts sys_write eld_slen eld_streq eld_int eld_puts ↻ el_new sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ eld_store_cap el_ok eld_run sys_mmap ↻ eld_arena_bytes el_alloc el_push el_set sys_now_us sys_mmap ↻ sys_clock_gettime_mono el_zone_begin el_push ↻ el_zone_end el_get

structs

none

consts

51const ELD_ARENA_PAD: i64 = 4096 // the same head-room nx_world_snap allocates beside CRAFT_TOTAL
52const ELD_TID_MAIN: i64 = 1 // one thread: this driver is single-threaded by construction
53const ELD_N_ARENA: i64 = 1 // interned zone/alloc name ids -- ids, never strings, in a hot loop
54const ELD_N_INIT: i64 = 2
55const ELD_N_TICK: i64 = 3
56const ELD_N_RENDER: i64 = 4
61const ELD_REC_PER_FRAME: i64 = 3
62const ELD_REC_PROLOGUE: i64 = 8
63const ELD_FRAMES_DEFAULT: i64 = 4
64const ELD_TICK_MS: i64 = 16 // one 60Hz step, the same dt nx_world_snap ticks with
65const ELD_TARGET_FPS_DEFAULT: i64 = 60
66const ELD_SEED_DEFAULT: i64 = 20260728 // the beach seed the acceptance corpus already uses
67const ELD_Q_DEFAULT: i64 = 1 // native resolution: a capture reduced by a load-sensitive
69const ELD_Q_GOVERNOR_ARG: i64 = 0 // q=0 asks for the engine own adaptive controller instead
70const ELD_MIN_CLOSED_FRAMES: i64 = 2 // fewer than two boundaries is not a pacing measurement
71const ELD_GRID_DEFAULT: i64 = 16 // golden grid, cells per axis
72const ELD_THRESH_DEFAULT: i64 = 4 // per-cell mean tolerance
73const ELD_DEC: i64 = 10
74const ELD_ASCII_0: i64 = 48
75const ELD_DIGIT_TOP: i64 = 9
76const ELD_NUMBUF: i64 = 32
77const ELD_RGB_CH: i64 = 3
78const ELD_BYTE_MASK: i64 = 255
79const ELD_G_SHIFT: i64 = 8
80const ELD_B_SHIFT: i64 = 16
81const ELD_NS_PER_US: i64 = 1000
82const ELD_PERMIL: i64 = 1000
83const ELD_SCRATCH_SLOTS: i64 = 32
84const ELD_ARGV_VERB: i64 = 1
85const ELD_EXIT_OK: i64 = 0
86const ELD_EXIT_FAIL: i64 = 1
87const ELD_EXIT_USAGE: i64 = 2
88const ELD_EXIT_UNMEASURABLE: i64 = 3
152const ELD_FRAME_A_Q: i64 = 5 // == EL_F_A, restated at its meaning
153const ELD_FRAME_B_RAYS: i64 = 6 // == EL_F_B

functions

91func eld_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: eld_puts
92func eld_puts(s: *u8) -> i64 { sys_write(1, s, eld_slen(s)); return 0 }
93func eld_pn(v: i64) -> i64
called by 1: eld_kv calls 3: sys_writesys_mmapsys_munmap
108func eld_kv(label: *u8, v: i64) -> i64 { eld_puts(label); eld_pn(v); eld_puts(" " as *u8); return 0 }
109func eld_nl() -> i64 { eld_puts("\n" as *u8); return 0 }
called by 2: eld_zone_lineeld_report calls 1: eld_puts
110func eld_int(s: *u8) -> i64
called by 1: main
120func eld_streq(a: *u8, b: *u8) -> i64
called by 1: main
129func eld_scratch() -> *i64 { return sys_mmap(ELD_SCRATCH_SLOTS * EL_I64) as *i64 }
132func eld_name(id: i64) -> i64
called by 1: eld_report calls 1: eld_puts
142func eld_arena_bytes() -> i64 { return CRAFT_TOTAL + ELD_ARENA_PAD }
called by 1: eld_run
143func eld_store_cap(frames: i64) -> i64 { return ELD_REC_PROLOGUE + frames * ELD_REC_PER_FRAME }
called by 1: main
146func eld_native_pixels() -> i64 { return W * H }
called by 1: eld_report
156func eld_run(st: *i64, v: i64, seed: i64, q: i64, frames: i64) -> i64
198func eld_zone_line(st: *i64, name: i64) -> i64
210func eld_report(st: *i64, base: i64, v: i64, seed: i64, q_arg: i64, frames: i64, target_fps: i64) -> i64
357func eld_img(base: i64) -> *VdImg
called by 1: main calls 1: sys_mmap
379func eld_usage() -> i64
called by 1: main calls 1: eld_puts
387func main(argc: i64, argv: *i64) -> i64