code wiki / (root) / nx_gsplat_res_gate.nx

nx_gsplat_res_gate.nx source

↩ module page · 187 lines · 10777 B

1// nx_gsplat_res_gate.nx -- THE VIEWPORT IS A PARAMETER, AND HERE IS THE PROOF. 2// 3// WHY THIS GATE EXISTS. Until 2026-08-23 nx_gsplat rendered at a COMPILE-TIME 512x384 = 196,608 px. 4// Every stage read the module consts GW/GH/GHW/GHH/GFOCAL, so the rasterizer -- and every "second 5// renderer" the three-stage decomposition exists to enable, nx_gsplat_tile_lib included -- could only 6// ever emit a postage stamp. A beauty-tier frame is 1920x1080 (10.55x the pixels). The ceiling was 7// never a graphics limit; it was five constants, and the inner stages (gs_blend_rect's stride_w, 8// gs_resolve's npx) were ALREADY viewport-agnostic. This gate holds the widening honest in BOTH 9// directions: the historic frame must be untouched, and the wide frame must actually be wide. 10// 11// THE TEETH A PLAUSIBLE-BUT-WRONG IMPLEMENTATION FAILS: 12// T4 is the ANTI-VACUITY tooth. An implementation that accepts w/h and IGNORES them still renders 13// 512x384 and passes every "it rendered something" check. It cannot pass T4, which requires lit 14// pixels at an index BEYOND the entire historic framebuffer -- a region that does not exist in a 15// 512x384 render -- and a lit-count ratio no unwidened renderer can reach (its ratio is exactly 1). 16// T1 is the NEUTRALITY control: the historic entry point and the _at entry point at the historic 17// viewport must produce BYTE-IDENTICAL frames. Widening that disturbs the incumbent is a revert. 18// T5/T6 are the FOV pair, asked both directions, because a derivation nobody can falsify is a guess. 19// gs_focal_for(h) scales focal by h/GH, which holds tan(vfov/2) constant. T5 requires the derived 20// focal to preserve the vertical angle; T6 requires the UNSCALED focal to BREAK it. A tooth that 21// only ever sees the right answer has not tested the derivation. 22// 23// NOTE ON ASPECT: focal scaling preserves the VERTICAL field of view. 512x384 is 4:3 and 1920x1080 is 24// 16:9, so the HORIZONTAL extent legitimately widens -- exactly as a real camera does when the gate is 25// opened wider. That is why T5 measures the vertical axis: it is the axis the derivation claims. 26// license_tier: ORIGINAL expect_exit: 0 27import "nx_syscalls.nx" 28import "nx_itrig.nx" 29import "nx_gsplat.nx" 30import "nx_gate_verdict.nx" 31 32// FIXTURE: the scene under test, declared out loud rather than hidden in the organ. 33const RG_GRID: i64 = 8 34const RG_NG: i64 = 64 // RG_GRID squared 35const RG_BW: i64 = 1920 // the operator's stated beauty-tier bar 36const RG_BH: i64 = 1080 37const RG_CAMZ: i64 = 30 38const RG_RTAN: i64 = 250 39const RG_XSPAN: i64 = 10000 40const RG_YSPAN: i64 = 8000 41const RG_PROBE_Y: i64 = 8000 // the vertical probe point for the FOV teeth 42const RG_W64: i64 = 8 43const RG_RATIO_FLOOR: i64 = 2 // see T4: the DERIVED ratio is 10.55; an unwidened renderer 44 // yields exactly 1. Any floor strictly between them discriminates; 45 // 2 is taken well below the derivation so the tooth tests the 46 // WIDENING, not the scene's particular coverage. 47 48func rg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } 49 50// an 8x8 lattice of camera-facing anisotropic surfels spanning the historic frame. 51func rg_scene(gauss: *i64) -> i64 { 52 let st: i64 = gs_stride_aniso() 53 var i: i64 = 0 54 while i < RG_NG { 55 let row: i64 = i / RG_GRID 56 let col: i64 = i - row * RG_GRID 57 let x: i64 = 0 - RG_XSPAN + col * (2 * RG_XSPAN / (RG_GRID - 1)) 58 let y: i64 = 0 - RG_YSPAN + row * (2 * RG_YSPAN / (RG_GRID - 1)) 59 gs_set_aniso(gauss, i, x, y, 0, 0, 0, 0 - gs_fxa(), RG_RTAN, 60 + i * 3, 200, 255 - i * 2, gs_fxa()) 60 i = i + 1 61 } 62 return RG_NG 63} 64 65// render at an explicit viewport. historic=1 takes the ORIGINAL entry point so T1 can compare the two. 66func rg_render(gauss: *i64, ng: i64, w: i64, h: i64, focal: i64, fb: *i64, historic: i64) -> i64 { 67 let npx: i64 = w * h 68 let acc: *i64 = sys_mmap(npx * 3 * RG_W64) as *i64 69 let trans: *i64 = sys_mmap(npx * RG_W64) as *i64 70 let depth: *i64 = sys_mmap(ng * RG_W64) as *i64 71 let sxb: *i64 = sys_mmap(ng * RG_W64) as *i64 72 let syb: *i64 = sys_mmap(ng * RG_W64) as *i64 73 let pa: *i64 = sys_mmap(ng * RG_W64) as *i64 74 let pb: *i64 = sys_mmap(ng * RG_W64) as *i64 75 let pc: *i64 = sys_mmap(ng * RG_W64) as *i64 76 let pdet: *i64 = sys_mmap(ng * RG_W64) as *i64 77 let order: *i64 = sys_mmap(ng * RG_W64) as *i64 78 let count: *i64 = sys_mmap((gs_nb() + 2) * RG_W64) as *i64 79 let explut: *i64 = sys_mmap(gs_expn() * RG_W64) as *i64 80 gs_build_explut(explut) 81 if historic == 1 { 82 return gs_render_aniso(gauss, ng, 0, RG_CAMZ, fb, acc, trans, depth, sxb, syb, pa, pb, pc, pdet, order, count, explut, 0, 0, 0) 83 } 84 return gs_render_aniso_at(gauss, ng, 0, RG_CAMZ, fb, acc, trans, depth, sxb, syb, pa, pb, pc, pdet, order, count, explut, 0, 0, 0, w, h, focal) 85} 86 87// background is 0,0,0 so a lit pixel is simply a non-zero one. 88func rg_lit(fb: *i64, from: i64, to: i64) -> i64 { 89 var n: i64 = 0 90 var i: i64 = from 91 while i < to { if fb[i] != 0 { n = n + 1 } i = i + 1 } 92 return n 93} 94func rg_same(a: *i64, b: *i64, n: i64) -> i64 { 95 var i: i64 = 0 96 while i < n { if a[i] != b[i] { return 0 } i = i + 1 } 97 return 1 98} 99 100func main() -> i64 { 101 let ctr: *i64 = gv_ctr() 102 gv_head("nx_gsplat_res_gate -- the viewport is a PARAMETER: a beauty-tier frame renders, the historic frame is untouched" as *u8) 103 104 let st: i64 = gs_stride_aniso() 105 let gauss: *i64 = sys_mmap(RG_NG * st * RG_W64) as *i64 106 let ng: i64 = rg_scene(gauss) 107 let sw: i64 = gs_w() 108 let sh: i64 = gs_h() 109 let sfoc: i64 = gs_focal_for(sh) 110 let bfoc: i64 = gs_focal_for(RG_BH) 111 let snpx: i64 = sw * sh 112 let bnpx: i64 = RG_BW * RG_BH 113 114 gv_puts(" historic viewport=" as *u8); gv_num(sw); gv_puts("x" as *u8); gv_num(sh) 115 gv_puts(" px=" as *u8); gv_num(snpx); gv_puts(" focal=" as *u8); gv_num(sfoc); gv_puts("\n" as *u8) 116 gv_puts(" beauty viewport=" as *u8); gv_num(RG_BW); gv_puts("x" as *u8); gv_num(RG_BH) 117 gv_puts(" px=" as *u8); gv_num(bnpx); gv_puts(" focal=" as *u8); gv_num(bfoc) 118 gv_puts(" pixel_ratio=" as *u8); gv_num(bnpx / snpx); gv_puts("\n" as *u8) 119 120 // ---- T1 NEUTRALITY: the two entry points must agree exactly at the historic viewport ---------- 121 let fb_hist: *i64 = sys_mmap(snpx * RG_W64) as *i64 122 let fb_at: *i64 = sys_mmap(snpx * RG_W64) as *i64 123 let vis_h: i64 = rg_render(gauss, ng, sw, sh, sfoc, fb_hist, 1) 124 let vis_a: i64 = rg_render(gauss, ng, sw, sh, sfoc, fb_at, 0) 125 let ident: i64 = rg_same(fb_hist, fb_at, snpx) 126 gv_puts(" neutrality: vis historic=" as *u8); gv_num(vis_h) 127 gv_puts(" vs _at=" as *u8); gv_num(vis_a) 128 gv_puts(" frames_byte_identical=" as *u8); gv_num(ident); gv_puts("\n" as *u8) 129 var t1: i64 = 0 130 if ident == 1 { if vis_h == vis_a { t1 = 1 } } 131 gv_check("T1 neutrality: widening did NOT disturb the historic path (byte-identical frame, same visible count)" as *u8, t1, ctr) 132 133 // ---- T2 the fixture actually reached the condition ------------------------------------------- 134 let lit_s: i64 = rg_lit(fb_hist, 0, snpx) 135 gv_puts(" fixture: visible=" as *u8); gv_num(vis_h); gv_puts(" of " as *u8); gv_num(ng) 136 gv_puts(" lit_small=" as *u8); gv_num(lit_s); gv_puts("\n" as *u8) 137 var t2: i64 = 0 138 if vis_h == ng { if lit_s > 0 { t2 = 1 } } 139 gv_check("T2 fixture-reached-the-condition: every gaussian projected and the historic frame has lit pixels" as *u8, t2, ctr) 140 141 // ---- T3 the beauty-tier frame renders at all ------------------------------------------------- 142 let fb_big: *i64 = sys_mmap(bnpx * RG_W64) as *i64 143 let vis_b: i64 = rg_render(gauss, ng, RG_BW, RG_BH, bfoc, fb_big, 0) 144 let lit_b: i64 = rg_lit(fb_big, 0, bnpx) 145 gv_puts(" beauty render: visible=" as *u8); gv_num(vis_b) 146 gv_puts(" lit_big=" as *u8); gv_num(lit_b); gv_puts("\n" as *u8) 147 var t3: i64 = 0 148 if vis_b == ng { if lit_b > 0 { t3 = 1 } } 149 gv_check("T3 the beauty-tier viewport RENDERS: every gaussian projected and the wide frame has lit pixels" as *u8, t3, ctr) 150 151 // ---- T4 ANTI-VACUITY: pixels exist BEYOND the entire historic framebuffer --------------------- 152 let lit_beyond: i64 = rg_lit(fb_big, snpx, bnpx) 153 gv_puts(" beyond-historic: lit at index >= " as *u8); gv_num(snpx) 154 gv_puts(" is " as *u8); gv_num(lit_beyond) 155 gv_puts(" | ratio lit_big/lit_small=" as *u8); gv_num(lit_b / lit_s) 156 gv_puts(" floor=" as *u8); gv_num(RG_RATIO_FLOOR); gv_puts("\n" as *u8) 157 var t4: i64 = 0 158 if lit_beyond > 0 { if lit_b > lit_s * RG_RATIO_FLOOR { t4 = 1 } } 159 gv_check("T4 anti-vacuity: a renderer that IGNORED w/h writes nothing past the historic frame and ratios exactly 1" as *u8, t4, ctr) 160 161 // ---- T5/T6 the FOV derivation, asked both directions ----------------------------------------- 162 // vertical offset of the same world point at both viewports; equal ANGLE means the normalized 163 // offsets match. Cross-multiplied to stay in integers: off_s/hh_s == off_b/hh_b. 164 let sy4: i64 = it_sin4096(0) 165 let cy4: i64 = it_cos4096(0) 166 let R: i64 = RG_CAMZ * gs_fx() 167 let hh_s: i64 = sh / 2 168 let hh_b: i64 = RG_BH / 2 169 let off_s: i64 = hh_s - gs_proj_y_at(0, RG_PROBE_Y, 0, sy4, cy4, R, hh_s, sfoc) 170 let off_b: i64 = hh_b - gs_proj_y_at(0, RG_PROBE_Y, 0, sy4, cy4, R, hh_b, bfoc) 171 let off_w: i64 = hh_b - gs_proj_y_at(0, RG_PROBE_Y, 0, sy4, cy4, R, hh_b, sfoc) 172 // BOUND, DERIVED (not chosen): each projection truncates by <1 px, contributing hh_b and hh_s to the 173 // cross-product; gs_focal_for truncates too, and d(off)/d(focal) = off/focal < 1 here, contributing a 174 // further hh_s. Total = hh_b + 2*hh_s. 175 let bound: i64 = hh_b + 2 * hh_s 176 let dgood: i64 = rg_abs(off_s * hh_b - off_b * hh_s) 177 let dbad: i64 = rg_abs(off_s * hh_b - off_w * hh_s) 178 gv_puts(" fov: off_small=" as *u8); gv_num(off_s); gv_puts(" off_big=" as *u8); gv_num(off_b) 179 gv_puts(" off_unscaled=" as *u8); gv_num(off_w); gv_puts("\n" as *u8) 180 gv_puts(" fov cross-product |diff|: derived_focal=" as *u8); gv_num(dgood) 181 gv_puts(" unscaled_focal=" as *u8); gv_num(dbad) 182 gv_puts(" derived_bound=" as *u8); gv_num(bound); gv_puts("\n" as *u8) 183 gv_check("T5 the derived focal PRESERVES the vertical field of view within a bound derived from truncation" as *u8, dgood <= bound, ctr) 184 gv_bite("neg-control-unscaled-focal-breaks-the-field-of-view" as *u8, dbad > bound, dgood > bound, ctr) 185 186 return gv_verdict("NX-GSPLAT-RES" as *u8, ctr, "the viewport is a parameter: the wide frame is genuinely wide and the historic frame is untouched" as *u8) 187}