nx_raster_sw.nx
buildroot/runtime/nx_raster_sw.nx
about
nx_raster_sw.nx -- bits-up integer software triangle rasterizer.
LINEAGE (per [[feedback-no-tool-proliferation-consolidate-or-justify]]
cardinal landed 2026-05-20):
Distinct from [[nx_raster.nx]] because: nx_raster.nx ships Bresenham
lines + Pineda triangles + barycentric-shaded triangles on the
*Image abstraction; this file ships Pineda strict-interior coverage
on the *i64 framebuffer directly, AND exposes the edge function +
signed-area helpers as public APIs for downstream composition.
Distinct from [[nx_raster_triangle.nx]] because: nx_raster_triangle.nx
adds a Z-buffer for 3D occlusion; this file is the 2D strict-interior
coverage path used by the perceptual-render demos that don't need
depth. The two compose: nx_raster_triangle.nx CALLS the edge
function exported here in its Pineda inner loop.
HONEST PROLIFERATION NOTE: the substrate has three rasterizer
primitives by 2026-05-20. Future raster work MUST extend one of
these three, not ship a fourth. When the substrate hits 4
rasterizers, consolidate per the cardinal.
G1 first stone of NISHI_GRAPHICS_ROADMAP.md. Pineda 1988 edge-
function method, absorbed clean-room from the ACM SIGGRAPH paper.
Pure integer i64 math; no libm; no float; no SIMD; no GPU.
Composes:
[[NISHI_GRAPHICS_ROADMAP]] G1
existing nx_framebuffer.nx (this rasterizer uses nx_fb_set as
its pixel write primitive; preserves additively per Cardinal 13)
[[feedback-bits-up-exceed-never-match]] (no Cairo, no Skia, no
Mesa, no AGG; integer-only Pineda)
[[feedback-no-false-ok-substrate-honesty-audit]] (degenerate +
CW triangles return 0 pixels deterministically; KAT verifies
known triangle -> known pixel count)
API:
nx_raster_signed_area_2x(x0,y0,x1,y1,x2,y2) -> i64
Returns twice the signed area. Positive => front-facing (drawable).
Zero => degenerate (collinear). Negative => back-facing (culled).
dependencies 2 imports · 3 importers
imports: nx_syscalls.nxnx_framebuffer.nx
imported by: nx_graphics_demo_test.nxnx_perceptual_render_test.nxnx_raster_sw_test.nx
structs
| none |
consts
| none |
functions
| 92 | func nx_raster_edge( |
| 103 | func nx_raster_signed_area_2x( |
| 113 | func nx_raster_min3(a: i64, b: i64, c: i64) -> i64 called by 1: nx_raster_triangle |
| 120 | func nx_raster_max3(a: i64, b: i64, c: i64) -> i64 called by 1: nx_raster_triangle |
| 127 | func nx_raster_clamp(v: i64, lo: i64, hi: i64) -> i64 called by 1: nx_raster_triangle |
| 138 | func nx_raster_triangle( |