nx_framebuffer.nx
buildroot/runtime/nx_framebuffer.nx
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
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
structs
| none |
consts
| 39 | const NX_MAGIC_65536: i64 = 65536 |
| 40 | const NX_MAGIC_16777216: i64 = 16777216 |
| 42 | const NX_FB_Q: nx_int = 16384 |
| 46 | const NX_FB_FAR_DEPTH_Q14: nx_int = 16384000000 |
functions
| 50 | func nx_fb_alloc(w: nx_int, h: nx_int) -> *i64 |
| 57 | func nx_fb_depth_alloc(w: nx_int, h: nx_int) -> *i64 |
| 65 | func nx_fb_clear(fb: *i64, w: nx_int, h: nx_int, color: nx_int) |
| 71 | func nx_fb_clear_depth(zb: *i64, w: nx_int, h: nx_int) called by 1: main |
| 85 | func nx_fb_set( |
| 95 | func nx_fb_get( |
| 107 | func nx_fb_depth_test_set( called by 1: main |
| 129 | func nx_fb_pack_rgba(r: nx_int, g: nx_int, b: nx_int, a: nx_int) -> nx_int |
| 146 | func nx_fb_unpack_r(color: nx_int) -> nx_int { return color % 256 } called by 1: main |
| 147 | func nx_fb_unpack_g(color: nx_int) -> nx_int { return (color / 256) % 256 } called by 1: main |
| 148 | func nx_fb_unpack_b(color: nx_int) -> nx_int { return (color / NX_MAGIC_65536) % 256 } called by 1: main |
| 149 | func nx_fb_unpack_a(color: nx_int) -> nx_int { return (color / NX_MAGIC_16777216) % 256 } called by 1: main |
| 152 | func main() -> i64 |