code wiki / (root) / nx_gpu_graphics_gate.nx

nx_gpu_graphics_gate.nx

buildroot/runtime/nx_gpu_graphics_gate.nx

11794 B170 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic gpu
docsdependenciesstructsconstsfunctions

about

nx_gpu_graphics_gate.nx -- GOAL-GPU-NATIVE rung-2: a GRAPHICS engine on the sovereign GPFIFO pipeline. Synthesis the operator asked for -- hardware rung up + game ecosystem + consume/produce, all sovereign. Builds on the RESEARCHED NVIDIA command model embodied in the BM-GPU organs (GF100 method-header decode + NVC56F class-binding via SET_OBJECT@0x0, spec-faithful). Adds a GRAPHICS class: a game/driver PRODUCES a draw-command pushbuffer (SET_OBJECT graphics, SET_FB/W/H, CLEAR, per-triangle state, DRAW), the modeled GPU host/FIFO CONSUMES the ring, and the GRAPHICS engine (our rung-1 rasterizer) PRODUCES pixels into GPU VRAM with a Z-buffer. This is the same submit->execute loop as compute, now driving the screen. produce (draw cmds) -> GPFIFO ring -> consume (FIFO decode) -> graphics engine -> produce (pixels in VRAM) KAT: the scene renders THROUGH the command stream; the Z-buffer is correct through the pipeline (a far triangle submitted LAST does not overwrite the near one); a TAMPER pushbuffer with NO SET_OBJECT renders NOTHING (dispatch gated on class-bind, faithful to the FIFO spec); the produced frame exports to BMP. HONEST SCOPE: spec-faithful FIFO decode + class-bind LOGIC; method offsets for the graphics class are representative; real silicon exec = the bare-metal PCIe/doorbell last mile (BM-GPU-6/7). No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_fb.nx nx_gate_verdict.nx nx_gpu_graphics_gate.nx

imports: nx_fb.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

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

main gg_puts build_scene gg_emit1 gg_wr32 gg_emit_tri gg_emit1 ↻ gpfifo_run_graphics gg_rd32 gg_clear gg_rast gg_edge gg_clamp gg_min3 gg_max3 count_scene fb_bmp_save sys_mmap fb_p32 fb_p16 sys_openat_wr sys_write sys_close sys_openat_wr ↻ gg_num gv_ctr sys_mmap ↻ gv_verdict gv_puts sys_write ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻

structs

none

consts

18const GRAPHICS_CLASS: i64 = 0xC397 // representative Ampere 3D class id

functions

20func gg_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
21func gg_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main
22func gg_rd32(b: *u8, o: i64) -> i64 { return (b[o] as i64)|((b[o+1] as i64)<<8)|((b[o+2] as i64)<<16)|((b[o+3] as i64)<<24) }
called by 1: gpfifo_run_graphics
23func gg_wr32(b: *u8, o: i64, v: i64) -> i64 { b[o]=(v&0xff) as u8; b[o+1]=((v>>8)&0xff) as u8; b[o+2]=((v>>16)&0xff) as u8; b[o+3]=((v>>24)&0xff) as u8; return 0 }
called by 1: gg_emit1
24func gg_edge(ax: i64, ay: i64, bx: i64, by: i64, px: i64, py: i64) -> i64 { return (bx-ax)*(py-ay) - (by-ay)*(px-ax) }
called by 1: gg_rast
25func gg_min3(a: i64, b: i64, c: i64) -> i64 { var m: i64=a; if b<m {m=b} if c<m {m=c} return m }
called by 1: gg_rast
26func gg_max3(a: i64, b: i64, c: i64) -> i64 { var m: i64=a; if b>m {m=b} if c>m {m=c} return m }
called by 1: gg_rast
27func gg_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v }
called by 1: gg_rast
30func gg_rast(gmem: *u8, zbuf: *i64, gs: *i64) -> i64
53func gg_clear(gmem: *u8, zbuf: *i64, gs: *i64, color: i64) -> i64
called by 1: gpfifo_run_graphics
61func gpfifo_run_graphics(gmem: *u8, pb_off: i64, pb_dwords: i64, gs: *i64, zbuf: *i64) -> i64
called by 1: main calls 3: gg_rd32gg_cleargg_rast
84func gg_emit1(gmem: *u8, off: i64, method: i64, data: i64) -> i64 { gg_wr32(gmem, off, (1<<29)|(1<<16)|((method>>2)&0xfff)); gg_wr32(gmem, off+4, data); return off+8 }
called by 2: gg_emit_tribuild_scene calls 1: gg_wr32
85func gg_emit_tri(gmem: *u8, off: i64, x0: i64, y0: i64, x1: i64, y1: i64, x2: i64, y2: i64, z: i64, c: *i64) -> i64
called by 1: build_scene calls 1: gg_emit1
94func build_scene(gmem: *u8, pb_off: i64, fb_va: i64, W: i64, H: i64, with_obj: i64) -> i64
called by 1: main calls 2: gg_emit1gg_emit_tri
108func count_scene(gmem: *u8, fb_va: i64, W: i64, H: i64, zbuf: *i64) -> i64
called by 1: main
112func main() -> i64