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:
authorNolan Cotter <186326284+NolanCotter@users.noreply.github.com>2026-11-22 20:39:59 -0700
committerNolan Cotter <186326284+NolanCotter@users.noreply.github.com>2026-11-22 20:39:59 -0700
commitfa5f26db8eafd2cc27f627b68c0a5a5949bcf2ff (patch)
treefc57e238be829295fc216dff89a6d93e64c16b50 /docs/embedded_shaders.md
parent9b693ecd8a2f90799f6c47f8f06cf062feb9820c (diff)
parent7b7d73f890f9fbbf5967bbb694390bbc99e33ba6 (diff)
Merge origin/main: DXGI device fields coexist with the console-ABI device state
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 8e0766993..24f0b9971 100644
--- a/docs/embedded_shaders.md
+++ b/docs/embedded_shaders.md
@@ -82,6 +82,13 @@ order of section 3; `CopyAndCompactBVH` is #52, not the first):
82| #14-#29 | `BitonicPreSortCS`, `BitonicOuterSortCS`, `BitonicInnerSortCS`, `BitonicPreSort64CS`, `BitonicOuterSort64CS`, `BitonicInnerSort64CS`, `RadixReset`, `RadixCount`, `PrefixSum64`, `PrefixSum128`, `PrefixSum256`, `PrefixSum512`, `PrefixSum1024`, `PrefixSum2048`, `PrefixSum4096`, `RadixAlloc` | 82| #14-#29 | `BitonicPreSortCS`, `BitonicOuterSortCS`, `BitonicInnerSortCS`, `BitonicPreSort64CS`, `BitonicOuterSort64CS`, `BitonicInnerSort64CS`, `RadixReset`, `RadixCount`, `PrefixSum64`, `PrefixSum128`, `PrefixSum256`, `PrefixSum512`, `PrefixSum1024`, `PrefixSum2048`, `PrefixSum4096`, `RadixAlloc` |
83| #30-#46 | `RearrangeTriangles`, `RearrangeBVHs`, `LoadInstances`, `SplitInstances`, `LoadTriangles`, `LoadProceduralGeometry`, `ReloadTriangles`, `ReloadProcedurals`, `PT_ConstructBVH4`, `ConstructBVH4`, `RefitBVH4`, `BuildBVHSplits`, `BuildBVHSplits64`, `FindTreelets`, `ResetKDOP`, `BuildKDOP`, `BuildApexPointMap` | 83| #30-#46 | `RearrangeTriangles`, `RearrangeBVHs`, `LoadInstances`, `SplitInstances`, `LoadTriangles`, `LoadProceduralGeometry`, `ReloadTriangles`, `ReloadProcedurals`, `PT_ConstructBVH4`, `ConstructBVH4`, `RefitBVH4`, `BuildBVHSplits`, `BuildBVHSplits64`, `FindTreelets`, `ResetKDOP`, `BuildKDOP`, `BuildApexPointMap` |
84| #47-#53 | `GetBVHCompactedSize`, `DecompressHeader`, `LeafRehydration`, `Box16Rehydration`, `Box32Rehydration`, `CopyAndCompactBVH`, `GetBVHCompactedSize` (again) | 84| #47-#53 | `GetBVHCompactedSize`, `DecompressHeader`, `LeafRehydration`, `Box16Rehydration`, `Box32Rehydration`, `CopyAndCompactBVH`, `GetBVHCompactedSize` (again) |
85container is created twice: **`GetBVHCompactedSize`** (RT-182). With `LEONIDA_BVH_RECORD62=1` the test prints each
86creation's container with its `ILDN` module name and the first bytes of its digest: creations 1 to 51 are 51
87distinct containers, `GetBVHCompactedSize` (5,284 bytes, 0x14a4) among them at 47; creation 52 is
88`CopyAndCompactBVH` (4,404 bytes, 0x1134); creation 53 is `GetBVHCompactedSize` again, with the same digest and
89size. So the 0x14a4-byte container `FUN_18001d400` passes for `XDXR PostBuildInfoQuery` is the
90`GetBVHCompactedSize` module, and the PSO for it is created twice. Measured on 1.0.2.1 with an RTX 5080 (driver
91621.01): all 53 creations return `S_OK`.
85 92
86## 3. The 52 modules 93## 3. The 52 modules
87 94
@@ -121,7 +128,7 @@ When this page was first written, 42 translated and 10 stopped at four rules. Th
121| `PT_LoadInstances` | `global_atomic_fmin` | translates | 128| `PT_LoadInstances` | `global_atomic_fmin` | translates |
122| `Box32Rehydration`, `ReloadTriangles` | `buffer_load_ushort` | translate | 129| `Box32Rehydration`, `ReloadTriangles` | `buffer_load_ushort` | translate |
123| `LeafRehydration` | `tbuffer_load_format_x GFX10_FORMAT_8_UINT` | translates | 130| `LeafRehydration` | `tbuffer_load_format_x GFX10_FORMAT_8_UINT` | translates |
124| `Box16Rehydration` | `buffer_load_ushort` | stops at `buffer_store_short` (#1864, open) | 131| `Box16Rehydration` | `buffer_load_ushort` | stops at `buffer_store_short` (#1864) |
125 132
126The disassembly count is unchanged: the same 42 programs have no invalid word, and 10 have invalid words in the 133The disassembly count is unchanged: the same 42 programs have no invalid word, and 10 have invalid words in the
127code. All 10 of those translate; `Box16Rehydration` is one of the 42 clean ones. 134code. All 10 of those translate; `Box16Rehydration` is one of the 42 clean ones.
@@ -176,9 +183,43 @@ python -I tools/rdna2spirv.py <work>/embedded/dxbc/disasm --out <work>/embedded/
176 output. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order 183 output. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order
177 above comes from `ILDN`, not from a runtime trace. The `STAT` metadata-only shape is consistent with reflection, 184 above comes from `ILDN`, not from a runtime trace. The `STAT` metadata-only shape is consistent with reflection,
178 but whether the builder consumes it has not been measured. 185 but whether the builder consumes it has not been measured.
186* **They run on a GPU (TEST-594).** `tools/bvh_gpu_smoke.py` translates them from the package and runs each through
187 `vk_compute_test`. Each program reads its root arguments from a table at `s[0:1]`, the heap base there, which the
188 tool seeds with `VKC_HEAP_INIT`: every table word points past the table into zeros. **All 49 that aren't
189 rehydration programs pass**: exit 0, no Khronos validation error, and the same heap bytes on a second run (AMD
190 Radeon RX 9070, Windows 11, `--max-shared-memory 32768`, package 1.0.2.1). With these inputs only seven change any
191 heap word (`InitHeaders`, `InitPartitionedHeaders`, `LoadInstances`, `LoadProceduralGeometry`, `LoadTriangles`,
192 `PT_BeginPass`, `PT_WriteInstances`); the others leave early. So this alone shows that the translated programs
193 run cleanly, not that their output is right. **Six are checked byte for byte** (`--checked`), the ones whose effect
194 reads straight off their code. `RadixReset`, `ResetKDOP`, `ResetToIndexBuffer`, `CopyCounters` and
195 `ResetCounterValues` get their root-table fields (an output address, a count of 20, a value or a source), and the
196 tool compares all 20 entries they write and the bytes after them, which must stay untouched. `PrefixSum64` scans 64
197 words in place into their exclusive prefix sum through five `ds_swizzle_b32` broadcast steps and stores the group's
198 total; the input wraps past 2^32. All six match exactly. Negative controls: with the translator made to skip
199 `v_add_nc_u32`, `ResetToIndexBuffer` fails (entries hold `base+4i` and zeros); with it skipping `ds_swizzle_b32`,
200 `PrefixSum64` fails from element 2 on. So the check sees a wrong translation. Two things found on the way:
201 * the wave64 bitonic sorts (`BitonicPreSort64CS`, `BitonicInnerSort64CS`) declare 32,780 bytes of workgroup memory
202 with the translator's default cap, 12 over the 32 KiB AMD's Windows driver allows
203 (`VUID-RuntimeSpirv-Workgroup-06530`). Their highest LDS offset is 8192, and `--max-shared-memory 32768` shrinks
204 the array to what they use;
205 * with every table word 0 instead, the descriptors point at the table itself, and `RadixCount` then writes into the
206 table that other waves are reading, so its output differs between runs. That is the test input, not the
207 translator; the tool's default avoids it.
208* **What is still open.** The other programs' outputs (the sorts, prefix sums, builders, refit and loaders) are not
209 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
210 above. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order
211 above comes from `ILDN`, not from a runtime trace. The `STAT` bitcode and the `0x07 NOBC` record are not
212 explained.
179 213
180## 6. Tool and tests 214## 6. Tool and tests
181 215
216`tools/bvh_gpu_smoke.py --game-dir <package> [--max-shared-memory N] [--checked] [--json report.json]` reproduces the
217GPU run above: the extraction and translation of §4, then two dispatches per program, and with `--checked` the six
218byte-exact cases. Its report holds module names, statuses
219and counts only. `tests/test_bvh_gpu_smoke.py` checks the heap image, the word count and the judging of runs with a
220fake `vk_compute_test`, and the checked cases' inputs and judging (a fake that does what each case describes passes,
221one wrong byte fails), without a GPU or game files.
222
182`tools/pe_shader_containers.py` is standard library only and reads the file, never runs it. It accepts a 223`tools/pe_shader_containers.py` is standard library only and reads the file, never runs it. It accepts a
183container only when the chunk table is sorted, 4-byte aligned, entirely inside the declared total and its last 224container only when the chunk table is sorted, 4-byte aligned, entirely inside the declared total and its last
184chunk ends exactly at that total; that is what rejects the FSR DLL's `DXBC` immediate. The synthetic tests in 225chunk ends exactly at that total; that is what rejects the FSR DLL's `DXBC` immediate. The synthetic tests in