nx_dxbc.nx
buildroot/runtime/nx_dxbc.nx
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
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
| 11 | const K_MAGIC_100000: i64 = 100000 |
| 12 | const K_MAGIC_2047: i64 = 2047 |
functions
| 14 | func dx_u32(b: *u8, o: i64) -> i64 |
| 17 | func dx_fourcc(a: i64, b: i64, c: i64, d: i64) -> i64 { return a | (b<<8) | (c<<16) | (d<<24) } |
| 20 | func dxbc_is(b: *u8, n: i64) -> i64 |
| 28 | func dxbc_total_size(b: *u8) -> i64 { return dx_u32(b, 24) } |
| 29 | func dxbc_chunk_count(b: *u8) -> i64 { return dx_u32(b, 28) } |
| 31 | func dxbc_chunk_off(b: *u8, i: i64) -> i64 { return dx_u32(b, 32 + i*4) } |
| 32 | func dxbc_chunk_tag(b: *u8, off: i64) -> i64 { return dx_u32(b, off) } |
| 33 | func dxbc_chunk_size(b: *u8, off: i64) -> i64 { return dx_u32(b, off + 4) } calls 1: dx_u32 |
| 36 | func dxbc_find(b: *u8, n: i64, tag: i64) -> i64 |
| 50 | func dxbc_program_type(ver: i64) -> i64 { return (ver >> 16) & 15 } |
| 55 | func dxbc_decode_shader(b: *u8, payoff: i64, n: i64, cnt: *i64) -> i64 |