code wiki / (root) / nx_wgsl_world_depth_t195.nx

nx_wgsl_world_depth_t195.nx

buildroot/runtime/nx_wgsl_world_depth_t195.nx

205067 B3514 linesdepth 9pulls 27 transitivereach 3 importersview sourcekind librarytopic wgsl
docsdependenciesstructsconstsfunctions

about

nx_wgsl.nx -- THE SHADER BACKENDS: NishiLang in, GLSL and WGSL out. CONTRACT SYMBOL: wgsl_emit_module (declared _ABSENT_ on the graphics compare board until now). THE SOURCE IS NISHILANG, NOT GLSL (operator 2026-08-23). This organ is NOT a GLSL->WGSL transpiler. A shader is authored ONCE against the nx_shader_ir representation; glsl_emit_module and wgsl_emit_module are two BACKENDS over that one source, exactly as nx_compile_x86 and the WAT lane are two backends over one NishiLang front-end. Neither dialect is authored, so neither can drift from the other -- disagreement is impossible BY CONSTRUCTION rather than by discipline. RUNG 1, SHIPPED HERE: the fullscreen-triangle VERTEX STAGE. It is not a toy -- it is the exact stage that ships TODAY, hand-written TWICE in nx_game_page_emit: GLSL VSH : void main(){vec2 v=vec2((gl_VertexID<<1)&2,gl_VertexID&2);gl_Position=vec4(v*2.-1.,0.,1.);} WGSL vs : @vertex fn vs(@builtin(vertex_index) vi:u32)->@builtin(position) vec4f{...} Those two hand copies are the duplication this rung deletes: below, ONE NishiLang source (shsrc_fullscreen_tri) emits both. WHY THIS STAGE PROVES THE THESIS. The two dialects are not spelling variants of each other: * GLSL ASSIGNS gl_Position; WGSL RETURNS @builtin(position). Different STRUCTURE. * GLSL gl_VertexID is i32; WGSL vertex_index is u32 and must be converted before i32 maths. * WGSL requires a u32 shift amount (1u); GLSL takes a plain int. * WGSL requires 0.0, never 0. ; GLSL accepts either. Every one of those is dialect knowledge the BACKEND owns. A translator would have to rediscover them from GLSL text; a backend simply knows them, once. COVERED SUBSET (rung 1) -- anything outside REFUSES BY NAME via sir_refuse and returns -1. A NAMED REFUSAL IS A CONTRACT; A SILENT MISTRANSLATION IN A SHADER BACKEND IS THE WORST AVAILABLE FAILURE: it compiles, it links, it runs, and it draws the wrong picture forever. decls : uniform (scalar + array); attribute and varying are GLSL-covered and, since S1 (2026-09-04), WGSL-REFUSED BY NAME (K_ATTRIB anywhere, K_VARY in a fragment stage) until the entry-parameter derivation that WGSL needs for them lands; a texture-typed uniform refuses in WGSL too -- it was being emitted INSIDE struct U S3 (2026-09-04): a TEXTURE is its own kind (K_TEXTURE / sir_texture) in BOTH backends: GLSL `uniform highp usampler3D`, WGSL a @group/@binding var OUTSIDE struct U with its binding DERIVED from declaration order; only texture_3d<u32> is covered, other texture types refuse S4 (2026-09-04): the FRAGMENT entry signature is DERIVED from the declared parameters (no longer a literal): a sir_param_position parameter is `@builtin(position) name:vec4f` in WGSL and gl_FragCoord in GLSL; a position READ with no such parameter, and any entry parameter a backend cannot bind (plain fragment params, any vertex/compute param), refuse by name stmts : var, assign, return, if/else, discard

dependencies 11 imports · 3 importers

nx_syscalls.nx nx_shader_ir.nx nx_cast_depth_build_t195.nx nx_world_shader_depth_t194.nx nx_types.nx nx_lex_kinds.nx nx_ir.nx nx_tokenizer.nx nx_parse.nx nx_opt.nx nx_wgsl_world_depth_t195.nx nx_ir_world_capacity_t206.nx nx_ir_world_identity_t206.nx nx_world_depth_gate_t195.nx

diagram shows first 10 each side; +1 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_shader_ir.nxnx_cast_depth_build_t195.nxnx_world_shader_depth_t194.nxnx_types.nxnx_lex_kinds.nxnx_ir.nxnx_tokenizer.nxnx_parse.nxnx_opt.nxnx_import.nx

imported by: nx_ir_world_capacity_t206.nxnx_ir_world_identity_t206.nxnx_world_depth_gate_t195.nx

structs

none

consts

78const STAGE_PLAIN: i64 = 0
79const STAGE_VERTEX: i64 = 1
80const STAGE_FRAGMENT: i64 = 2
82const STAGE_COMPUTE: i64 = 3
87const WG_WORKGROUP: i64 = 64
91const WG_TRACE_CAP: i64 = SIR_MAXNODE
95const WG_EMIT_CAP: i64 = SIR_MAXNODE * 16
97const WG_C_BANG: i64 = 33
99const WG_NUMBUF: i64 = 32
107const WG_MSGBUF: i64 = 128
114const WG_BIND_GROUP: i64 = 0
119const WG_BIND_UNIFORM: i64 = 0
120const WG_BIND_TEX_FIRST: i64 = WG_BIND_UNIFORM + 1
264const WG_F32ARR_LANES: i64 = 4
2095const WG_UNIFORM_STRIDE_MULTIPLE: i64 = 16
2232const WG_MODE_0644: i64 = 420
2885const SHL_EXPAND_CAP: i64 = 4194304
2886const SHL_LEX_CAP: i64 = 262144

functions

118func wg_group(m: *i64) -> i64 { return WG_BIND_GROUP + m[M_BINDGROUP] }
123func gl_ty(t: i64) -> *u8
142func wg_ty(t: i64) -> *u8
165func gl_tyname(m: *i64, t: i64) -> *u8
170func wg_tyname(m: *i64, t: i64) -> *u8
179func wg_is_texty(t: i64) -> i64
192func wg_name_is(m: *i64, id: i64, name: *u8) -> i64
196func wg_fn_param(m: *i64, fn: i64, name: *u8) -> i64
206func wg_fn_position_param(m: *i64, fn: i64) -> i64
216func wg_chain_local(m: *i64, head: i64, name: *u8) -> i64
231func wg_decl_named(m: *i64, kind: i64, name: *u8) -> i64
241func wg_resolves_to_uniform(m: *i64, name: *u8) -> i64
251func wg_resolves_to_varying(m: *i64, name: *u8) -> i64
265func wg_f32arr_vec4n(n: i64) -> i64 { return (n + WG_F32ARR_LANES - 1) / WG_F32ARR_LANES }
267func wg_f32arr_len(m: *i64, name: *u8) -> i64
277func wg_decl_kind_first(m: *i64, kind: i64) -> i64
286func wg_decl_kind_count(m: *i64, kind: i64) -> i64
297func wg_fragout(m: *i64) -> i64 { return wg_decl_kind_first(m, K_FRAGOUT) }
302func wg_chain_returns_value(m: *i64, head: i64) -> i64
319func wg_chain_assigns(m: *i64, head: i64, name: *u8) -> i64
337func wg_chain_last_is_return(m: *i64, head: i64) -> i64
347func wg_tex_binding(m: *i64, tex: i64) -> i64
358func wg_storage_at(m: *i64, binding: i64) -> i64
368func gl_expr(m: *i64, id: i64, out: *u8, pos: i64, cap: i64, trace: *i64, tcap: i64, tn: *i64) -> i64
503func wg_chain_has_depth(m: *i64, head: i64) -> i64
518func wg_depth_flow(m: *i64, head: i64, color_ty: i64) -> i64
544func wg_depth_contract(m: *i64, stage: i64) -> i64
575func gl_stmts(m: *i64, head: i64, out: *u8, pos: i64, cap: i64, trace: *i64, tcap: i64, tn: *i64) -> i64
657func glsl_emit_module(m: *i64, stage: i64, out: *u8, cap: i64, trace: *i64, tcap: i64, tn: *i64) -> i64
848func wg_fn_is_plain(m: *i64, f: i64, stage: i64) -> i64
856func wg_rev(out: *u8, a: i64, b: i64) -> i64
875func wg_splat_callee(n: *u8) -> i64
884func wg_vec_arg_ty(m: *i64, id: i64) -> i64
896func wg_expr(m: *i64, id: i64, out: *u8, pos: i64, cap: i64, trace: *i64, tcap: i64, tn: *i64) -> i64
1110func wg_is_position(m: *i64, id: i64) -> i64
1118func wg_stmts(m: *i64, head: i64, out: *u8, pos: i64, cap: i64, trace: *i64, tcap: i64, tn: *i64) -> i64
1229func wgsl_compute_stage(m: *i64, f: i64, out: *u8, pos: i64, cap: i64) -> i64
1240func wgsl_emit_module(m: *i64, stage: i64, out: *u8, cap: i64, trace: *i64, tcap: i64, tn: *i64) -> i64
1633func shsrc_fullscreen_tri(m: *i64) -> i64
1663func shsrc_depth_min(m: *i64) -> i64
1675func wg_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
1677func wg_streq(a: *u8, b: *u8) -> i64
1686func wg_compute_demo() -> i64
1738func wg_probe(m: *i64, stage: i64, label: *u8, dialect_wgsl: i64, trace: *i64, tn: *i64) -> i64
1757func wg_trace_eq(a: *i64, an: i64, b: *i64, bn: i64) -> i64
1767func shsrc_frag_const(m: *i64) -> i64
1785func shsrc_fullscreen_tri_scaled(m: *i64) -> i64
1802func shsrc_fullscreen_tri_shadowlocal(m: *i64) -> i64
1820func shsrc_plain_shadowparam(m: *i64) -> i64
1836func shsrc_private_demo(m: *i64) -> i64
1853func shsrc_tex2d_sample(m: *i64) -> i64
1861func shsrc_tex_plain(m: *i64) -> i64
1881func shsrc_frag_pos(m: *i64) -> i64
1897func shsrc_frag_pos_undeclared(m: *i64) -> i64
1912func shsrc_frag_plainparam(m: *i64) -> i64
1930func shsrc_frag_discard(m: *i64) -> i64
1940func shsrc_frag_noout(m: *i64) -> i64
1954func shsrc_frag_loc2(m: *i64) -> i64
1968func shsrc_vert_fragout(m: *i64) -> i64
1975func shsrc_frag_twoout(m: *i64) -> i64
1982func shsrc_frag_const_body(m: *i64) -> i64
1998func shsrc_texsample(m: *i64) -> i64
2009func shsrc_select_let(m: *i64) -> i64
2024func shsrc_for_until(m: *i64) -> i64
2040func shsrc_struct(m: *i64) -> i64
2063func shsrc_struct_ret(m: *i64) -> i64
2096func wg_round_up(al: i64, n: i64) -> i64 { return ((n + al - 1) / al) * al }
2097func wg_align_of(t: i64) -> i64
2109func wg_size_of(t: i64) -> i64
2126func wg_uniform_layout(m: *i64, out: *u8, pos: i64, cap: i64) -> i64 { return wg_uniform_layout_k(m, out, pos, cap, "struct_u_size=" as *u8) }
2127func wg_uniform_layout_k(m: *i64, out: *u8, pos: i64, cap: i64, key: *u8) -> i64
2180func shsrc_world_uniforms(m: *i64) -> i64
2192func shsrc_neg_uninit(m: *i64) -> i64
2203func wg_world_demo() -> i64
2234func wg_glsl_to_path(m: *i64, stage: i64, outp: *u8, label: *u8) -> i64
2252func wg_cast_demo(outp: *u8, outf: *u8) -> i64
2323func wg_layout_demo() -> i64
2392func gl_call_name(name: *u8) -> *u8
2403func wg_decls_demo() -> i64
2891func shl_ty(t: *Type) -> i64
2901func shl_op(op: i64) -> *u8
2924func shl_val(m2: *i64, f: *Function, vid: i64, nb: *u8) -> i64
2950func shl_blk(m2: *i64, f: *Function, fn2: i64, bb: *BasicBlock, nb: *u8, msg: *u8, seen: *i64) -> i64
3027func shl_bid(f: *Function, id: i64) -> *BasicBlock
3040func shl_reaches(f: *Function, from: i64, to: i64, mark: *i64, wl: *i64) -> i64
3070func shl_reaches_avoid(f: *Function, from: i64, to: i64, avoid: i64, mark: *i64, wl: *i64) -> i64
3099func shl_dominates(f: *Function, b: i64, p: i64, mark: *i64, wl: *i64) -> i64
3114func shl_is_header(f: *Function, bb: *BasicBlock, mark: *i64, wl: *i64) -> i64
3143func shl_region(m2: *i64, f: *Function, fn2: i64, eid: i64, stop: i64, nb: *u8, msg: *u8, seen: *i64, mark: *i64, wl: *i64, depth: i64) -> i64
3260func shl_lower(m2: *i64, f: *Function, fname: *u8) -> i64
3326func main(argc: i64, argv: *i64) -> i64