code wiki / (root) / nx_wgsl_rung2_gate.nx

nx_wgsl_rung2_gate.nx

buildroot/runtime/nx_wgsl_rung2_gate.nx

26241 B330 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic wgsl
docsdependenciesstructsconstsfunctions

about

nx_wgsl_rung2_gate.nx -- IS THE FRONT HALF REAL? Rung 2 is the claim that a shader is an ORDINARY NISHILANG FUNCTION compiled by the SAME front-end as every other program, with GLSL and WGSL as two backends over the shared nx_ir SSA. This gate measures that claim. WHY A SEPARATE GATE FROM nx_wgsl_gate: that one covers the rung-1 BUILDER path (a module assembled by sir_* calls). The path shipped in rung 2 -- real source -> expand_imports -> lex_source -> parse_module -> opt_run -> lowering -> two dialects -- was UNGATED, and an ungated rung is one this estate does not ship. SUBJECT: ./nx_wgsl.elf forked per fixture (e2e; an in-process gate would prove the source compiles, never that the SHIPPED artifact behaves). EVERY EXPECTED VALUE BELOW WAS MEASURED FIRST by running the fixtures, never guessed -- teeth written against assumed output are the vacuous-test defect wearing a gate's clothes. SCOPE, STATED SO IT CANNOT BE MISREAD: not one tooth renders a frame. GREEN means the two dialects are emitted from one NishiLang source and agree structurally. It does NOT mean a GPU drew the same pixels from both -- that is nx_wgsl_pixel_gate, and it is OWED.

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_gatekit_lib.nx nx_wgsl_rung2_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_gatekit_lib.nx

imported by: nobody (leaf or entry point)

structs

none

consts

24const R2_ELF: *u8 = "./nx_wgsl.elf"
28const R2_CAP: i64 = 65536
40const R2_GATE_NAME: *u8 = "nx_wgsl_rung2_gate"
43const R2_PATHCAP: i64 = 512
46const R2_FIXTURES: i64 = 10
48const R2_FN_CLIP: *u8 = "nxsh_clip.nx"
49const R2_FN_CLIP2: *u8 = "nxsh_clip2.nx"
50const R2_FN_BRANCH: *u8 = "nxsh_branch.nx"
51const R2_FN_I64: *u8 = "nxsh_i64.nx"
52const R2_FN_REM: *u8 = "nxsh_rem.nx"
53const R2_FN_LOOP: *u8 = "nxsh_loop.nx"
54const R2_FN_SKIN: *u8 = "nxsh_skin.nx"
55const R2_FN_LAYERS: *u8 = "nxsh_layers.nx"
56const R2_FN_IFELSE: *u8 = "nxsh_ifelse.nx"
57const R2_FN_LITCTL: *u8 = "nxsh_litctl.nx"
59const R2_TX_CLIP: *u8 = "// nxsh_clip.nx -- A SHADER, WRITTEN AS AN ORDINARY NISHILANG FUNCTION.\n//\n// There is no GLSL and no WGSL in this file. It is compiled by the SAME lexer, the SAME parser\n// and the SAME optimiser as every other NishiLang program (nx_tokenizer -> nx_parse -> nx_opt),\n// and nx_wgsl's two backends emit both dialects from the resulting nx_ir SSA. That is rung 2:\n// the shader IS the language, not a string literal written in another one.\n//\n// Deliberately straight-line: GLSL and WGSL have no goto, so a branchy function needs structured\n// control-flow recovery, which nx_wgsl REFUSES BY NAME today rather than guessing at (rung 2b).\n\nfunc shader_main(vi: i32) -> i32 {\n let a: i32 = vi * 2\n let b: i32 = a - 1\n return b\n}\n"
60const R2_TX_CLIP2: *u8 = "// FIXTURE for nx_wgsl_gate: the CORRUPTION NEG-CONTROL. Identical to nxsh_clip.nx except for one\n// extra statement. Trace identity across the two dialects would be satisfied by two backends that\n// both emitted NOTHING, so it is only evidence if a CHANGED SOURCE produces a CHANGED trace --\n// this fixture is what makes that tooth load-bearing instead of decorative.\nfunc shader_main(vi: i32) -> i32 {\n let a: i32 = vi * 2\n let b: i32 = a - 1\n let c: i32 = b + 7\n return c\n}\n"
61const R2_TX_BRANCH: *u8 = "// FIXTURE for nx_wgsl_gate: a BRANCHY shader function. GLSL and WGSL have no goto, so lowering\n// a multi-block CFG needs structured control-flow recovery (rung 2b -- the problem WebAssembly\n// had to solve). The backend must REFUSE THIS BY NAME rather than emit something plausible.\nfunc shader_main(vi: i32) -> i32 {\n var r: i32 = vi\n if vi > 0 { r = vi - 1 }\n return r\n}\n"
62const R2_TX_I64: *u8 = "// FIXTURE for nx_wgsl_gate: an i64 shader function. GLSL ES 3.00 HAS NO 64-BIT INTEGER, so the\n// only honest answers are refuse or narrow -- and narrowing is the exact silent mistranslation\n// this backend exists to prevent (it would compile, link, run, and compute the wrong number).\n// The backend must REFUSE THIS BY NAME.\nfunc shader_main(vi: i64) -> i64 {\n let a: i64 = vi * 2\n return a\n}\n"
63const R2_TX_REM: *u8 = "// FIXTURE for nx_wgsl_gate: an opcode OUTSIDE the covered subset (remainder). The refusal must\n// name the opcode NUMBER -- a refusal truncated before its actionable field costs the reader the\n// investigation it exists to save them (measured on this backend's own first run).\nfunc shader_main(vi: i32) -> i32 {\n let a: i32 = vi % 3\n return a\n}\n"
64const R2_TX_LOOP: *u8 = "// FIXTURE for nx_wgsl_rung2_gate: a LOOP. A back edge is the case the if-diamond recogniser\n// cannot handle and must never guess at -- the general answer is a relooper-class algorithm\n// (node duplication or a dispatch loop over a state variable), which is rung 2b-general.\n// The backend must REFUSE THIS BY NAME.\nfunc shader_main(vi: i32) -> i32 {\n var r: i32 = vi\n while r > 0 { r = r - 1 }\n return r\n}\n"
65const R2_TX_SKIN: *u8 = "// FIXTURE for nx_wgsl rung 2b: the SKINNING shape the character pass ACTUALLY produces --\n// a bounded loop over bone influences with a conditional skip for zero-weight slots.\n// This is loop-CONTAINING-if: the COMPOSITION a FLAT shape recogniser cannot match even\n// though it already handles each shape ALONE.\n//\n// TWO DELIBERATE RESTRICTIONS so that any refusal here is attributable to CONTROL FLOW alone:\n// (1) operators limited to + - < >, all of them already proven by earlier rungs;\n// (2) NO integer-literal initialiser. A bare literal types as i64 and `var a: i32 = 0` is\n// refused by shl_blk as 'stored value type has no GLSL ES 3.00 counterpart'. That is a\n// SCALAR-LITERAL TYPING gap, NOT a control-flow one, and knowledge/nxsh_litctl.nx is the\n// one-block control that proves it (ir_blocks=1, same refusal, no branch and no loop).\n// Literal OPERANDS are fine, which is why `i > 0` and `i - 1` appear freely below.\nfunc shader_main(vi: i32) -> i32 {\n var acc: i32 = vi\n var i: i32 = vi\n while i > 0 {\n let w: i32 = vi - i\n if w > 0 { acc = acc + w }\n i = i - 1\n }\n return acc\n}\n"
66const R2_TX_LAYERS: *u8 = "// FIXTURE for nx_wgsl rung 2b: the PAINT-LAYER shape -- NESTED bounded loops (layer x channel).\n// Nesting is the SECOND composition a flat recogniser cannot match. Same two restrictions as\n// nxsh_skin.nx (proven operators only; no integer-literal initialiser, see nxsh_litctl.nx) so\n// that a refusal here is attributable to control-flow recovery and to nothing else.\nfunc shader_main(vi: i32) -> i32 {\n var out: i32 = vi\n var l: i32 = vi\n while l > 0 {\n var c: i32 = vi\n while c > 0 {\n out = out + l\n c = c - 1\n }\n l = l - 1\n }\n return out\n}\n"
67const R2_TX_IFELSE: *u8 = "// NEGATIVE CONTROL for nx_wgsl rung 2b -- and a NAMED capability gap in the same file.\n//\n// Structured NishiLang source cannot express an irreducible CFG (there is no goto), so the\n// reducer's multi-entry and irreducible refusals cannot be fired from source at all. This is the\n// refusal that CAN be fired: an if/ELSE. Both arms are non-empty, so the entry's two successors\n// are then-block and else-block, and the then-block falls through to a JOIN that is neither of\n// them -- which is not the if-diamond shape the reducer recognises.\n//\n// It must REFUSE BY NAME. A reducer whose refusals have never fired is unverified, and this is\n// the one that keeps it honest. It also names the next rung: if/else lowering is NOT implemented,\n// and that is a real gap rather than a hypothetical one -- shaders use else constantly.\nfunc shader_main(vi: i32) -> i32 {\n var r: i32 = vi\n if vi > 0 { r = vi - 1 } else { r = vi + 1 }\n return r\n}\n"
68const R2_TX_LITCTL: *u8 = "// CONTROL for nx_wgsl rung 2b. ONE block, no branch, no loop -- the ONLY thing it exercises that\n// the earlier fixtures did not is an integer LITERAL initialiser for an i32 local. If this refuses\n// with the same 'stored value type' message that nxsh_skin.nx hit, then that refusal is a TYPE\n// gap and has nothing to do with control-flow recovery. A control is the cheapest way to stop a\n// failure being attributed to the rung that happened to be under test when it appeared.\nfunc shader_main(vi: i32) -> i32 {\n var a: i32 = 0\n return a\n}\n"

functions

72func r2_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
74func r2_has(buf: *u8, n: i64, ned: *u8) -> i64
90func r2_num(buf: *u8, n: i64, key: *u8) -> i64
115func r2_run(src: *u8, buf: *u8, bl: *i64) -> i64
122func main() -> i64