code wiki / (root) / nx_dxbc.nx

nx_dxbc.nx

buildroot/runtime/nx_dxbc.nx

4621 B86 linesdepth 2pulls 2 transitivereach 6 importersview sourcekind librarytopic dxbc
docsdependenciesstructsconstsfunctions

about

nx_dxbc.nx -- D1 of the D3D-game ladder: a real DXBC (DirectX ByteCode) container + shader-token DECODER. A Windows D3D9-11 game ships COMPILED shaders as DXBC blobs; running them starts with PARSING them. This decodes: CONTAINER: "DXBC" magic, 16B checksum, u32 1, u32 total_size, u32 chunk_count, u32[chunk_count] offsets, then chunks each = FourCC tag + u32 byte-size + payload. (little-endian, the real on-disk layout.) SHADER CHUNK (SHEX/SHDR): u32 version (program-type in high nibble: 0=pixel 1=vertex ...) + u32 dword-length, then a stream of instruction tokens: token = [opcode 0:10][length 24:30]; length = dwords incl the token, so the next instruction is at +length. We classify the opcode (dcl_*, mov, add, mul, mad, dp3/dp4, sample, ret) and count instructions -- the basis D2 lowers to our ISA / SPIR-V. Pure integer, bounds-checked (defensive at the boundary: this is untrusted external input). license_tier: ORIGINAL

dependencies 1 imports · 6 importers

nx_syscalls.nx nx_dxbc.nx nishi_export_lib.nx nx_d3d_shade_gate.nx nx_dxbc_exec.nx nx_dxbc_exec_gate.nx nx_dxbc_gate.nx nx_dxbc_real_gate.nx

imports: nx_syscalls.nx

imported by: nishi_export_lib.nxnx_d3d_shade_gate.nxnx_dxbc_exec.nxnx_dxbc_exec_gate.nxnx_dxbc_gate.nxnx_dxbc_real_gate.nx

structs

none

consts

11const K_MAGIC_100000: i64 = 100000
12const K_MAGIC_2047: i64 = 2047

functions

14func dx_u32(b: *u8, o: i64) -> i64
17func dx_fourcc(a: i64, b: i64, c: i64, d: i64) -> i64 { return a | (b<<8) | (c<<16) | (d<<24) }
20func dxbc_is(b: *u8, n: i64) -> i64
called by 2: mainmain
28func dxbc_total_size(b: *u8) -> i64 { return dx_u32(b, 24) }
called by 3: nx_ctx_drawmainmain calls 1: dx_u32
29func dxbc_chunk_count(b: *u8) -> i64 { return dx_u32(b, 28) }
called by 3: dxbc_findmainmain calls 1: dx_u32
31func dxbc_chunk_off(b: *u8, i: i64) -> i64 { return dx_u32(b, 32 + i*4) }
called by 1: dxbc_find calls 1: dx_u32
32func dxbc_chunk_tag(b: *u8, off: i64) -> i64 { return dx_u32(b, off) }
called by 1: dxbc_find calls 1: dx_u32
33func dxbc_chunk_size(b: *u8, off: i64) -> i64 { return dx_u32(b, off + 4) }
calls 1: dx_u32
36func dxbc_find(b: *u8, n: i64, tag: i64) -> i64
50func dxbc_program_type(ver: i64) -> i64 { return (ver >> 16) & 15 }
called by 3: mainmainmain
55func dxbc_decode_shader(b: *u8, payoff: i64, n: i64, cnt: *i64) -> i64
called by 2: mainmain calls 1: dx_u32