003e7812 loads EXEC before OpSelectionMerge in global_atomic and global_atomic_x2,
so FindTreelets assembles and validates. The 10 left are still the four rules.
7.7 KiB
Shader containers embedded in the package's DLLs
Status: measured on the 1.0.2.1 package. This note covers the shader programs that ship outside
shaders.rpf: the DXBC containers inside the package's DLLs, what each one carries, and what the measurement
changes for the ray-tracing and upscaling paths. No container, shader or payload is reproduced here; the tables
hold counts, offsets, chunk names and module identifiers.
1. Why they matter
make_game.py's shaders stage carves shaders.rpf only (make_game.py:655). Two DLLs in the same package
carry compute programs of their own:
XboxBvhBuilder.dll, Microsoft's XDXR acceleration-structure builder. Its constructor creates compute PSOs through device slot 62, and the builder is on the critical path for ray tracing.amd_fidelityfx_upscaler_xbox.dll, the FidelityFX 4.1.1 upscaler. Its programs are theACCC/FSPXformat covered in fspx.md; this note only counts them.
tools/pe_shader_containers.py scans a binary for DXBC containers, validates the chunk table, reads the ILDN
module name and reports what each container carries. --extract writes the containers and an index.json the
translator reads; extracted shaders are game data and must stay in the user's work folder.
python -I tools/pe_shader_containers.py <dll> --json <work>/containers.json --extract <work>/embedded/dxbc
2. Inventory
The 16 DLLs and the package's root files were scanned. All the containers are in two DLLs:
| image | containers | bytes | min / median / max | chunks |
|---|---|---|---|---|
XboxBvhBuilder.dll |
52 | 674,404 | 4,072 / 7,454 / 74,508 | SFI0 ISG1 OSG1 PSV0 RTS0 STAT ILDN HASH DXIL |
amd_fidelityfx_upscaler_xbox.dll |
29 | 289,656 | 1,764 / 5,176 / 42,616 | SFI0 ISG1 OSG1 PSV0 RTS0 HASH ACCC |
| other 14 DLLs | 0 | 0 | — | — |
The 29 ACCC containers hold FSPX payloads (fspx.md); the 52 DXIL containers are the subject of
this note. The FSR DLL has one rejected DXBC hit: the bytes are an immediate in its own magic check, and the
validator rejects it (the scan reports both counts).
Every one of the 52 containers carries two representations of its program:
- an LLVM bitcode blob in the
DXILchunk (BC C0 DE, 1,820 to 70,276 bytes), and - an
XDATdirectory with tag0x0dwhose payload starts withXBCH: the console program. The same chunk also holds tag0x07(a secondDXILprogram header) and tag0x12(a 16-byte hash). TheSTATchunk holds a second, different bitcode blob, not the same one.
The bitcode is what a PC D3D12 compiler consumes; the runtime path is the XBCH record. The constructor passes
the whole container to the compute-PSO call: at 0x180021330 it loads DAT_180025700 with size 0x1134
(4,404 bytes, the size of container 0, CopyAndCompactBVH) and calls FUN_18000c470, whose vtable call at
+0x1f0 (slot 62) receives that pointer, its size and two zero words. FUN_18001d400 adds two more PSOs,
XDXR PostBuildInfoQuery (0x14a4 bytes) and XDXR GetBVHCompactedSize. bvh_builder_test measures 53 PSO
creations during construction over the 52 containers (d3d12_vulkan.md A.2), so one
container is created twice; which one is Open.
3. The 52 modules
The ILDN PDB path gives one module per container, all under
X:\americas\src\dev\rage\3rdparty\Microsoft\XboxBvhBuilder\Build\Release\Output\XboxBvhBuilder\ (Microsoft's
component integrated into RAGE, not Rockstar shader code). Grouped by phase:
| phase | modules |
|---|---|
| sort (11) | BitonicPreSortCS, BitonicPreSort64CS, BitonicInnerSortCS, BitonicInnerSort64CS, BitonicOuterSortCS, BitonicOuterSort64CS, RadixCount, RadixAlloc, RadixReset, CalculateMortonCodes, CalculateMortonCodes64 |
| prefix (7) | PrefixSum64, PrefixSum128, PrefixSum256, PrefixSum512, PrefixSum1024, PrefixSum2048, PrefixSum4096 |
| kdop (3) | BuildKDOP, ResetKDOP, BuildApexPointMap |
| build (7) | ConstructBVH4, BuildBVHSplits, BuildBVHSplits64, SplitInstances, FindTreelets, RearrangeBVHs, RearrangeTriangles |
| refit (2) | RefitBVH4, CopyForBVHUpdate |
| load (6) | LoadTriangles, ReloadTriangles, LoadInstances, LoadProceduralGeometry, ReloadProcedurals, ResetToIndexBuffer |
| path tracing (6) | PT_ConstructBVH4, PT_BeginPass, PT_LoadInstances, PT_WriteInstances, PT_WritePartitions, PT_WriteOfflinePartition |
| rehydration (3) | Box16Rehydration, Box32Rehydration, LeafRehydration |
| headers/util (7) | DecompressHeader, InitHeaders, InitPartitionedHeaders, GetBVHCompactedSize, CopyCounters, ResetCounterValues, CopyAndCompactBVH |
4. They are console FSSM, and the existing translator already takes them
The XBCH record has the same shape as the game's own shaders: XBCH + stored/unpacked sizes + a zlib stream
that expands to FSSM (fssm_crosscheck.md). On all 52 containers:
| step | result |
|---|---|
tools/fssm_unpack.py |
52/52 decompress to a valid FSSM blob (716 B to 101,320 B, median 2,200 B) |
tools/shader_disasm.py --mcpu gfx1013 |
52/52 disassemble; 42 with no invalid word, 10 with invalid words in the code |
tools/rdna2spirv.py |
42 translate and pass spirv-val |
The 10 untranslated programs stop at four rules:
| module(s) | blocker |
|---|---|
BuildKDOP, LoadInstances, ReloadProcedurals, LoadProceduralGeometry, LoadTriangles |
global_atomic_fmax |
PT_LoadInstances |
global_atomic_fmin |
Box16Rehydration, Box32Rehydration, ReloadTriangles |
buffer_load_ushort |
LeafRehydration |
tbuffer_load_format_x GFX10_FORMAT_8_UINT |
Reproduction, after --extract above:
python -I tools/fssm_unpack.py <work>/embedded/dxbc
python -I tools/shader_disasm.py <work>/embedded/dxbc/fssm --out <work>/embedded/dxbc/disasm --mcpu gfx1013
python -I tools/rdna2spirv.py <work>/embedded/dxbc/disasm --out <work>/embedded/spirv
5. What this changes
- The RT builder does not need a DXIL path for the console code. Its programs are RDNA2
FSSM, and 41 of 52 already passspirv-valwith the translator the project uses for the game's 26,503 shaders. The bitcode in the same container is a second representation (the one the PC-compiler experiment measured); it is not what the console runtime executes. - The four missing rules are small and have real fixtures.
global_atomic_fmax/fmincover 6 programs,buffer_load_ushort3 andtbuffer_load_format_xwith format 8 one. They are ordinary translator rules, not a new compiler backend. - The rehydration programs are the ones closest to the shipped data.
Box16Rehydration,Box32RehydrationandLeafRehydrationare exactly the programs that would turn the dehydrated BVH packs into runtime trees (bvh.md §3.1). Two of the four rules stand between them and translation. - What is still open. None of the 52 has been executed on a GPU; translation and
spirv-valdo not prove the output. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order above comes fromILDN, not from a runtime trace. TheSTATbitcode and the0x07 NOBCrecord are not explained.
6. Tool and tests
tools/pe_shader_containers.py is standard library only and reads the file, never runs it. It accepts a
container only when the chunk table is sorted, 4-byte aligned, entirely inside the declared total and its last
chunk ends exactly at that total; that is what rejects the FSR DLL's DXBC immediate. The synthetic tests in
tests/test_pe_shader_containers.py build containers by hand (no game data) and cover the accepted layout, a
bare magic, a truncated chunk, an ACCC/FSPX container, the ILDN name and the extraction index.