nx_nishios_raster.nx
buildroot/runtime/nx_nishios_raster.nx
about
nx_nishios_raster.nx -- GOAL-GPU-NATIVE rung-1: a sovereign SOFTWARE RASTERIZER (seed of the 3D stack).
First concrete rung toward native gaming (No Man's Sky-class, the north star): real triangles drawn
into the nx_fb framebuffer via EDGE FUNCTIONS (per-pixel inside test), BARYCENTRIC GOURAUD shading
(per-vertex colour interpolation), and a Z-BUFFER (per-pixel depth). The z-buffer is what makes it
3D, not 2D: a NEAR triangle must occlude a FAR one regardless of DRAW ORDER. Scene: a far gradient
triangle, a near solid-yellow triangle over it, then a far cyan triangle drawn LAST over the near one
-- the depth test must REJECT the late far triangle so the near yellow survives.
KAT: triangles rasterize (substantial coverage, corner is background); Z-BUFFER correct (every pixel
the near triangle owns stays near-yellow even though a far triangle was drawn over it afterward);
Gouraud shading produces real colour variation; BMP exported. All integer math, fully sovereign.
HONEST SCOPE: flat per-triangle depth + 2D screen-space tris (the raster core); 3D transform/clip/
perspective + a sovereign GPU to run it fast = the rungs above, toward measured-vs-DirectX.
No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_fb.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 15 | const K_MAGIC_1500: i64 = 1500 |
functions
| 17 | func rs_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 |
| 18 | func rs_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 |
| 19 | func rs_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: raster_tri |
| 20 | func rs_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: raster_tri |
| 21 | func rs_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: raster_tri |
| 22 | func rs_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } called by 1: raster_tri |
| 25 | func raster_tri(fb: *u8, zbuf: *i64, W: i64, H: i64, v: *i64, z: i64, col: *i64) -> i64 |
| 59 | func main() -> i64 |