nx_raster.nx
buildroot/runtime/nx_raster.nx
about
nx_raster.nx -- SOVEREIGN INTEGER-DETERMINISTIC RASTERIZER (the render-pipeline seed; the better-than-DirectX core).
An edge-function triangle rasterizer over an INTEGER packed-RGB framebuffer. 100% integer -> BIT-EXACT, the SAME
framebuffer on ANY CPU (native x86 on this laptop, RISC-V, no-FPU MCU) with NO GPU/driver/API. DirectX/Vulkan/
Metal are float + GPU-driver-bound -> frames differ across hardware (non-deterministic); we are reproducible.
T1 raster a triangle -> filled pixels > 0. T2 an inside pixel is filled, an outside corner is not.
T3 (EXCEED) determinism -- two rasterizations give a BIT-IDENTICAL framebuffer checksum. T4 bounds (no OOB).
expect_exit: 0 Sovereign: nx_syscalls. NEVER-BRICK: software raster, writes 0 GPU firmware.
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_zbuf.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 9 | const K_MAGIC_5381: i64 = 5381 |
| 15 | const W: i64 = 32 |
| 16 | const H: i64 = 32 |
functions
| 11 | func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 12 | func g_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 } |
| 13 | func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c } |
| 17 | func fb_clear(fb: *i64) -> i64 { var i: i64=0; while i<W*H { fb[i]=0; i=i+1 } return 0 } called by 1: main |
| 18 | func 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: draw_tri |
| 19 | func draw_tri(fb: *i64, x0: i64, y0: i64, x1: i64, y1: i64, x2: i64, y2: i64, color: i64) -> i64 |
| 33 | func fb_get(fb: *i64, x: i64, y: i64) -> i64 { return fb[y*W+x] } called by 1: main |
| 34 | func fb_filled(fb: *i64) -> i64 { var c: i64=0; var i: i64=0; while i<W*H { if fb[i]!=0 { c=c+1 } i=i+1 } return c } called by 1: main |
| 35 | func fb_checksum(fb: *i64) -> i64 { var h: i64=K_MAGIC_5381; var i: i64=0; while i<W*H { h=((h<<5)+h)+fb[i]; i=i+1 } return h } called by 1: main |
| 37 | func main() -> i64 |