upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/embedded_shaders.md
diff options
context:
space:
mode:
authorAlex Collini <pipodi93@gmail.com>2026-11-23 04:54:39 +0100
committerAlex Collini <pipodi93@gmail.com>2026-11-23 04:54:39 +0100
commitbaefe6d6433a22af808397a30a57df6837cbd488 (patch)
tree3d3222e60e825cffac1068ea06ca23ca538ac1c2 /docs/embedded_shaders.md
parenta3f28baa348448d94bcdb077079ca158546858bf (diff)
parent2d3369a4c82e6f36c5190c4c534d3df600e135ec (diff)
Merge main 2d3369a4 into #4113
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/embedded_shaders.md')
-rw-r--r--docs/embedded_shaders.md43
1 files changed, 42 insertions, 1 deletions
diff --git a/docs/embedded_shaders.md b/docs/embedded_shaders.md
index 4d9b2fb81..a7cd949b0 100644
--- a/docs/embedded_shaders.md
+++ b/docs/embedded_shaders.md
@@ -89,6 +89,13 @@ order of section 3; `CopyAndCompactBVH` is #52, not the first):
89| #30-#46 | `RearrangeTriangles`, `RearrangeBVHs`, `LoadInstances`, `SplitInstances`, `LoadTriangles`, `LoadProceduralGeometry`, `ReloadTriangles`, `ReloadProcedurals`, `PT_ConstructBVH4`, `ConstructBVH4`, `RefitBVH4`, `BuildBVHSplits`, `BuildBVHSplits64`, `FindTreelets`, `ResetKDOP`, `BuildKDOP`, `BuildApexPointMap` | 89| #30-#46 | `RearrangeTriangles`, `RearrangeBVHs`, `LoadInstances`, `SplitInstances`, `LoadTriangles`, `LoadProceduralGeometry`, `ReloadTriangles`, `ReloadProcedurals`, `PT_ConstructBVH4`, `ConstructBVH4`, `RefitBVH4`, `BuildBVHSplits`, `BuildBVHSplits64`, `FindTreelets`, `ResetKDOP`, `BuildKDOP`, `BuildApexPointMap` |
90| #47-#53 | `GetBVHCompactedSize`, `DecompressHeader`, `LeafRehydration`, `Box16Rehydration`, `Box32Rehydration`, `CopyAndCompactBVH`, `GetBVHCompactedSize` (again) | 90| #47-#53 | `GetBVHCompactedSize`, `DecompressHeader`, `LeafRehydration`, `Box16Rehydration`, `Box32Rehydration`, `CopyAndCompactBVH`, `GetBVHCompactedSize` (again) |
91 91
92The test also prints each creation's container with its `ILDN` module name and the first bytes of its digest
93(RT-182): creations 1 to 51 are 51 distinct containers, `GetBVHCompactedSize` (5,284 bytes, 0x14a4) among them at 47;
94creation 52 is `CopyAndCompactBVH` (4,404 bytes, 0x1134); creation 53 is `GetBVHCompactedSize` again, with the
95same digest and size. So the 0x14a4-byte container `FUN_18001d400` passes is the `GetBVHCompactedSize` module, and
96the PSO for it is created twice (under one name, `XDXR GetBVHCompactedSize`, per the SetName record above). Measured on 1.0.2.1 with an RTX 5080 (driver
97621.01): all 53 creations return `S_OK`.
98
92## 3. The 52 modules 99## 3. The 52 modules
93 100
94The `ILDN` PDB path gives one module per container, all under 101The `ILDN` PDB path gives one module per container, all under
@@ -127,7 +134,7 @@ When this page was first written, 42 translated and 10 stopped at four rules. Th
127| `PT_LoadInstances` | `global_atomic_fmin` | translates | 134| `PT_LoadInstances` | `global_atomic_fmin` | translates |
128| `Box32Rehydration`, `ReloadTriangles` | `buffer_load_ushort` | translate | 135| `Box32Rehydration`, `ReloadTriangles` | `buffer_load_ushort` | translate |
129| `LeafRehydration` | `tbuffer_load_format_x GFX10_FORMAT_8_UINT` | translates | 136| `LeafRehydration` | `tbuffer_load_format_x GFX10_FORMAT_8_UINT` | translates |
130| `Box16Rehydration` | `buffer_load_ushort` | stops at `buffer_store_short` (#1864, open) | 137| `Box16Rehydration` | `buffer_load_ushort` | stops at `buffer_store_short` (#1864) |
131 138
132The disassembly count is unchanged: the same 42 programs have no invalid word, and 10 have invalid words in the 139The disassembly count is unchanged: the same 42 programs have no invalid word, and 10 have invalid words in the
133code. All 10 of those translate; `Box16Rehydration` is one of the 42 clean ones. 140code. All 10 of those translate; `Box16Rehydration` is one of the 42 clean ones.
@@ -182,9 +189,43 @@ python -I tools/rdna2spirv.py <work>/embedded/dxbc/disasm --out <work>/embedded/
182 output. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order 189 output. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order
183 above comes from `ILDN`, not from a runtime trace. The `STAT` metadata-only shape is consistent with reflection, 190 above comes from `ILDN`, not from a runtime trace. The `STAT` metadata-only shape is consistent with reflection,
184 but whether the builder consumes it has not been measured. 191 but whether the builder consumes it has not been measured.
192* **They run on a GPU (TEST-594).** `tools/bvh_gpu_smoke.py` translates them from the package and runs each through
193 `vk_compute_test`. Each program reads its root arguments from a table at `s[0:1]`, the heap base there, which the
194 tool seeds with `VKC_HEAP_INIT`: every table word points past the table into zeros. **All 49 that aren't
195 rehydration programs pass**: exit 0, no Khronos validation error, and the same heap bytes on a second run (AMD
196 Radeon RX 9070, Windows 11, `--max-shared-memory 32768`, package 1.0.2.1). With these inputs only seven change any
197 heap word (`InitHeaders`, `InitPartitionedHeaders`, `LoadInstances`, `LoadProceduralGeometry`, `LoadTriangles`,
198 `PT_BeginPass`, `PT_WriteInstances`); the others leave early. So this alone shows that the translated programs
199 run cleanly, not that their output is right. **Six are checked byte for byte** (`--checked`), the ones whose effect
200 reads straight off their code. `RadixReset`, `ResetKDOP`, `ResetToIndexBuffer`, `CopyCounters` and
201 `ResetCounterValues` get their root-table fields (an output address, a count of 20, a value or a source), and the
202 tool compares all 20 entries they write and the bytes after them, which must stay untouched. `PrefixSum64` scans 64
203 words in place into their exclusive prefix sum through five `ds_swizzle_b32` broadcast steps and stores the group's
204 total; the input wraps past 2^32. All six match exactly. Negative controls: with the translator made to skip
205 `v_add_nc_u32`, `ResetToIndexBuffer` fails (entries hold `base+4i` and zeros); with it skipping `ds_swizzle_b32`,
206 `PrefixSum64` fails from element 2 on. So the check sees a wrong translation. Two things found on the way:
207 * the wave64 bitonic sorts (`BitonicPreSort64CS`, `BitonicInnerSort64CS`) declare 32,780 bytes of workgroup memory
208 with the translator's default cap, 12 over the 32 KiB AMD's Windows driver allows
209 (`VUID-RuntimeSpirv-Workgroup-06530`). Their highest LDS offset is 8192, and `--max-shared-memory 32768` shrinks
210 the array to what they use;
211 * with every table word 0 instead, the descriptors point at the table itself, and `RadixCount` then writes into the
212 table that other waves are reading, so its output differs between runs. That is the test input, not the
213 translator; the tool's default avoids it.
214* **What is still open.** The other programs' outputs (the sorts, prefix sums, builders, refit and loaders) are not
215 checked against a reference yet; the rehydration trio has one in TEST-376 (`tools/bvh_rehydrate.py`); `LeafRehydration` does not finish within 60 s with either table described
216 above. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order
217 above comes from `ILDN`, not from a runtime trace. The `STAT` bitcode and the `0x07 NOBC` record are not
218 explained.
185 219
186## 6. Tool and tests 220## 6. Tool and tests
187 221
222`tools/bvh_gpu_smoke.py --game-dir <package> [--max-shared-memory N] [--checked] [--json report.json]` reproduces the
223GPU run above: the extraction and translation of §4, then two dispatches per program, and with `--checked` the six
224byte-exact cases. Its report holds module names, statuses
225and counts only. `tests/test_bvh_gpu_smoke.py` checks the heap image, the word count and the judging of runs with a
226fake `vk_compute_test`, and the checked cases' inputs and judging (a fake that does what each case describes passes,
227one wrong byte fails), without a GPU or game files.
228
188`tools/pe_shader_containers.py` is standard library only and reads the file, never runs it. It accepts a 229`tools/pe_shader_containers.py` is standard library only and reads the file, never runs it. It accepts a
189container only when the chunk table is sorted, 4-byte aligned, entirely inside the declared total and its last 230container only when the chunk table is sorted, 4-byte aligned, entirely inside the declared total and its last
190chunk ends exactly at that total; that is what rejects the FSR DLL's `DXBC` immediate. The synthetic tests in 231chunk ends exactly at that total; that is what rejects the FSR DLL's `DXBC` immediate. The synthetic tests in