code wiki / (root) / nx_tex_sample.nx

nx_tex_sample.nx

buildroot/runtime/nx_tex_sample.nx

9492 B269 linesdepth 5pulls 8 transitivereach 7 importersview sourcekind tooltopic tex
docsdependenciesstructsconstsfunctions

about

nx_tex_sample.nx -- UV texture sampling on Image (graphics). Distinct from nx_texture.nx (Haralick GLCM + LBP texture ANALYSIS for image classification). This file is texture SAMPLING for rendering -- the GLSL texture2D / HLSL Sample / Metal texture-access primitive. Completes the graphics minimum stack (nx_raster + nx_zbuf + this). Pure i64 substrate -- no FPU, no GPU. Substrate can now sample textures with bilinear filtering + wrap modes on any backend including Cortex-M3 with a framebuffer. L3 composition (bits-up): nx_image.Image (canonical pixel container, L1) nx_loop.LoopVerdict (bounded loops) ===== UV convention ============================================= (u, v) in Q10 fixed-point representing [0, 1) UV space. u_q10 = 0 -> left edge of texture u_q10 = 1024 -> right edge (exclusive) v_q10 = 0 -> top edge of texture v_q10 = 1024 -> bottom edge (exclusive) Q10 over Q14: bilinear weights need sub-pixel accuracy that 8-bit can't give; Q14 is too tight for clean integer multiplication; Q10 = sweet spot for the substrate's existing arithmetic. ===== Wrap modes (sealed enum) ================================== NX_TEX_WRAP_CLAMP -- saturate to [0, W-1] / [0, H-1] NX_TEX_WRAP_REPEAT -- modulo W / H (tile) NX_TEX_WRAP_MIRROR -- ping-pong: every other tile is flipped ===== Filter modes ============================================== NX_TEX_FILTER_NEAREST -- single texel lookup; fast, blocky NX_TEX_FILTER_BILINEAR -- 4-tap weighted average; smooth genealogy_id: catmull_smith_1980_texture_mapping +

dependencies 4 imports · 3 importers

nx_syscalls.nx nx_tier.nx nx_loop.nx nx_image.nx nx_tex_sample.nx nx_render_pass.nx nx_tex_sample_gate.nx nx_textured_tri.nx

imports: nx_syscalls.nxnx_tier.nxnx_loop.nxnx_image.nx

imported by: nx_render_pass.nxnx_tex_sample_gate.nxnx_textured_tri.nx

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

main nx_image_alloc sys_mmap nx_image_set nx_txs_sample_nearest _txs_wrap_coord nx_image_get nx_txs_sample_bilinear _txs_wrap_coord ↻ nx_image_get ↻ nx_txs_verdict_is_valid nx_txs_wrap_is_valid nx_txs_filter_is_valid

structs

none

consts

58const NX_TXS_Q10: nx_int = 1024
62const NX_TXS_WRAP_CLAMP: nx_int = 0
63const NX_TXS_WRAP_REPEAT: nx_int = 1
64const NX_TXS_WRAP_MIRROR: nx_int = 2
65const NX_TXS_WRAP_N: nx_int = 3
75const NX_TXS_FILTER_NEAREST: nx_int = 0
76const NX_TXS_FILTER_BILINEAR: nx_int = 1
77const NX_TXS_FILTER_N: nx_int = 2
87const NX_TXS_OK: nx_int = 0
88const NX_TXS_ERR_BAD_TEXTURE: nx_int = 1
89const NX_TXS_ERR_BAD_KIND: nx_int = 2
90const NX_TXS_N_VERDICTS: nx_int = 3

functions

67func nx_txs_wrap_is_valid(k: nx_int) -> nx_int
called by 1: main
79func nx_txs_filter_is_valid(k: nx_int) -> nx_int
called by 1: main
92func nx_txs_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
100func _txs_wrap_coord(x: nx_int, dim: nx_int, mode: nx_int) -> nx_int
124func nx_txs_sample_nearest(tex: *Image, u_q10: nx_int, v_q10: nx_int,
141func nx_txs_sample_bilinear(tex: *Image, u_q10: nx_int, v_q10: nx_int,
180func nx_txs_sample(tex: *Image, u_q10: nx_int, v_q10: nx_int,
198func main() -> i64