code wiki / (root) / nx_framebuffer.nx

nx_framebuffer.nx

buildroot/runtime/nx_framebuffer.nx

8453 B213 linesdepth 2pulls 2 transitivereach 7 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_framebuffer.nx -- u32 pixel buffer + z-buffer foundation. Per gap roadmap Phase 1: substrate needs a framebuffer for the software rasterizer to write into. This primitive provides: - u32 packed-RGBA framebuffer (w x h i64 cells) - Q14 depth buffer (parallel array) - Clear / set-pixel / set-depth primitives - Tile-clear for chunked updates PIXEL FORMAT: 0xRRGGBBAA packed in low 32 bits of i64. DEPTH FORMAT: Q14 metres signed. Initial depth = MAX (far plane). Caller allocates the buffer; primitive just provides accessors. To compose with the canvas blit, the JS shim reads the buffer's low 32 bits and writes RGBA8. PUBLIC APIs: nx_fb_alloc(w, h) -> *i64 framebuffer (w * h cells) nx_fb_depth_alloc(w, h) -> *i64 depth buffer nx_fb_clear(fb, w, h, color) fill with solid color nx_fb_clear_depth(zb, w, h) reset depth to far plane nx_fb_set(fb, w, h, x, y, color) nx_fb_get(fb, w, h, x, y) -> i64 nx_fb_depth_test_set(fb, zb, w, h, x, y, z, color) -> 0/1 Returns 1 if pixel written (z < existing); 0 otherwise. nx_fb_pack_rgba(r, g, b, a) -> i64 packed color helper genealogy_id: software_rasterizer_canon + frame_buffer_canon lineage_id: nx_framebuffer_q14_v1

dependencies 2 imports · 5 importers

nx_syscalls.nx nx_tier.nx nx_framebuffer.nx nx_graphics_demo_test.nx nx_perceptual_render_test.nx nx_raster_sw.nx nx_raster_sw_test.nx nx_swapchain.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_graphics_demo_test.nxnx_perceptual_render_test.nxnx_raster_sw.nxnx_raster_sw_test.nxnx_swapchain.nx

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

main nx_fb_alloc sys_mmap nx_fb_depth_alloc sys_mmap ↻ nx_fb_pack_rgba nx_fb_clear nx_fb_get nx_fb_set nx_fb_unpack_r nx_fb_unpack_g nx_fb_unpack_b nx_fb_unpack_a nx_fb_clear_depth nx_fb_depth_test_set

structs

none

consts

39const NX_MAGIC_65536: i64 = 65536
40const NX_MAGIC_16777216: i64 = 16777216
42const NX_FB_Q: nx_int = 16384
46const NX_FB_FAR_DEPTH_Q14: nx_int = 16384000000

functions

50func nx_fb_alloc(w: nx_int, h: nx_int) -> *i64
called by 4: mainmainmainmain calls 1: sys_mmap
57func nx_fb_depth_alloc(w: nx_int, h: nx_int) -> *i64
called by 1: main calls 1: sys_mmap
65func nx_fb_clear(fb: *i64, w: nx_int, h: nx_int, color: nx_int)
71func nx_fb_clear_depth(zb: *i64, w: nx_int, h: nx_int)
called by 1: main
85func nx_fb_set(
95func nx_fb_get(
called by 3: mainmainmain
107func nx_fb_depth_test_set(
called by 1: main
129func nx_fb_pack_rgba(r: nx_int, g: nx_int, b: nx_int, a: nx_int) -> nx_int
called by 3: mainmainmain
146func nx_fb_unpack_r(color: nx_int) -> nx_int { return color % 256 }
called by 1: main
147func nx_fb_unpack_g(color: nx_int) -> nx_int { return (color / 256) % 256 }
called by 1: main
148func nx_fb_unpack_b(color: nx_int) -> nx_int { return (color / NX_MAGIC_65536) % 256 }
called by 1: main
149func nx_fb_unpack_a(color: nx_int) -> nx_int { return (color / NX_MAGIC_16777216) % 256 }
called by 1: main
152func main() -> i64