code wiki / _hdl_build / nx_sdfrender_gate.nx

nx_sdfrender_gate.nx

buildroot/runtime/_hdl_build/nx_sdfrender_gate.nx

20779 B378 linesdepth 4pulls 9 transitivereach 0 importersview sourcekind gate/prooftopic sdfrender
docsdependenciesstructsconstsfunctions

about

nx_sdfrender_gate.nx -- gate for the SMOOTH-UNION SDF body (sovereign software GPU, continuous surface). T1 the body renders (solid skin block) T2 per-pixel shading gradient (SDF-gradient normals -> real lighting) T3 full figure top->bottom T4 CONTINUOUS: the centre column is ONE fused run (the parts FUSED, not disjoint blobs) -- the whole point of smooth-union over the rasterized ellipsoids T5 THE CAPTURE ACTUALLY LANDS -- four teeth where there used to be one, see the block below T6 pre-integrated SSS (sr_sss_preint), the non-gameable quad =================================================================================================== WHY T5 IS FOUR TEETH NOW (debt 1787678931, MEASURED 2026-08-25 -- this gate WAS the defect). The old T5 was one line: write_png(fb, ww(), hh(), "knowledge/nx_sdfbody.png"); if diff == 0 { PASS "determinism + PNG" } It DISCARDED write_png's return and gated on DETERMINISM ONLY. Determinism is trivially satisfied by WRITING NOTHING TWICE, so the tooth could not distinguish a landed capture from no capture at all. PROOF IT DID NOT: two runs whose framebuffers provably DIFFERED (skin 37624 vs 37626, bands 10352/18040/9232 vs 10353/18042/9231) left knowledge/nx_sdfbody.png byte-identical at 827bc7718e15f0437a1600326e7bc7ec46a34dfc7c189d2a51607f7ccdf185a5 / 142629 B across BOTH -- while this gate printed "T5 PASS determinism + PNG". A whole rung shipped with no trustworthy before/after image. A TOOTH THAT DISCARDS ITS ACTUATOR'S RETURN CANNOT SEE THE ACTUATOR FAIL. DETERMINISM IS NECESSARY AND IS NOT SUFFICIENT, AND THE TOOTH THAT NAMES ONLY THE NECESSARY HALF READS EXACTLY LIKE A PROOF OF THE WHOLE. The four that replace it, each named for what it can refute: T5a the publish RETURNS a byte count and the ARTIFACT ON DISK IS THAT SIZE -- receipt AND artifact T5b determinism, RENAMED so it can never again be read as evidence the file was written T5c A/B: two captures whose SHADER PROVABLY DIFFERS must be DIFFERENT FILES. This is the tooth a no-op writer, a stale-file writer and an open-that-silently-failed all die at, and the one the old gate had no analogue of. T5d fixture-reached-the-condition: the two swatches' shader values really do differ, asserted ARITHMETICALLY and FIRST, so a T5c failure can never be blamed on a fixture that never varied. plus two neg-controls that must FAIL for the teeth above to mean anything. AND THE OWED ARTIFACT. T5c's A/B pair is not a synthetic fixture -- it IS the before/after this rung owes. nx_sdfrender's own shading site says "curv=0 reproduces the former fixed 120/60/26 widths bit-for-bit", so evaluating the SHIPPED sr_sss_preint over the whole (N.L x curvature) domain with curvature PASSED THROUGH gives the rung, and with curvature FORCED TO ZERO gives the pre-rung shader exactly. Two images, one shipped function, no second implementation to be wrong: knowledge/nx_sdfsss_before.png pre-rung fixed wrap (every row identical: curvature ignored) knowledge/nx_sdfsss_after.png the shipped rung (rows widen with curvature)

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_png.nx nx_sdfrender.nx nx_sdfrender_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_png.nxnx_sdfrender.nx

imported by: nobody (leaf or entry point)

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

main gv_ctr 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 ↻ gv_head gv_puts sys_write ↻ sys_mmap ↻ sdf_bytes sdf_body sdf_clear_ops sdf_set_floor sdf_set_mtx_amp sdf_set_kb sdf_render sdf_render_rows it_cos4096 it_sin4096 it_sin4096 ↻ sdf_isqrt vm_isqrt sdf_shade_ray sdf_eval sdf_part_distance sdf_lidshell sdf_ellip sdf_ellip_rot

structs

none

consts

53const SDG_SKIN_MIN_PX: i64 = 8000 // T1 floor: fewer than this and no body rendered
54const SDG_SKIN_MAX_PX: i64 = 90000 // T1 ceiling: more than this and the frame is flooded
55const SDG_LUM_SPAN_MIN: i64 = 200 // T2: summed-RGB luminance span that proves per-pixel shading
56const SDG_BAND_TOP_MIN: i64 = 300 // T3: head band
57const SDG_BAND_MID_MIN: i64 = 1500 // T3: torso band
58const SDG_BAND_BOT_MIN: i64 = 300 // T3: legs band
59const SDG_TRUNK_RUNS_MAX: i64 = 3 // T4: chin/crotch may break the centre column, nothing more
60const SDG_BANDS: i64 = 3 // T3 splits the frame into three equal horizontal bands
61const SDG_TRUNK_MIN_DIV: i64 = 2 // T4: the trunk spans more than hh()/2
65const SDG_OLDWRAP_R: i64 = 120
66const SDG_OLDWRAP_G: i64 = 60
67const SDG_OLDWRAP_B: i64 = 26
70const SDG_SSS_PK: i64 = 1024 // the (wR,wG,wB) packing radix of sr_sss_preint_n (nx_sdfrender)
71const SDG_PACK_G: i64 = 256 // write_png contract: c = r + g*256 + b*65536
72const SDG_PACK_B: i64 = 65536
73const SDG_PNG_CH_MAX: i64 = 255 // 8-bit PNG channel maximum -- fixed by the FORMAT, not chosen
74const SDG_PERMIL: i64 = 1000
75const SDG_DIR_MODE_0755: i64 = 0x1ed // rwxr-xr-x, for the gate's own /tmp scratch directory
76const SDG_SEEK_END: i64 = 2
77const SDG_PTR_BYTES: i64 = 8 // one i64 out-parameter slot
78const SDG_PX_BYTES: i64 = 8 // the framebuffer write_png consumes is one packed i64 per pixel
80const SDG_YAW: i64 = 0
81const SDG_CAMZ: i64 = 5
82const SDG_SKIN_R: i64 = 240
83const SDG_SKIN_G: i64 = 184
84const SDG_SKIN_B: i64 = 160
86const SDG_CURV_PASSTHROUGH: i64 = 1 // the shipped rung: curvature varies down the image
87const SDG_CURV_FORCED_FLAT: i64 = 0 // the pre-rung shader: curvature ignored, every row identical

functions

89func sdg_is_skin(px: i64) -> i64 { let r: i64 = px & 255; let b: i64 = (px >> 16) & 255; if r >= b { return 1 } return 0 }
called by 1: main
90func sdg_lum(px: i64) -> i64 { return (px & 255) + ((px >> 8) & 255) + ((px >> 16) & 255) }
called by 1: main
93func sdg_size(path: *u8) -> i64
102func sdg_did_not_land(path: *u8, claimed: i64) -> i64
called by 1: main calls 1: sdg_size
109func sdg_noop_writer(path: *u8) -> i64 { return 0 }
called by 1: main
113func sdg_files_differ(a: *u8, b: *u8, outoff: *i64) -> i64
called by 1: main calls 2: sys_mmapsys_read_file
139func sdg_swatch(fb: *i64, w: i64, h: i64, usecurv: i64) -> i64
called by 1: main calls 1: sr_sss_preint
162func main() -> i64