upleb.uk

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

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorc0pperlane <84517100+c0pperlane@users.noreply.github.com>2026-11-26 00:58:30 +0100
committerc0pperlane <84517100+c0pperlane@users.noreply.github.com>2026-11-26 00:58:30 +0100
commitde3ee203b23eb6cb3a20d7f1b78ea1d6473ba927 (patch)
tree8a474c141a39b7f74be27b98e379a8889f9fc517 /docs
parent6c6a8cd47d74e5dc94751f4efdaa603e893b20f9 (diff)
parent33bd07cf86bb42236635c27341359b3fe841d1d5 (diff)
Merge remote-tracking branch 'origin/main' into vk-pipeline-large-admission
Conflict in runtime/test/large_module_gate.h: kept main's forwarding header to runtime/src/large_module_gate.h (unchanged) and put LargeModuleQueue after the include; it admits with the gate's admits() and a blocking Ticket under its own mutex, so try_enter and the try_to_lock Ticket are no longer needed.
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md2
-rw-r--r--docs/boot.md62
-rw-r--r--docs/boot_leads.md14
-rw-r--r--docs/bvh.md39
-rw-r--r--docs/cpu_features.md19
-rw-r--r--docs/d3d12_command_objects.md37
-rw-r--r--docs/d3d12_vulkan.md102
-rw-r--r--docs/d3d12_xs_surface.md125
-rw-r--r--docs/design.md22
-rw-r--r--docs/first_light.md8
-rw-r--r--docs/gbuffer.md13
-rw-r--r--docs/gpu_test_results.md58
-rw-r--r--docs/i18n/README.md5
-rw-r--r--docs/i18n/it/quickstart.md4
-rw-r--r--docs/i18n/ja/quickstart.md4
-rw-r--r--docs/i18n/pl-PL/quickstart.md4
-rw-r--r--docs/i18n/ru/quickstart.md10
-rw-r--r--docs/linux.md33
-rw-r--r--docs/models.md2
-rw-r--r--docs/movies.md5
-rw-r--r--docs/pipeline_check.md6
-rw-r--r--docs/progress_dashboard.md15
-rw-r--r--docs/related_projects.md18
-rw-r--r--docs/retail_boot_chain.md50
-rw-r--r--docs/rpf.md11
-rw-r--r--docs/runtime_imports.md35
-rw-r--r--docs/shader_validation.md44
-rw-r--r--docs/testing.md16
-rw-r--r--docs/world.md7
-rw-r--r--docs/world_lights_paths.md4
-rw-r--r--docs/xcl_compare.md2
-rw-r--r--docs/xdxr.md21
-rw-r--r--docs/xmem_exe_calls.md56
33 files changed, 720 insertions, 133 deletions
diff --git a/docs/README.md b/docs/README.md
index d6bca1754..1e4aaa2e4 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -69,7 +69,7 @@ method, scope and caveats. No game data is included.
69| [mobile.md](mobile.md) | arm64/mobile path: the x86-64 → arm64 static-recompiler groundwork (`tools/x64_recomp.py`), the `.pdata` coverage census (`tools/recomp_census.py`), and what still blocks iOS. | 69| [mobile.md](mobile.md) | arm64/mobile path: the x86-64 → arm64 static-recompiler groundwork (`tools/x64_recomp.py`), the `.pdata` coverage census (`tools/recomp_census.py`), and what still blocks iOS. |
70| [first_run_ui.md](first_run_ui.md) | Build the Windows integration and display the offline first-run controller prompts. | 70| [first_run_ui.md](first_run_ui.md) | Build the Windows integration and display the offline first-run controller prompts. |
71| [boot.md](boot.md) | The first real boot: the `gta6rt --trace`/`--trace-d3d12` runbook, the startup + D3D12 trace summary (`tools/boot_trace.py`), the triage order and the Q1–Q22 checklist. | 71| [boot.md](boot.md) | The first real boot: the `gta6rt --trace`/`--trace-d3d12` runbook, the startup + D3D12 trace summary (`tools/boot_trace.py`), the triage order and the Q1–Q22 checklist. |
72| [retail_boot_chain.md](retail_boot_chain.md) | How far `gta6rt --run` gets with the retail executable: the stops in order and what clears each, the physical-page export shapes, and device slots 26, 48 and 73. | 72| [retail_boot_chain.md](retail_boot_chain.md) | How far `gta6rt --run` gets with the retail executable: the stops in order and what clears each, the physical-page export shapes, device slots 26, 48 and 73, and the device slots the executable calls, counted from the file (`tools/d3d12_device_calls.py`). |
73| [retail_boot_intel_host.md](retail_boot_intel_host.md) | The retail boot on an Intel host with 16 GB: which stops of the two boot pages hold there with #7111, the commit-limit stop at the 6.1 GiB physical-page request that #7556 clears, the frame loop to the 900 s timeout with stub pipelines, and what the layer refuses at that depth (the console mesh-shader subobject among it). | 73| [retail_boot_intel_host.md](retail_boot_intel_host.md) | The retail boot on an Intel host with 16 GB: which stops of the two boot pages hold there with #7111, the commit-limit stop at the 6.1 GiB physical-page request that #7556 clears, the frame loop to the 900 s timeout with stub pipelines, and what the layer refuses at that depth (the console mesh-shader subobject among it). |
74| [modding.md](modding.md) | The mod format: a `mods/<folder>/mod.json` next to `gta6rt.exe` or under `--mods DIR`, swapping a named (or `joaat`) archetype for another; the `tools/leonida_mods.py` manager (`Mods.bat` on Windows, `Mods.sh` on Linux and macOS); load order, the start-up log, and the fact that a swap waits for the executable's archetype lookup address (RT-5). | 74| [modding.md](modding.md) | The mod format: a `mods/<folder>/mod.json` next to `gta6rt.exe` or under `--mods DIR`, swapping a named (or `joaat`) archetype for another; the `tools/leonida_mods.py` manager (`Mods.bat` on Windows, `Mods.sh` on Linux and macOS); load order, the start-up log, and the fact that a swap waits for the executable's archetype lookup address (RT-5). |
75| [descriptor_lookup_apple.md](descriptor_lookup_apple.md) | M3 Max GPU timings for texture and sampler descriptor lookups at 1k, 10k and 100k live entries. | 75| [descriptor_lookup_apple.md](descriptor_lookup_apple.md) | M3 Max GPU timings for texture and sampler descriptor lookups at 1k, 10k and 100k live entries. |
diff --git a/docs/boot.md b/docs/boot.md
index 4e38da7d4..3ba791f88 100644
--- a/docs/boot.md
+++ b/docs/boot.md
@@ -95,9 +95,11 @@ Useful switches:
95 This switch covers imports only; it does not affect the D3D12 outcomes. 95 This switch covers imports only; it does not affect the D3D12 outcomes.
96* `LEONIDA_SKIP_CPU_CHECK=1` skips the AVX preflight of `--init` and `--run`, which otherwise exits 4 with one line 96* `LEONIDA_SKIP_CPU_CHECK=1` skips the AVX preflight of `--init` and `--run`, which otherwise exits 4 with one line
97 naming the missing feature on a host without AVX (a QEMU `qemu64` guest; under Rosetta, set 97 naming the missing feature on a host without AVX (a QEMU `qemu64` guest; under Rosetta, set
98 `ROSETTA_ADVERTISE_AVX=1` instead). The game itself still needs AVX, so this is for the #UD emulation work. 98 `ROSETTA_ADVERTISE_AVX=1` instead). The game itself still needs AVX, so this is for the #UD emulation work (see
99 [cpu_features.md](cpu_features.md#hosts-without-avx) for what works on a host without AVX).
99* `LEONIDA_SKIP_INT3=1` (with `--trace`) steps over each int3 in guest code and logs it once per address as an 100* `LEONIDA_SKIP_INT3=1` (with `--trace`) steps over each int3 in guest code and logs it once per address as an
100 `int3_skipped` event, so a boot can be followed past soft asserts (an int3 followed by code that carries on). 101 `int3_skipped` event, so a boot can be followed past soft asserts (an int3 followed by code that carries on). It is
102 read when the trace opens.
101 Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file 103 Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file
102 open is always traced as `file_open_failed` (path, error, caller) when `--trace` is on. 104 open is always traced as `file_open_failed` (path, error, caller) when `--trace` is on.
103* `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry 105* `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry
@@ -120,21 +122,71 @@ Useful switches:
120 (`runtime/shims/title_hud.h`). It updates twice a second with: 122 (`runtime/shims/title_hud.h`). It updates twice a second with:
121 - the frame rate and the average and worst frame time from PresentX, or, when no frame came in that half 123 - the frame rate and the average and worst frame time from PresentX, or, when no frame came in that half
122 second, how long since the last one (a hang reads "0 fps, no frame for 12.5 s"); 124 second, how long since the last one (a hang reads "0 fps, no frame for 12.5 s");
123 - the process's private memory and working set; 125 - the process's private memory (its commit charge; Wine fills only `PagefileUsage`, which is the same figure)
124 - its local GPU memory against the DXGI budget, and its shared GPU memory; 126 and working set;
127 - its GPU memory: in use and the budget over the device-local heaps, and in use in the other heaps, read from
128 the Vulkan device through `VK_EXT_memory_budget`. Without that extension it falls back to DXGI's
129 `QueryVideoMemoryInfo`, which reads 0 under Wine; with neither the field reads `VRAM n/a`, not a false 0.
130 Both memory figures and their text come from `runtime/src/memory_figures.h`, which the dev overlay shows too;
125 - the graphics and compute pipelines created, and the seconds spent in `vkCreate*Pipelines` in the last half 131 - the graphics and compute pipelines created, and the seconds spent in `vkCreate*Pipelines` in the last half
126 second. A pipeline compiled in the frame shows up there as a hitch. This needs `LEONIDA_MEM_PROBE`; without it 132 second. A pipeline compiled in the frame shows up there as a hitch. This needs `LEONIDA_MEM_PROBE`; without it
127 the field reads `PSO -`. 133 the field reads `PSO -`.
128 - the time since the first present. 134 - the time since the first present.
129 135
130 A thread of its own sets the text with `SendMessageTimeout`, so a busy window thread never holds a present. 136 A thread of its own sets the text with `SendMessageTimeout`, so a busy window thread never holds a present.
137* `LEONIDA_DEV_OVERLAY=1` (Windows) shows what the runtime is doing in a small click-through window over the top left
138 corner of the title's window, while that window is in front (`runtime/src/dev_overlay.h`): frames and submissions a
139 second, where a submission's CPU time goes, the phase that is running now and for how long, pipeline builds in
140 flight, indirect draws emitted and skipped, cores, free RAM, and the same private memory and GPU memory figures as
141 `LEONIDA_TITLE_HUD` (`VRAM n/a` without `VK_EXT_memory_budget`). The device publishes its GPU memory figure, and
142 the overlay and the HUD read it at most once per half second. The rates cover the last two seconds. It has its own
143 thread, so it also counts while the title presents nothing, and it is in no capture. `LEONIDA_TITLE_HUD` shows frame
144 times and compile times in the title bar instead; both can be on.
131* `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their 145* `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their
132 implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known 146 implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known
133 problems"). 147 problems").
134* `--overlay DIR` sends the guest's writes to DIR instead of the default `<game-dir>\overlay` (useful when the 148* `--overlay DIR` sends the guest's writes to DIR instead of the default `<game-dir>\overlay` (useful when the
135 package drive is read-only); the package itself is never written. Set `LEONIDA_WRITE_DIR` to override that folder 149 package drive is read-only); the package itself is never written. Set `LEONIDA_WRITE_DIR` to override that folder
136 for one run (it wins over `--overlay`). For a fresh first-run profile, also set `LEONIDA_SAVE_DIR` to a separate 150 for one run (it wins over `--overlay`). For a fresh first-run profile, also set `LEONIDA_SAVE_DIR` to a separate
137 empty directory for the local game-save provider. 151 empty directory for the local game-save provider. The title's `T:` drive (its temporary drive,
152 where it writes its crash dump `T:\<guid>.dmp` and crash log) is a folder of each process's own inside the overlay,
153 `<overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>` (the process's start time in UTC and its id).
154 The folder is reserved with a create-only `CreateDirectoryW` when `gta6rt` starts the title (or on the first `T:`
155 call): when that name already exists, as after a reused process id in the same millisecond, it takes `-2`, `-3`,
156 ... (up to 1000 names), so a run never writes into a folder that existed before it. The startup line names it
157 (`console paths: GAME: -> ..., writes -> ..., T: -> ...`).
158 Folders of earlier runs are kept, so a run's crash files can be read after it stops; delete them by hand. With
159 one folder for every run, a `CREATE_NEW` of a name an earlier run had left failed with `ERROR_FILE_EXISTS` (80)
160 and no report landed (old upstream issue 7913).
161
162### Under Wine on Linux
163
164The prefix has to supply a `d3d12.dll` that exports `D3D12SerializeVersionedRootSignature`, because the executable
165imports it. Wine's own `d3d12.dll` does not answer that export for the runtime's shim, and the failure is quiet:
166the D3D12 trace ends at about 1,658 calls, the startup trace ends in an access violation inside the executable,
167and the one line that names the cause is
168`[rt] d3d12_xs: host d3d12.dll has no D3D12SerializeVersionedRootSignature`. The run never reaches
169`CreateRootSignature`.
170
171Copying the DLLs a Proton prefix installs is not enough on its own: Wine keeps preferring its own copy next to
172them. Name them in the overrides.
173
174```bash
175GE=$HOME/GE-Proton11-13-x86_64/files/lib/wine
176cp "$GE/vkd3d-proton/x86_64-windows/d3d12.dll" \
177 "$GE/vkd3d-proton/x86_64-windows/d3d12core.dll" \
178 "$GE/dxvk/x86_64-windows/dxgi.dll" "$WINEPREFIX/drive_c/windows/system32/"
179export WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n,b"
180export LEONIDA_D3D12=vulkan
181export LEONIDA_SHADERS='Z:\path\to\shaders\spirv'
182wine ./gta6rt.exe --run 'Z:\path\to\game_scarlett_master.exe' --game-dir 'Z:\path\to\the\package' \
183 --trace /tmp/boot.jsonl --trace-d3d12
184```
185
186With those three DLLs and the override, the same prefix reaches the frame loop: about 1.4 million D3D12 calls in
18790 s, no exception, `PresentX ready`, against 1,658 calls and an access violation without them, measured on Wine
18811.13 (GE-Proton 11-13) with an RDNA2 iGPU. A prefix that Proton itself created already carries these files and
189needs no override.
138 190
139## 3. Triage order 191## 3. Triage order
140 192
diff --git a/docs/boot_leads.md b/docs/boot_leads.md
index 56ec05436..b3e0207f9 100644
--- a/docs/boot_leads.md
+++ b/docs/boot_leads.md
@@ -80,12 +80,14 @@ your own copy or with a synthetic test before you build on it, and record the re
80- **Finding:** a console descriptor word may be a 32-bit GPU address rather than a heap offset. 80- **Finding:** a console descriptor word may be a 32-bit GPU address rather than a heap offset.
81- **Where:** the "descriptor-table record model" listed as open in [d3d12_vulkan.md](d3d12_vulkan.md), next to the 81- **Where:** the "descriptor-table record model" listed as open in [d3d12_vulkan.md](d3d12_vulkan.md), next to the
82 descriptor-heap start-handle convention in §7 of that page. 82 descriptor-heap start-handle convention in §7 of that page.
83- **Implement:** census the descriptor words the title writes (count how many are valid addresses inside the arena 83- **Result:** measured by retail descriptor heap census (1,245,184 slots across submits 50, 500 and 5000; RTX 5070, Windows 11).
84 and how many are not). If the census holds, translate a word to the buffer device address or bindless index it 84 The heap holds: 910,244 empty slots; 327,543 free-list links (`value = next slot index`, terminating at `0xFFFFFFFF`);
85 stands for, the way root-descriptor addresses already go through the arena. 85 261 T# with layer-assigned addresses above 4 GiB; 5,840 V# (3,024 with a null base, 2,816 with a sub-4-GiB base);
86- **Test:** a synthetic heap whose words are arena addresses, round-tripped through the translation. 86 1,296 slots of interleaved constant data; and **0 slots that are bare 32-bit GPU addresses**.
87- **Record it in:** [d3d12_vulkan.md](d3d12_vulkan.md) with the census counts. 87- **Conclusion:** BL-4 hypothesis is not supported on this stack. Descriptors pack 48-bit addresses into V# / T# fields rather
88- **Needs:** game files for the census. 88 than exposing bare 32-bit pointer words. Characterized by model-level reference contract suite `tests/test_descriptor_address_translation.py` (53 tests modeling the documented arena bitfield partitioning and address extraction contracts).
89- **Record it in:** [d3d12_vulkan.md](d3d12_vulkan.md) §3.4 with the census breakdown.
90- **Needs:** none (census completed and verified).
89 91
90## BL-5: a possible gap in the shader corpus count 92## BL-5: a possible gap in the shader corpus count
91 93
diff --git a/docs/bvh.md b/docs/bvh.md
index 203a88c2d..ee4316672 100644
--- a/docs/bvh.md
+++ b/docs/bvh.md
@@ -123,8 +123,42 @@ So the "`u16` table at header `0x130`" of section 4 is not a table: it is these
123(a root pointer, the element offset and the parent offset, the last usually negative; hence "often monotonic"). With `offsetToPrimRemap` 0 everywhere there is no 123(a root pointer, the element offset and the parent offset, the last usually negative; hence "often monotonic"). With `offsetToPrimRemap` 0 everywhere there is no
124primitive remap table either, and the element region allocates 64 bytes per element, `numElements` of them, padded 124primitive remap table either, and the element region allocates 64 bytes per element, `numElements` of them, padded
125to 128 bytes (a stride, not a record layout: section 4a describes the packed arrays inside it). 125to 128 bytes (a stride, not a record layout: section 4a describes the packed arrays inside it).
126**Open:** where the parent array starts and how big it is. Neither `offsetToParents + 4 * unit` against the header end 126**The parent table (BUILD-1390).** The traversal shader finds the entry for the 64-byte unit `u` at
127or `offsetToElements`, nor a size of `4 *` the node or element count, holds on every stream. 127`offsetToParents + 4 * (u - offsetToElements / 64)` (`XboxBvh4Node_GetParentTableOffset` and
128`XboxBvh4Node_LoadParentPointer`, L3254-L3275 of the `.hlsli` above, 32-bit arithmetic). It only looks up the
129parent of a box node: the node it climbs from is the last non-triangle node (L6212), asserted to be above `TRI3`
130(L6265). The table is laid out for the box nodes only:
131
132* *Start:* `offsetToParents = 0x40 - (((offsetToNodes - offsetToElements) / 16) & ~127)`. The element units'
133 entries take `(offsetToNodes - offsetToElements) / 16` bytes; their whole 128-byte blocks sit below the header
134 end, which is why the word is negative from 32 element units up. The first box node's entry is then at
135 `offsetToParents + (offsetToNodes - offsetToElements) / 16`, in `[0x40, 0xc0)`.
136* *Extent:* one entry per box unit (a BOX16 node takes one, a BOX32 node two) from the first box entry, and
137 `offsetToElements` is the end of the last one rounded up to 128 bytes. The bytes between the header end and the
138 first box entry, and after the last one, are the only slack.
139* *Not shipped:* the bytes from `0x40` to `offsetToElements` are all zero; rehydration writes the entries
140 (`tools/bvh_rehydrate.py`, which matches the library byte for byte on 8 samples, §4a).
141* *The units the header counts:* `totalSizeIn64BNodes + 1` is the end of the last box group in 64-byte units plus
142 `ceil((4 + 8 * levels) / 64)` units for the level table (§4a). The level table's units have no entry, so the end
143 `offsetToParents + 4 * (totalSizeIn64BNodes + 1 - offsetToElements / 64)` taken from the header alone, rounded up
144 to 128, lands on `offsetToElements` on only 259,456 of the 272,858 box-rooted streams.
145
146Measured over every stream of both packs, with a scratch probe over the `tools/bvh_index.py` scan and then with
147`tools/bvh_packing_check.py`, which now checks all three (§4a): 272,874 streams (271,627 complete and 10 joined in
148`core_bvh4.rpf`, 1,237 in `shared_minigame000_bvh4.rpf`). Counts only.
149
150| rule | holds on |
151|---|---|
152| `[0x40, offsetToElements)` is zero | 272,874 / 272,874 |
153| `offsetToParents` from the start rule | 272,874 / 272,874 |
154| `offsetToElements` from the extent rule (box root) | 272,858 / 272,858 |
155| `totalSizeIn64BNodes + 1` = box groups' end plus the level table's units (box root) | 272,858 / 272,858 |
156| leaf root (`numElements` 1): `offsetToElements` `0x80`, `offsetToNodes` `0x100`, `offsetToParents` `0x40`, `totalSizeIn64BNodes` 3 | 16 / 16 |
157| no slack after the last box entry | 8,973 (1 to 31 entries on the rest) |
158
159**Hypothesis:** the console builder sizes the table from the box nodes it wrote and aligns it the same way for
160updatable or top-level structures. Every measured stream has `flags` `0x81020006`, a BLAS without the updatable
161bit `0x00040000`, so where an updatable structure keeps its leaves' entries is not measured.
128 162
129The `flags` word has version `6` in its low 16 bits. It also sets `0x80000000` (bottom level), `0x00020000` 163The `flags` word has version `6` in its low 16 bits. It also sets `0x80000000` (bottom level), `0x00020000`
130(offline) and `0x01000000` (dehydrated). It does not set `0x00010000` (compressed). The sample is therefore a 164(offline) and `0x01000000` (dehydrated). It does not set `0x00010000` (compressed). The sample is therefore a
@@ -506,6 +540,7 @@ bytes form exactly one tree:
506* a box pointer names a node of its own width on a lower level; 540* a box pointer names a node of its own width on a lower level;
507* a TRI0 pointer names a leaf slot `offsetToElements + 64 * k` with `k < numElements`; 541* a TRI0 pointer names a leaf slot `offsetToElements + 64 * k` with `k < numElements`;
508* nothing points to the root, and every other node and every leaf has exactly one parent; 542* nothing points to the root, and every other node and every leaf has exactly one parent;
543* the parent table is not shipped and its start and extent follow the element and box regions (§3.1);
509* every vertex-order byte is a permutation; 544* every vertex-order byte is a permutation;
510* every stored override lies inside `sceneBounds` in the leaf frame. 545* every stored override lies inside `sceneBounds` in the leaf frame.
511 546
diff --git a/docs/cpu_features.md b/docs/cpu_features.md
index 5ecea005f..47ffd81dc 100644
--- a/docs/cpu_features.md
+++ b/docs/cpu_features.md
@@ -69,3 +69,22 @@ in the image.
69 answers is not measured here. 69 answers is not measured here.
70 70
71Not measured: which of these sites a boot reaches, and in which order. 71Not measured: which of these sites a boot reaches, and in which order.
72
73### Hosts without AVX
74
75Measured on one host: Intel Xeon X5675 (Westmere, SSE4.2; no AVX, AVX2, FMA, BMI2 or XSAVE), Fedora 44,
76`wine-11.21 (Staging)`, Intel SDE 10.13.1, and a local `gta6rt.exe` build from 2026-11-24.
77
78- **What works without AVX:** building the native Linux runtime and Vulkan test tools (`ctest`), running the Vulkan GPU
79 suite (`scripts/run_gpu_tests.py`), shader translation and asset export (`make_game.py` stages).
80- **Running `gta6rt` directly:** `--init` and `--run` exit 4 at the AVX preflight. With `LEONIDA_SKIP_CPU_CHECK=1`,
81 the preflight is skipped and the guest faults on its first AVX instruction.
82- **Under Intel SDE (`sde64 -hsw`):** without `-chip_check_disable 1`, SDE aborts on `clzero` instead of raising
83 `SIGILL` for `gta6rt`'s handler. With `-chip_check_disable 1`, the guest passes its first AVX instruction and reaches
84 `InitializeApiImplEx2` (offline) after ~110 s, then stops before any window or D3D12 call: SDE traps an `int 3`
85 without `-raise-int3`, and with `-raise-int3` the process terminates with `SIGSEGV` (`LEONIDA_SKIP_INT3=1` with
86 `--trace` did not change this, recording `0` `int3_skipped` events). Adding `-ptr-raise` causes Pin to abort with an
87 internal instrumentation error under Wine's exception handling.
88- **Outcome on this host:** no useful path to boot `gta6rt --run` was found under SDE + Wine.
89
90Not measured: other emulators (such as QEMU TCG with AVX2) or Rosetta 2.
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md
index 36a02e874..eea693c70 100644
--- a/docs/d3d12_command_objects.md
+++ b/docs/d3d12_command_objects.md
@@ -136,8 +136,41 @@ following each `0x40`/`0x48`/`0x60`/`0x120` call back to its receiver.
136 136
137So the four slots' callers are in the game executable, which the package does not contain (the 137So the four slots' callers are in the game executable, which the package does not contain (the
138same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is 138same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is
139still the SDK baseline. Once the executable is available, `tools/d3d12_iid_scan.py` run on it 139still the SDK baseline.
140shows whether it carries these IIDs, and its call sites through them give the slots. 140
141**Measured on the retail executable** (`python -I tools/d3d12_iid_scan.py`, 80 SDK IIDs read from
142the Windows SDK 10.0.26100 `d3d12.h`): the image carries 13 of them, and it carries the whole
143queue/allocator/list/fence set except the two base/second-generation names:
144
145| IID | In the executable |
146|---|---|
147| `ID3D12CommandQueue` | present |
148| `ID3D12CommandAllocator` | present |
149| `ID3D12GraphicsCommandList` | present (one slot-73 site; startup lists use the console IID below) |
150| `ID3D12Fence` | present |
151| `ID3D12CommandList` (base) | absent |
152| `ID3D12Fence1` | absent |
153
154The other carried IIDs are `ID3D12CommandSignature`, `ID3D12DescriptorHeap`, `ID3D12Device11`,
155`ID3D12PipelineState`, `ID3D12QueryHeap`, `ID3D12Resource`, `ID3D12RootSignature`,
156`ID3D12StateObject` and `ID3D12StateObjectProperties`; the image imports only
157`D3D12ConfigureVirtualMemoryX`, `D3D12SerializeVersionedRootSignature` and
158`D3D12XboxCreateDevice` from `d3d12_xs.dll`. `ID3D12Device11`
159(`{5405C344-D457-444E-B4DD-2366E45AEE39}`, `d3d12.h:24502,35748`, `.rdata` `0x1461E0638`) is the
160`riid` the executable passes to `D3D12XboxCreateDevice` (`0x14247856C` → `0x1424785B7`), which is
161why both `d3d12_iid_scan.py` and `is_device_iid` in `runtime/shims/d3d12_xs_device.cpp` recognise
162it during [retail_boot_chain.md](retail_boot_chain.md).
163
164A carried IID is necessary but not sufficient: it says the binary can ask for the interface, not
165where it does. The slots stay **Open** until a call site is followed.
166
167One console command-list IID is outside `d3d12.h`, so the scan cannot see it, and a proxy has to
168answer it rather than forward it to the PC device: `{C3827890-4024-474C-98CF-645B51DC4874}`
169(`.rdata` `0x1461E0668`), passed to Xbox device slot 73 (`CreateCommandListX`) in renderer startup
170at `0x142478B56` → `0x142478B71` ([retail_boot_chain.md](retail_boot_chain.md) §3.3,
171[#523](https://github.com/ubiquitarianism/leonida/issues/523)); the carried
172`IID_ID3D12GraphicsCommandList` (`0x1461ECFA0`) is passed to slot 73 at a separate site
173(`0x1417F6D1D` → `0x1417F6D34`).
141 174
142### 2.2 Queue, allocator and fence 175### 2.2 Queue, allocator and fence
143 176
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md
index 6df6657bd..c29a9ab2f 100644
--- a/docs/d3d12_vulkan.md
+++ b/docs/d3d12_vulkan.md
@@ -344,10 +344,10 @@ What is implemented (all of it testable without the game):
344 that reaches past the end of the buffer stops there, as the hardware's bounds check would. 344 that reaches past the end of the buffer stops there, as the hardware's bounds check would.
345 - Values follow D3D's rules (`runtime/src/uav_clear.h`): Uint copies the low bits of each value into its channel 345 - Values follow D3D's rules (`runtime/src/uav_clear.h`): Uint copies the low bits of each value into its channel
346 with no conversion, whatever the format's type; Float converts (UNORM/SNORM clamp and round to nearest, NaN is 346 with no conversion, whatever the format's type; Float converts (UNORM/SNORM clamp and round to nearest, NaN is
347 0; 16-bit and the packed 11/10-bit floats round to nearest even). A raw or structured view takes value 0 for 347 0; 16-bit and the packed 11/10-bit floats round toward zero, a finite value too large becoming the largest
348 every 32-bit word (Float: its bits). D3D11 calls Float on an integer view invalid and D3D12 does not say; here 348 finite). A raw or structured view takes value 0 for every 32-bit word (Float: its bits). D3D11 calls Float on an
349 the value is converted (toward zero, clamped, NaN 0) so the result is defined. These are checked against 349 integer view invalid and D3D12 does not say; here the value is converted (toward zero, clamped, NaN 0) so the
350 hand-computed elements in `d3d12_uav_clear_test`. 350 result is defined. These are checked against hand-computed elements in `d3d12_uav_clear_test`.
351 - Buffers: elements of up to 4 bytes repeat in every aligned word, so `vkCmdFillBuffer` writes the aligned middle 351 - Buffers: elements of up to 4 bytes repeat in every aligned word, so `vkCmdFillBuffer` writes the aligned middle
352 and `vkCmdCopyBuffer` copies the unaligned ends from it (an 8-bit view at an odd offset, say). 8- and 16-byte 352 and `vkCmdCopyBuffer` copies the unaligned ends from it (an 8-bit view at an odd offset, say). 8- and 16-byte
353 elements are written with `vkCmdUpdateBuffer` (up to 64 KiB) and doubled with copies. A rectangle is an 353 elements are written with `vkCmdUpdateBuffer` (up to 64 KiB) and doubled with copies. A rectangle is an
@@ -788,7 +788,14 @@ descriptor, as D3D12 refuses it), and stencil-plane views (`PlaneSlice` 1, as
788`X24_TYPELESS_G8_UINT` or `X32_TYPELESS_G8X24_UINT`) are an 8_UINT T# that set 0 shows through the stencil 788`X24_TYPELESS_G8_UINT` or `X32_TYPELESS_G8X24_UINT`) are an 8_UINT T# that set 0 shows through the stencil
789aspect, in its float-typed sampled arrays like other single-sampled UINT views. Other gaps include descriptors 789aspect, in its float-typed sampled arrays like other single-sampled UINT views. Other gaps include descriptors
790the game writes itself, which need 790the game writes itself, which need
791the execute-time scan of section 3.4 (only descriptors made through the device are registered); the literal S#s of shaders (`literal_samplers` in the index), 791the execute-time scan of section 3.4 (only descriptors made through the device are registered). A retail
792descriptor heap census (BL-4, measuring the primary 1,245,184-slot console CBV/SRV/UAV heap across submissions
79350, 500, and 5000 on RTX 5070 / Windows 11) confirms the slot distribution: 910,244 empty slots; 327,543 single-dword
794free-list links (`value = slot_index + 1`, ending at `0xFFFFFFFF`); 261 T# with layer-assigned addresses above 4 GiB;
7955,840 V# (3,024 with a null base, 2,816 with a sub-4-GiB arena base); 1,296 slots containing interleaved constant data
796(IEEE-754 floats); and zero bare 32-bit GPU addresses. Console descriptors do not store standalone 32-bit pointer words;
797buffer and image base addresses are packed into standard 48-bit V# and T# records conforming to the arena layout
798(modeled by model-level reference contract suite `tests/test_descriptor_address_translation.py`); the literal S#s of shaders (`literal_samplers` in the index),
792which `rt::d3d12::register_samplers` registers without a heap slot but which nothing passes to it yet (the call at 799which `rt::d3d12::register_samplers` registers without a heap slot but which nothing passes to it yet (the call at
793pipeline creation comes with the shader index, #291); 800pipeline creation comes with the shader index, #291);
794custom border colours without VK_EXT_custom_border_color, and minimum/maximum filters, anisotropy or mirror-once addressing without the Vulkan 801custom border colours without VK_EXT_custom_border_color, and minimum/maximum filters, anisotropy or mirror-once addressing without the Vulkan
@@ -1837,7 +1844,10 @@ The game can use D3D12 descriptors in three ways, and the layer must handle all
1837 No sampler-indexing entry had a matched layout. Putting the resource heap first when both flags are set, then the 1844 No sampler-indexing entry had a matched layout. Putting the resource heap first when both flags are set, then the
1838 sampler in the next dword, remains a hypothesis. D3D-329's adjacent SGPR examples alone do not establish it. 1845 sampler in the next dword, remains a hypothesis. D3D-329's adjacent SGPR examples alone do not establish it.
1839 The runtime snapshots the bound resource and sampler heap pointers in that order after the explicit 1846 The runtime snapshots the bound resource and sampler heap pointers in that order after the explicit
1840 arguments for direct and indirect compute dispatches with an inline signature. An unbound heap contributes 1847 arguments for direct and indirect compute dispatches with an inline signature. Bound console descriptor heap
1848 base addresses are remapped through `console_descriptor_table_va` so that user SGPRs receive the arena copy's
1849 shader virtual address (where GPU descriptor reads land, preventing `READ_INVALID` device loss during world
1850 load), while unshadowed host heaps remain unchanged. An unbound heap contributes
1841 zero, and rebinding affects later commands. A heap that cannot fit in the inline user data is reported once, 1851 zero, and rebinding affects later commands. A heap that cannot fit in the inline user data is reported once,
1842 and a signature whose compute arguments spill gets nothing written (logged once). Set 1852 and a signature whose compute arguments spill gets nothing written (logged once). Set
1843 `LEONIDA_COMPUTE_DIRECT_HEAPS=0` to restore the previous compute arguments. 1853 `LEONIDA_COMPUTE_DIRECT_HEAPS=0` to restore the previous compute arguments.
@@ -2158,7 +2168,21 @@ sets them, and it does so twice.
2158 2168
2159`amd_fidelityfx_upscaler_xbox.dll` does neither. Its 29 `RTS0` parts carry `Flags = 0`, and no instruction in it uses 2169`amd_fidelityfx_upscaler_xbox.dll` does neither. Its 29 `RTS0` parts carry `Flags = 0`, and no instruction in it uses
2160the constant `0x3000000`. So the bits are not a property of every console root signature; this builder adds them. The 2170the constant `0x3000000`. So the bits are not a property of every console root signature; this builder adds them. The
2161game executable is not in the package, so whether its root signatures carry them is open. 2171retail executable's root signatures do not carry them either (old upstream PR 7140): its direct call passes a 1.1
2172description with `Flags = 0x80` (`LOCAL_ROOT_SIGNATURE`), and its root-signature decoder reads `Flags` as a
2173zero-extended 16-bit value.
2174
2175The mask stays unconditional, because it can't touch a public flag: it clears bits 24-31
2176(`kXboxRootSignatureFlagHighByte`, `runtime/shims/d3d12_xs_rootsig.h`), and every public
2177`D3D12_ROOT_SIGNATURE_FLAGS` value is in bits 0-11 (the highest is `SAMPLER_HEAP_DIRECTLY_INDEXED`, `0x800`). So it is
2178safe on every descriptor and blob, whatever built it. `root_sig_public_flags_test` pins this:
2179
2180- the helpers keep every flag value in `[0, 0xFFFF]`;
2181- the shims' serializers give the host's blob byte for byte for each public flag the host takes. Where the host
2182 refuses only `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` or `SAMPLER_HEAP_DIRECTLY_INDEXED` (Windows 10's in-box `d3d12.dll`),
2183 they serialize on purpose: the blob is the host's blob without those bits, with the full flags in `RTS0` and a valid
2184 container hash (`kDirectlyIndexedFlags`, `runtime/shims/d3d12_xs_rootsig.h`);
2185- a blob with `0x03000080` comes back as `0x80`.
2162 2186
2163**Version 1.2 on older runtimes.** The in-box `d3d12.dll` of Windows 10 (measured on 22H2, 10.0.19045, without the 2187**Version 1.2 on older runtimes.** The in-box `d3d12.dll` of Windows 10 (measured on 22H2, 10.0.19045, without the
2164Agility SDK) and of Windows 11 23H2 (#361) serializes root signatures only up to 1.1. On Windows 10 it rejects even an 2188Agility SDK) and of Windows 11 23H2 (#361) serializes root signatures only up to 1.1. On Windows 10 it rejects even an
@@ -2439,9 +2463,7 @@ Pipeline creation:
2439 is when each is compiled alone, so a PSO released meanwhile waits for the submission. The workers have ended before 2463 is when each is compiled alone, so a PSO released meanwhile waits for the submission. The workers have ended before
2440 the session cache is read at device teardown. `LEONIDA_PIPELINE_THREADS=<n>` sets the workers: unset, half the 2464 the session cache is read at device teardown. `LEONIDA_PIPELINE_THREADS=<n>` sets the workers: unset, half the
2441 logical processors and at most 8; `0` compiles each pipeline on the submitting thread where `prepare()` meets it. 2465 logical processors and at most 8; `0` compiles each pipeline on the submitting thread where `prepare()` meets it.
2442 Graphics pipelines of 1 MiB of SPIR-V or more, and compute pipelines over 128 KiB (`LEONIDA_SERIAL_BIG_COMPILES`), 2466 Large pipelines (below) are compiled within a memory budget, and the variants of one PSO one after another.
2443 are compiled one after another beside the smaller ones, because a compile takes the driver some hundred bytes of
2444 memory for each byte of SPIR-V ([pipeline_check.md](pipeline_check.md)); so are the variants of one PSO.
2445 `LEONIDA_ASYNC_PIPELINES=1` is not changed: its builds stay on the compile worker. Measured with synthetic programs 2467 `LEONIDA_ASYNC_PIPELINES=1` is not changed: its builds stay on the compile worker. Measured with synthetic programs
2446 never compiled before and the warm-up off (RTX 3080, NVIDIA 621.24, Windows 11, 16 logical processors, 8 workers, 2468 never compiled before and the warm-up off (RTX 3080, NVIDIA 621.24, Windows 11, 16 logical processors, 8 workers,
2447 three runs each): the first submission of 192 graphics pipelines takes 126 to 143 ms instead of 861 to 882, of 192 2469 three runs each): the first submission of 192 graphics pipelines takes 126 to 143 ms instead of 861 to 882, of 192
@@ -2449,6 +2471,29 @@ Pipeline creation:
2449 holds about 50 MiB more (the driver keeps memory for each thread that compiles). One `VkPipelineCache` is enough: one 2471 holds about 50 MiB more (the driver keeps memory for each thread that compiles). One `VkPipelineCache` is enough: one
2450 cache per thread, merged, was about as fast. Tested by `pipeline_workers`, `replay_pipeline_compiles` and 2472 cache per thread, merged, was about as fast. Tested by `pipeline_workers`, `replay_pipeline_compiles` and
2451 `d3d12_pipeline_workers`. 2473 `d3d12_pipeline_workers`.
2474- Large pipelines: a compile takes the driver some hundred bytes of memory for each byte of SPIR-V
2475 ([pipeline_check.md](pipeline_check.md), "Limiting concurrent compilation of large modules"), so compute modules over
2476 128 KiB and graphics pipelines of 1 MiB or more compile side by side only while their estimates (512 bytes for each
2477 byte of SPIR-V) fit a budget: three quarters of the smaller of the free RAM and the room under the commit limit, read
2478 again whenever a place at the gate (`runtime/src/large_module_gate.h`, one for the process) is given or returned. One
2479 always gets in when none is, so a pipeline larger than the budget compiles alone. An estimate counts in full until
2480 the compile ends, although the driver has taken part of it by then. They get in in the order they came; while the
2481 first in line does not fit, the next behind it that does may pass, as long as all that have passed it would fit the
2482 budget together with it, so that a stream of small ones does not keep it out. The ones a submission waits for (and
2483 those of `LEONIDA_ASYNC_PIPELINES`) go before the warm-up's, which take a quarter of the budget at most and none while
2484 a submission that has large ones is compiling on its workers. A thread that waits for its place holds no PSO's lock,
2485 and one that has a place waits for none. `PipelineCompiles::build` gives a submission
2486 as many jobs for large ones as its smallest could be in at once, largest first; where the next one does not fit, the
2487 job compiles small ones in the meantime. `LEONIDA_SERIAL_BIG_COMPILES=1` compiles them one after another instead, as
2488 before there was a budget, `=0` has no limit, `LEONIDA_BIG_COMPILE_BUDGET_MB` fixes the budget. Measured with
2489 synthetic integer modules never compiled before and the warm-up off (RTX 3080, NVIDIA 621.24, Ryzen 7 5800X3D, 8
2490 workers and the submitting thread, three alternating runs each): the first submission of 16 modules of 256 KiB takes
2491 0.8 s instead of 4.0 to 4.8 s, 16 of 512 KiB 2.0 to 2.2 s instead of 10.2 to 11.4, 15 of 1 MiB 5.8 to 6.1 s instead
2492 of 29.2 to 31.2, 12 of 0.5 to 2 MiB 8.0 to 10.5 s instead of 38.9 to 39.9. While the 15 of 1 MiB compile, private
2493 memory peaks 656 to 676 MiB over what it was, instead of 140 to 147 (one compile takes 85 to 131 bytes for each byte
2494 of SPIR-V here, and the driver keeps memory for each thread that compiles). With a budget of 1536 MiB, two at once,
2495 they take 18.5 s and peak 202 MiB over. Not measured: other drivers, and the title. Tested by `big_compile_gate`,
2496 `replay_pipeline_compiles` and `d3d12_big_compute`.
2452 2497
2453**Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear. 2498**Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear.
2454The trace will enumerate them. 2499The trace will enumerate them.
@@ -3508,7 +3553,11 @@ will forward to. The queue-side calls ignore which queue they came on (one `VkQu
3508 `WaitFrameEventX` returns at the next origin with the next token (1, 2, 3, ...; 0 is the null token) and does not 3553 `WaitFrameEventX` returns at the next origin with the next token (1, 2, 3, ...; 0 is the null token) and does not
3509 return while `latency` presented frames are still waiting for their vblank. A frame presented before the origin event 3554 return while `latency` presented frames are still waiting for their vblank. A frame presented before the origin event
3510 is armed is not paced (`PresentX` does not hold it for a vblank), so it is shown at once and never waits for a vblank: 3555 is armed is not paced (`PresentX` does not hold it for a vblank), so it is shown at once and never waits for a vblank:
3511 blank presents of a loading screen do not delay the first wait. A wait that comes late returns at once 3556 blank presents of a loading screen do not delay the first wait. At most `latency` frames are in flight once the event
3557 is armed: a present into a full queue (several presents with no wait between them) replaces the newest queued frame
3558 and takes its vblank, like a mailbox, so the replaced frame is never shown (no display statistic) and the older ones
3559 keep their vblanks. However many presents come between two waits, the next wait passes when the oldest frame is
3560 shown. A wait that comes late returns at once
3512 with the newest passed origin; the missed ones are skipped. A finite timeout gives 3561 with the newest passed origin; the missed ones are skipped. A finite timeout gives
3513 `HRESULT_FROM_WIN32(WAIT_TIMEOUT)`; nothing registered, or suspended, gives `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`. 3562 `HRESULT_FROM_WIN32(WAIT_TIMEOUT)`; nothing registered, or suspended, gives `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`.
3514 `LEONIDA_PRESENT_UNCAP` (any non-empty value other than "0", read when the object is made) takes the frame-rate 3563 `LEONIDA_PRESENT_UNCAP` (any non-empty value other than "0", read when the object is made) takes the frame-rate
@@ -3524,8 +3573,11 @@ will forward to. The queue-side calls ignore which queue they came on (one `VkQu
3524 `SuspendX`/`ResumeX` so suspended pauses are excluded), computing nearest-rank `p50`/`p95`/`p99` and the mean drift 3573 `SuspendX`/`ResumeX` so suspended pauses are excluded), computing nearest-rank `p50`/`p95`/`p99` and the mean drift
3525 against the active target interval (`FramePacer::pacing_summary()`). On teardown after at least one present, 3574 against the active target interval (`FramePacer::pacing_summary()`). On teardown after at least one present,
3526 `XboxPresentation` logs a single `[rt] present: pacing summary ...` line on stderr, which `tools/boot_trace.py` 3575 `XboxPresentation` logs a single `[rt] present: pacing summary ...` line on stderr, which `tools/boot_trace.py`
3527 surfaces beside the D3D12 call counts. Confirmed on a fake clock by `frame_pacer_test` (known 100-frame distribution, 3576 surfaces beside the D3D12 call counts. The intervals are between `PresentX` calls, not between frames shown: a frame
3528 positive and negative drift, ring-buffer wrap-around, suspend/resume exclusion, uncapped mode) and by 3577 replaced in a full queue (see the latency limit above) still counts as a present with its real interval, so the
3578 percentiles describe the title's present cadence, and a burst of presents between two waits shows up as short
3579 intervals. Confirmed on a fake clock by `frame_pacer_test` (known 100-frame distribution,
3580 positive and negative drift, ring-buffer wrap-around, suspend/resume exclusion, uncapped mode, replaced frames) and by
3529 `tests/test_boot_trace.py`. 3581 `tests/test_boot_trace.py`.
3530- *`PresentX`*: 0 planes presents a black frame (no token needed). 1 plane blits plane 0's first resource (a 3582- *`PresentX`*: 0 planes presents a black frame (no token needed). 1 plane blits plane 0's first resource (a
3531 single-sample 2D colour texture in `PRESENT`) to the swapchain image, limited to `pSrcViewRects[0]` when set 3583 single-sample 2D colour texture in `PRESENT`) to the swapchain image, limited to `pSrcViewRects[0]` when set
@@ -3744,7 +3796,8 @@ will forward to. The queue-side calls ignore which queue they came on (one `VkQu
3744 (placement, point/bilinear, alpha overlay, HDR10 and PQ conversions, refusals; against a CPU model), token errors, 3796 (placement, point/bilinear, alpha overlay, HDR10 and PQ conversions, refusals; against a CPU model), token errors,
3745 statistics, suspend/resume, `ImmediateThresholdPercent` with a late frame at several thresholds (immediate mode 3797 statistics, suspend/resume, `ImmediateThresholdPercent` with a late frame at several thresholds (immediate mode
3746 chosen, or not for 0, below the lateness, on time) and with `LEONIDA_PRESENT_NO_TEAR=1`, 30 frames at 60 Hz in real 3798 chosen, or not for 0, below the lateness, on time) and with `LEONIDA_PRESENT_NO_TEAR=1`, 30 frames at 60 Hz in real
3747 time; skipped, exit 77, without a Vulkan device). `frame_pacer_test` also sweeps `decide_present_sync`. 3799 time; skipped, exit 77, without a Vulkan device). `frame_pacer_test` also sweeps `decide_present_sync`, and checks
3800 that 1000 presents between two waits leave at most `latency` frames in flight (latency 1, 2 and 3).
3748 3801
3749### 4.6 Queries 3802### 4.6 Queries
3750 3803
@@ -3767,15 +3820,20 @@ Implemented (`QueryHeap` in `runtime/shims/d3d12_vulkan_device.cpp`, the query c
3767 (`compare_invalid_arguments`, "query heap:", RTX 5070 / 621.14): `E_INVALIDARG` for no queries, a node other than 3820 (`compare_invalid_arguments`, "query heap:", RTX 5070 / 621.14): `E_INVALIDARG` for no queries, a node other than
3768 node 0, or a type past `PIPELINE_STATISTICS1` (7), checked before the output; a valid description with a null 3821 node 0, or a type past `PIPELINE_STATISTICS1` (7), checked before the output; a valid description with a null
3769 output is then `E_UNEXPECTED`, not `S_FALSE`. 3822 output is then `E_UNEXPECTED`, not `S_FALSE`.
3770- **Stream-output statistics** (D3D-302). The layer has no stream output: a graphics PSO with `StreamOutput` 3823- **Stream-output statistics** (D3D-302). The layer still refuses `StreamOutput` PSOs and does not implement
3771 entries is refused and `SOSetTargets` is not implemented, so no primitive reaches a stream and every 3824 `SOSetTargets`, so no primitive reaches a stream yet. With `VK_EXT_transform_feedback` enabled on the device
3772 `SO_STATISTICS_STREAM0..3` query counts 0 written and 0 needed. An `SO_STATISTICS` heap is therefore made without 3825 (`D3D-TRANSFORM-FEEDBACK-DEVICE`) and its `transformFeedbackQueries` property set, an `SO_STATISTICS` heap is a
3773 a `VkQueryPool`: `BeginQuery`/`EndQuery` record nothing in Vulkan (D3D12's call rules are still kept, and the 3826 real `VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT` pool begun and ended indexed on the stream
3827 (`vkCmdBeginQueryIndexedEXT` / `vkCmdEndQueryIndexedEXT`), and `ResolveQueryData` copies the two 64-bit results per
3828 query (16 bytes: `NumPrimitivesWritten`, `PrimitivesStorageNeeded`), in the same order; with no stream output they
3829 are 0. A stream at or above the device's `maxTransformFeedbackStreams` runs nothing and resolves zero, as if the
3830 heap had no pool. Without the feature, the property, or a nonzero `maxTransformFeedbackStreams`, the heap is made
3831 without a `VkQueryPool`: `BeginQuery`/`EndQuery` run nothing in Vulkan (D3D12's call rules are still kept, and the
3774 heap's queries track ended or not as the others do), they overlap no other query, and `ResolveQueryData` writes 3832 heap's queries track ended or not as the others do), they overlap no other query, and `ResolveQueryData` writes
3775 zeros (`vkCmdFillBuffer`, 16 bytes per query: `NumPrimitivesWritten`, `PrimitivesStorageNeeded`), with no 3833 zeros (`vkCmdFillBuffer`, 16 bytes per query), with no statistics split since nothing is dispatched. Two
3776 statistics split since nothing is dispatched. When stream output lands, the heap becomes a 3834 overlapping `SO_STATISTICS` queries on one stream would be two active indexed queries in one pool
3777 `VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT` pool begun with `vkCmdBeginQueryIndexedEXT` on the stream, whose two 3835 (`VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753`), so `prepare()` refuses such a list
3778 results are in the same order. 3836 (`ReplayResult::invalid_query`); queries on different streams are fine.
3779- **Recording.** The list keeps D3D12's rules for the calls: timestamps only have `EndQuery`; every other query is 3837- **Recording.** The list keeps D3D12's rules for the calls: timestamps only have `EndQuery`; every other query is
3780 begun and ended in the same list with the same type, is not begun again while it runs, and is not resolved while 3838 begun and ended in the same list with the same type, is not begun again while it runs, and is not resolved while
3781 it runs; resolve offsets are multiples of 8. A list closed with a query still running reports `E_INVALIDARG` and 3839 it runs; resolve offsets are multiples of 8. A list closed with a query still running reports `E_INVALIDARG` and
diff --git a/docs/d3d12_xs_surface.md b/docs/d3d12_xs_surface.md
index 0cae107f7..460b50d29 100644
--- a/docs/d3d12_xs_surface.md
+++ b/docs/d3d12_xs_surface.md
@@ -450,6 +450,124 @@ before treating it as new. For `OMSetFrontAndBackStencilRef` the signature is id
450GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the 450GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the
451wrong slot. Leonida's public-chain command list already has it at GCL8. 451wrong slot. Leonida's public-chain command list already has it at GCL8.
452 452
453### 5.2 Arity and receiver of device slots 86, 101, 108, 132 and 133 (and offset `+0x418` / 131)
454
455These six offsets are called in the title's executable; five reach the device and `+0x418` (131)
456does not. `+0x2B0`, `+0x328`, `+0x360` and `+0x418`-`+0x428` are past every published interface,
457so they are console slots on whatever object the call is made on, and the receiver is not
458automatically the device: the console runtime repeats offsets across object vtables. The whole
459image has **243** indirect calls `call [reg+disp]` at these six offsets; most of them are *not* on
460the device, and a count that ignores the receiver overstates the device surface by an order of
461magnitude.
462
463The receiver is proven by a backward definition chain from the `call` that ends in a full-width load
464of the device pointer. The title keeps that pointer in a block of `.data` aliases
465(`0x1475DF000`-`0x1475DF048` and `0x148759D00`) that one constructor fills with the same value
466(`0x1424785D4`-`0x142478621` copies the qword at `0x1475DF048` into the other eleven). A site whose
467chain ends in one of those globals is a device site. A site whose chain ends in a *different*
468global, in an argument of unknown provenance or in the return of a helper is counted but not
469attributed.
470
471| Slot | Offset | Raw sites | Sites on the device | Receiver at those sites | Registers / stack at those sites | What the device sites support |
472|---:|---|---:|---:|---|---|---|
473| 86 | `+0x2B0` | 37 | **1** (`0x142479A87`) | `[0x1475DF000]` (alias of the device pointer) | `rcx`=device, `rdx`=&desc (first qword `0x2B0`), `r8`=&`IID_ID3D12PipelineState`, `r9`=&out | three-argument, `riid`-out PSO stream creation (`CreatePipelineState` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
474| 101 | `+0x328` | 28 | **1** (`0x1424813EF`) | `[0x1475DF018]` (alias) | `rcx`=device, `rdx`=&desc (dword 0 = `3`, dword 4 = index, `+8` = pointer), `r8`=&`IID_ID3D12StateObject`, `r9`=&out | three-argument, `riid`-out state-object creation with a leading type word `3` (`CreateStateObject` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
475| 108 | `+0x360` | 31 | **2** (`0x140ABFDA9`, `0x140ABFE07`) | vtable fetched from the device (`[0x1475DF030]` / `[0x1475DF035]`); `rdx` is the device itself: the slot returns a 16-byte struct, so the MSVC x64 ABI puts the hidden return buffer in `rcx` and `this` moves to `rdx` | `rcx`=&16-byte `D3D12_RESOURCE_ALLOCATION_INFO` return, `rdx`=device, `r8d`=1 (`visibleMask`), `r9d`=1 (`numResourceDescs`), `[rsp+0x20]`=&56-byte `D3D12_RESOURCE_DESC`, `[rsp+0x28]`=&24-byte scratch (`D3D12_RESOURCE_ALLOCATION_INFO1`-sized) | allocation-info query over one 56-byte resource description (4 KiB small-resource retry; routed as `GetResourceAllocationInfo2` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
476| 131 | `+0x418` | 26 | **0** | - | - | the offset is called, but only on non-device receivers here; a device form is unproven |
477| 132 | `+0x420` | 47 | **1** (`0x1424745E4`) | `[0x1475DF048]` (the alias the copy loop reads) | `rcx`=device, `edx`=3 | single small enum/int argument |
478| 133 | `+0x428` | 74 | **5** (`0x14006DD85`, `0x14193DFF8`, `0x14193E2D4`, `0x141E8684C`, `0x1456F802B`) | `[0x1475DF048]` or `[0x148759D00]` | `rcx`=device, `rdx`=GPU VA, `r8`=&`D3D12_RESOURCE_DESC`, `r9d`=state (`6`, `0xFFFFFFFF` or a register), `[rsp+0x20]`=clear, `[rsp+0x28]`=&`IID_ID3D12Resource`, `[rsp+0x30]`=&out | six-argument placed-resource creation, stable across all five sites |
479
480Per slot:
481
482- **86.** The `riid` at `0x1461E06B8` is `765a30f3-f624-4c6f-a828-ace948622445`,
483 `IID_ID3D12PipelineState` (§3), so the device form creates a PSO: `(desc, riid, out)`, which
484 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) routes as
485 `CreatePipelineState` to PC slot 47 (`ID3D12Device2::CreatePipelineState`). The
486 descriptor's first qword is the slot number itself (`mov qword ptr [rdx], 0x2B0`), i.e. the
487 caller keeps a command record. A second caller reaches the pair 86/87 on *another* object: at
488 `0x14258FC20`-`0x14258FC56` it loads the vtable into `r8`, sets `edx`, branches on a byte and
489 calls `+0x2B8` or `+0x2B0` with that one argument, then tags the returned qword `4` or `3`. So
490 the recorder form is one argument and a returned value, and the device form is the three-argument
491 creation; do not generalise either to the other. A shim that only knows 86 will miss the 87
492 branch.
493- **101.** The `riid` at `0x1461E06D8` is `47016943-fca8-4594-93ea-af258b55346d`,
494 `IID_ID3D12StateObject` (SDK `d3d12.h:44486`, not in the 28-IID set of §3). The descriptor is
495 `{dword 3, dword index, pointer}`: `[rdx]` is the type word `3` (`D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE`
496 or collection), `[rdx+4]` an index into the table the caller just filled (`0x142481350`-`0x1424813BD`)
497 and `[rdx+8]` a pointer (`rdi`). That is the DXR state-object side of the game, routed in
498 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) as
499 `CreateStateObject(desc, riid, out)` to PC slot 62 (`ID3D12Device5::CreateStateObject`).
500- **108.** No GUID is compared at either site. Both sit in one function, `0x140ABFAE0`-`0x140ABFE6C`
501 (reached through the thunk at `0x140ABFAD0`), which first computes the surface size and then makes
502 the one call twice at most. The 5th argument is a 56-byte `D3D12_RESOURCE_DESC`: the callee reads
503 `Dimension` at `+0`, `Alignment` at `+8`, `Width` at `+0x10`, `Height` at `+0x18`,
504 `DepthOrArraySize` at `+0x1C`, `Format` at `+0x20`, `Layout` at `+0x2C` and `Flags` at `+0x30`, and
505 writes back the 4-texel-aligned `Width`/`Height` for block-compressed formats
506 (`0x140ABFB2B`-`0x140ABFB40`). `Format` becomes bits per pixel through `0x144D9F3C0`, which indexes
507 the 128/96/64/32/16/8/4-bit table at `0x1461ED5B8`; dimension 4 (3D) with `Layout` 0 has `Layout`
508 set to the console word `0x105` (`0x140ABFD4B`-`0x140ABFD57`), dimension 3 (2D) takes the tile-shape
509 table, and a buffer is plain `Width × Height × Depth × bits`. When the whole surface is under
510 `0x80008` bits it writes `Alignment = 0x1000`, asks for that alignment, and if the returned alignment
511 is not `0x1000` clears `Alignment` to 0 and calls again (`0x140ABFDBF`-`0x140ABFE07`) — the retry the
512 SDK's small-resource sample does with `D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT` (4096,
513 `d3d12.h:1304`), and the 4 KiB small-texture alignment the host layer already answers
514 ([d3d12_vulkan.md](d3d12_vulkan.md) §4.2). The 16-byte return is `{SizeInBytes, Alignment}` and the
515 code traps unless the high dword of `SizeInBytes` is 0, so a returned size has to fit 32 bits
516 (`0x140ABFE15`).
517 That is the argument list, return placement and struct use of
518 `ID3D12Device4::GetResourceAllocationInfo1(visibleMask, numResourceDescs, pResourceDescs,
519 pResourceAllocationInfo1)` (`d3d12.h:12418-12422`), including a 24-byte
520 `D3D12_RESOURCE_ALLOCATION_INFO1` buffer as the 4th argument (`d3d12.h:2965-2970`);
521 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) serves it by
522 expanding the 56-byte `D3D12_RESOURCE_DESC` (normalising `0x105` and Xbox flag bits) and routing to
523 PC slot 68 (`ID3D12Device8::GetResourceAllocationInfo2`). **Measured**: the shape, the struct
524 offsets, `0x1000`/`0x105`, the retry and the assert. **Open**: the exact console wire method name
525 (`GetResourceAllocationInfo1` vs `GetResourceAllocationInfoX` / `2`) — no IID or symbol string is
526 present at the sites.
527- **131.** Twenty-six sites, none on the device. Two are on sub-objects reached through another
528 global (`0x1415A487D` indexes a table at `[rax+0x28]`), one at `0x14437CFED` follows slot 130
529 (`+0x410`) on the same receiver and reads the out dword it wrote, and the rest are on arguments
530 whose caller does not carry the device. The shape there is `(dword* out)` with a returned value
531 that a site compares (`0x141F9BE30`), plus a four-argument form
532 (`0xC280`, `0x20000`, `0`, `0xFFFFFFFFFF00` at `0x141560994`). It sits in the 0x400 block with
533 132/133, and both of those do have device sites, so a device form is plausible but not shown:
534 do not implement it on the strength of these sites.
535- **132.** The only device site passes `edx=3` and nothing else. Off the device the same offset is
536 a predicate taking one 32-bit constant (`2`, `3`, `0xFFF7E7A4`, `0xBD8817DB`) and returning in
537 `al` (`test al, al` at `0x14118ABB4`), which reads as a feature or capability query; that family's
538 receiver is not the device, so `3` cannot be read as a capability id for the device form yet.
539- **133.** All five device sites are identical: VA, a console `D3D12_RESOURCE_DESC` (Xbox `Flags`
540 bits above the PC ones), state, clear, `IID_ID3D12Resource`, out. That is the same shape and the
541 same `riid` the retail run logged (`retail_boot_chain.md` §3.4, "device slot 133 places a
542 resource at a virtual address"), measured independently here from the same `riid` constant at
543 `0x1463FA690` in three different sites, all `696442be-a72e-4059-bc79-5b5c98040fad`.
544 Static and run agree on six arguments and on the order. This is the strongest row of the six.
545 Off the device the same offset is a different shape - `this` only, returning an object, at
546 `0x14107D67F`; `this` + `0` at `0x143BF0C50` - so 133 on another receiver is not this method.
547
548The co-occurrence fits the block reading: 108 is called alongside 106/107/109/110/111 in
549`0x140504AB0`, 131 alongside 57 in `0x14123C630`/`0x14123CD70`, and 132 with 133 in
550`0x1403D2260`, `0x14060C420`, `0x14060CA50`, `0x141394800` and `0x141597B60`, always with the same
551argument (`rdx` = the struct that carries the size/VA). None of those receivers is proven to be
552the device, so the pairing says "one feature area", not "same arity" and not "device slot".
553
554What this does not say:
555
556- A raw site count is not a device count. The largest raw buckets are argument-provenance sites
557 (26 of 47 at 132, 40 of 74 at 133), many of them in wrapper code that re-dispatches on an
558 inherited or returned pointer. The same offset also carries a different arity off the device
559 (`0x14107D67F`, `0x143BF0C50` above), so an offset alone never names a method.
560- `rdx`, `r8` and `r9` at a site can be dead for the method; only the setup within the last few
561 instructions is listed. The arity above is the *caller's* setup, not a header.
562- No symbol string appears at any of the six call-site groups. On the device, 86, 101, 108 and
563 133 match the routes in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 and
564 [retail_boot_chain.md](retail_boot_chain.md) §3.4 (`CreatePipelineState`, `CreateStateObject`,
565 `GetResourceAllocationInfo2` and `CreatePlacedResourceX` in
566 `runtime/shims/d3d12_xs_device.cpp`). Offsets `+0x418` (131) and `+0x420` (132) remain unnamed
567 here, and 131 has no device receiver.
568- The proxy table must still be long enough: slot 133 is the highest slot the title reaches, so a
569 128-entry table faults (retail observation) and anything below 134 is a guess.
570
453## 6. Command lists and `CreateCommandList` 571## 6. Command lists and `CreateCommandList`
454 572
455The one measured console command-list rule, quoted from the UMD: 573The one measured console command-list rule, quoted from the UMD:
@@ -675,7 +793,7 @@ evidence.
675| Leonida unknown | Status after SCARAB (and §7.1) | What is actually new | 793| Leonida unknown | Status after SCARAB (and §7.1) | What is actually new |
676|---|---|---| 794|---|---|---|
677| #1 device entry point and 24-word params | **described** | The separate console device export exists at ordinal 13 and is named `D3D12ConsCreateDevice` internally / `D3D12XboxCreateDevice` publicly; the params struct is named `D3D12CONS_CREATE_DEVICE_PARAMETERS`. Public sources name 17 fields and their x64 offsets, plus two more field names; a 24-word block still has at least four words unaccounted (§7.1). | 795| #1 device entry point and 24-word params | **described** | The separate console device export exists at ordinal 13 and is named `D3D12ConsCreateDevice` internally / `D3D12XboxCreateDevice` publicly; the params struct is named `D3D12CONS_CREATE_DEVICE_PARAMETERS`. Public sources name 17 fields and their x64 offsets, plus two more field names; a 24-word block still has at least four words unaccounted (§7.1). |
678| #2 device/heap/queue/command-list slots | **partly measured** | SCARAB has no console slot map. Its appended-after-GCL6 model conflicts with the SDK's GCL8/GCL9 methods (§5.1). Public §7.1 gives the presentation slots (device 78-81, queue 30/32); the heap and command-list slot map is still unknown. Do not use SCARAB as a slot source. | 796| #2 device/heap/queue/command-list slots | **partly measured** | §5.2 measures the arity and receiver of device slots 86, 101, 108, 132 and 133 (86, 101, 108 and 133 match the routes in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 and [retail_boot_chain.md](retail_boot_chain.md) §3.4); offset `+0x418` (131) has no device receiver, so it stays open. SCARAB has no console slot map. Its appended-after-GCL6 model conflicts with the SDK's GCL8/GCL9 methods (§5.1). Public §7.1 gives the presentation slots (device 78-81, queue 30/32); the heap and command-list slot map is still unknown. Do not use SCARAB as a slot source. |
679| #3 root signature → `s0..s31` | **still unknown** | Only flag names (`D3D12CONS_ROOT_SIGNATURE_FLAG_FORCE_MEMORY_BASED_ABI`, `_RAYTRACING`); no mapping. Leonida's own register-based/spill facts already go further. | 797| #3 root signature → `s0..s31` | **still unknown** | Only flag names (`D3D12CONS_ROOT_SIGNATURE_FLAG_FORCE_MEMORY_BASED_ABI`, `_RAYTRACING`); no mapping. Leonida's own register-based/spill facts already go further. |
680| #4 descriptor bytes and increments | **still unknown** | No measured increment. `D3D12CONS_DESCRIPTOR_HEAP_TYPE_SAMPLER_UNBOUNDED` is a new name, not a size. | 798| #4 descriptor bytes and increments | **still unknown** | No measured increment. `D3D12CONS_DESCRIPTOR_HEAP_TYPE_SAMPLER_UNBOUNDED` is a new name, not a size. |
681| #5 VA range / arena capacity | **still unknown** | — | 799| #5 VA range / arena capacity | **still unknown** | — |
@@ -693,8 +811,9 @@ evidence.
693| free-function dispositions | **answered as a list** | 7 standard + 16 console-only; Leonida serves 4 today. | 811| free-function dispositions | **answered as a list** | 7 standard + 16 console-only; Leonida serves 4 today. |
694 812
695The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives 813The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives
696a **name-level map** of the extension surface. It does not close presentation, slots, struct 814a **name-level map** of the extension surface. It does not close presentation, the slot map,
697layouts, numeric flags or tiling. 815struct layouts, numeric flags or tiling; §5.2 adds five device slots to what the game itself
816answers (leaving offset `+0x418` / 131 open with 0 device sites).
698 817
699## 10. Claims that did not hold up 818## 10. Claims that did not hold up
700 819
diff --git a/docs/design.md b/docs/design.md
index eecb1cb84..0a77c2404 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -68,8 +68,12 @@ This writes `reports/exe/` (JSON plus a readable summary). Check it in this orde
68 68
691. **Section entropy.** Sections near 8.0 bits/byte are still encrypted or compressed. If `.text` is one of them, 691. **Section entropy.** Sections near 8.0 bits/byte are still encrypted or compressed. If `.text` is one of them,
70 nothing else can be done yet. 70 nothing else can be done yet.
712. **Import table.** Each DLL is marked `bundled` (in the game folder), `system` (present on this Windows), or 712. **Import table.** Each DLL is marked `bundled` (in the game folder, any case), `system` (present on this Windows),
72 `shim` (needs a reimplementation). The `shim` list is the real to-do list. 72 or `shim` (needs a reimplementation). The `shim` list is the real to-do list. On Linux or macOS, `system` is
73 checked in the Wine prefix's `system32` and its `apisetschema.dll` (`$WINEPREFIX`, else `~/.wine`), so the
74 list matches the Windows one. With no prefix, a DLL that is neither bundled nor owned by the runtime's shims
75 is `system (unverified)` (`"where": "unverified"` in the JSON) and is listed after the to-do. The report's
76 `system_dlls` field says where `system` was checked.
733. **.pdata function count.** This gives function boundaries for patching and later analysis. 773. **.pdata function count.** This gives function boundaries for patching and later analysis.
744. **Inline command-list writes.** `python -I tools/inline_scan.py <game>\game_scarlett_master.exe --sites` (a few 784. **Inline command-list writes.** `python -I tools/inline_scan.py <game>\game_scarlett_master.exe --sites` (a few
75 minutes; it streams `dumpbin /disasm`; it exits 2 when it reads no instructions). "UNCHECKED 0" means every 79 minutes; it streams `dumpbin /disasm`; it exits 2 when it reads no instructions). "UNCHECKED 0" means every
@@ -91,6 +95,17 @@ This writes `reports/exe/` (JSON plus a readable summary). Check it in this orde
91Then `runtime\build\gta6rt.exe --dry-run <exe>` maps the image and binds every import to the shim table without 95Then `runtime\build\gta6rt.exe --dry-run <exe>` maps the image and binds every import to the shim table without
92running any game code. It reports what it couldn't bind. 96running any game code. It reports what it couldn't bind.
93 97
98The PE report's `resources` field (the Markdown's "Resources" section) lists the resource types with entry and
99byte counts and reads the first `RT_VERSION` block. It gives the fixed file info's numbers (`file_version`,
100`product_version`, `flags` and `flag_names`, `os`, `type`, `subtype`, `date`), the `translations`, and per string
101table (`lang_codepage`) each standard key with its value's length (`chars`) and SHA-256 (of the value as UTF-8,
102without its NUL). The values are never written, as they can name the title: two builds compare by hash. A key
103outside the standard names, and a named resource type, are hashed or counted instead. A damaged tree or block
104(cut short, a loop, a bad signature) is listed in `problems` and the rest of the report is still written. stdout
105gets one line per image with a version block: its two versions and its key count. The 1.0.2.1 executable has no
106resource directory (data directory 2 is zero and no `VS_VERSION_INFO` key is anywhere in the file), so its report
107says `none`; 14 of the package's other 16 PE files carry a version block.
108
94## Reproduce the shader tests 109## Reproduce the shader tests
95 110
96Build the hand-written tests where LLVM supports AMDGPU and SPIRV-Tools is available. Run the generated shaders 111Build the hand-written tests where LLVM supports AMDGPU and SPIRV-Tools is available. Run the generated shaders
@@ -418,6 +433,7 @@ How the generated SPIR-V expects the runtime to work:
418| Workgroup memory limit (SHADER-309) | A compute shader's Workgroup variables, the LDS array plus `%x_buf` (the wave64 exchange, 2·L + 6·W + 7 dwords, or the 3 barrier-round counts, which move into the LDS array when they would push the total past 16,384 B: see "Barrier-round count in LDS (SHADER-579)"), must fit in the device's `maxComputeSharedMemorySize`. `spirv-val` does not check device limits, and RADV (Mesa 27.0.0-devel, RX 7600) dies with SIGFPE in `vkCreateComputePipelines` on a module 4 bytes over 64 KiB (#1721, hand-built repro by YaBulochka). The limit differs per device: 65536 on RADV and NVIDIA, 32768 on the AMD Windows driver (RX 9070 XT, 32.0.32029.2010) and Intel (UHD 770, 101.7092), measured by towade in #1745; the Vulkan minimum is 16384. The translator runs offline, so it has two parts. (1) `rdna2spirv.py` keeps every module under a hard cap, `MAX_SHARED_BYTES` (`--max-shared-memory`, default 65536): the LDS array is the program's need (RSRC2 LDS_SIZE, or the end of the furthest constant-offset access, counted exactly from the offset and the access width: a b32 at offset 65,532 ends at 16,384 dwords) rounded up to a power of two; when that plus `%x_buf` is over the cap but the need still fits, the array shrinks to the RSRC2 allocation and its accesses are bounds-checked (below); when the need itself does not fit (a 64 KiB LDS under `--wave64-emulate`) the shader is refused (`Unsupported`, with the byte counts). The array is clipped to 16,384 dwords, but an RSRC2 allocation over the cap (LDS_SIZE above 128 units, so 66,048 B or more) is counted at its full size and refused, native or emulated, instead of being cut. LDS bounds: RDNA2 LDS does not wrap, and an access outside the workgroup's allocation reads 0 and its write is dropped (RDNA2 ISA sections 3.6.1 and 3.6.6). The wrapped power-of-two array aliases such an access onto a valid word, so when a program's constant offsets reach past its RSRC2 allocation, or the array was shrunk, the array is the allocation and `Gen.lds_access` checks every dword (`index < allocation`, else a read or an atomic's old value is 0 and the write or atomic is skipped): `ds_read*`/`ds_write*` of every width (b64/b96/b128 and read2/write2 per dword), the sub-dword reads and writes, every LDS atomic, `ds_cmpst`, `ds_mskor`, `ds_wrxchg*`. `ds_swizzle`/`ds_bpermute`/`ds_permute` do not use `%lds`; `ds_append`/`ds_consume` were already refused. Every other shader keeps the wrapped array and emits no check, as before. **No game shader takes this path.** Counted over a 1.0.2.1 corpus by towade (#1882, counts only), and again at `main` `aa2988cc` by running `translate()` on every CS: with the exact need (offset + access width), none of the 485 LDS-using CS reaches past its RSRC2 allocation with a constant offset, and none is shrunk, natively or with `--wave64-emulate`. So none gets a bounds check (no `OpULessThan` added), and only the synthetic tests below exercise it. The earlier "16 of 486" came from the older offset + 4-dword estimate; at `aa2988cc` that bound flags 37 of the 485, all inside their allocation. Hypothesis, not yet counted over the corpus: the 16 of 486 LDS-using CS that index past LDS_SIZE with constant offsets (the Compute shaders row) now read 0 there, as the ISA says, where they used to read the wrapped word. Counted over a 1.0.2.1 corpus by towade (#1882, counts only): with the exact need (offset + access width) none of the 485 LDS-using CS reaches past its RSRC2 allocation with a constant offset, so none gets a bounds check (no `OpULessThan` added, native or emulated); the "16 of 486" in the Compute shaders row came from the older offset + 4-dword estimate. `%x_buf` is already sized to the workgroup's waves, so it has nothing to give back. `lds_bytes` in `index.json` is the module's whole Workgroup total (LDS, `%x_buf`, a mesh shader's `%ms_counts`). (2) The D3D12 shim's `create_compute` compares `lds_bytes` with the device's `maxComputeSharedMemorySize` and refuses the pipeline with a log line (`E_NOTIMPL`) instead of creating an invalid one. Pinned by `tests/semantic/test_cs_shared_memory_limit.py` (Workgroup bytes counted from the emitted SPIR-V: under the cap unchanged, shrunk to the 51,200 B allocation and bounds-checked, the exact-cap boundary, an access ending at 64 KiB counted exactly, a 64 KiB LDS refused when emulated and accepted natively, a native 66,048 B allocation refused, run through `spirv_mini_interp`: an out-of-range write dropped with the word it would wrap to intact, out-of-range reads (b32, u16) giving 0, a b64 write straddling the allocation's end, out-of-range atomics returning 0 and changing nothing, and an in-range shader with no check; `lds_bytes` equal to the SPIR-V total) and `shader_library_test` (`lds_bytes` read from the index). Confirmed by those CPU tests only; GPU runs (RADV; AMD Windows and Intel at 32 KiB) are pending. Not covered: mesh shaders against `maxMeshSharedMemorySize`. | 433| Workgroup memory limit (SHADER-309) | A compute shader's Workgroup variables, the LDS array plus `%x_buf` (the wave64 exchange, 2·L + 6·W + 7 dwords, or the 3 barrier-round counts, which move into the LDS array when they would push the total past 16,384 B: see "Barrier-round count in LDS (SHADER-579)"), must fit in the device's `maxComputeSharedMemorySize`. `spirv-val` does not check device limits, and RADV (Mesa 27.0.0-devel, RX 7600) dies with SIGFPE in `vkCreateComputePipelines` on a module 4 bytes over 64 KiB (#1721, hand-built repro by YaBulochka). The limit differs per device: 65536 on RADV and NVIDIA, 32768 on the AMD Windows driver (RX 9070 XT, 32.0.32029.2010) and Intel (UHD 770, 101.7092), measured by towade in #1745; the Vulkan minimum is 16384. The translator runs offline, so it has two parts. (1) `rdna2spirv.py` keeps every module under a hard cap, `MAX_SHARED_BYTES` (`--max-shared-memory`, default 65536): the LDS array is the program's need (RSRC2 LDS_SIZE, or the end of the furthest constant-offset access, counted exactly from the offset and the access width: a b32 at offset 65,532 ends at 16,384 dwords) rounded up to a power of two; when that plus `%x_buf` is over the cap but the need still fits, the array shrinks to the RSRC2 allocation and its accesses are bounds-checked (below); when the need itself does not fit (a 64 KiB LDS under `--wave64-emulate`) the shader is refused (`Unsupported`, with the byte counts). The array is clipped to 16,384 dwords, but an RSRC2 allocation over the cap (LDS_SIZE above 128 units, so 66,048 B or more) is counted at its full size and refused, native or emulated, instead of being cut. LDS bounds: RDNA2 LDS does not wrap, and an access outside the workgroup's allocation reads 0 and its write is dropped (RDNA2 ISA sections 3.6.1 and 3.6.6). The wrapped power-of-two array aliases such an access onto a valid word, so when a program's constant offsets reach past its RSRC2 allocation, or the array was shrunk, the array is the allocation and `Gen.lds_access` checks every dword (`index < allocation`, else a read or an atomic's old value is 0 and the write or atomic is skipped): `ds_read*`/`ds_write*` of every width (b64/b96/b128 and read2/write2 per dword), the sub-dword reads and writes, every LDS atomic, `ds_cmpst`, `ds_mskor`, `ds_wrxchg*`. `ds_swizzle`/`ds_bpermute`/`ds_permute` do not use `%lds`; `ds_append`/`ds_consume` were already refused. Every other shader keeps the wrapped array and emits no check, as before. **No game shader takes this path.** Counted over a 1.0.2.1 corpus by towade (#1882, counts only), and again at `main` `aa2988cc` by running `translate()` on every CS: with the exact need (offset + access width), none of the 485 LDS-using CS reaches past its RSRC2 allocation with a constant offset, and none is shrunk, natively or with `--wave64-emulate`. So none gets a bounds check (no `OpULessThan` added), and only the synthetic tests below exercise it. The earlier "16 of 486" came from the older offset + 4-dword estimate; at `aa2988cc` that bound flags 37 of the 485, all inside their allocation. Hypothesis, not yet counted over the corpus: the 16 of 486 LDS-using CS that index past LDS_SIZE with constant offsets (the Compute shaders row) now read 0 there, as the ISA says, where they used to read the wrapped word. Counted over a 1.0.2.1 corpus by towade (#1882, counts only): with the exact need (offset + access width) none of the 485 LDS-using CS reaches past its RSRC2 allocation with a constant offset, so none gets a bounds check (no `OpULessThan` added, native or emulated); the "16 of 486" in the Compute shaders row came from the older offset + 4-dword estimate. `%x_buf` is already sized to the workgroup's waves, so it has nothing to give back. `lds_bytes` in `index.json` is the module's whole Workgroup total (LDS, `%x_buf`, a mesh shader's `%ms_counts`). (2) The D3D12 shim's `create_compute` compares `lds_bytes` with the device's `maxComputeSharedMemorySize` and refuses the pipeline with a log line (`E_NOTIMPL`) instead of creating an invalid one. Pinned by `tests/semantic/test_cs_shared_memory_limit.py` (Workgroup bytes counted from the emitted SPIR-V: under the cap unchanged, shrunk to the 51,200 B allocation and bounds-checked, the exact-cap boundary, an access ending at 64 KiB counted exactly, a 64 KiB LDS refused when emulated and accepted natively, a native 66,048 B allocation refused, run through `spirv_mini_interp`: an out-of-range write dropped with the word it would wrap to intact, out-of-range reads (b32, u16) giving 0, a b64 write straddling the allocation's end, out-of-range atomics returning 0 and changing nothing, and an in-range shader with no check; `lds_bytes` equal to the SPIR-V total) and `shader_library_test` (`lds_bytes` read from the index). Confirmed by those CPU tests only; GPU runs (RADV; AMD Windows and Intel at 32 KiB) are pending. Not covered: mesh shaders against `maxMeshSharedMemorySize`. |
419| Wave64 leading-bit scans | With `--wave64-emulate`, `s_flbit_i32_b32` and `s_flbit_i32` of a lane mask use the same wave-wide exchange as `s_bcnt1` and `s_ff1`. These reads prevent lane-local EXEC-zero folding and require synchronized scheduling in wave-divergent blocks. Plain scalar inputs still allow the fold. Hand-written compute shaders in `tests/semantic/test_wave64_emulate_opt.py` check EXECZ at 64 and 128 threads and a branch on SCC taken by just one wave at 128 threads. The strict CPU workgroup interpreter observes the unsigned scan of VCC_LO = 8 returning 28 in the expected invocations. Both scan forms pass `spirv-val --target-env vulkan1.2`. | 434| Wave64 leading-bit scans | With `--wave64-emulate`, `s_flbit_i32_b32` and `s_flbit_i32` of a lane mask use the same wave-wide exchange as `s_bcnt1` and `s_ff1`. These reads prevent lane-local EXEC-zero folding and require synchronized scheduling in wave-divergent blocks. Plain scalar inputs still allow the fold. Hand-written compute shaders in `tests/semantic/test_wave64_emulate_opt.py` check EXECZ at 64 and 128 threads and a branch on SCC taken by just one wave at 128 threads. The strict CPU workgroup interpreter observes the unsigned scan of VCC_LO = 8 returning 28 in the expected invocations. Both scan forms pass `spirv-val --target-env vulkan1.2`. |
420| Wave64 emulation: scalar exits from a folded EXECZ region | A folded lane-local `s_cbranch_execz`/`execnz` region may leave to its join from inside, for example `s_cmp` + `s_cbranch_scc0/scc1` straight to the label that restores EXEC. The ISA then skips the rest of the region for the whole wave. `find_local_exec_folds` in `tools/wave64_emulate_opt.py` builds the region's sub-CFG with an exit node for every edge to the join, so `cfg_structure.structure` puts each later block of the region behind a `%pc` guard; the exit node itself emits nothing. Before this the edge was dropped and the block after the branch ran whenever the lane was active. Confirmed on the CPU against the native wave64 translation and the ISA: `tests/semantic/test_wave64_emulate_opt.py` `test_folded_region_scalar_branch_to_join_skips_the_rest` (taken and not-taken `scc0`/`scc1`, 64 and 128 threads, the region still folded) fails before the change on the four taken cases. **Not GPU-verified.** | 435| Wave64 emulation: scalar exits from a folded EXECZ region | A folded lane-local `s_cbranch_execz`/`execnz` region may leave to its join from inside, for example `s_cmp` + `s_cbranch_scc0/scc1` straight to the label that restores EXEC. The ISA then skips the rest of the region for the whole wave. `find_local_exec_folds` in `tools/wave64_emulate_opt.py` builds the region's sub-CFG with an exit node for every edge to the join, so `cfg_structure.structure` puts each later block of the region behind a `%pc` guard; the exit node itself emits nothing. Before this the edge was dropped and the block after the branch ran whenever the lane was active. Confirmed on the CPU against the native wave64 translation and the ISA: `tests/semantic/test_wave64_emulate_opt.py` `test_folded_region_scalar_branch_to_join_skips_the_rest` (taken and not-taken `scc0`/`scc1`, 64 and 128 threads, the region still folded) fails before the change on the four taken cases. **Not GPU-verified.** |
436| Wave64 emulation: cross-lane reads of missing lanes | With `--wave64-emulate`, a read of another lane's exchange slot (`ds_swizzle_b32`, `ds_bpermute_b32`, `ds_permute_b32`'s targets and data, `v_readlane_b32`, `v_readfirstlane_b32`, DPP and the other reads behind `Gen.x_round`) gives 0 when the source lane doesn't exist in a partial last wave (`Gen.x_lane_word`: `x_wbase + lane < threads`, else 0), as a source lane that isn't running reads 0 on the hardware. The prologue still zeroes those slots, but a read must not depend on it: RADV (Mesa 26.3.1, gfx1036 iGPU and RX 7900 XTX) compiled the store, barrier and load of an exchange behind a branch into `masked_swizzle_amd` with `fetch_inactive` (`RADV_DEBUG=shaders`), so in a 40-thread group lanes 32-39 of `ds_swizzle_b32 offset:swizzle(SWAP,8)` read the missing lanes' registers, garbage that changed between runs. Workgroups whose size is a multiple of 64 emit the same module as before. Confirmed by `runtime/test/shaders/cs_w64x_partial_swizzle.asm` (40 threads: SWAP 8, BROADCAST 16,15 and `ds_bpermute_b32` from lanes 40-47; its 8 words measured natively on gfx1036 through `tools/hw_oracle`): emulated at subgroup 32 (RADV, Mesa 26.3.1), words 2 and 3 wrong before in 20 of 20 runs on the gfx1036 iGPU and 19 of 20 on the RX 7900 XTX, and all 8 words right in 20 of 20 runs on both after; native wave64 and emulated at subgroup 64 right both times. `scripts/run_gpu_tests.py` runs the partial-wave fixtures emulated at subgroup 32, as `check.py` does, since at RADV's default of 64 this fixture passed before the change too; by `crosslane_fuzz.py --wave 64 --ext --dpp --no-maskdata --programs 1000 --seed 48315`, emulated: on the gfx1036 iGPU 993 match and 7 hyp_only (all 40-thread groups, lanes 32-39 reading a swizzle source of 40-47) before, 1000/1000 after, and on the RX 7900 XTX 995 match and 5 hyp_only before, 1000/1000 after; and by `tests/semantic/test_w64x_partial_swizzle.py` (fixture `w64x_partial_swizzle.asm`, 40 and 104 threads, the prologue's zero stores replaced by a poison word in the workgroup interpreter; both cases fail before the change). |
421| Barycentric fallback (`--bary-fallback`) | For devices without `VK_KHR_fragment_shader_barycentric` (NVIDIA Pascal, for one), and for Mesa ANV's known BaryCoordKHR.i bug (SHADER-925). The raw pair a PS reads comes from an ordinary vec3 input, `%bary`, at the lowest location none of the shader's attributes uses, instead of `BuiltIn BaryCoordKHR`. The module needs neither the `FragmentBarycentricKHR` capability nor the extension, and the index records the location as `bary_fallback_input`. `tools/bary_fallback_gs.py` writes a pass-through geometry shader that supplies (1,0,0), (0,1,0), (0,0,1) at the triangle vertices. GPU-checked on NVIDIA Pascal and Intel Arc B580/Mesa ANV: ANV native `ps_uniform_branch` and `ps_scc_mask32` fail with i=0.0, while the fallback passes and `ps_bary` passes natively. `make_game.py` and `scripts/run_gpu_tests.py` select the fallback automatically for Mesa ANV. `LEONIDA_BARY_FALLBACK=1` forces fallback and `LEONIDA_BARY_FALLBACK=0` forces native barycentrics consistently in both entry points; explicit `--bary-fallback` also forces the fallback in `make_game.py`. The standalone `build.py`/`check.py` path follows the same variable/probe rule. Checked in `tests/semantic/test_bary_fallback.py` and the builder/runner wiring tests. | 437| Barycentric fallback (`--bary-fallback`) | For devices without `VK_KHR_fragment_shader_barycentric` (NVIDIA Pascal, for one), and for Mesa ANV's known BaryCoordKHR.i bug (SHADER-925). The raw pair a PS reads comes from an ordinary vec3 input, `%bary`, at the lowest location none of the shader's attributes uses, instead of `BuiltIn BaryCoordKHR`. The module needs neither the `FragmentBarycentricKHR` capability nor the extension, and the index records the location as `bary_fallback_input`. `tools/bary_fallback_gs.py` writes a pass-through geometry shader that supplies (1,0,0), (0,1,0), (0,0,1) at the triangle vertices. GPU-checked on NVIDIA Pascal and Intel Arc B580/Mesa ANV: ANV native `ps_uniform_branch` and `ps_scc_mask32` fail with i=0.0, while the fallback passes and `ps_bary` passes natively. `make_game.py` and `scripts/run_gpu_tests.py` select the fallback automatically for Mesa ANV. `LEONIDA_BARY_FALLBACK=1` forces fallback and `LEONIDA_BARY_FALLBACK=0` forces native barycentrics consistently in both entry points; explicit `--bary-fallback` also forces the fallback in `make_game.py`. The standalone `build.py`/`check.py` path follows the same variable/probe rule. Checked in `tests/semantic/test_bary_fallback.py` and the builder/runner wiring tests. |
422| Metadata index | `spirv/index.json`: one entry per translated shader with its stage, `wave64` / `subgroup_size`, SPIR-V capabilities and extensions, the Vulkan **features** to enable (barycentrics, interlock, mesh, geometry, Float64, Int64, buffer device address, write-without-format, `shaderFmaFloat32` for `--fma khr`, …), `needs_maintenance8`, the descriptor bindings it uses (set 0), push-constant size, `local_size`, `user_sgprs` (CS), `lds_bytes`, mesh `max_vertices`/`max_primitives`/`params`, geometry inputs/outputs, vertex-input locations and types, full `vertex_input_signature` (ISG1 register/mask/system-value/component-type, for PSO lookup), `wave64_emulated` (true for VS/PS/GS wave64, which the translator emits as per-subgroup code with no cross-half exchange, and for compute/mesh translated with `--wave64-emulate`; the runtime does not use it: it reads `wave64`, `subgroup_size` and `wave64_exchange`), `dynamic_format` (runtime V# FORMAT: codes outside FORMATS decode to 0) / `fixed_format_codes`, `src_sha256` and optional `fssm_sha256` (via `--fssm-dir`), PS system inputs, `bary_fallback_input` (`--bary-fallback`: the location of the barycentric input), `mesh_compute` (`--mesh-compute`: the slot layout and push-constant size), `pc_tail` (`--pc-tail-ubo`: the set, binding and size of the uniform block that holds the push-constant tail), and input/output locations. A shader translated with `--wave64-emulate` carries `wave64_exchange: "workgroup"` and `subgroup_size: null`: any subgroup size is exact, request none. Otherwise `subgroup_size` (64 for wave64, 32) is what the PSO asks for through `VkPipelineShaderStageRequiredSubgroupSizeCreateInfo` where the device lists the stage in `requiredSubgroupSizeStages` (docs/d3d12_vulkan.md section 3.2): that list is the driver's, not "compute/mesh only". The AMD Windows driver reports FRAGMENT, COMPUTE, TASK and MESH (measured on a Radeon 880M, driver 26.11.2, sizes 32..64), and current Mesa RADV on GFX10+ reports COMPUTE, FRAGMENT and task/mesh (`src/amd/vulkan/radv_physical_device.c`, `requiredSubgroupSizeStages`, Mesa main at 152b9cde; older Mesa: compute only), so wave64 pixel shaders can run exact there. NVIDIA lists every stage but only size 32, so there a native wave64 shader cannot get 64 and wave64 PS/VS/GS stay 2x32. A runtime can create every pipeline at load time from it without parsing SPIR-V. | 438| Metadata index | `spirv/index.json`: one entry per translated shader with its stage, `wave64` / `subgroup_size`, SPIR-V capabilities and extensions, the Vulkan **features** to enable (barycentrics, interlock, mesh, geometry, Float64, Int64, buffer device address, write-without-format, `shaderFmaFloat32` for `--fma khr`, …), `needs_maintenance8`, the descriptor bindings it uses (set 0), push-constant size, `local_size`, `user_sgprs` (CS), `lds_bytes`, mesh `max_vertices`/`max_primitives`/`params`, geometry inputs/outputs, vertex-input locations and types, full `vertex_input_signature` (ISG1 register/mask/system-value/component-type, for PSO lookup), `wave64_emulated` (true for VS/PS/GS wave64, which the translator emits as per-subgroup code with no cross-half exchange, and for compute/mesh translated with `--wave64-emulate`; the runtime does not use it: it reads `wave64`, `subgroup_size` and `wave64_exchange`), `dynamic_format` (runtime V# FORMAT: codes outside FORMATS decode to 0) / `fixed_format_codes`, `src_sha256` and optional `fssm_sha256` (via `--fssm-dir`), PS system inputs, `bary_fallback_input` (`--bary-fallback`: the location of the barycentric input), `mesh_compute` (`--mesh-compute`: the slot layout and push-constant size), `pc_tail` (`--pc-tail-ubo`: the set, binding and size of the uniform block that holds the push-constant tail), and input/output locations. A shader translated with `--wave64-emulate` carries `wave64_exchange: "workgroup"` and `subgroup_size: null`: any subgroup size is exact, request none. Otherwise `subgroup_size` (64 for wave64, 32) is what the PSO asks for through `VkPipelineShaderStageRequiredSubgroupSizeCreateInfo` where the device lists the stage in `requiredSubgroupSizeStages` (docs/d3d12_vulkan.md section 3.2): that list is the driver's, not "compute/mesh only". The AMD Windows driver reports FRAGMENT, COMPUTE, TASK and MESH (measured on a Radeon 880M, driver 26.11.2, sizes 32..64), and current Mesa RADV on GFX10+ reports COMPUTE, FRAGMENT and task/mesh (`src/amd/vulkan/radv_physical_device.c`, `requiredSubgroupSizeStages`, Mesa main at 152b9cde; older Mesa: compute only), so wave64 pixel shaders can run exact there. NVIDIA lists every stage but only size 32, so there a native wave64 shader cannot get 64 and wave64 PS/VS/GS stay 2x32. A runtime can create every pipeline at load time from it without parsing SPIR-V. |
423| Full-corpus pipeline build | `vk_pipeline_check <spirv dir> pipeline_cache.bin --jobs 4` on an RTX 4060 Ti (NVIDIA 595 driver): **all 26,503 shaders become real pipelines, 0 failures** (cs 2,689, ps 12,101, ms 9,282, vs 2,236, gs 195; graphics stages with generated stub partners). Compile time 40,784 s of CPU (2.84 h wall on 4 threads): cs 23,633 s (mean 8.8 s; the ray-tracing ScreenProbes/RTShadowTrace shaders take 2-19 min each), ps 11,481 s, ms 5,395 s, vs 275 s. The resulting `VkPipelineCache` is 3.81 GB; seeding a run with it makes those pipelines instant, which is what a fast first boot needs. The cache is per driver and GPU, and a shader whose SPIR-V changes compiles again (the checker resumes from the file). Neither register storage (one variable per register) nor smaller SPIR-V cut NVIDIA compile time: the big ray-tracing shaders are expensive as such, so the runtime should compile them in the background rather than block on them. | 439| Full-corpus pipeline build | `vk_pipeline_check <spirv dir> pipeline_cache.bin --jobs 4` on an RTX 4060 Ti (NVIDIA 595 driver): **all 26,503 shaders become real pipelines, 0 failures** (cs 2,689, ps 12,101, ms 9,282, vs 2,236, gs 195; graphics stages with generated stub partners). Compile time 40,784 s of CPU (2.84 h wall on 4 threads): cs 23,633 s (mean 8.8 s; the ray-tracing ScreenProbes/RTShadowTrace shaders take 2-19 min each), ps 11,481 s, ms 5,395 s, vs 275 s. The resulting `VkPipelineCache` is 3.81 GB; seeding a run with it makes those pipelines instant, which is what a fast first boot needs. The cache is per driver and GPU, and a shader whose SPIR-V changes compiles again (the checker resumes from the file). Neither register storage (one variable per register) nor smaller SPIR-V cut NVIDIA compile time: the big ray-tracing shaders are expensive as such, so the runtime should compile them in the background rather than block on them. |
@@ -516,7 +532,7 @@ How the generated SPIR-V expects the runtime to work:
516| Whole-quad mode (`s_wqm_b64` / `s_wqm_b32`) | A lane mask register holds only this lane's bit, so WQM on one (EXEC, VCC, an SGPR the mask analysis found) ORs the bit of the lane's quad, lanes 4n..4n+3 of the wave: two `OpGroupNonUniformQuadSwap` (horizontal, then vertical; capability `GroupNonUniformQuad`) in the default mode in fragment and compute shaders (quad operations are only guaranteed there; vertex, geometry and mesh shaders shuffle from the quad's four lanes), or the four lanes' values read through `%x_buf` under `--wave64-emulate` (no subgroup operation there). A quad never crosses lane 31/32, so the mask bits are exact per half on a 32-wide subgroup; SCC is a wave vote, so on wave64 it needs a 64-wide subgroup or `--wave64-emulate` (as every wave-wide mask op). The result goes to EXEC, VCC or an SGPR pair as a mask, SCC = the wave-wide any of it (same vote as the other mask ops). A 32-bit form in wave64 (`exec_lo`/`exec_hi`, `vcc_lo`/`vcc_hi`, a half-mask SGPR) writes only its own half (`exec_half_write`) and votes SCC over that half only (`cs_wqm_w64_half`). A source that is not a lane mask (a value loaded from memory, a literal) is data: `((x \| x>>1 \| x>>2 \| x>>3) & 0x11111111) * 15` per 32-bit word and SCC = result != 0, no subgroup operation. Assumptions: in compute and mesh shaders the subgroup lane is `LocalInvocationIndex` mod the subgroup size (as for every cross-lane op); a hardware quad is four consecutive lanes of a wave, and in a pixel shader Vulkan's quad (the 2x2 pixels, helper invocations included) is the same four lanes; GPU-checked on both AMD and NVIDIA with `ps_wqm.asm` (every 2x2 block of a 64x64 target, fully covered). **Helper lanes at a triangle edge, measured on RDNA2** (gfx1036, wave64, raw ISA through `tools/ps_oracle.py` on RADV; `tools/ps_helper_probe.py`, docs/shader_validation.md): a pixel wave's entry EXEC is exactly its covered pixels (helpers off); `s_wqm_b64 exec, exec` turns on exactly the quads with a covered pixel, which are packed from lane 0 (a quad with no covered pixel isn't in the wave); lane % 4 = (x & 1) + 2 (y & 1), so lanes 0-3 are top-left, top-right, bottom-left, bottom-right; a helper's `v_interp` gives its own pixel centre (extrapolated, as precisely as a covered pixel), and its v0/v1 hold its own I/J before `s_wqm` too; without `s_wqm` its VGPRs aren't written; an `exp ... vm` with helpers on in EXEC writes no pixel outside the triangle. Not covered: helper-invocation behaviour at triangle edges is untested, and in native mode an absent invocation in a partial quad (a compute group whose size is not a multiple of 4) gives an undefined value (emulated, the missing lanes of a partial wave read as 0). Before this the instruction was the identity, so helper lanes stayed off (#156 SHADER-34: `s_wqm_b64` appears in 4,285 pixel shaders). GPU-checked with `runtime/test/shaders/cs_wqm_w64.asm`, `cs_wqm_w64_half.asm`, `cs_wqm_w32.asm` and `ps_wqm.asm` on AMD Radeon 880M (subgroup 64) and NVIDIA GeForce RTX 5070 Laptop (subgroup 32; `cs_wqm_w64` there needs `LEONIDA_W64_EMULATE=1`), with and without `--wave64-emulate`. | 532| Whole-quad mode (`s_wqm_b64` / `s_wqm_b32`) | A lane mask register holds only this lane's bit, so WQM on one (EXEC, VCC, an SGPR the mask analysis found) ORs the bit of the lane's quad, lanes 4n..4n+3 of the wave: two `OpGroupNonUniformQuadSwap` (horizontal, then vertical; capability `GroupNonUniformQuad`) in the default mode in fragment and compute shaders (quad operations are only guaranteed there; vertex, geometry and mesh shaders shuffle from the quad's four lanes), or the four lanes' values read through `%x_buf` under `--wave64-emulate` (no subgroup operation there). A quad never crosses lane 31/32, so the mask bits are exact per half on a 32-wide subgroup; SCC is a wave vote, so on wave64 it needs a 64-wide subgroup or `--wave64-emulate` (as every wave-wide mask op). The result goes to EXEC, VCC or an SGPR pair as a mask, SCC = the wave-wide any of it (same vote as the other mask ops). A 32-bit form in wave64 (`exec_lo`/`exec_hi`, `vcc_lo`/`vcc_hi`, a half-mask SGPR) writes only its own half (`exec_half_write`) and votes SCC over that half only (`cs_wqm_w64_half`). A source that is not a lane mask (a value loaded from memory, a literal) is data: `((x \| x>>1 \| x>>2 \| x>>3) & 0x11111111) * 15` per 32-bit word and SCC = result != 0, no subgroup operation. Assumptions: in compute and mesh shaders the subgroup lane is `LocalInvocationIndex` mod the subgroup size (as for every cross-lane op); a hardware quad is four consecutive lanes of a wave, and in a pixel shader Vulkan's quad (the 2x2 pixels, helper invocations included) is the same four lanes; GPU-checked on both AMD and NVIDIA with `ps_wqm.asm` (every 2x2 block of a 64x64 target, fully covered). **Helper lanes at a triangle edge, measured on RDNA2** (gfx1036, wave64, raw ISA through `tools/ps_oracle.py` on RADV; `tools/ps_helper_probe.py`, docs/shader_validation.md): a pixel wave's entry EXEC is exactly its covered pixels (helpers off); `s_wqm_b64 exec, exec` turns on exactly the quads with a covered pixel, which are packed from lane 0 (a quad with no covered pixel isn't in the wave); lane % 4 = (x & 1) + 2 (y & 1), so lanes 0-3 are top-left, top-right, bottom-left, bottom-right; a helper's `v_interp` gives its own pixel centre (extrapolated, as precisely as a covered pixel), and its v0/v1 hold its own I/J before `s_wqm` too; without `s_wqm` its VGPRs aren't written; an `exp ... vm` with helpers on in EXEC writes no pixel outside the triangle. Not covered: helper-invocation behaviour at triangle edges is untested, and in native mode an absent invocation in a partial quad (a compute group whose size is not a multiple of 4) gives an undefined value (emulated, the missing lanes of a partial wave read as 0). Before this the instruction was the identity, so helper lanes stayed off (#156 SHADER-34: `s_wqm_b64` appears in 4,285 pixel shaders). GPU-checked with `runtime/test/shaders/cs_wqm_w64.asm`, `cs_wqm_w64_half.asm`, `cs_wqm_w32.asm` and `ps_wqm.asm` on AMD Radeon 880M (subgroup 64) and NVIDIA GeForce RTX 5070 Laptop (subgroup 32; `cs_wqm_w64` there needs `LEONIDA_W64_EMULATE=1`), with and without `--wave64-emulate`. |
517| `buffer_atomic_{and,or,xor,swap}_x2` | `M = op(M, DATA)` on the 64-bit element at the MUBUF address (two dwords, low first); with `glc` the old 64 bits are returned in `vdata[0:1]`. A bitwise op or an exchange leaves the same memory done one dword at a time, so each dword is its own 32-bit `OpAtomic*` and no Int64 atomics are needed. **Approximation:** the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done. Each dword is its own 32-bit `OpAtomic*`, so no Int64 atomics are needed; a bitwise op leaves the same memory that way, since its bits are independent. **Approximation:** an exchange can tear, since two lanes swapping into one element at once can leave one's low dword with the other's high dword (A.lo, B.lo, B.hi, A.hi), and the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done. **Bounds:** the check covers the whole 8-byte element, all or nothing, as for a typed 32_32 element (`buffer_address(elem="fmt")`). An out-of-range or inactive lane leaves memory alone and returns 0, as `buffer_atomic` does. How hardware treats a 64-bit atomic that is only partly in range is **not measured**. Still `Unsupported`: `add/sub/min/max_x2` and `cmpswap_x2`. Until 2026-11-22 every `_x2` buffer atomic was rejected. CPU-checked by `tests/semantic/test_buffer_atomics_x2.py` (the four ops with and without `glc`, an element ending exactly at `num_records`, half and fully out of range, seeded values, rejected forms). **Not GPU-verified.** | 533| `buffer_atomic_{and,or,xor,swap}_x2` | `M = op(M, DATA)` on the 64-bit element at the MUBUF address (two dwords, low first); with `glc` the old 64 bits are returned in `vdata[0:1]`. A bitwise op or an exchange leaves the same memory done one dword at a time, so each dword is its own 32-bit `OpAtomic*` and no Int64 atomics are needed. **Approximation:** the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done. Each dword is its own 32-bit `OpAtomic*`, so no Int64 atomics are needed; a bitwise op leaves the same memory that way, since its bits are independent. **Approximation:** an exchange can tear, since two lanes swapping into one element at once can leave one's low dword with the other's high dword (A.lo, B.lo, B.hi, A.hi), and the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done. **Bounds:** the check covers the whole 8-byte element, all or nothing, as for a typed 32_32 element (`buffer_address(elem="fmt")`). An out-of-range or inactive lane leaves memory alone and returns 0, as `buffer_atomic` does. How hardware treats a 64-bit atomic that is only partly in range is **not measured**. Still `Unsupported`: `add/sub/min/max_x2` and `cmpswap_x2`. Until 2026-11-22 every `_x2` buffer atomic was rejected. CPU-checked by `tests/semantic/test_buffer_atomics_x2.py` (the four ops with and without `glc`, an element ending exactly at `num_records`, half and fully out of range, seeded values, rejected forms). **Not GPU-verified.** |
518| Per-lane descriptor selection | The translator executes the first-active-lane read, EXEC selection, scalar descriptor load and remaining-lane retry as ordinary wave instructions. The hand-written `waterfall_table_offset.asm` fixture reads four different buffers and checks every lane on wave32, native wave64 and emulated wave64. The graphics partition analysis accepts an unmodified full-word integer equality as evidence that selected lanes hold the first lane's word. A float comparison accepts both signs of zero. The signed-zero execution fixture produces different raw outputs when a 64-lane group is split and therefore requires tier C. See Marvis's VIctory waterfall analysis (b1c8306, ffe310e) for the distinction between comparing descriptor words and comparing the offset of a descriptor load. | 534| Per-lane descriptor selection | The translator executes the first-active-lane read, EXEC selection, scalar descriptor load and remaining-lane retry as ordinary wave instructions. The hand-written `waterfall_table_offset.asm` fixture reads four different buffers and checks every lane on wave32, native wave64 and emulated wave64. The graphics partition analysis accepts an unmodified full-word integer equality as evidence that selected lanes hold the first lane's word. A float comparison accepts both signs of zero. The signed-zero execution fixture produces different raw outputs when a 64-lane group is split and therefore requires tier C. See Marvis's VIctory waterfall analysis (b1c8306, ffe310e) for the distinction between comparing descriptor words and comparing the offset of a descriptor load. |
519| Wave64 graphics: partition invariance (SHADER-10) | A wave64 VS/PS/GS on a 32-wide subgroup is exact **iff its observable results do not change when the wave is cut into two 32-lane halves** (the host forms the subgroups of graphics stages, so there is no partner half to exchange with). `tools/wave64_halves.py` decides it from the code (forward taint dataflow over the basic blocks, plus control dependence on wave-wide votes) and the translator records it in `index.json` as `wave64_graphics` (`A`/`B`/`C`), `wave64_graphics_reasons` (tier C) and `wave64_graphics_idioms` (tier B). **A**: only per-lane arithmetic, votes that skip lane-masked work (`s_cbranch_execz/execnz`; `vccz/vccnz` whose run side starts by narrowing EXEC to that VCC and whose other side is the join, with no code of its own: a half that votes no runs that side, the wave does not; the same holds for `s_cbranch_execz/execnz`: the side that runs when EXEC is zero is taken by a half with no active lane, so it must be the join (or only jumps to it) or the exit of a loop the vote closes, else tier C `unsafe-execz-branch`; `s_cbranch_scc*` after a vote is the same kind of skip, any other reader of that SCC, `s_cselect`/`s_cmov`/`s_addc`, is tier C; a vote is on the mask register's value when it was taken, so a new value in that register before the branch (`v_cmp` into the pair or VCC, `s_mov_b64`, `s_cselect_b64`: none of them writes SCC) ends it, and the branch is judged as a plain SCC branch, SHADER-820), whole-quad masks, `ds_bpermute`/`ds_permute`/`v_permlane16`/`v_permlanex16`/`ds_swizzle` (they stay inside a half), a `ds_bpermute`/`ds_permute` address made from the lane id (`v_mbcnt_lo` then `v_mbcnt_hi` of -1) when it is the same modulo 128 bytes in the wave and in a half (the id is 0..63 there and 0..31 here, equal modulo 32 lanes; sums, differences and bitwise ops with invariant values keep that, a left shift by c multiplies the modulus by 2^c, and the permute uses address bits 2..6 of its half only: `(id ^ 1) << 2` is exact, `id << 1`, a right shift of the id or the low count alone stay tier C `lane-id`), loops closed by `execnz` with no scalar state carried, and the early exit of a pixel kill: `s_cbranch_scc0/scc1` (or `vccz/vccnz`) on a lane mask's own "not empty" (the last SCC writer is a 64-bit logic op into that mask, e.g. `s_andn2_b64 live, live, exec`, or `s_cmp_lg_u64 mask, 0`, and nothing rewrites the mask before the branch) to a block that only sets EXEC from that mask or 0 (`s_mov_b64 exec`, or `s_and_b64 exec` with it), may then export with that EXEC (an export is allowed, not required), and ends (no other code, store or successor), while the run side narrows EXEC into the mask's whole quads before anything but mask arithmetic (`s_mov_b64`, `s_and_b64`, `s_wqm_b64`) runs, the narrowing itself possibly an `s_and_saveexec_b64` / `s_andn2_saveexec_b64` (or `_wrexec_`) whose source is inside, and keeps it inside on every path from there, loops included (a must-dataflow: an EXEC write keeps it inside only when it is provably a subset: `v_cmpx`, `s_and_b64` with one operand known inside, `s_andn2_b64` / `s_andn2_saveexec_b64` whose first operand is, `s_and_saveexec_b64` while inside or from one that is, `s_andn1`/`s_or`/`s_xor_saveexec_b64` only while inside (the latter two also from one that is), and copies, `s_wqm_b64`, `s_or_b64` and `s_xor_b64` of operands known to be inside (0 counts as inside); a saveexec destination holds the old EXEC and a wrexec one the new, each inside only if that EXEC was), and no `exp ... vm` can run before the vote. A half whose mask is empty then writes nothing and discards its pixels in the exit, and in the wave its lanes are off to the end, so the wave discards them too; an exit shared by several kills reads a mask redefined behind the earlier votes and stays tier C. GPU-checked by `ps_w64_a_discard` (below). `s_cbranch_scc*` after a vote is the same kind of skip, any other reader of that SCC, `s_cselect`/`s_cmov`/`s_addc`, is tier C; a vote is on the mask register's value when it was taken, so a new value in that register before the branch (`v_cmp` into the pair or VCC, `s_mov_b64`, `s_cselect_b64`: none of them writes SCC) ends it, and the branch is judged as a plain SCC branch, SHADER-820), whole-quad masks, `ds_bpermute`/`v_permlane16` (they stay inside a half, not GPU-tested here: no fixture; `s_cbranch_scc*` after a vote is the same kind of skip, any other reader of that SCC, `s_cselect`/`s_cmov`/`s_addc`, is tier C), whole-quad masks, `ds_bpermute`/`v_permlane16` (they stay inside a half, not GPU-tested here: no fixture; `ds_swizzle` and `v_permlanex16` likewise; GPU-checked at required 64 and 32 lanes by `ps_w64_a_bpermute`, `ps_w64_a_permlane` (`v_permlane16` and `v_permlanex16`) and `ps_w64_a_swizzle` in `w64_graphics.py`, TEST-433), loops closed by `execnz` with no scalar state carried. `ds_swizzle` and `v_permlanex16` likewise), loops closed by `execnz` with no scalar state carried. A `vccz`/`vccnz` on a wave-uniform compare is no lane vote and is tier A too: a `v_cmp` made while EXEC is the launch mask from untainted immediates, scalars that are no lane mask and VGPRs written from them (optionally ANDed with EXEC, the LLVM form `s_and_b64 vcc, exec, s[..]`) gives every launch lane or none, so each half votes as the wave does and both sides may have code and scalars of their own (if/else, a uniform loop back edge; the mask itself read as data, e.g. exported, is still tier C `cross-lane`), while the same compare under a narrowed EXEC (a half with no active lane votes no and keeps its own scalars) or on a tainted value (`v_readfirstlane` of a varying VGPR, a lane count, an AND with a lane mask) stays tier C; confirmed on the wave interpreter (`UniformVote` in `tests/semantic/test_wave64_halves.py`: 64 lanes against two waves of 32, equal for the accepted forms with s4 = 9 and s4 = 1, different for each near miss) and by `ps_w64_a_uniform_vote`, which gives its derived words on an NVIDIA GeForce RTX 5080 (Linux, driver 580.65.06, 32 only). **B**: also a waterfall loop (`v_readfirstlane` of a varying value, `v_cmp_eq` against the same VGPR, `saveexec`, body, `s_xor exec`, `execnz`; the scalar only used inside the body), a wave-aggregated atomic (`s_bcnt1` of EXEC, `v_mbcnt` rank of that same EXEC, one `buffer_atomic_add` of that count (the count of the mask the rank ranks) by the rank-0 lane only, at a wave-uniform address (a uniform VGPR, or one the elected lane wrote from scalars and constants since EXEC last changed; a per-lane address such as a pixel coordinate is tier C `elected-lane`, since each half elects its own lane and bumps another counter), `v_readfirstlane` of the result with EXEC restored, base + rank as a store address, the rank counting the very mask the atomic's count was taken of (a rank of the entry EXEC or of a saved copy next to a base of the narrowed one is tier C `lane-rank`); the rank alone or the base alone is not a slot: exact as a set of slots, **the order of the slots within a wave is not preserved**, a 64-lane wave takes one run of slots, two halves take two), `v_readfirstlane` / `v_readlane` of a VGPR written from scalars and constants while EXEC was the launch mask (the same in every lane), a `v_writelane` / `v_readlane` spill pair on one constant lane below 32. **C**: anything else that reaches an export, a store's data, a branch or EXEC: lane count / rank / first-lane index / raw lane id (`v_mbcnt` of -1), `v_readlane` of a varying value at any lane (on a wave64 every lane gets hardware lane N, in halves each half gets its own lane N, so lane 7 is as wrong as lane 40; the research note's row 9 is too generous here); an analysis failure is tier C with reason `analysis-error` (the translation does not fail), `v_writelane` to a non-constant or >= 32 lane, a 32-bit access to half of a lane mask (`exec_hi`, `vcc_hi`, a mask pair's odd register), a mask read as data (including a mask combined by `s_and/or/andn2_b64` with a register that is not one: a user value, a loaded mask), a scalar defined behind a wave-wide vote and read where it may not have run (`s_add s5, s5, 1` after `s_cbranch_vccz`; a trip count in an SGPR of a divergent loop: the halves vote differently), a branch on a count, an elected-lane side effect that is not a count, `ds_append`/`ds_consume`. The check is conservative: unknown means C. `--wave64-graphics=warn` (default) marks tier C and counts it in the summary line, `error` refuses it (`Unsupported`), `off` skips the analysis; `python tools/wave64_halves.py --census <spirv>/index.json` prints tier, reason and idiom counts (no names); it complements `tools/wave64_graphics_scan.py` (#1132), which counts candidate cross-half opcodes in the disassembly before translation and decides nothing. **Corpus census** (1.0.2.1, all 26,503 shaders translated at `main` `f847748c` with `--wave64-emulate`, `--census` over that index): 13,405 wave64 graphics shaders (2,236 VS, 10,974 PS, 195 GS, the FSSM header's wave size, see *Wave size*); tier A 4,033 (30.1%), B 85 (0.6%), C 9,287 (69.3%): VS 1,455/79/702, PS 2,383/6/8,585, GS 195/0/0. Tier C reasons (a shader can have several): unsafe-vote-branch 8,285, tainted-branch 6,547, tainted-exec 5,189, cross-lane 4,764, stale-scalar 3,415, mask-half 759, unsafe-execz-branch 583, first-lane 353, waterfall-scalar 161, lane-id 152, lane-count 1. Idiom tags, counted on every shader that carries one whatever its tier (`--census` prints them as "tier B idioms"; 85 shaders are tier B): readfirstlane-uniform 626, lane-spill 287, waterfall 35. (Earlier censuses counted 11,405 shaders, from when the wave size came from code markers: TEST-319 had A 1,919, B 17, C 9,469 with all 195 GS in C; its re-run with the GS ring rule below and #1982 had A 2,117, B 17, C 9,271 with all 195 GS in A.) The lane-id bpermute rule moves no corpus shader. (The TEST-319 census, from when the wave size came from code markers and before the GS ring-address rule below, counted 11,405 shaders: A 1,919, B 17, C 9,469, with all 195 GS in C.) The lane-id bpermute rule moves no corpus shader. **Corpus census** (TEST-319, 1.0.2.1, `--census` over the translated index, re-run with the GS ring rule below and #1982): 11,405 wave64 graphics shaders (1,179 VS, 10,031 PS, 195 GS); tier A 2,117 (18.6%), B 17 (0.1%), C 9,271 (81.3%): VS 479/14/686, PS 1,443/3/8,585, GS 195/0/0. Tier C reasons (a shader can have several): unsafe-vote-branch 8,285, tainted-branch 6,550, tainted-exec 5,189, cross-lane 4,760, stale-scalar 3,415, mask-half 758, unsafe-execz-branch 583, first-lane 353, waterfall-scalar 161, lane-id 152, lane-count 1. 11,405 wave64 graphics shaders (1,179 VS, 10,031 PS, 195 GS); tier A 1,919 (16.8%), B 17 (0.1%), C 9,469 (83.0%): VS 465/14/700, PS 1,454/3/8,574, GS 0/0/195. Tier C reasons (a shader can have several): unsafe-vote-branch 8,175, tainted-branch 6,582, cross-lane 6,111, tainted-exec 4,959, stale-scalar 3,162, mask-half 758, unsafe-execz-branch 583, first-lane 353, lane-id 277, waterfall-scalar 167, lane-count 1. Tier B idioms: readfirstlane-uniform 558, lane-spill 287, waterfall 35. The lane-id bpermute rule moves no corpus shader. **Corpus coverage is not measured here**: it needs a run over the game's shaders by someone who has them. **Rewrite (the only one the emission needs)**: `v_readlane_b32` of a proven-uniform VGPR reads the lane's own copy instead of shuffling from lane N, because a subgroup shuffle from lane >= 32 of a 32-wide subgroup is undefined (143 of 144 test shaders translate byte-identically to origin/main, only `ps_w64_b_readlane_uniform` changed). Everything else tier B needs is what the translator already emits per subgroup: the ballot/count/rank/first-lane words of `wave_mask` are the subgroup's own (the high word is 0), `v_readfirstlane` is the subgroup's first active lane, a waterfall runs once per distinct value of the subgroup. GPU-checked on AMD Radeon 880M (driver 26.11.2; `requiredSubgroupSizeStages` has FRAGMENT, size 32..64) with `runtime/test/shaders/w64_graphics.py`: each `ps_w64_*` fixture drawn with the fragment subgroup size required to 64 (one hardware wave) and to 32 (two halves). `ps_w64_a_skip`, `_b_waterfall`, `_b_readfirstlane`, `_b_readlane_uniform` and `_b_ballot_atomic` (counter 1024 and the 1024 slot words as a set; slot order differs) match each other and the words their headers derive; `_c_bcnt_export`, `_c_lane_id`, `_c_readlane`, `_c_vote_stale`, `_c_vote_else`, `_c_scc_vote`, `_c_execz_sgpr` (an SGPR written on the exec-zero side and exported) and `_c_waterfall_count` differ between 64 and 32 (the detector is right). `ps_w64_a_one_lane` is the case where only one pixel votes yes (so one half votes and the other does not, in the wave and in the halves): its skip regions (`execz`, `vccz`, `vccnz` with a jump-only fall-through) give equal images at 64 and 32; `_c_vote_else` (code on the vote's no side) and `_c_scc_vote` (SCC of a vote as data) differ. `ps_w64_a_discard` (three kills, two of them dropping whole regions so that some halves lose every pixel while the other half of their wave lives) was drawn on an AMD Radeon RX 580 (RADV, Mesa 26.0.8, required size 64, saved with `W64G_SAVE_REF`) and an NVIDIA GeForce RTX 5070 (32 only, driver 620.73.04, compared with `W64G_REF`): both equal the derived words, discarded pixels keeping the clear value, and each other. NVIDIA GeForce RTX 5070 Laptop (32 only, driver 617.42): tier A/B fixtures equal the derived words and the 880M@64 images (`W64G_SAVE_REF` / `W64G_REF`), tier C fixtures differ from the 880M@64 images. `ps_w64_a_permlane`, `_a_swizzle` and `_a_bpermute` (TEST-319: permlane16 neighbour selects, permlanex16 there and back, swizzle quad-permute, swap and broadcast modes, bpermute from lane-id addresses; every read stays in the pixel's 2x2 quad or comes back, so the words do not depend on how pixels are packed into lanes) give the derived words on an NVIDIA GeForce RTX 5070 (Linux, driver 620.73.04, 32 only). With an AMD Radeon RX 580 (Polaris, RADV Mesa 26.0.8) as the 64-lane reference (`W64G_SAVE_REF`; GCN has one subgroup size, 64, in every stage but no FRAGMENT in `requiredSubgroupSizeStages`, so `vk_harness` counts a requested size equal to a device's only size as applied), the RTX 5070 run of every fixture (`W64G_REF`) equals the reference for all 13 tier A/B fixtures and differs from it for all 11 tier C ones, pixel and vertex; the same reads in a vertex shader run on the wave interpreter (64 lanes against two waves of 32, equal) because a GPU's partial vertex waves leave the lanes they would read empty. Vertex shaders: the VS stage cannot be forced on the 880M (no VERTEX in `requiredSubgroupSizeStages`), so VS is covered by the strict wave interpreter (`tests/semantic/test_wave64_halves.py`: 64 lanes against two waves of 32; tier A/B equal, tier C differs); geometry shaders are not tested (the corpus ones are wave64, see *Wave size*; no fixture). 64 lanes against two waves of 32; tier A/B equal, tier C differs), and on RADV also on the GPU (TEST-251): RADV runs the VS stage (NGG) as wave64 by default and as wave32 with `RADV_PERFTEST=gewave32` (GFX10+, seen in the `RADV_DEBUG=shaders` dump: 64-bit EXEC operations against `exec_lo`), so `w64_graphics.py` draws each `vs_w64_*` fixture both ways, 960 zero-area vertices (`VKH_VERTICES`) that store four words each to the heap, with `vs_w64_c_lane_id` as the probe that the wave size changed (largest lane id 63, then 31). RADV packs 62 or 64 vertices into a wave64 and 30 or 32 into a wave32, so the 32-lane run repacks the vertices rather than halving the waves; tier A/B words are keyed on the vertex index, which makes this the stricter test. `vs_w64_a_skip`, `_b_waterfall`, `_b_readlane_uniform` (readfirstlane and readlane 40/63 of uniform VGPRs) and `_b_ballot_atomic` (240 slots as a set) give the derived words at both sizes; `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (no fixture; the corpus has 195 wave64 geometry shaders, all tier C, see the census). `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders likewise (TEST-251): RADV runs the GS stage (NGG) as wave64 by default and as wave32 with `gewave32`, and `w64_graphics.py` draws each `gs_w64_*` fixture after `vs_ids` (960 vertices, 320 triangles, `VKH_GS`), each invocation finding its triangle from `vs_ids`'s vertex number and storing four words to the heap, with `gs_w64_c_lane_id` as the probe (largest lane id 41, RADV puts at most 42 GS invocations in a wave64, then 31). **LDS writes of a legacy GS:** `rdna2spirv.gs_ds` maps one to an output slot from its offset alone and drops the VGPR address (the lane's GSVS area), so `wave64_halves.py` checks only the data a GS `ds_write` writes, not its address; before, a lane id that only formed the GSVS base made the shader tier C `lane-id`. Confirmed three ways: a hand-written GS with the base `lane id * 96` translates, after `spirv-opt -O`, to the same instructions as without it; `gs_w64_a_ring` (that shape) gives the derived records at wave64 and wave32 on both GPUs; and `tests/semantic/test_wave64_halves.py` (`GeometryRing`) keeps the lane id in the written data, or in a memory store's address, tier C. The corpus GS were that false tier C: all 195 contain `v_mbcnt_hi`, all 195 were tier C in the TEST-319 census, and `wave64_halves.py --census` on the corpus translated at `f847748c` puts all 195 in tier A. `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (the corpus ones are wave64, see *Wave size*; no fixture). The corpus GS form their GSVS base from `v_mbcnt_lo/hi` (all 195 contain `v_mbcnt_hi`): they were all a false tier C, and the census above has all 195 at tier A. `wave64_halves.py --census` on a translated corpus shows it. `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (the corpus ones are wave32; no fixture). Not checked: helper lanes of partial quads; `VK_KHR_shader_maximal_reconvergence` is assumed for waterfall and election loops. Tiers A and B assume subgroups of at least 32 lanes: a fragment stage may run fewer live lanes than the subgroup size it reports (Intel UHD 770: gl_SubgroupSize 32, ballot count 16, a shuffle from lane L^16 returns garbage; measured by kapitche, TEST-433), so `w64_graphics.py` skips the tier A/B pixel fixtures on a device whose minimum subgroup size is below 32 when neither the 64 nor the 32 run took effect; deriving the skip from a measured live fragment width (ballot count) in `vk_harness` is a follow-up. **ADD_TID_ENABLE** (SHADER-833, finding by @shdann in #4571): an access with no `idxen` through a V# whose word3 is a literal (`s_mov_b32` earlier in the block, the notion `rdna2spirv` uses for `sgpr_imm`) with bit 23 set takes the wave lane as its index (`idxen` ignores the bit, see *Swizzled buffer addressing*), so its `buffer_load*`/`tbuffer_load*` result and its `buffer_store*`/`tbuffer_store*`/`buffer_atomic*` address carry the raw lane id: tier C `lane-id`. A literal with the bit clear, and every access with `idxen`, are unchanged. **Assumption**: through a run-time V# (loaded from memory or user data) tiers A and B take ADD_TID_ENABLE as 0 for an access without `idxen`; the code cannot say otherwise. The literal is tracked with the same folds `rdna2spirv` applies to `sgpr_imm` (mirrored in `Analysis.literal_sgpr`: `s_mov_b32/b64`, `s_movk_i32`, `s_pack_*`, `s_bfm_b32`, `s_not_b32`, `s_and/lshl/lshr_b32`, `s_mul_i32`; other folded ops count as run-time). The corpus census was not re-measured with this rule: its tier counts above are from before it and may change. Follow-up, needs the game: count the bound V#s with word3 bit 23 set at run time, and re-run `--census`. | 535| Wave64 graphics: partition invariance (SHADER-10) | A wave64 VS/PS/GS on a 32-wide subgroup is exact **iff its observable results do not change when the wave is cut into two 32-lane halves** (the host forms the subgroups of graphics stages, so there is no partner half to exchange with). `tools/wave64_halves.py` decides it from the code (forward taint dataflow over the basic blocks, plus control dependence on wave-wide votes) and the translator records it in `index.json` as `wave64_graphics` (`A`/`B`/`C`), `wave64_graphics_reasons` (tier C) and `wave64_graphics_idioms` (tier B). **A**: only per-lane arithmetic, votes that skip lane-masked work (`s_cbranch_execz/execnz`; `vccz/vccnz` whose run side starts by narrowing EXEC to that VCC and whose other side is the join, with no code of its own: a half that votes no runs that side, the wave does not; the same holds for `s_cbranch_execz/execnz`: the side that runs when EXEC is zero is taken by a half with no active lane, so it must be the join (or only jumps to it) or the exit of a loop the vote closes, else tier C `unsafe-execz-branch`; `s_cbranch_scc*` after a vote is the same kind of skip, any other reader of that SCC, `s_cselect`/`s_cmov`/`s_addc`, is tier C; a vote is on the mask register's value when it was taken, so a new value in that register before the branch (`v_cmp` into the pair or VCC, `s_mov_b64`, `s_cselect_b64`: none of them writes SCC) ends it, and the branch is judged as a plain SCC branch, SHADER-820), whole-quad masks, `ds_bpermute`/`ds_permute`/`v_permlane16`/`v_permlanex16`/`ds_swizzle` (they stay inside a half), a `ds_bpermute`/`ds_permute` address made from the lane id (`v_mbcnt_lo` then `v_mbcnt_hi` of -1) when it is the same modulo 128 bytes in the wave and in a half (the id is 0..63 there and 0..31 here, equal modulo 32 lanes; sums, differences and bitwise ops with invariant values keep that, a left shift by c multiplies the modulus by 2^c, and the permute uses address bits 2..6 of its half only: `(id ^ 1) << 2` is exact, `id << 1`, a right shift of the id or the low count alone stay tier C `lane-id`), loops closed by `execnz` with no scalar state carried, and the early exit of a pixel kill: `s_cbranch_scc0/scc1` (or `vccz/vccnz`) on a lane mask's own "not empty" (the last SCC writer is a 64-bit logic op into that mask, e.g. `s_andn2_b64 live, live, exec`, or `s_cmp_lg_u64 mask, 0`, and nothing rewrites the mask before the branch) to a block that only sets EXEC from that mask or 0 (`s_mov_b64 exec`, or `s_and_b64 exec` with it), may then export with that EXEC (an export is allowed, not required), and ends (no other code, store or successor), while the run side narrows EXEC into the mask's whole quads before anything but mask arithmetic (`s_mov_b64`, `s_and_b64`, `s_wqm_b64`) runs, the narrowing itself possibly an `s_and_saveexec_b64` / `s_andn2_saveexec_b64` (or `_wrexec_`) whose source is inside, and keeps it inside on every path from there, loops included (a must-dataflow: an EXEC write keeps it inside only when it is provably a subset: `v_cmpx`, `s_and_b64` with one operand known inside, `s_andn2_b64` / `s_andn2_saveexec_b64` whose first operand is, `s_and_saveexec_b64` while inside or from one that is, `s_andn1`/`s_or`/`s_xor_saveexec_b64` only while inside (the latter two also from one that is), and copies, `s_wqm_b64`, `s_or_b64` and `s_xor_b64` of operands known to be inside (0 counts as inside); a saveexec destination holds the old EXEC and a wrexec one the new, each inside only if that EXEC was), and no `exp ... vm` can run before the vote. A half whose mask is empty then writes nothing and discards its pixels in the exit, and in the wave its lanes are off to the end, so the wave discards them too; an exit shared by several kills reads a mask redefined behind the earlier votes and stays tier C. GPU-checked by `ps_w64_a_discard` (below). `s_cbranch_scc*` after a vote is the same kind of skip, any other reader of that SCC, `s_cselect`/`s_cmov`/`s_addc`, is tier C; a vote is on the mask register's value when it was taken, so a new value in that register before the branch (`v_cmp` into the pair or VCC, `s_mov_b64`, `s_cselect_b64`: none of them writes SCC) ends it, and the branch is judged as a plain SCC branch, SHADER-820), whole-quad masks, `ds_bpermute`/`v_permlane16` (they stay inside a half, not GPU-tested here: no fixture; `s_cbranch_scc*` after a vote is the same kind of skip, any other reader of that SCC, `s_cselect`/`s_cmov`/`s_addc`, is tier C), whole-quad masks, `ds_bpermute`/`v_permlane16` (they stay inside a half, not GPU-tested here: no fixture; `ds_swizzle` and `v_permlanex16` likewise; GPU-checked at required 64 and 32 lanes by `ps_w64_a_bpermute`, `ps_w64_a_permlane` (`v_permlane16` and `v_permlanex16`) and `ps_w64_a_swizzle` in `w64_graphics.py`, TEST-433), loops closed by `execnz` with no scalar state carried. `ds_swizzle` and `v_permlanex16` likewise), loops closed by `execnz` with no scalar state carried. A `vccz`/`vccnz` on a wave-uniform compare is no lane vote and is tier A too: a `v_cmp` made while EXEC is the launch mask from untainted immediates, scalars that are no lane mask and VGPRs written from them (optionally ANDed with EXEC, the LLVM form `s_and_b64 vcc, exec, s[..]`) gives every launch lane or none, so each half votes as the wave does and both sides may have code and scalars of their own (if/else, a uniform loop back edge; the mask itself read as data, e.g. exported, is still tier C `cross-lane`), while the same compare under a narrowed EXEC (a half with no active lane votes no and keeps its own scalars) or on a tainted value (`v_readfirstlane` of a varying VGPR, a lane count, an AND with a lane mask) stays tier C; confirmed on the wave interpreter (`UniformVote` in `tests/semantic/test_wave64_halves.py`: 64 lanes against two waves of 32, equal for the accepted forms with s4 = 9 and s4 = 1, different for each near miss) and by `ps_w64_a_uniform_vote`, which gives its derived words on an NVIDIA GeForce RTX 5080 (Linux, driver 580.65.06, 32 only). **B**: also a waterfall loop (`v_readfirstlane` of a varying value, `v_cmp_eq` against the same VGPR, `saveexec`, body, `s_xor exec`, `execnz`; the scalar only used inside the body), a wave-aggregated atomic (`s_bcnt1` of EXEC, `v_mbcnt` rank of that same EXEC, one `buffer_atomic_add` of that count (the count of the mask the rank ranks) by the rank-0 lane only, at a wave-uniform address (a uniform VGPR, or one the elected lane wrote from scalars and constants since EXEC last changed; a per-lane address such as a pixel coordinate is tier C `elected-lane`, since each half elects its own lane and bumps another counter), `v_readfirstlane` of the result with EXEC restored, base + rank as a store address, the rank counting the very mask the atomic's count was taken of (a rank of the entry EXEC or of a saved copy next to a base of the narrowed one is tier C `lane-rank`); the rank alone or the base alone is not a slot: exact as a set of slots, **the order of the slots within a wave is not preserved**, a 64-lane wave takes one run of slots, two halves take two), `v_readfirstlane` / `v_readlane` of a VGPR written from scalars and constants while EXEC was the launch mask (the same in every lane), a `v_writelane` / `v_readlane` spill pair on one constant lane below 32. **C**: anything else that reaches an export, a store's data, a branch or EXEC: lane count / rank / first-lane index / raw lane id (`v_mbcnt` of -1), `v_readlane` of a varying value at any lane (on a wave64 every lane gets hardware lane N, in halves each half gets its own lane N, so lane 7 is as wrong as lane 40; the research note's row 9 is too generous here); an analysis failure is tier C with reason `analysis-error` (the translation does not fail), `v_writelane` to a non-constant or >= 32 lane, a 32-bit access to half of a lane mask (`exec_hi`, `vcc_hi`, a mask pair's odd register), a mask read as data (including a mask combined by `s_and/or/andn2_b64` with a register that is not one: a user value, a loaded mask), a scalar defined behind a wave-wide vote and read where it may not have run (`s_add s5, s5, 1` after `s_cbranch_vccz`; a trip count in an SGPR of a divergent loop: the halves vote differently), a branch on a count, an elected-lane side effect that is not a count, `ds_append`/`ds_consume`. The check is conservative: unknown means C. `--wave64-graphics=warn` (default) marks tier C and counts it in the summary line, `error` refuses it (`Unsupported`), `off` skips the analysis; `python tools/wave64_halves.py --census <spirv>/index.json` prints tier, reason and idiom counts (no names); it complements `tools/wave64_graphics_scan.py` (#1132), which counts candidate cross-half opcodes in the disassembly before translation and decides nothing. **Corpus census** (1.0.2.1, all 26,503 shaders translated at `main` `f847748c` with `--wave64-emulate`, `--census` over that index): 13,405 wave64 graphics shaders (2,236 VS, 10,974 PS, 195 GS, the FSSM header's wave size, see *Wave size*); tier A 4,033 (30.1%), B 85 (0.6%), C 9,287 (69.3%): VS 1,455/79/702, PS 2,383/6/8,585, GS 195/0/0. Tier C reasons (a shader can have several): unsafe-vote-branch 8,285, tainted-branch 6,547, tainted-exec 5,189, cross-lane 4,764, stale-scalar 3,415, mask-half 759, unsafe-execz-branch 583, first-lane 353, waterfall-scalar 161, lane-id 152, lane-count 1. Idiom tags, counted on every shader that carries one whatever its tier (`--census` prints them as "tier B idioms"; 85 shaders are tier B): readfirstlane-uniform 626, lane-spill 287, waterfall 35. (Earlier censuses counted 11,405 shaders, from when the wave size came from code markers: TEST-319 had A 1,919, B 17, C 9,469 with all 195 GS in C; its re-run with the GS ring rule below and #1982 had A 2,117, B 17, C 9,271 with all 195 GS in A.) The lane-id bpermute rule moves no corpus shader. (The TEST-319 census, from when the wave size came from code markers and before the GS ring-address rule below, counted 11,405 shaders: A 1,919, B 17, C 9,469, with all 195 GS in C.) The lane-id bpermute rule moves no corpus shader. **Corpus census** (TEST-319, 1.0.2.1, `--census` over the translated index, re-run with the GS ring rule below and #1982): 11,405 wave64 graphics shaders (1,179 VS, 10,031 PS, 195 GS); tier A 2,117 (18.6%), B 17 (0.1%), C 9,271 (81.3%): VS 479/14/686, PS 1,443/3/8,585, GS 195/0/0. Tier C reasons (a shader can have several): unsafe-vote-branch 8,285, tainted-branch 6,550, tainted-exec 5,189, cross-lane 4,760, stale-scalar 3,415, mask-half 758, unsafe-execz-branch 583, first-lane 353, waterfall-scalar 161, lane-id 152, lane-count 1. 11,405 wave64 graphics shaders (1,179 VS, 10,031 PS, 195 GS); tier A 1,919 (16.8%), B 17 (0.1%), C 9,469 (83.0%): VS 465/14/700, PS 1,454/3/8,574, GS 0/0/195. Tier C reasons (a shader can have several): unsafe-vote-branch 8,175, tainted-branch 6,582, cross-lane 6,111, tainted-exec 4,959, stale-scalar 3,162, mask-half 758, unsafe-execz-branch 583, first-lane 353, lane-id 277, waterfall-scalar 167, lane-count 1. Tier B idioms: readfirstlane-uniform 558, lane-spill 287, waterfall 35. The lane-id bpermute rule moves no corpus shader. **Corpus coverage is not measured here**: it needs a run over the game's shaders by someone who has them. **Rewrite (the only one the emission needs)**: `v_readlane_b32` of a proven-uniform VGPR reads the lane's own copy instead of shuffling from lane N, because a subgroup shuffle from lane >= 32 of a 32-wide subgroup is undefined (143 of 144 test shaders translate byte-identically to origin/main, only `ps_w64_b_readlane_uniform` changed). Everything else tier B needs is what the translator already emits per subgroup: the ballot/count/rank/first-lane words of `wave_mask` are the subgroup's own (the high word is 0), `v_readfirstlane` is the subgroup's first active lane, a waterfall runs once per distinct value of the subgroup. GPU-checked on AMD Radeon 880M (driver 26.11.2; `requiredSubgroupSizeStages` has FRAGMENT, size 32..64) with `runtime/test/shaders/w64_graphics.py`: each `ps_w64_*` fixture drawn with the fragment subgroup size required to 64 (one hardware wave) and to 32 (two halves). `ps_w64_a_skip`, `_b_waterfall`, `_b_readfirstlane`, `_b_readlane_uniform` and `_b_ballot_atomic` (counter 1024 and the 1024 slot words as a set; slot order differs) match each other and the words their headers derive; `_c_bcnt_export`, `_c_lane_id`, `_c_readlane`, `_c_vote_stale`, `_c_vote_else`, `_c_scc_vote`, `_c_execz_sgpr` (an SGPR written on the exec-zero side and exported) and `_c_waterfall_count` differ between 64 and 32 (the detector is right). `ps_w64_a_one_lane` is the case where only one pixel votes yes (so one half votes and the other does not, in the wave and in the halves): its skip regions (`execz`, `vccz`, `vccnz` with a jump-only fall-through) give equal images at 64 and 32; `_c_vote_else` (code on the vote's no side) and `_c_scc_vote` (SCC of a vote as data) differ. `ps_w64_a_discard` (three kills, two of them dropping whole regions so that some halves lose every pixel while the other half of their wave lives) was drawn on an AMD Radeon RX 580 (RADV, Mesa 26.0.8, required size 64, saved with `W64G_SAVE_REF`) and an NVIDIA GeForce RTX 5070 (32 only, driver 620.73.04, compared with `W64G_REF`): both equal the derived words, discarded pixels keeping the clear value, and each other. NVIDIA GeForce RTX 5070 Laptop (32 only, driver 617.42): tier A/B fixtures equal the derived words and the 880M@64 images (`W64G_SAVE_REF` / `W64G_REF`), tier C fixtures differ from the 880M@64 images. `ps_w64_a_permlane`, `_a_swizzle` and `_a_bpermute` (TEST-319: permlane16 neighbour selects, permlanex16 there and back, swizzle quad-permute, swap and broadcast modes, bpermute from lane-id addresses; every read stays in the pixel's 2x2 quad or comes back, so the words do not depend on how pixels are packed into lanes) give the derived words on an NVIDIA GeForce RTX 5070 (Linux, driver 620.73.04, 32 only). With an AMD Radeon RX 580 (Polaris, RADV Mesa 26.0.8) as the 64-lane reference (`W64G_SAVE_REF`; GCN has one subgroup size, 64, in every stage but no FRAGMENT in `requiredSubgroupSizeStages`, so `vk_harness` counts a requested size equal to a device's only size as applied), the RTX 5070 run of every fixture (`W64G_REF`) equals the reference for all 13 tier A/B fixtures and differs from it for all 11 tier C ones, pixel and vertex; the same reads in a vertex shader run on the wave interpreter (64 lanes against two waves of 32, equal) because a GPU's partial vertex waves leave the lanes they would read empty. Vertex shaders: the VS stage cannot be forced on the 880M (no VERTEX in `requiredSubgroupSizeStages`), so VS is covered by the strict wave interpreter (`tests/semantic/test_wave64_halves.py`: 64 lanes against two waves of 32; tier A/B equal, tier C differs); geometry shaders are not tested (the corpus ones are wave64, see *Wave size*; no fixture). 64 lanes against two waves of 32; tier A/B equal, tier C differs), and on RADV also on the GPU (TEST-251): RADV runs the VS stage (NGG) as wave64 by default and as wave32 with `RADV_PERFTEST=gewave32` (GFX10+, seen in the `RADV_DEBUG=shaders` dump: 64-bit EXEC operations against `exec_lo`), so `w64_graphics.py` draws each `vs_w64_*` fixture both ways, 960 zero-area vertices (`VKH_VERTICES`) that store four words each to the heap, with `vs_w64_c_lane_id` as the probe that the wave size changed (largest lane id 63, then 31). RADV packs 62 or 64 vertices into a wave64 and 30 or 32 into a wave32, and the wave32 waves are the two halves of the wave64 ones: each vertex's wave32 lane is its wave64 lane & 31 (`vs_w64_c_lane_id`, all 960 vertices: waves of 64, 62, 64, 62 ... vertices starting at 0, 64, 126, 190 ... against 32, 32, 32, 30 ... starting at 0, 32, 64, 96, 126 ..., a period of 126 both ways; RADV Mesa 26.3.1 on a gfx1036 iGPU (Raphael, found by sskver) and an RX 7900 XTX (NAVI31, RDNA3); TEST-1700. GFX12 gives the same waves and starts, with every wave32 wave inside one half of a wave64 wave: RX 9070 XT, GFX1201, RDNA4, RADV Mesa 26.2.6, sperm's old upstream PR 7354 (GFX1201 data)), so the 32-lane run is the cut into halves that the tiers describe, not a repacking; tier A/B words are keyed on the vertex index. `vs_w64_a_skip`, `_b_waterfall`, `_b_readlane_uniform` (readfirstlane and readlane 40/63 of uniform VGPRs) and `_b_ballot_atomic` (240 slots as a set) give the derived words at both sizes; `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (no fixture; the corpus has 195 wave64 geometry shaders, all tier C, see the census). `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders likewise (TEST-251): RADV runs the GS stage (NGG) as wave64 by default and as wave32 with `gewave32`, and `w64_graphics.py` draws each `gs_w64_*` fixture after `vs_ids` (960 vertices, 320 triangles, `VKH_GS`), each invocation finding its triangle from `vs_ids`'s vertex number and storing four words to the heap, with `gs_w64_c_lane_id` as the probe (largest lane id 41, RADV puts at most 42 GS invocations in a wave64, then 31). **LDS writes of a legacy GS:** `rdna2spirv.gs_ds` maps one to an output slot from its offset alone and drops the VGPR address (the lane's GSVS area), so `wave64_halves.py` checks only the data a GS `ds_write` writes, not its address; before, a lane id that only formed the GSVS base made the shader tier C `lane-id`. Confirmed three ways: a hand-written GS with the base `lane id * 96` translates, after `spirv-opt -O`, to the same instructions as without it; `gs_w64_a_ring` (that shape) gives the derived records at wave64 and wave32 on both GPUs; and `tests/semantic/test_wave64_halves.py` (`GeometryRing`) keeps the lane id in the written data, or in a memory store's address, tier C. The corpus GS were that false tier C: all 195 contain `v_mbcnt_hi`, all 195 were tier C in the TEST-319 census, and `wave64_halves.py --census` on the corpus translated at `f847748c` puts all 195 in tier A. `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (the corpus ones are wave64, see *Wave size*; no fixture). The corpus GS form their GSVS base from `v_mbcnt_lo/hi` (all 195 contain `v_mbcnt_hi`): they were all a false tier C, and the census above has all 195 at tier A. `wave64_halves.py --census` on a translated corpus shows it. `_c_bcnt_export`, `_c_readlane` and `_c_lane_id` differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (the corpus ones are wave32; no fixture). Not checked: helper lanes of partial quads; `VK_KHR_shader_maximal_reconvergence` is assumed for waterfall and election loops. Tiers A and B assume subgroups of at least 32 lanes: a fragment stage may run fewer live lanes than the subgroup size it reports (Intel UHD 770: gl_SubgroupSize 32, ballot count 16, a shuffle from lane L^16 returns garbage; measured by kapitche, TEST-433), so `w64_graphics.py` skips the tier A/B pixel fixtures on a device whose minimum subgroup size is below 32 when neither the 64 nor the 32 run took effect; deriving the skip from a measured live fragment width (ballot count) in `vk_harness` is a follow-up. **ADD_TID_ENABLE** (SHADER-833, finding by @shdann in #4571): an access with no `idxen` through a V# whose word3 is a literal (`s_mov_b32` earlier in the block, the notion `rdna2spirv` uses for `sgpr_imm`) with bit 23 set takes the wave lane as its index (`idxen` ignores the bit, see *Swizzled buffer addressing*), so its `buffer_load*`/`tbuffer_load*` result and its `buffer_store*`/`tbuffer_store*`/`buffer_atomic*` address carry the raw lane id: tier C `lane-id`. A literal with the bit clear, and every access with `idxen`, are unchanged. **Assumption**: through a run-time V# (loaded from memory or user data) tiers A and B take ADD_TID_ENABLE as 0 for an access without `idxen`; the code cannot say otherwise. The literal is tracked with the same folds `rdna2spirv` applies to `sgpr_imm` (mirrored in `Analysis.literal_sgpr`: `s_mov_b32/b64`, `s_movk_i32`, `s_pack_*`, `s_bfm_b32`, `s_not_b32`, `s_and/lshl/lshr_b32`, `s_mul_i32`; other folded ops count as run-time). The corpus census was not re-measured with this rule: its tier counts above are from before it and may change. Follow-up, needs the game: count the bound V#s with word3 bit 23 set at run time, and re-run `--census`. |
520| Wave64 graphics: a uniform vote under whole-quad EXEC (SHADER-W64-WQM-UVOTE) | SHADER-10 (the row above) takes a `vccz`/`vccnz` on a wave-uniform compare for no lane vote only while EXEC is the launch mask. A pixel shader that needs derivatives starts with `s_wqm_b64 exec, exec`, and LLVM branches on uniform conditions inside that region in the same form: `v_cmp_* sN, <scalars>` / `s_and_b64 vcc, exec, s[N:N+1]` / `s_cbranch_vccnz` (or the compare straight into VCC). **That is exact too, for a compare of immediates and scalars**: it is the same in every lane, so its mask is every lane of EXEC or none; EXEC is the whole quads of the launch mask, a quad is four consecutive lanes and never straddles the two 32-lane halves, and a half that runs has a launch lane, so EXEC has a lane in every half that runs and each half votes as the wave does. Both sides of the branch may then have code and scalars of their own (if/else, a uniform loop back edge), as under the launch mask. `tools/wave64_halves.py` carries it as a dataflow fact (`q`: EXEC is the whole quads of the launch mask), set by `s_wqm_b64 exec, exec` while EXEC is the launch mask and dropped by every other write to EXEC; `uniform_cmp` and the `s_and_b64 .., exec, ..` of a uniform mask accept it next to the launch mask. **What stays tier C, and why**: a VGPR source, even one SHADER-10 calls uniform (it was written under the launch mask, and the helper lanes EXEC now includes never got it, so they compare what they held; a VGPR written inside the region is refused as well, because the analysis does not tell the two apart); the whole quads of a narrowed EXEC, and any narrowing after the `s_wqm_b64` (a half can be empty); whole quads saved and put back later, or made in a register and copied to EXEC (only the write by `s_wqm_b64 exec, exec` is modelled); and a compare on a path where a scalar was read out of a uniform VGPR from a lane the launch mask may not have written, by `v_readlane_b32` at any time or by `v_readfirstlane_b32` while EXEC was not the launch mask (`qr`, kept for the rest of the path: SHADER-10 treats such a scalar as uniform, this rule does not build on that). **Corpus** (1.0.2.1, all 26,503, `wave64_halves.analyse` on every wave64 VS/PS/GS, with SHADER-W64-SDST-PAIR on `main` `3ed8e50b7` as the baseline, because the listings name the compare's destination by one register and without that rule the vote is hidden behind `tainted-branch`): **452 pixel shaders go from tier C to A**, no shader moves the other way and no vertex or geometry shader moves: A 5,267 to 5,719, B 397, C 7,741 to 7,289 (PS 3,545/34/7,395 to 3,997/34/6,943). Reasons: `unsafe-vote-branch` 7,362 to 6,861, `tainted-exec` 5,829 to 5,793, `stale-scalar` 3,287 to 3,254, the others unchanged; 802 shaders still have `unsafe-vote-branch` as their only reason. CPU-checked by `tests/semantic/test_wave64_halves_wqm_uvote.py`: the accepted forms in both printed forms of the destination, ten near misses that stay tier C, and a vertex and a pixel shader run on the wave interpreter as one wave of 64 lanes and as two of 32, equal and equal to the derived words with s4 = 9 and s4 = 1 (every lane covered there: the interpreters do not model a helper lane in a quad swap, so partial coverage rests on the argument above). GPU-checked by `ps_w64_a_wqm_uniform_vote` (`w64_graphics.py`: an if/else on a compare into VCC, the LLVM form through an SGPR pair and a loop closed by the vote, all under `s_wqm_b64 exec, exec`, EXEC put back before the export), which gives the words its header derives on an NVIDIA GeForce RTX 4070 Ti (Linux, driver 620.70.06, 32 only). That device has one subgroup size, so the 64-lane image was not drawn there and the full-screen draw has no partly covered quad; the run confirms the translated SPIR-V against the ISA reference, not native RDNA2 behaviour. | 536| Wave64 graphics: a uniform vote under whole-quad EXEC (SHADER-W64-WQM-UVOTE) | SHADER-10 (the row above) takes a `vccz`/`vccnz` on a wave-uniform compare for no lane vote only while EXEC is the launch mask. A pixel shader that needs derivatives starts with `s_wqm_b64 exec, exec`, and LLVM branches on uniform conditions inside that region in the same form: `v_cmp_* sN, <scalars>` / `s_and_b64 vcc, exec, s[N:N+1]` / `s_cbranch_vccnz` (or the compare straight into VCC). **That is exact too, for a compare of immediates and scalars**: it is the same in every lane, so its mask is every lane of EXEC or none; EXEC is the whole quads of the launch mask, a quad is four consecutive lanes and never straddles the two 32-lane halves, and a half that runs has a launch lane, so EXEC has a lane in every half that runs and each half votes as the wave does. Both sides of the branch may then have code and scalars of their own (if/else, a uniform loop back edge), as under the launch mask. `tools/wave64_halves.py` carries it as a dataflow fact (`q`: EXEC is the whole quads of the launch mask), set by `s_wqm_b64 exec, exec` while EXEC is the launch mask and dropped by every other write to EXEC; `uniform_cmp` and the `s_and_b64 .., exec, ..` of a uniform mask accept it next to the launch mask. **What stays tier C, and why**: a VGPR source, even one SHADER-10 calls uniform (it was written under the launch mask, and the helper lanes EXEC now includes never got it, so they compare what they held; a VGPR written inside the region is refused as well, because the analysis does not tell the two apart); the whole quads of a narrowed EXEC, and any narrowing after the `s_wqm_b64` (a half can be empty); whole quads saved and put back later, or made in a register and copied to EXEC (only the write by `s_wqm_b64 exec, exec` is modelled); and a compare on a path where a scalar was read out of a uniform VGPR from a lane the launch mask may not have written, by `v_readlane_b32` at any time or by `v_readfirstlane_b32` while EXEC was not the launch mask (`qr`, kept for the rest of the path: SHADER-10 treats such a scalar as uniform, this rule does not build on that). **Corpus** (1.0.2.1, all 26,503, `wave64_halves.analyse` on every wave64 VS/PS/GS, with SHADER-W64-SDST-PAIR on `main` `3ed8e50b7` as the baseline, because the listings name the compare's destination by one register and without that rule the vote is hidden behind `tainted-branch`): **452 pixel shaders go from tier C to A**, no shader moves the other way and no vertex or geometry shader moves: A 5,267 to 5,719, B 397, C 7,741 to 7,289 (PS 3,545/34/7,395 to 3,997/34/6,943). Reasons: `unsafe-vote-branch` 7,362 to 6,861, `tainted-exec` 5,829 to 5,793, `stale-scalar` 3,287 to 3,254, the others unchanged; 802 shaders still have `unsafe-vote-branch` as their only reason. CPU-checked by `tests/semantic/test_wave64_halves_wqm_uvote.py`: the accepted forms in both printed forms of the destination, ten near misses that stay tier C, and a vertex and a pixel shader run on the wave interpreter as one wave of 64 lanes and as two of 32, equal and equal to the derived words with s4 = 9 and s4 = 1 (every lane covered there: the interpreters do not model a helper lane in a quad swap, so partial coverage rests on the argument above). GPU-checked by `ps_w64_a_wqm_uniform_vote` (`w64_graphics.py`: an if/else on a compare into VCC, the LLVM form through an SGPR pair and a loop closed by the vote, all under `s_wqm_b64 exec, exec`, EXEC put back before the export), which gives the words its header derives on an NVIDIA GeForce RTX 4070 Ti (Linux, driver 620.70.06, 32 only). That device has one subgroup size, so the 64-lane image was not drawn there and the full-screen draw has no partly covered quad; the run confirms the translated SPIR-V against the ISA reference, not native RDNA2 behaviour. |
521| GFX10.1 (console gfx1013) / GFX10.3 (gfx1030, gfx1036 oracle) opcode differences | Found by disassembling every opcode of every GFX10 encoding (SOP1/SOP2/SOPK/SOPC/SOPP, SMEM, VOP1/VOP2/VOPC/VOP3/VOP3P, DS, FLAT/GLOBAL/SCRATCH, MUBUF/MTBUF, MIMG) with LLVM 21 `llvm-mc` for `-mcpu=gfx1013` and for `gfx1030`/`gfx1036` (the two gfx103x lists are identical). Every other opcode slot decodes to the same mnemonic on both, so the hardware-oracle rows measured on gfx1036 are about the same instructions the console runs (the microarchitectures still differ, which no opcode table shows). **On gfx1013 only:** `v_mac_f32`/`v_mad_f32` (VOP2 0x1f, VOP3 0x11f/0x141) and `v_mac_legacy_f32`/`v_mad_legacy_f32` (VOP2 0x06, VOP3 0x106/0x140), translated (rows above; not measurable on gfx103x, where 0x06/0x106/0x140 are the fused `v_fmac_legacy_f32`/`v_fma_legacy_f32`); `v_mul_lo_i32` (VOP3 0x16b; `Unsupported` until #3504 translates it); `s_get_waveid_in_workgroup` (SMEM 0x2a), translated in compute and mesh shaders; scalar stores (`s_store_dword*`, `s_buffer_store_dword*`), scalar atomics (`s_atomic_*`, `s_buffer_atomic_*`, 32- and 64-bit), scalar scratch (`s_scratch_load/store_dword*`), `s_dcache_wb`, `s_dcache_discard(_x2)` and the 31 LDS `ds_*_src2_*` forms, all `Unsupported`. **On gfx103x only:** `v_dot2c_f32_f16`, `v_dot4c_i32_i8`, the VOP3P `v_dot2_f32_f16`, `v_dot2_i32_i16`/`u32_u16`, `v_dot4_i32_i8`/`u32_u8`, `v_dot8_i32_i4`/`u32_u4`, `v_fmac_legacy_f32`/`v_fma_legacy_f32`, `global_load/store_dword_addtid`, `global_atomic_csub`, `buffer_atomic_csub`. The console's code can't contain these; the translator handles the integer dot products (rows above, measured on gfx1036) and refuses the rest, so a listing disassembled for the wrong target (VOP2 0x06 printed as `v_fmac_legacy_f32`) fails loudly instead of being translated as a fused multiply-add. Not covered by the sweep: opcodes whose operand template did not decode on either target, and behaviour that differs without an opcode change. | 537| GFX10.1 (console gfx1013) / GFX10.3 (gfx1030, gfx1036 oracle) opcode differences | Found by disassembling every opcode of every GFX10 encoding (SOP1/SOP2/SOPK/SOPC/SOPP, SMEM, VOP1/VOP2/VOPC/VOP3/VOP3P, DS, FLAT/GLOBAL/SCRATCH, MUBUF/MTBUF, MIMG) with LLVM 21 `llvm-mc` for `-mcpu=gfx1013` and for `gfx1030`/`gfx1036` (the two gfx103x lists are identical). Every other opcode slot decodes to the same mnemonic on both, so the hardware-oracle rows measured on gfx1036 are about the same instructions the console runs (the microarchitectures still differ, which no opcode table shows). **On gfx1013 only:** `v_mac_f32`/`v_mad_f32` (VOP2 0x1f, VOP3 0x11f/0x141) and `v_mac_legacy_f32`/`v_mad_legacy_f32` (VOP2 0x06, VOP3 0x106/0x140), translated (rows above; not measurable on gfx103x, where 0x06/0x106/0x140 are the fused `v_fmac_legacy_f32`/`v_fma_legacy_f32`); `v_mul_lo_i32` (VOP3 0x16b; `Unsupported` until #3504 translates it); `s_get_waveid_in_workgroup` (SMEM 0x2a), translated in compute and mesh shaders; scalar stores (`s_store_dword*`, `s_buffer_store_dword*`), scalar atomics (`s_atomic_*`, `s_buffer_atomic_*`, 32- and 64-bit), scalar scratch (`s_scratch_load/store_dword*`), `s_dcache_wb`, `s_dcache_discard(_x2)` and the 31 LDS `ds_*_src2_*` forms, all `Unsupported`. **On gfx103x only:** `v_dot2c_f32_f16`, `v_dot4c_i32_i8`, the VOP3P `v_dot2_f32_f16`, `v_dot2_i32_i16`/`u32_u16`, `v_dot4_i32_i8`/`u32_u8`, `v_dot8_i32_i4`/`u32_u4`, `v_fmac_legacy_f32`/`v_fma_legacy_f32`, `global_load/store_dword_addtid`, `global_atomic_csub`, `buffer_atomic_csub`. The console's code can't contain these; the translator handles the integer dot products (rows above, measured on gfx1036) and refuses the rest, so a listing disassembled for the wrong target (VOP2 0x06 printed as `v_fmac_legacy_f32`) fails loudly instead of being translated as a fused multiply-add. Not covered by the sweep: opcodes whose operand template did not decode on either target, and behaviour that differs without an opcode change. |
522| Buffer bounds checking | MUBUF `buffer_load*`, `buffer_store*`, and `buffer_atomic*` enforce `num_records` (V# word 2). Out-of-bounds stores/atomics skip memory access completely and out-of-bounds loads return 0 without a load. **The RX 6800 measurement behind RAW loads** (`buffer_load_dword`/`x2`/`x3`/`x4`, stride 0, no `idxen`, OOB_SELECT 3; the per-mode rule below covers every mode, stride and `idxen`): the byte offset O = inst_offset + soffset + (offen ? vaddr : 0) is exact (nothing truncated, and the address keeps base & 3), and dword i is data when O + 4·i + 4 ≤ num_records, else 0, measured on AMD Radeon RX 6800 (gfx1030, Windows driver 32.0.21045.29003) by running the instructions as a raw compute kernel, wave32 and wave64 (155 runs, every result either 0 or the stored data, wave32 = wave64 in every dword), for x1/x2/x4 with V# word3 0x31016fac (OOB_SELECT 3) at offsets 0..63 per lane, NUM_RECORDS 17..23 and 0x1000, base & 3 = 0 and 3: a dword at 0xf with NUM_RECORDS 18 is 0 (a start-only check reads it); x4 at 3 with 18 gives three data dwords and 0 for the fourth, which starts at 15 < 18 (so neither a whole-load nor a per-dword start check), and the zero is a whole 0, not partial bytes; x4 at offset:13 with 20 gives data, 0, 0, 0; inst_offset, soffset and offen are summed before the check; base & 3 = 3 flips at the same offsets. `x3` gets the rule without a measurement. **Per-mode check (V# OOB_SELECT, word3 bits [29:28])**, for every MUBUF/MTBUF access, as measured natively on RDNA2 (gfx1036, 732 cases, `docs/buffer_bounds.md`; Mesa's GFX11 column, not its GFX10 one). `idx` = `vindex` (0 without `idxen`), `off` = inst_offset + vaddr offset (offen), `offs` = `off` + soffset. A dword at byte 4·k of the access is out of range when: **0 STRUCTURED_WITH_OFFSET** `idx >= num_records` or `off + 4k + 4 > stride`; **1 STRUCTURED** `idx >= num_records` (no `idxen`: idx 0, so only `num_records == 0`); **2 DISABLED** `num_records == 0`; **3 RAW** `offs + 4k + 4 > num_records` (`idx * stride` is in the address, not in the check). A literal word3 (`s_mov_b32` earlier in the block) folds the mode, a run-time one selects with `OpSelect`. Multi-dword accesses, measured on the Radeon 880M (gfx1150, a valid proxy: gfx1036 follows the same column and gfx1150 matched it bit-exactly): in modes 0 and 3 **`buffer_load_dwordx2..x4` and `buffer_store_dwordx2..x4` are per dword**, for loads and stores alike (x4 at off 20 of 32 in RAW loads/stores 3 dwords, at 28 one, at 32 none; mode 0 likewise at the stride); modes 1 and 2 check once and always take the whole access. **A typed element (`buffer_load_format_*`, `buffer_store_format_*`) is all or nothing and ends at its format's size** (32_32_32_32 at off 20 of 32 reads or writes nothing), and an atomic checks its dword's end like a dword access. The translator does the same: per-dword guarded loads and stores for modes 0 and 3 (a store that straddled the edge used to write past it), the element size from the instruction's format, a literal word3 or the V#. The same oracle confirmed the terms (504 `buffer_load_dword` probes, idxen/offen/inst_offset/soffset at the stride and record edges, 0 disagreements): mode 0's `off` has `inst_offset` and no soffset, mode 1 reads nothing but the index, mode 3 adds inst_offset and soffset. `s_buffer_load` (SMEM) is separate: it keeps the `num_records` bound of the Scalar/buffer row and ignores OOB_SELECT (the same pattern for 0 to 3). **Swizzle**: SWIZZLE_ENABLE (V# word1 bit 31, Mesa `gfx10-rsrc.json` line 326; word1 [31:30] on GFX11, `gfx11-rsrc.json` line 259) and ADD_TID_ENABLE (word3 bit 23, line 337) change the address and the bounds in every mode and are modelled; see the Swizzled buffer addressing row. SWIZZLE_ENABLE and ADD_TID_ENABLE are modelled; see the Swizzled buffer addressing row. SWIZZLE_ENABLE (V# word1 bit 31, Mesa `gfx10-rsrc.json` line 326; word1 [31:30] on GFX11, `gfx11-rsrc.json` line 259) and ADD_TID_ENABLE (word3 bit 23, line 337) change the address and the bounds in every mode and are not modelled: a literal V# with either set is `Unsupported`, a run-time V# with them is translated unswizzled, which is silently wrong (known gap). Until 2026-11-22 the translator ignored OOB_SELECT and checked by stride alone (`offset < num_records`, `index < num_records`, or `offset < num_records * stride`): a V# with word3 = 0 (mode 0, stride 0) was fully readable and is now always out of range, as on hardware, so the test harnesses' output V# is `0x31016fac` now (`vk_compute_test`, the interpreter tests, `cs_bounds.asm`, `cs_fmt_1010102.asm`, `cs_store.asm`). **How confirmed**: the native RDNA2 measurement (gfx1036) and the gfx1150 oracle (RDNA3.5, same column); GPU test `cs_oob_select.asm` (every mode, literal and run-time V#, words derived from the rules) on an NVIDIA RTX 5070 and an AMD Radeon 880M, which checks the translation, not RDNA2; `tests/semantic/test_buffer_oob_select.py` (a hand-written table of 33 cases over the four modes, loads and stores, both V# forms, plus the multi-dword stores and typed elements); `cs_oob_tail.asm` pins the end-based edge, per-dword x4 loads and stores and the all-or-nothing element, where Mesa's GFX10 column gives other words. **RDNA1 (gfx1011, Navi 12) follows the same RDNA2/GFX11 column**: `tools/buffer_bounds_probe.py` ran 12 one-lane 4-byte `buffer_load_dword` cases at wave32 and wave64 through `tools/hw_oracle` (24 groups, 0 wave32/64 differences); all matched the measured column and 8 disagreed with Mesa's GFX10 column (SHADER-341, results in `docs/buffer_bounds.md`). **Unmeasured**: gfx1013/GFX10.1 itself (see `docs/buffer_bounds.md`), swizzle, unaligned addresses, and the mode 1/2 boundary of `buffer_load_dwordx2..x4` on RDNA2 hardware proper (the gfx1150 proxy shows all dwords in). Checked by `tests/semantic/test_value_semantics.py` (`RawBufferTailBounds`: the RX 6800 rows, values and the addresses loaded) and the GPU tests `runtime/test/shaders/cs_bounds.asm` (AMD Radeon RX 9070 XT, RX 6800), `cs_buf_tail.asm` (RX 6800, Vulkan, driver 26.11.2; aligned offsets only, since the translator's `Aligned 4` loads at byte-exact addresses were not checked on a Vulkan driver) `cs_oob_select.asm` and `cs_oob_tail.asm`. `cs_fmt_xy_xyz.asm` shows the whole element deciding for `_xy` and `_xyz` too, measured natively on a Radeon 680M (gfx1035, RDNA2): components that end inside num_records, in an element that doesn't, read 0 and store nothing. | 538| Buffer bounds checking | MUBUF `buffer_load*`, `buffer_store*`, and `buffer_atomic*` enforce `num_records` (V# word 2). Out-of-bounds stores/atomics skip memory access completely and out-of-bounds loads return 0 without a load. **The RX 6800 measurement behind RAW loads** (`buffer_load_dword`/`x2`/`x3`/`x4`, stride 0, no `idxen`, OOB_SELECT 3; the per-mode rule below covers every mode, stride and `idxen`): the byte offset O = inst_offset + soffset + (offen ? vaddr : 0) is exact (nothing truncated, and the address keeps base & 3), and dword i is data when O + 4·i + 4 ≤ num_records, else 0, measured on AMD Radeon RX 6800 (gfx1030, Windows driver 32.0.21045.29003) by running the instructions as a raw compute kernel, wave32 and wave64 (155 runs, every result either 0 or the stored data, wave32 = wave64 in every dword), for x1/x2/x4 with V# word3 0x31016fac (OOB_SELECT 3) at offsets 0..63 per lane, NUM_RECORDS 17..23 and 0x1000, base & 3 = 0 and 3: a dword at 0xf with NUM_RECORDS 18 is 0 (a start-only check reads it); x4 at 3 with 18 gives three data dwords and 0 for the fourth, which starts at 15 < 18 (so neither a whole-load nor a per-dword start check), and the zero is a whole 0, not partial bytes; x4 at offset:13 with 20 gives data, 0, 0, 0; inst_offset, soffset and offen are summed before the check; base & 3 = 3 flips at the same offsets. `x3` gets the rule without a measurement. **Per-mode check (V# OOB_SELECT, word3 bits [29:28])**, for every MUBUF/MTBUF access, as measured natively on RDNA2 (gfx1036, 732 cases, `docs/buffer_bounds.md`; Mesa's GFX11 column, not its GFX10 one). `idx` = `vindex` (0 without `idxen`), `off` = inst_offset + vaddr offset (offen), `offs` = `off` + soffset. A dword at byte 4·k of the access is out of range when: **0 STRUCTURED_WITH_OFFSET** `idx >= num_records` or `off + 4k + 4 > stride`; **1 STRUCTURED** `idx >= num_records` (no `idxen`: idx 0, so only `num_records == 0`); **2 DISABLED** `num_records == 0`; **3 RAW** `offs + 4k + 4 > num_records` (`idx * stride` is in the address, not in the check). A literal word3 (`s_mov_b32` earlier in the block) folds the mode, a run-time one selects with `OpSelect`. Multi-dword accesses, measured on the Radeon 880M (gfx1150, a valid proxy: gfx1036 follows the same column and gfx1150 matched it bit-exactly): in modes 0 and 3 **`buffer_load_dwordx2..x4` and `buffer_store_dwordx2..x4` are per dword**, for loads and stores alike (x4 at off 20 of 32 in RAW loads/stores 3 dwords, at 28 one, at 32 none; mode 0 likewise at the stride); modes 1 and 2 check once and always take the whole access. **A typed element (`buffer_load_format_*`, `buffer_store_format_*`) is all or nothing and ends at its format's size** (32_32_32_32 at off 20 of 32 reads or writes nothing), and an atomic checks its dword's end like a dword access. The translator does the same: per-dword guarded loads and stores for modes 0 and 3 (a store that straddled the edge used to write past it), the element size from the instruction's format, a literal word3 or the V#. The same oracle confirmed the terms (504 `buffer_load_dword` probes, idxen/offen/inst_offset/soffset at the stride and record edges, 0 disagreements): mode 0's `off` has `inst_offset` and no soffset, mode 1 reads nothing but the index, mode 3 adds inst_offset and soffset. `s_buffer_load` (SMEM) is separate: it keeps the `num_records` bound of the Scalar/buffer row and ignores OOB_SELECT (the same pattern for 0 to 3). **Swizzle**: SWIZZLE_ENABLE (V# word1 bit 31, Mesa `gfx10-rsrc.json` line 326; word1 [31:30] on GFX11, `gfx11-rsrc.json` line 259) and ADD_TID_ENABLE (word3 bit 23, line 337) change the address and the bounds in every mode and are modelled; see the Swizzled buffer addressing row. SWIZZLE_ENABLE and ADD_TID_ENABLE are modelled; see the Swizzled buffer addressing row. SWIZZLE_ENABLE (V# word1 bit 31, Mesa `gfx10-rsrc.json` line 326; word1 [31:30] on GFX11, `gfx11-rsrc.json` line 259) and ADD_TID_ENABLE (word3 bit 23, line 337) change the address and the bounds in every mode and are not modelled: a literal V# with either set is `Unsupported`, a run-time V# with them is translated unswizzled, which is silently wrong (known gap). Until 2026-11-22 the translator ignored OOB_SELECT and checked by stride alone (`offset < num_records`, `index < num_records`, or `offset < num_records * stride`): a V# with word3 = 0 (mode 0, stride 0) was fully readable and is now always out of range, as on hardware, so the test harnesses' output V# is `0x31016fac` now (`vk_compute_test`, the interpreter tests, `cs_bounds.asm`, `cs_fmt_1010102.asm`, `cs_store.asm`). **How confirmed**: the native RDNA2 measurement (gfx1036) and the gfx1150 oracle (RDNA3.5, same column); GPU test `cs_oob_select.asm` (every mode, literal and run-time V#, words derived from the rules) on an NVIDIA RTX 5070 and an AMD Radeon 880M, which checks the translation, not RDNA2; `tests/semantic/test_buffer_oob_select.py` (a hand-written table of 33 cases over the four modes, loads and stores, both V# forms, plus the multi-dword stores and typed elements); `cs_oob_tail.asm` pins the end-based edge, per-dword x4 loads and stores and the all-or-nothing element, where Mesa's GFX10 column gives other words. **RDNA1 (gfx1011, Navi 12) follows the same RDNA2/GFX11 column**: `tools/buffer_bounds_probe.py` ran 12 one-lane 4-byte `buffer_load_dword` cases at wave32 and wave64 through `tools/hw_oracle` (24 groups, 0 wave32/64 differences); all matched the measured column and 8 disagreed with Mesa's GFX10 column (SHADER-341, results in `docs/buffer_bounds.md`). **Unmeasured**: gfx1013/GFX10.1 itself (see `docs/buffer_bounds.md`), swizzle, unaligned addresses, and the mode 1/2 boundary of `buffer_load_dwordx2..x4` on RDNA2 hardware proper (the gfx1150 proxy shows all dwords in). Checked by `tests/semantic/test_value_semantics.py` (`RawBufferTailBounds`: the RX 6800 rows, values and the addresses loaded) and the GPU tests `runtime/test/shaders/cs_bounds.asm` (AMD Radeon RX 9070 XT, RX 6800), `cs_buf_tail.asm` (RX 6800, Vulkan, driver 26.11.2; aligned offsets only, since the translator's `Aligned 4` loads at byte-exact addresses were not checked on a Vulkan driver) `cs_oob_select.asm` and `cs_oob_tail.asm`. `cs_fmt_xy_xyz.asm` shows the whole element deciding for `_xy` and `_xyz` too, measured natively on a Radeon 680M (gfx1035, RDNA2): components that end inside num_records, in an element that doesn't, read 0 and store nothing. |
diff --git a/docs/first_light.md b/docs/first_light.md
index 9eaff8f37..c3cb2bf1d 100644
--- a/docs/first_light.md
+++ b/docs/first_light.md
@@ -70,9 +70,7 @@ python -I tools/first_light.py --check --out ~/leonida-work/first_light/out
70 70
71`--check` on an existing folder re-runs the harness through the same fresh path and `check_image` as the test; a 71`--check` on an existing folder re-runs the harness through the same fresh path and `check_image` as the test; a
72harness that exits 0 without writing, an all-opaque image and a swapped-U/V image all exit 1. The test has 72harness that exits 0 without writing, an all-opaque image and a swapped-U/V image all exit 1. The test has
73twenty-five cases: the two package-gated draw/manifest checks, the `--check` command, four oracle fixtures, the 7348 cases; `python -I tests/test_first_light.py -v` prints each one.
74mesh depth fit, a preview with non-finite readback channels, the stage files of two shaders with the same name, two
75OBJ parsing checks, seven checks of the textured path (section 6) and six CPU checks of `--camera` (section 7).
76 74
77`first_light.py` carves `shaders.rpf` if the work folder does not have it, translates only the chosen pair, converts 75`first_light.py` carves `shaders.rpf` if the work folder does not have it, translates only the chosen pair, converts
78the OBJ to the harness's mesh file (`u32 vertex_count, u32 index_count`, `(x,y,z,u,v) f32` vertices, `u32` 76the OBJ to the harness's mesh file (`u32 vertex_count, u32 index_count`, `(x,y,z,u,v) f32` vertices, `u32`
@@ -140,10 +138,10 @@ The CPU oracle (`check_image`) samples the decoded `R8G8B8A8_UNORM` texture bili
140`centre_uv` and each `uv_probes` entry and requires the GPU readback to match within `0.02` (rejecting the 138`centre_uv` and each `uv_probes` entry and requires the GPU readback to match within `0.02` (rejecting the
141magenta unbound-texture fallback and wrong-colour probes). Verified on Windows 11 with an NVIDIA GeForce RTX 3060 139magenta unbound-texture fallback and wrong-colour probes). Verified on Windows 11 with an NVIDIA GeForce RTX 3060
142(driver 621.24, Vulkan 1.4.357): **12,804/16,384 (0.781)** covered. Without `LEONIDA_FIRST_LIGHT_DIR`, 140(driver 621.24, Vulkan 1.4.357): **12,804/16,384 (0.781)** covered. Without `LEONIDA_FIRST_LIGHT_DIR`,
143`python -I tests/test_first_light.py -v` runs **46 tests: 42 passed, 4 skipped** (the 3 package-gated 141`python -I tests/test_first_light.py -v` runs **48 tests: 44 passed, 4 skipped** (the 3 package-gated
144`FirstLightTests` require `LEONIDA_FIRST_LIGHT_DIR`, and `test_harness_rejects_wrapped_tsharp_va_overflow` needs a 142`FirstLightTests` require `LEONIDA_FIRST_LIGHT_DIR`, and `test_harness_rejects_wrapped_tsharp_va_overflow` needs a
145built `vk_harness`; the 4 `OracleTests` and the other 11 `TexturedOracleTests` run without a package). With 143built `vk_harness`; the 4 `OracleTests` and the other 11 `TexturedOracleTests` run without a package). With
146`LEONIDA_FIRST_LIGHT_DIR` set against a local package run (and `vk_harness` built) none of the 46 is skipped. 144`LEONIDA_FIRST_LIGHT_DIR` set against a local package run (and `vk_harness` built) none of the 48 is skipped.
147 145
148```sh 146```sh
149python -I tools/first_light.py --game "<package>" --work ~/leonida-work \ 147python -I tools/first_light.py --game "<package>" --work ~/leonida-work \
diff --git a/docs/gbuffer.md b/docs/gbuffer.md
index de76f4746..9813a3306 100644
--- a/docs/gbuffer.md
+++ b/docs/gbuffer.md
@@ -82,3 +82,16 @@ captured PSO):
82 verified against the lighting pass). 82 verified against the lighting pass).
83- The runtime must therefore bind the PSO's declared `RTVFormats[]` rather than inferring `R16G16B16A16_FLOAT` for all 83- The runtime must therefore bind the PSO's declared `RTVFormats[]` rather than inferring `R16G16B16A16_FLOAT` for all
84 G-buffer attachments from `OSG1` or `exp ... compr`. 84 G-buffer attachments from `OSG1` or `exp ... compr`.
85
86## 4. Reproducing the census (`tools/gbuffer_census.py`)
87
88```powershell
89python -I tools/gbuffer_census.py <work>\shaders\dxbc [--disasm <dir>] [--payload-coverage]
90```
91
92Reads `index.json`, each pixel shader's `OSG1` output signature, and the matching `.s` listing under `--disasm`
93(default `<dxbc>\disasm`), and prints JSON counts for four cohorts (all indexed PS, case-folded `deferred` entry
94names, case-sensitive `Deferred` stems, and `PS_DeferredTextured` stems) with declared target counts, signature
95layouts, and observed `exp mrtN` export modes (`compr` vs `uncompressed`). With `--payload-coverage`, it also counts
96distinct whole FSSM payloads per cohort and histograms how many indexed entries share each payload. Standard library
97only; outputs counts and layouts only (no shader text).
diff --git a/docs/gpu_test_results.md b/docs/gpu_test_results.md
index 25a73c7f5..1c3d4d894 100644
--- a/docs/gpu_test_results.md
+++ b/docs/gpu_test_results.md
@@ -6,12 +6,17 @@ post counts and pass/fail lines there, never game shaders, logs or private paths
6 6
7| GPU | Driver, OS | Commit | build.py | check.py | run_gpu_tests.py | Failed | Entry | 7| GPU | Driver, OS | Commit | build.py | check.py | run_gpu_tests.py | Failed | Entry |
8|---|---|---|---|---|---|---|---| 8|---|---|---|---|---|---|---|---|
9| NVIDIA GeForce RTX 5070 Ti (Blackwell), subgroup 32 | NVIDIA 621.01, Windows 11 26300.9457 | `e0b08c7` | not run; pre-disassembled subset | run via run_gpu_tests.py | **Subset:** 82/98 passed, 16 skipped (native); 98/98 passed (`LEONIDA_W64_EMULATE=1`); Python assembler, no spirv-val. ctest 280/280 (MSVC) | none in the subset | [local note](../gpu-test-results/RTX5070Ti-62101.txt) |
9| NVIDIA GeForce RTX 3080 Ti (Ampere), subgroup 32..32 | NVIDIA 616.92, Windows 11 26300.9974 | `d478a92` | not run; pre-disassembled subset | run via run_gpu_tests.py | **Subset:** 81/97 passed, 16 skipped (native); 97/97 passed (`LEONIDA_W64_EMULATE=1`); Python assembler, no spirv-val | none in the subset | [local note](../gpu-test-results/RTX3080Ti-61692.txt) | 10| NVIDIA GeForce RTX 3080 Ti (Ampere), subgroup 32..32 | NVIDIA 616.92, Windows 11 26300.9974 | `d478a92` | not run; pre-disassembled subset | run via run_gpu_tests.py | **Subset:** 81/97 passed, 16 skipped (native); 97/97 passed (`LEONIDA_W64_EMULATE=1`); Python assembler, no spirv-val | none in the subset | [local note](../gpu-test-results/RTX3080Ti-61692.txt) |
10| AMD Radeon RX 9070 GRE (RDNA4, GFX1201), subgroup 32..64 | RADV, Mesa 26.3.1-arch3.5, Vulkan 1.4.363, CachyOS | `05961f0` | 264/264 translated and valid | 203/206 pass, 3 skipped | 218/235 passed, 16 skipped (native and emulated) | `ms_wave_info_s3`, flaky (see below) | [local note](../gpu-test-results/RX9070GRE.txt) | 11| AMD Radeon RX 9070 GRE (RDNA4, GFX1201), subgroup 32..64 | RADV, Mesa 26.3.1-arch3.5, Vulkan 1.4.363, CachyOS | `05961f0` | 264/264 translated and valid | 203/206 pass, 3 skipped | 218/235 passed, 16 skipped (native and emulated) | `ms_wave_info_s3`, flaky (see below) | [local note](../gpu-test-results/RX9070GRE.txt) |
11| AMD Radeon RX 9070 XT (RDNA4, GFX1201), subgroup 32..64 | AMD 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 26300.9550 | `5d74c27` | not run | not run | 224/241 passed, 16 skipped, 1 failed (native); 225/241 passed, 0 failed (`LEONIDA_W64_EMULATE=1`) | `ms_wave_info_s3`, every native run, flaky emulated (see below) | [local note](../gpu-test-results/RX9070XT.txt) | 12| AMD Radeon RX 9070 XT (RDNA4, GFX1201), subgroup 32..64 | AMD 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 26200.9974 | `58be9cd` | exit 0 (native and emulated) | 219/222 pass, 3 skipped (mesh fixtures build.py does not build) | 236/252 passed, 16 skipped, 0 failed (native and `LEONIDA_W64_EMULATE=1`) | none | [local note](../gpu-test-results/RX9070XT.txt) |
13| AMD Radeon RX 9070 (RDNA4, GFX1201), subgroup 32..64 | AMD 26.11.2 (LLPC), 32.0.32029.2010, Vulkan 1.4.359, Windows 11 26200.9974 | `d0da7da` | not run | not run | 231/249 passed, 16 skipped, 2 failed (native and `LEONIDA_W64_EMULATE=1` alike) | `cs_imgload_tfe`, `cs_imgload_d16_tfe`: the fixtures' expectation (#98); `ms_wave_info_s3` passes | [local note](../gpu-test-results/RX9070.txt) |
14| AMD Radeon Graphics, Ryzen 5 7600X iGPU (RDNA2, gfx1036), subgroup 32..64 | AMD 26.11.2, 32.0.21045.29003, Vulkan 1.4.315, Windows 11 26200.9974 | `d0da7da` | not run | not run | 224/249 passed, 23 skipped, 2 failed (native and `LEONIDA_W64_EMULATE=1` alike) | `cs_imgload_tfe`, `cs_imgload_d16_tfe`: the fixtures' expectation (#98) | [local note](../gpu-test-results/Raphael-7600X-Win.txt) |
12| AMD Radeon RX 7900 GRE (RDNA3, gfx1100), subgroup 32..64 | AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 x64 | `5d74c27` | 247/247 translated and valid | run via run_gpu_tests.py | 225/241 passed, 16 skipped | none | [#166](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7115041436) | 15| AMD Radeon RX 7900 GRE (RDNA3, gfx1100), subgroup 32..64 | AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 x64 | `5d74c27` | 247/247 translated and valid | run via run_gpu_tests.py | 225/241 passed, 16 skipped | none | [#166](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7115041436) |
13| Intel Graphics (Meteor Lake, Xe-LPG), subgroup 8..32 | ANV, Mesa 26.2.7, Vulkan 1.4.354, Fedora 45 | `84347bb` | 279/279 translated and valid | 177/219 pass, 40 skipped, 2 failed | 194/248 passed, 52 skipped (native); 226/248 passed, 20 skipped (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31; pass with #98) | [local note](../gpu-test-results/IntelMTL.txt) | 16| Intel Graphics (Meteor Lake, Xe-LPG), subgroup 8..32 | ANV, Mesa 26.2.7, Vulkan 1.4.354, Fedora 45 | `84347bb` | 279/279 translated and valid | 177/219 pass, 40 skipped, 2 failed | 194/248 passed, 52 skipped (native); 226/248 passed, 20 skipped (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31; pass with #98) | [local note](../gpu-test-results/IntelMTL.txt) |
17| NVIDIA GeForce RTX 5070 Ti (Blackwell), subgroup 32..32 | NVIDIA 617.42, Vulkan 1.4.351, Windows 11 Pro 26300 | `21625bc` | 257/257 translated and valid (run_gpu_tests.py) | run via run_gpu_tests.py | 197/248 passed, 49 skipped, 2 failed (native); 229/248 passed, 17 skipped, 2 failed (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31) | [local note](../gpu-test-results/RTX5070Ti.txt) |
14| Apple M5 Pro (16-core GPU, Metal 4), subgroup 4..32 | MoltenVK 1.4.2 (Homebrew), Vulkan 1.4.357, macOS 26.7.3 (25G342) | `d42773d07` | 280/280 translated and valid | 175/219 pass, 39 skipped, 5 failed | 183/248 passed, 61 skipped, 4 failed (native); 214/248 passed, 30 skipped, 4 failed (`LEONIDA_W64_EMULATE=1`) | `cs_fma_fused` (known row), `cs_imgload_tfe`, `cs_imgload_d16_tfe` (pass with #291), `ps_imgatomic` flake (#543) | [local note](../gpu-test-results/AppleM5Pro.txt) | 18| Apple M5 Pro (16-core GPU, Metal 4), subgroup 4..32 | MoltenVK 1.4.2 (Homebrew), Vulkan 1.4.357, macOS 26.7.3 (25G342) | `d42773d07` | 280/280 translated and valid | 175/219 pass, 39 skipped, 5 failed | 183/248 passed, 61 skipped, 4 failed (native); 214/248 passed, 30 skipped, 4 failed (`LEONIDA_W64_EMULATE=1`) | `cs_fma_fused` (known row), `cs_imgload_tfe`, `cs_imgload_d16_tfe` (pass with #291), `ps_imgatomic` flake (#543) | [local note](../gpu-test-results/AppleM5Pro.txt) |
19| NVIDIA GeForce RTX 3080 (Ampere, GA102, 10 GB GDDR6X), subgroup 32..32 | NVIDIA 580.178.04, Vulkan 1.4.312, Ubuntu 26.04 LTS | `d2cd6c0` | not run | not run | 197/248 passed, 49 skipped, 2 failed (native); 229/248 passed, 17 skipped, 2 failed (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31; see #280) | [local note](../gpu-test-results/RTX3080.txt) |
15 20
16## AMD Radeon RX 9070 GRE — 2026-11-23 21## AMD Radeon RX 9070 GRE — 2026-11-23
17 22
@@ -37,43 +42,38 @@ Every pixel test other than the flaky mesh fixture was exact (4096/4096).
37AI-assisted (Hermes Agent): built `main` at `05961f0`, ran `build.py`, `check.py` and 42AI-assisted (Hermes Agent): built `main` at `05961f0`, ran `build.py`, `check.py` and
38`run_gpu_tests.py` (native and emulated) on this GPU, and verified the isolated reruns of the one failure. 43`run_gpu_tests.py` (native and emulated) on this GPU, and verified the isolated reruns of the one failure.
39 44
40## AMD Radeon RX 9070 XT — 2026-11-23 45## AMD Radeon RX 9070 XT — 2026-11-24
41 46
42``` 47```
43GPU: AMD Radeon RX 9070 XT (RDNA4 / GFX1201, Navi 48, PCI 1002:7550), subgroup 32..64 48GPU: AMD Radeon RX 9070 XT (RDNA4 / GFX1201, Navi 48, PCI 1002:7550), subgroup 32..64
44Driver: AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359 49Driver: AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359
45Subgroup: 32..64 (minSubgroupSize 32, maxSubgroupSize 64; default 64, subgroupSizeControl) 50Subgroup: 32..64 (minSubgroupSize 32, maxSubgroupSize 64; default 64, subgroupSizeControl)
46OS: Windows 11, 10.0.26300.9550 51OS: Windows 11, 10.0.26200.9974
47Commit: 5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (main, 2026-11-23) 52Commit: 58be9cdf8df9a31bc7f6c068991f1aed381f7f4d (main, 2026-11-24)
48Tools: llvm-mc from ROCm/AOMP 18.0-12 (LLVM 19.0.0git), SPIRV-Tools v2026.4, 53Tools: llvm-mc LLVM 23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4,
49 CMake 4.4.5, Visual Studio 17 2022 generator, MSVC 19.44.35230.0, Python 3.11.9 54 CMake 4.4.4, Visual Studio 17 2022 generator, MSVC 14.44.35207, Python 3.12.10
50run_gpu_tests.py: 247 shaders: 247 translated, 247 pass spirv-val 55run_gpu_tests.py: 261 shaders: 261 translated, 261 pass spirv-val
51 native: 224/241 passed, 16 skipped, 1 failed 56 native: 236/252 passed, 16 skipped, 0 failed
52 LEONIDA_W64_EMULATE=1: 225/241 passed, 16 skipped, 0 failed 57 LEONIDA_W64_EMULATE=1: 236/252 passed, 16 skipped, 0 failed
53Failed: ms_wave_info_s3: at (0,0) got (-1,-1,-1,-1), want (0.0078,0.0078,0.5,1.0). 58build.py: exit 0, native and emulated (6 mesh fixtures need a DXBC container and are not built)
54 Native: 3 of 3 isolated --filter reruns failed. Emulated: the full-suite 59check.py: 219 of 222 pass, 3 skipped (those mesh fixtures), native and emulated
55 run passed it, then 1 of 3 isolated reruns passed, so the emulated path 60Failed: none
56 is flaky here while native fails every time. Same signature as #6172 /
57 #5273 and as the RTX 4060 record (#8752), where it failed 3 of 3.
58Skipped: 16 skips are the documented "run by d3d12_*_test / w64_graphics.py" cases. 61Skipped: 16 skips are the documented "run by d3d12_*_test / w64_graphics.py" cases.
59``` 62```
60 63
61Setup: `cmake -S runtime -B runtime/build` (default Visual Studio 17 2022 generator) and 64Setup: `cmake -S runtime -B runtime/build` (default Visual Studio 17 2022 generator) and
62`cmake --build runtime/build --config RelWithDebInfo`. The suite ran on the AMD LLPC driver with 65`cmake --build runtime/build --config RelWithDebInfo`; then `run_gpu_tests.py`, and `build.py <out>` with
63the project's own `vk_harness`, `vk_compute_test` and `vk_store_test` binaries; no implicit layer 66`check.py <out> runtime/build/RelWithDebInfo`, each once without and once with `LEONIDA_W64_EMULATE=1`. The suites
64beyond the Vulkan SDK's. Every other pixel and compute case was exact. 67ran on the AMD LLPC driver with the project's own `vk_harness`, `vk_compute_test` and `vk_store_test` binaries; no
65 68implicit layer beyond the Vulkan SDK's.
66The one failure is worth a note for #6172: on this machine the native 64-wide path fails 69
67`ms_wave_info_s3` on every run, while `LEONIDA_W64_EMULATE=1` passes it most of the time, which is 70This replaces the 2026-11-23 record (`5d74c27`), which had `ms_wave_info_s3` failing on every native run and
68the shape a lane-set-dependent race takes rather than a driver-specific miscompile. It also 71`build.py` / `check.py` not run. On `58be9cd` the same driver passes `ms_wave_info_s3` with 4096/4096 exact pixels in
69reproduces with an AMD proprietary driver, so the symptom is not tied to RADV or to Mesa's shader 72both full runs and in 3 of 3 isolated `--filter` reruns each way, and the D3D12-side columns are measured for the
70cache. 73first time on this card. The two `cs_imgload*_tfe` failures of earlier runs are gone with the fixture fix (#892).
71 74
72`build.py` and `check.py` (the D3D12-side rows in the table) were not run here; the counts above 75AI-assisted: built `main` at `58be9cd` with MSVC, ran the three scripts native and under `LEONIDA_W64_EMULATE=1`,
73come from `run_gpu_tests.py`, which builds and translates the same fixtures. 76and reran `ms_wave_info_s3` in isolation three times each way.
74
75AI-assisted (Cline): built `main` at `5d74c27` with MSVC, ran `run_gpu_tests.py` native and under
76`LEONIDA_W64_EMULATE=1`, and reran the failure in isolation three times each way.
77 77
78## AMD Radeon RX 7900 GRE — 2026-11-23 78## AMD Radeon RX 7900 GRE — 2026-11-23
79 79
diff --git a/docs/i18n/README.md b/docs/i18n/README.md
index 35fa1ef96..82cb57c29 100644
--- a/docs/i18n/README.md
+++ b/docs/i18n/README.md
@@ -24,3 +24,8 @@ A language is added when a contributor volunteers to maintain it and keeps the s
24| Deutsch (`de`) | [`de/quickstart.md`](de/quickstart.md) | `aa2988cc` | `@zGLados` | 24| Deutsch (`de`) | [`de/quickstart.md`](de/quickstart.md) | `aa2988cc` | `@zGLados` |
25| Italiano (`it`) | [`it/quickstart.md`](it/quickstart.md) | `49475796` | `@MeNoSkills` | 25| Italiano (`it`) | [`it/quickstart.md`](it/quickstart.md) | `49475796` | `@MeNoSkills` |
26| العربية (`ar`) | [`ar/quickstart.md`](ar/quickstart.md) | `561b65a` | `@Mohamed-Leo` | 26| العربية (`ar`) | [`ar/quickstart.md`](ar/quickstart.md) | `561b65a` | `@Mohamed-Leo` |
27
28## Other community translations
29
30- French translation of [`CONTRIBUTING.md`](../../CONTRIBUTING.md): [`fr/contributing.md`](fr/contributing.md), synced
31 with commit `1ab957b3`. No maintainer is named in the file.
diff --git a/docs/i18n/it/quickstart.md b/docs/i18n/it/quickstart.md
index d42f35727..432b1eb72 100644
--- a/docs/i18n/it/quickstart.md
+++ b/docs/i18n/it/quickstart.md
@@ -96,8 +96,8 @@ python -I make_game.py --wave64-emulate off # auto (predefinito), on
96``` 96```
97 97
98La fase `check` viene eseguita sempre per prima; poi, quando sono selezionate, `shaders`, `assets` e `runtime` vengono eseguite insieme (non dipendono l'una dall'altra). `pipelines` parte quando gli shader tradotti sono pronti. 98La fase `check` viene eseguita sempre per prima; poi, quando sono selezionate, `shaders`, `assets` e `runtime` vengono eseguite insieme (non dipendono l'una dall'altra). `pipelines` parte quando gli shader tradotti sono pronti.
99`pipelines` crea ogni shader tradotto sul driver della tua GPU e salva una cache delle pipeline, così al primo 99`pipelines` crea ogni shader tradotto sul driver della tua GPU e salva una cache delle pipeline in
100avvio non devono essere compilati. La traduzione degli shader è il passaggio più lungo: usa `--jobs` processi 100`pipeline_cache.bin` (in `--out`). La traduzione degli shader è il passaggio più lungo: usa `--jobs` processi
101(per impostazione predefinita metà dei thread della CPU). 101(per impostazione predefinita metà dei thread della CPU).
102 102
103- **`--wave64-emulate`**: traduce gli shader compute e mesh wave64 in modo che siano esatti con qualunque 103- **`--wave64-emulate`**: traduce gli shader compute e mesh wave64 in modo che siano esatti con qualunque
diff --git a/docs/i18n/ja/quickstart.md b/docs/i18n/ja/quickstart.md
index 2924be033..d9a45926f 100644
--- a/docs/i18n/ja/quickstart.md
+++ b/docs/i18n/ja/quickstart.md
@@ -84,8 +84,8 @@ python -I make_game.py --wave64-emulate off # auto(既定)、onã€
84``` 84```
85 85
86`check` ステージは常に最初に実行され、選択した場合は `shaders`、`assets`、`runtime` が同時に実行されます(互いに依存しません)。`pipelines` は翻訳済みのシェーダーが揃い次第開始されます。このステージは 86`check` ステージは常に最初に実行され、選択した場合は `shaders`、`assets`、`runtime` が同時に実行されます(互いに依存しません)。`pipelines` は翻訳済みのシェーダーが揃い次第開始されます。このステージは
87翻訳済みの各シェーダーをあなたの GPU ドライバー上で生成してパイプラインキャッシュを保存するので、初回起動時の 87翻訳済みの各シェーダーをあなたの GPU ドライバー上で生成し、パイプラインキャッシュを `--out` の
88コンパイルが不要になります。最も時間がかかるのはシェーダーの翻訳で、`--jobs` 個のプロセスで実行されます 88`pipeline_cache.bin` に保存します。最も時間がかかるのはシェーダーの翻訳で、`--jobs` 個のプロセスで実行されます
89(既定では CPU スレッド数の半分)。 89(既定では CPU スレッド数の半分)。
90 90
91- **`--wave64-emulate`**: wave64 の compute / mesh シェーダーを、どのサブグループサイズでも正確になるように 91- **`--wave64-emulate`**: wave64 の compute / mesh シェーダーを、どのサブグループサイズでも正確になるように
diff --git a/docs/i18n/pl-PL/quickstart.md b/docs/i18n/pl-PL/quickstart.md
index 29cfb6a08..3bad5af88 100644
--- a/docs/i18n/pl-PL/quickstart.md
+++ b/docs/i18n/pl-PL/quickstart.md
@@ -95,8 +95,8 @@ python -I make_game.py --wave64-emulate off # auto (domyślnie), on l
95``` 95```
96 96
97Etap `check` zawsze wykonuje się pierwszy; następnie, jeśli zostały wybrane, `shaders`, `assets` i `runtime` wykonują się równocześnie (nie zależą od siebie). Etap `pipelines` startuje, gdy przetłumaczone shadery są gotowe. Ten etap 97Etap `check` zawsze wykonuje się pierwszy; następnie, jeśli zostały wybrane, `shaders`, `assets` i `runtime` wykonują się równocześnie (nie zależą od siebie). Etap `pipelines` startuje, gdy przetłumaczone shadery są gotowe. Ten etap
98tworzy każdy przetłumaczony shader na sterowniku Twojej karty graficznej i zapisuje cache potoków, żeby pierwsze 98tworzy każdy przetłumaczony shader na sterowniku Twojej karty graficznej i zapisuje cache potoków
99uruchomienie nie musiało ich kompilować. Tłumaczenie shaderów trwa najdłużej i domyślnie używa połowy wątków 99w `pipeline_cache.bin` (w `--out`). Tłumaczenie shaderów trwa najdłużej i domyślnie używa połowy wątków
100procesora (można to zmienić przez `--jobs`). 100procesora (można to zmienić przez `--jobs`).
101 101
102- **`--wave64-emulate`**: decyduje, czy shadery compute i mesh wave64 są tłumaczone tak, by były dokładne przy 102- **`--wave64-emulate`**: decyduje, czy shadery compute i mesh wave64 są tłumaczone tak, by były dokładne przy
diff --git a/docs/i18n/ru/quickstart.md b/docs/i18n/ru/quickstart.md
index 818e47fe4..4b1d89a80 100644
--- a/docs/i18n/ru/quickstart.md
+++ b/docs/i18n/ru/quickstart.md
@@ -112,10 +112,12 @@ python -I make_game.py --game "D:\путь\к\пакету" --wav # ещё и Op
112python -I make_game.py --wave64-emulate off # auto (по умолчанию), on или off 112python -I make_game.py --wave64-emulate off # auto (по умолчанию), on или off
113``` 113```
114 114
115Этапы идут в таком порядке: `check`, `shaders`, `assets`, `runtime`, `pipelines`. Последний создаёт все 115`check` всегда идёт первым; затем выбранные `shaders`, `assets` и `runtime` выполняются одновременно (они не
116переведённые шейдеры на драйвере вашей видеокарты, проверяет, что они компилируются, сообщает о пропущенных и 116зависят друг от друга). `pipelines` начинается, как только готовы переведённые шейдеры и, если в этот запуск входит
117сохраняет кеш конвейеров в `pipeline_cache.bin` в `--out`. Runtime этот кеш пока не загружает, так что первую 117`runtime`, этот этап закончил пересобирать `vk_pipeline_check`, так что он может идти параллельно с остатком
118загрузку он не ускоряет. Перевод шейдеров самый долгий: он выполняется в `--jobs` процессов (по умолчанию 118`assets`. Этап `pipelines` создаёт все переведённые шейдеры на драйвере вашей видеокарты, проверяет, что они
119компилируются, сообщает о пропущенных и сохраняет кеш конвейеров в `pipeline_cache.bin` в `--out`. Runtime этот
120кеш пока не загружает, так что первую загрузку он не ускоряет. Перевод шейдеров самый долгий: он выполняется в `--jobs` процессов (по умолчанию
119половина потоков процессора). 121половина потоков процессора).
120 122
121- **`--wave64-emulate`**: переводить ли compute- и mesh-шейдеры wave64 так, чтобы они работали точно при любом 123- **`--wave64-emulate`**: переводить ли compute- и mesh-шейдеры wave64 так, чтобы они работали точно при любом
diff --git a/docs/linux.md b/docs/linux.md
index 555cb3ed4..c9ea03b84 100644
--- a/docs/linux.md
+++ b/docs/linux.md
@@ -119,3 +119,36 @@ python3 -I tests/test_<name>.py # one standard-
119 119
120[testing.md](testing.md) covers the GPU tests (`scripts/run_gpu_tests.py`), running them on llvmpipe, and choosing 120[testing.md](testing.md) covers the GPU tests (`scripts/run_gpu_tests.py`), running them on llvmpipe, and choosing
121the GPU. 121the GPU.
122
123### Without root (micromamba)
124
125If you cannot install distribution packages (no `sudo`), you can install `llvm-tools` and `spirv-tools` into a
126user-owned folder with [micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)
127(x86-64 glibc; for ARM64 use `linux-aarch64` from the micromamba guide; musl/Alpine is not natively supported) and let
128CMake fetch its pinned, hash-checked Vulkan headers if the system does not provide them:
129
130```bash
131LEO=$HOME/leonida-tools
132mkdir -p "$LEO/bin" "$LEO/mamba"
133# Note: `latest` is unpinned and downloaded without signature verification; inspect or pin per the micromamba guide.
134curl -fsSLo "$LEO/micromamba.tar.bz2" https://micro.mamba.pm/api/micromamba/linux-64/latest
135tar -xjf "$LEO/micromamba.tar.bz2" -C "$LEO/bin" --strip-components=1 bin/micromamba
136
137export MAMBA_ROOT_PREFIX="$LEO/mamba"
138"$LEO/bin/micromamba" create -y -n leonida -c conda-forge --override-channels "llvm-tools>=21" spirv-tools
139export PATH="$LEO/mamba/envs/leonida/bin:$PATH"
140
141cmake -S runtime -B runtime/build/linux -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_VULKAN_HEADERS_FETCH=ON
142cmake --build runtime/build/linux --parallel "$(nproc)"
143LLVM_MC=llvm-mc LEONIDA_VK_DEVICE="<part of your GPU name>" \
144 python3 -I scripts/run_gpu_tests.py --build runtime/build/linux --work "$LEO/run" --require-pass | tee "$LEO/run.log"
145echo "runner exit: ${PIPESTATUS[0]}"
146```
147
148Notes:
149- `LEONIDA_VK_DEVICE` selects the physical GPU by substring so the runner does not fall back to Mesa's `llvmpipe`.
150- Keep `$LEO` on a filesystem without `noexec` (`findmnt -no OPTIONS "$LEO"`).
151- System prerequisites still needed: a working Vulkan driver/loader (`vulkaninfo --summary`), `cmake`, `ninja`, `g++`
152 (or `clang++`), `python3`, `curl`, `tar`, and `bzip2`.
153- Cleanup: delete `$LEO` and `runtime/build/linux`. micromamba also writes `~/.conda/environments.txt` and
154 `~/.mamba/pkgs/urls.txt` (delete only those files if you already use conda).
diff --git a/docs/models.md b/docs/models.md
index 85b805feb..ba1cd5433 100644
--- a/docs/models.md
+++ b/docs/models.md
@@ -799,7 +799,7 @@ the drawable's local joint palette through the drawable and ped tables, and emit
799in [character_skeleton.md](character_skeleton.md#skinned-glb-export). On the 1.0.2.1 package, the 799in [character_skeleton.md](character_skeleton.md#skinned-glb-export). On the 1.0.2.1 package, the
800head (8,983 v) and biker jacket (9,818 v) produce one skin with 596 ped joints (703 with the 800head (8,983 v) and biker jacket (9,818 v) produce one skin with 596 ped joints (703 with the
801jacket's `GM_U01_*` helpers); every weight sums to 255 and the rest-pose reconstruction error is 801jacket's `GM_U01_*` helpers); every weight sums to 255 and the rest-pose reconstruction error is
8026e-8 m. `python -I tests/test_skinned_glb.py` runs 24 synthetic tests and needs no game files. 8026e-8 m. `python -I tests/test_skinned_glb.py` runs 30 synthetic tests and needs no game files.
803 803
804`tools/glb_inspect.py` reads such a GLB back without a library, so an export can be checked 804`tools/glb_inspect.py` reads such a GLB back without a library, so an export can be checked
805before it is opened in a viewer: 805before it is opened in a viewer:
diff --git a/docs/movies.md b/docs/movies.md
index e8df76d29..252bef758 100644
--- a/docs/movies.md
+++ b/docs/movies.md
@@ -114,8 +114,9 @@ and then only to a temporary file that is deleted.
114 114
115On this archive both tools find the same 515 streams, the same 8,831,336,892 bytes, 1,094,744 bytes of zero 115On this archive both tools find the same 515 streams, the same 8,831,336,892 bytes, 1,094,744 bytes of zero
116padding and 22,812 bytes after the last stream. Those 22,812 are 3,884 zero bytes and the 18,928-byte RPF trailer 116padding and 22,812 bytes after the last stream. Those 22,812 are 3,884 zero bytes and the 18,928-byte RPF trailer
117(counted by reading the tail directly); `bink_index.py` now counts them as zero padding and `rpf_trailer`, which for 117(counted by reading the tail directly). A read-only rerun of `bink_index.py` at `2d53a8055` on 2026-11-23
118this archive gives `unread_bytes` 0 and zero padding 1,098,628 (derived from the measured tail, not a rerun). Running `bink_index.py` on the 515 carved 118confirmed 1,098,628 bytes of zero padding, 18,928 trailer bytes and 0 unread bytes. The archive matched the
1191.0.2.1 manifest by size and SHA-256. Running `bink_index.py` on the 515 carved
119`.bk2` files finds 515 streams with zero unread bytes, which confirms the stored sizes cover each file exactly. 120`.bk2` files finds 515 streams with zero unread bytes, which confirms the stored sizes cover each file exactly.
120 121
121## 4. Decoding 122## 4. Decoding
diff --git a/docs/pipeline_check.md b/docs/pipeline_check.md
index bf1295c95..e8c447629 100644
--- a/docs/pipeline_check.md
+++ b/docs/pipeline_check.md
@@ -256,7 +256,7 @@ acceptance only.
256 256
257A SPIR-V module larger than 4 MiB is "large". [#884](https://github.com/ItsNotRexed/Leonida/issues/884) 257A SPIR-V module larger than 4 MiB is "large". [#884](https://github.com/ItsNotRexed/Leonida/issues/884)
258showed why that matters: several compiles that each needed gigabytes of host RAM ran at the same time. Large 258showed why that matters: several compiles that each needed gigabytes of host RAM ran at the same time. Large
259modules now share a memory budget (`runtime/test/large_module_gate.h`): each one reserves 512 bytes of RAM per 259modules now share a memory budget (`runtime/src/large_module_gate.h`): each one reserves 512 bytes of RAM per
260SPIR-V byte, and they enter the driver while their reservations fit three quarters of the memory available when 260SPIR-V byte, and they enter the driver while their reservations fit three quarters of the memory available when
261the run starts, up to `--jobs` of them. One large module always gets in when none is compiling, so a module 261the run starts, up to `--jobs` of them. One large module always gets in when none is compiling, so a module
262bigger than the whole budget still compiles, alone among the large ones. Small modules are never held back, and a 262bigger than the whole budget still compiles, alone among the large ones. Small modules are never held back, and a
@@ -459,6 +459,10 @@ driver gives it the same cache key in both programs. Measured on Windows with an
459 `VK_KHR_maintenance8` into the pipeline cache key even for compute shaders, so the checker enables both whenever 459 `VK_KHR_maintenance8` into the pipeline cache key even for compute shaders, so the checker enables both whenever
460 supported and keeps `meshShaderQueries` on. 460 supported and keeps `meshShaderQueries` on.
461- On a Windows RTX 5070 Ti (617.42), a compute-only seed missed with mesh features omitted and hit with the supported mesh and mesh-query features enabled on both devices. The shader, push constants and pipeline layout were identical. Cache-producing runs request this device configuration for every selected shader batch. 461- On a Windows RTX 5070 Ti (617.42), a compute-only seed missed with mesh features omitted and hit with the supported mesh and mesh-query features enabled on both devices. The shader, push constants and pipeline layout were identical. Cache-producing runs request this device configuration for every selected shader batch.
462- On Windows with an AMD Radeon RX 7900 XT, `VK_EXT_transform_feedback` (with `transformFeedback` enabled, and
463 `geometryStreams` when the device offers it) is part of the key: the runtime enables it whenever the extension is
464 present (D3D-302), so the checker enables it too. Without it, `pipeline_cache_seed` failed 3 of 3 on that GPU and
465 passed 3 of 3 on `main`. NVIDIA leaves it out of the key, which is why it did not show up on the RTX 3080 Ti.
462- The executable's file name is part of the key; its folder is not. A copy of the checker under another name 466- The executable's file name is part of the key; its folder is not. A copy of the checker under another name
463 misses the cache the original wrote, and the runtime's device hits the checker's cache only from a program 467 misses the cache the original wrote, and the runtime's device hits the checker's cache only from a program
464 with the checker's file name. So on this driver a cache written by `vk_pipeline_check.exe` does not hit in 468 with the checker's file name. So on this driver a cache written by `vk_pipeline_check.exe` does not hit in
diff --git a/docs/progress_dashboard.md b/docs/progress_dashboard.md
index 88647e1f0..8a99ebd8b 100644
--- a/docs/progress_dashboard.md
+++ b/docs/progress_dashboard.md
@@ -13,6 +13,21 @@ start ..\leonida_progress\progress.html
13The page is one self-contained HTML file: no network, no packages, it opens from disk. The project logo 13The page is one self-contained HTML file: no network, no packages, it opens from disk. The project logo
14(`assets/logo.png`) is embedded in it, and the page follows the system theme until you pick one with its theme button. 14(`assets/logo.png`) is embedded in it, and the page follows the system theme until you pick one with its theme button.
15 15
16Use a CTest JUnit report when the run includes tests configured with `SKIP_RETURN_CODE`. CTest can log those
17skips as `Test Passed.` in `LastTest.log`. `--ctest-junit` replaces the local log with the report, which preserves
18the skipped status. Use `--junit` to add independent runs. A new file name for each run keeps an aborted CTest run
19from reusing an older report.
20
21```powershell
22$report = Join-Path $env:TEMP ("leonida-ctest-{0}.xml" -f [guid]::NewGuid())
23ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure --output-junit $report
24if (Test-Path -LiteralPath $report -PathType Leaf) {
25 python -I tools/progress_dashboard.py --out ..\leonida_progress --ctest-junit $report
26} else {
27 throw "CTest did not produce a JUnit report (exit $LASTEXITCODE)."
28}
29```
30
16## Sources 31## Sources
17 32
18Each source is optional. A missing one is listed under "Sources" on the page; it is never counted as zero or as a failure. 33Each source is optional. A missing one is listed under "Sources" on the page; it is never counted as zero or as a failure.
diff --git a/docs/related_projects.md b/docs/related_projects.md
index b1e8e77ec..a3a58ff99 100644
--- a/docs/related_projects.md
+++ b/docs/related_projects.md
@@ -139,6 +139,24 @@ re-measured on this package by `tools/navmesh_nodes.py`
139confirmed by the lane-graph heights. The label is consistent with the count, but not settled by it: nine in ten 139confirmed by the lane-graph heights. The label is consistent with the count, but not settled by it: nine in ten
140lane nodes stand on polygons with both bit 8 and bit 13, and which bit or combination means road surface is open. 140lane nodes stand on polygons with both bit 8 and bit 13, and which bit or combination means road surface is open.
141 141
142## Marvisak/VIctory
143
144<https://github.com/Marvisak/VIctory>
145
146A Windows compatibility project for Xbox Series. Its GPU layer translates console command streams to host
147Direct3D 12.
148
149**Licence:** **GPL-3.0-or-later**, as declared in the [workspace manifest][victory-workspace] and the
150[README][victory-readme]. The [GPU crate][victory-gpu] inherits the workspace licence.
151
152**What we use it for:** prior art for deferring CPU-side value writes until the recorded command-list work has
153completed, as discussed in [#622](https://github.com/ubiquitarianism/leonida/pull/622). That PR uses synthetic
154tests to verify the ordering of submissions and writes in Leonida's own implementation.
155
156[victory-workspace]: https://github.com/Marvisak/VIctory/blob/ffe310eb2098e52169f4c44db5ffdabf43a72622/Cargo.toml
157[victory-readme]: https://github.com/Marvisak/VIctory/blob/ffe310eb2098e52169f4c44db5ffdabf43a72622/README.md#license
158[victory-gpu]: https://github.com/Marvisak/VIctory/blob/ffe310eb2098e52169f4c44db5ffdabf43a72622/crates/victory-gpu/Cargo.toml
159
142## microsoft/libHttpClient 160## microsoft/libHttpClient
143 161
144<https://github.com/microsoft/libHttpClient> 162<https://github.com/microsoft/libHttpClient>
diff --git a/docs/retail_boot_chain.md b/docs/retail_boot_chain.md
index e693b2a2b..70953f46b 100644
--- a/docs/retail_boot_chain.md
+++ b/docs/retail_boot_chain.md
@@ -106,3 +106,53 @@ not an `E_NOTIMPL`.
106 106
107These are one run's first failures, not a list of what is missing. Every stand-in above is local and untested 107These are one run's first failures, not a list of what is missing. Every stand-in above is local and untested
108beyond "the title goes on to the next call". Nothing has reached a draw or a present yet. 108beyond "the title goes on to the next call". Nothing has reached a draw or a present yet.
109
110## 5. The device slots the executable calls, from the file (RT-566)
111
112The chain above finds the next slot by running the title; `tools/d3d12_device_calls.py` reads the file alone,
113without running anything, and reports the statically resolved `ID3D12Device` vtable call sites for the device paths
114it follows:
115
116```sh
117python -I tools/d3d12_device_calls.py <game>/game_scarlett_master.exe --out <work>/device_calls
118```
119
120It writes `<exe>.device_calls.txt` (slot numbers and counts only) and `.json` (the same, plus each site's RVA for
121local follow-up; don't paste that part) into the `--out` folder. It reads the executable only, so a slot called only
122from a bundled DLL is absent from it: slot 76, for one, isn't in the census, yet `docs/d3d12_vulkan.md` (the slot 76
123row of its contract table, and §4.2) records the FidelityFX upscaler DLL creating its resources through it. A slot
124missing from the census is not a slot the title never uses. The method, in its docstring: it finds the
125`D3D12XboxCreateDevice` call sites, follows the out-pointer in `r9` to the global or stack slot it fills and the
126globals the device is copied to, and counts per slot the `mov vtable,[device]` → `call [vtable+disp]` (or
127`call reg`, or a call to a dispatch routine with the method in `rax`) sites, with `disp / 8` as the slot. A
128dispatch routine counts only when its code reaches `jmp rax` or `call rax` without writing `rax`, calling or
129returning first; a call to any other target with a method in `rax` is reported as not resolved. Per slot it shows
130calls and tail jumps, whether the device is in `rcx` or in `rdx` (the return-buffer form of §3.1), and an
131argument-count estimate. Slots 0-43 carry the PC method names, which the console keeps where measured (8, 9, 14, 26,
13236); past 43 only the slots `runtime/shims/d3d12_xs_device.h` and §3 name are named.
133
134The walk follows forward branches within a function (a `jmp rel32` there is a branch, not a tail call) and keeps
135a fact at a join only when both paths agree. What it doesn't see, and says so: the device reached through an object
136member, a function parameter or a getter's return value; a path it loses, such as a loop's back edge; an indexed
137method load. The report counts the vtable loads with no matched call, the calls with a method in `rax`
138to a target that isn't a verified dispatch routine, the calls that are handed the device (not followed into), and
139the stores of the device to non-stack memory. A slot can be called more often than the report says, or on a
140path it doesn't follow, so a slot with no row (12 and 51, for example) isn't shown to be uncalled.
141
142On the 1.0.2.1 executable it finds one `D3D12XboxCreateDevice` call site writing a global and 95 sites across
14342 slots: 94 indirect vtable calls and one indirect vtable tail jump (at slot 2), with no dispatch call resolved;
144the `rdx` form at slots 25, 26 and 108 only; and 12 sites it reports as not resolved. Every device slot
145the chain above reached (8, 26, 48, 73, 133) is among them; slots like 49, 55, 57, 61, 70, 71, 74, 81, 86, 101,
146108, 119, 127 and 132 are called but have no name in this repository yet.
147
148For some of the unnamed slots there is a call shape from an independent static read with a different scanner, by
149TreXito (in the review of old upstream PR 7998), with the same site counts for 49, 50, 55, 57, 71 and 81. These
150are their reads, not this tool's:
151
152| Slot | What the call is (TreXito's read) |
153|---:|---|
154| 49 | Only behind an OS-version gate; no run reaches it today |
155| 50 | Only on a fatal path that ends in `int3` |
156| 55 | `CreateDerivedPipelineState(base, n, records, riid, out)`, on a PSO-cache hit (old upstream PR 7759) |
157| 57 | `(desc, IID_ID3D12PipelineState, out)`, the native-record graphics pipeline |
158| 81 | `(object, a constant flags argument, &count, out)`; the result is used only on success |
diff --git a/docs/rpf.md b/docs/rpf.md
index 7bc656845..8b374ce42 100644
--- a/docs/rpf.md
+++ b/docs/rpf.md
@@ -129,6 +129,17 @@ scanners on a 48 MiB gap and checks that each one's Python heap peak stays under
129The carve is read-only and works on any `.rpf`, `.ttpf` or archive-like file. It does not decrypt the TOC, use 129The carve is read-only and works on any `.rpf`, `.ttpf` or archive-like file. It does not decrypt the TOC, use
130keys, or write anything outside the output directory. 130keys, or write anything outside the output directory.
131 131
132Once one or more archives have been carved under `<work>\carve`, `tools/classify_carve.py` groups every entry by
133signature using only the per-archive `index.json` files (no carved payload reads):
134
135```powershell
136python -I tools/classify_carve.py <work>\carve
137```
138
139It classifies each entry as `bink2` (`KB2x`), `rbf0` (`52424630`), `respage` (`42400000`), `gpu-zerohdr` (16+ leading
140zero bytes), or `other:<hex>` (first 4 bytes), prints a summary table, and writes `<work>\carve\types.json` with
141overall and per-archive file counts, total bytes, and `min`/`max`/`median` (`median_low`) byte sizes.
142
132## Recovery tools 143## Recovery tools
133 144
134`tools/rpf9dump` is a bulk exporter built on the Core library from 145`tools/rpf9dump` is a bulk exporter built on the Core library from
diff --git a/docs/runtime_imports.md b/docs/runtime_imports.md
index 3d6efb25f..e38dfbf74 100644
--- a/docs/runtime_imports.md
+++ b/docs/runtime_imports.md
@@ -290,10 +290,17 @@ and the `api-ms-win-core-file-*` sets a GDK title links against.
290 passed to the host unchanged. `--game-dir` defaults to the image's folder. `gta6rt` makes it and `--overlay` 290 passed to the host unchanged. `--game-dir` defaults to the image's folder. `gta6rt` makes it and `--overlay`
291 absolute at startup, so a bare image name (`gta6rt --run game.exe` from the game folder) and a relative folder 291 absolute at startup, so a bare image name (`gta6rt --run game.exe` from the game folder) and a relative folder
292 both keep naming the same place after the title changes its current directory (CTest `run_tiny_game_dir`). 292 both keep naming the same place after the title changes its current directory (CTest `run_tiny_game_dir`).
293 `G:\` is the same folder as `GAME:`, and `T:\` is a scratch folder, `<overlay>\.gta6rt-temp`, that `GAME:` does 293 `G:\` is the same folder as `GAME:`, and `T:\` is a scratch folder that `GAME:` does not see (RT-218; the other
294 not see (RT-218; the other console layers map those two drives this way, and only the executable can say which 294 console layers map those two drives this way, and only the executable can say which spelling GTA VI uses). Each
295 spelling GTA VI uses). A path under `--game-dir` or the overlay is always a host path, so a package that sits on 295 process has its own, `<overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>` (start time in UTC and process id,
296 a host drive `G:` keeps working, and with no folders configured `G:` and `T:` stay host drives. 296 `rt::fs::scratch_dir()`, named on the startup line), as the console's temporary drive is empty at launch and
297 shared with no other run: with one folder for all runs, a `CREATE_NEW` of a name an earlier run left failed with
298 `ERROR_FILE_EXISTS` (old upstream issue 7913). `rt::fs::reserve_unique_dir` reserves it once per overlay with a
299 create-only `CreateDirectoryW`; a name that already exists (a reused process id in the same millisecond) is skipped
300 for `-2`, `-3`, ... up to 1000 names, after which `T:` paths fail with `ERROR_INVALID_NAME` and the reason is
301 printed once. Earlier runs' folders are kept, never reused, and `T:\..` cannot reach them. A path under
302 `--game-dir` or the overlay is always a host path, so a package that sits on a host drive `G:` keeps working, and
303 with no folders configured `G:` and `T:` stay host drives.
297 `T:\` is a drive root like `GAME:\`: its folder is made on the first `T:` call, so it is a folder before anything 304 `T:\` is a drive root like `GAME:\`: its folder is made on the first `T:` call, so it is a folder before anything
298 is written there, and removing or moving it fails with `ERROR_ACCESS_DENIED`. 305 is written there, and removing or moving it fails with `ERROR_ACCESS_DENIED`.
299- An open that can write, and `DeleteFile`, use the overlay: `--overlay DIR`, default `<game-dir>\overlay`. A 306- An open that can write, and `DeleteFile`, use the overlay: `--overlay DIR`, default `<game-dir>\overlay`. A
@@ -317,7 +324,9 @@ and the `api-ms-win-core-file-*` sets a GDK title links against.
317 package has, fails with `ERROR_ALREADY_EXISTS`; a missing parent with `ERROR_PATH_NOT_FOUND`. 324 package has, fails with `ERROR_ALREADY_EXISTS`; a missing parent with `ERROR_PATH_NOT_FOUND`.
318- `RemoveDirectory*` needs the folder empty in the title's view (`ERROR_DIR_NOT_EMPTY` otherwise). An overlay folder is 325- `RemoveDirectory*` needs the folder empty in the title's view (`ERROR_DIR_NOT_EMPTY` otherwise). An overlay folder is
319 removed; a package folder is hidden by a `.gta6rt-dir` marker inside its marker folder, and stays on disk. A marker 326 removed; a package folder is hidden by a `.gta6rt-dir` marker inside its marker folder, and stays on disk. A marker
320 folder on its own (left by a file deleted below it) does not hide anything. 327 folder on its own (left by a file deleted below it) does not hide anything. A remove and a write-open or
328 `CreateDirectory*` inside the folder on another thread are ordered as on the host: one goes first, and the create
329 fails with `ERROR_PATH_NOT_FOUND` or the remove with `ERROR_DIR_NOT_EMPTY`, never both succeeding.
321- `MoveFile*` writes the destination in the overlay. A package file is copied there and its old name deleted by a 330- `MoveFile*` writes the destination in the overlay. A package file is copied there and its old name deleted by a
322 marker; an overlay file or an overlay-only folder is renamed. An existing destination needs 331 marker; an overlay file or an overlay-only folder is renamed. An existing destination needs
323 `MOVEFILE_REPLACE_EXISTING` even when only the package has it. Moving a package folder fails with 332 `MOVEFILE_REPLACE_EXISTING` even when only the package has it. Moving a package folder fails with
@@ -411,6 +420,22 @@ families are not listed. The sources are the Microsoft Learn pages for the D3D12
411(`gaming/gdk/docs/reference/system/<family>/functions/<name>`); `D3D12XboxCreateDevice` is matched by name from the 420(`gaming/gdk/docs/reference/system/<family>/functions/<name>`); `D3D12XboxCreateDevice` is matched by name from the
412measurement in `d3d12_vulkan.md`, because its page could not be found. 421measurement in `d3d12_vulkan.md`, because its page could not be found.
413 422
423### Delay imports and thread events: where the loader differs from Windows
424
425- **Delay imports are bound eagerly.** `Loader::bind_imports` (`runtime/src/pe_loader.cpp`) binds the delay-import
426 table at load time, like the import table, so `--dry-run` shows the whole import surface. A delay-loaded DLL or
427 function that nothing serves becomes an unimplemented thunk, which follows `LEONIDA_UNIMPLEMENTED` at its first
428 call (return 0 by default). On Windows the delay-load helper raises `0xC06D007E` (module not found) or
429 `0xC06D007F` (procedure not found) at that call instead, and a title can catch it and take a fallback; that fallback
430 never runs here. `--trace` writes a `delay_import_unimplemented` event (`module`, `import`) for each such import
431 when the image is loaded.
432- **Thread events reach TLS callbacks in TLS slot order.** A new thread's `DLL_THREAD_ATTACH` runs the mapped
433 modules' TLS callbacks in the order of their TLS slots (`DLL_THREAD_DETACH` in reverse). A module takes the lowest
434 free slot when it is mapped, before its imports are loaded, so the executable's callbacks run before those of the
435 DLLs it imports; a slot freed by an unloaded module goes to the next one. Windows does not document its order, so a
436 title that depends on DLL-first order would see a difference here. Mapped DLLs' `DllMain` gets no thread events
437 (`runtime/README.md`, PE loader).
438
414## Run-time loaded modules 439## Run-time loaded modules
415 440
416Not every console module is reached through an import table. `libHttpClient.GDK.dll` and `XCurl.dll` both use the 441Not every console module is reached through an import table. `libHttpClient.GDK.dll` and `XCurl.dll` both use the
diff --git a/docs/shader_validation.md b/docs/shader_validation.md
index ac33debfa..f97182ee8 100644
--- a/docs/shader_validation.md
+++ b/docs/shader_validation.md
@@ -1668,6 +1668,29 @@ Measured on an RX 6700 (gfx1031, AMD Windows driver 32.0.21045.29003, ROCm wheel
1668each value is staged once, and that the kernels assemble for gfx1031. A fake oracle plays the GPU to check the exit 1668each value is staged once, and that the kernels assemble for gfx1031. A fake oracle plays the GPU to check the exit
1669codes. On a GFX10 GPU the test runs UNORM8 and checks the controls. 1669codes. On a GFX10 GPU the test runs UNORM8 and checks the controls.
1670 1670
1671### d16 rounding of image loads and samples (`tools/d16_image_probe.py`)
1672
1673The image counterpart to `tools/d16_format_probe.py` checks how a GFX10 GPU (RDNA1/RDNA2, through `tools/hw_oracle`)
1674rounds d16 image results to f16 across three paths: `image_load` (unnormalized integer coordinates), point-filtered
1675`image_sample_lz`, and bilinear `image_sample_lz` (`--frac` texels to the right of the texel centre), in wave32 and
1676wave64. It covers `unorm8`, `snorm8`, `unorm16`, `snorm16`, `float16` (control: returns its own bits), and `float32`
1677(1,024 patterns starting with exact f16 halfway points such as `0x3f7ff000` and `0x3f7fb000` plus their neighbours).
1678Point loads and point samples are compared against the candidate rules of `tools/d16_format_probe.py` (`rte`,
1679`f32_rte`, and their toward-zero and denormal-flushing variants), while bilinear d16 samples are compared against the
1680hardware's own f32 bilinear sample rounded to nearest even or toward zero.
1681
1682```
1683python -I tools/d16_image_probe.py --formats unorm8,unorm16 --waves 32,64 --frac 0.5 --json out.json
1684python -I tools/d16_image_probe.py --hw-arch gfx1031 --json out.json
1685python -I tools/d16_image_probe.py --self-test
1686python -I tests/test_d16_image_probe.py
1687```
1688
1689Exit status is 0 when the sweep ran, 1 when wave32 and wave64 disagree, 2 on a harness or control error (f32 load
1690mismatch, point sample differing from load, `float16` mismatch, or misaligned texture), and 77 when the hardware oracle
1691is unavailable or the GPU is not GFX10. `tests/test_d16_image_probe.py` covers the rules, texel generators, descriptors,
1692and exit codes without a GPU or game files.
1693
1671### Widening a 16-bit float NaN in a typed buffer load (`tools/f16_widen_probe.py`) 1694### Widening a 16-bit float NaN in a typed buffer load (`tools/f16_widen_probe.py`)
1672 1695
1673A typed buffer load of a half NaN had never been measured: `tools/mem_diff.py` decoded 16_FLOAT with 1696A typed buffer load of a half NaN had never been measured: `tools/mem_diff.py` decoded 16_FLOAT with
@@ -2329,6 +2352,27 @@ completing draws (`89` non-clear exact + `64` clear-only exact across `573/573`
2329`ps_sweep.py compare --exact`. All `3` whole-corpus shaders combining raw barycentrics and `v_interp_*_f16` also draw 2352`ps_sweep.py compare --exact`. All `3` whole-corpus shaders combining raw barycentrics and `v_interp_*_f16` also draw
2330bit-for-bit identically (`3/3` draws, `11/11` targets) against `default` on the RX 6650 XT. 2353bit-for-bit identically (`3/3` draws, `11/11` targets) against `default` on the RX 6650 XT.
2331 2354
2355### Op-scoped mutation testing for `tests/semantic` (`tools/semantic_mutants.py`)
2356
2357`tools/semantic_mutants.py` checks which one-line bugs in `tools/rdna2spirv.py` a given `tests/semantic` file would
2358miss. You scope the slice by instruction branch (`--op`), translator method (`--function`), or 1-based line range
2359(`--lines`); it generates one-line mutants (swapped SPIR-V and `GLSL.std.450` opcode pairs, comparison polarity and
2360signedness flips, `self.cu(N)` off-by-one constants, swapped `OpSelect` arms, and duplicated trailing operands) in a
2361private temporary copy of `tools/` and runs the test file against each copy through `LEONIDA_TOOLS_DIR` (the same hook
2362used by `tests/semantic/test_mutations.py`), leaving the repository untouched.
2363
2364```
2365python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8
2366python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8 --list
2367python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8 --timeout 120
2368python -I tests/test_semantic_mutants.py
2369```
2370
2371Any mutant the test file still passes is reported as `SURVIVED` (read each lead before adding cases, since some mutants
2372are equivalent). Exit status is 0 when every mutant is caught, 1 when any survives, and 2 on a usage error or when the
2373unmutated baseline fails. Synthetic only (no GPU or game files); `tests/test_semantic_mutants.py` covers mutant
2374generation, scoping, and CLI exit codes.
2375
2332## Coverage plan and cost 2376## Coverage plan and cost
2333 2377
2334Start with straight-line scalar/vector ALU because it is deterministic, needs no descriptors and 2378Start with straight-line scalar/vector ALU because it is deterministic, needs no descriptors and
diff --git a/docs/testing.md b/docs/testing.md
index ffe729d24..671c5548c 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -9,11 +9,12 @@ issue][claims] helps more.
9 9
10This page collects the setup steps and the problems testers have run into so far. 10This page collects the setup steps and the problems testers have run into so far.
11 11
12[claims]: https://github.com/ubiquitarianism/leonida/issues/14 12[claims]: https://github.com/ubiquitarianism/leonida/issues?q=is%3Aissue%20is%3Aopen%20in%3Atitle%20%22Coordinating%20who%20works%20on%20what%22
13 13
14## What you need 14## What you need
15 15
16- **Python 3.11+.** `scripts/run_gpu_tests.py` needs at least 3.10. 16- **Python 3.12+**, which `make_game.py` requires (it stops with "Python 3.12 or newer is needed" on an older one, so
17 its tests fail there too). `scripts/run_gpu_tests.py` on its own runs on 3.10 or newer.
17- **`llvm-mc` with the AMDGPU target** (LLVM 21+). The official LLVM Windows release has no AMDGPU target. On 18- **`llvm-mc` with the AMDGPU target** (LLVM 21+). The official LLVM Windows release has no AMDGPU target. On
18 Windows, use one of: 19 Windows, use one of:
19 - `scripts\build_llvm_mc.ps1`, which builds a native `llvm-mc.exe` (needs git and the Visual Studio C++ tools); 20 - `scripts\build_llvm_mc.ps1`, which builds a native `llvm-mc.exe` (needs git and the Visual Studio C++ tools);
@@ -661,8 +662,12 @@ also advertises the feature but returns a wrong third `BaryCoordKHR` component,
661expected (#5933: Vega 8, PCI 1002:15E7, driver 31.0.21921.13001). `ps_bary`, `ps_persp_bary` and `ps_ij_computed` 662expected (#5933: Vega 8, PCI 1002:15E7, driver 31.0.21921.13001). `ps_bary`, `ps_persp_bary` and `ps_ij_computed`
662fail natively; through the fallback `ps_bary` and `ps_persp_bary` pass. `tools/vk_subgroup_info.py` reports 663fail natively; through the fallback `ps_bary` and `ps_persp_bary` pass. `tools/vk_subgroup_info.py` reports
663`barycentric_fallback` for these PCI IDs under `VK_DRIVER_ID_AMD_PROPRIETARY`, so `make_game.py` and 664`barycentric_fallback` for these PCI IDs under `VK_DRIVER_ID_AMD_PROPRIETARY`, so `make_game.py` and
664`run_gpu_tests.py` turn the fallback on by themselves there, with the same `LEONIDA_BARY_FALLBACK` override. RADV and 665`run_gpu_tests.py` turn the fallback on by themselves there, with the same `LEONIDA_BARY_FALLBACK` override. RADV
665other GCN 5 GPUs are not covered: none has been measured. 666(Mesa 26.2.6) on the same Vega 8 doesn't list `VK_KHR_fragment_shader_barycentric` at all, though it sets the
667`fragmentShaderBarycentric` feature, so the four raw-barycentric tests skip there and pass with
668`LEONIDA_BARY_FALLBACK=1`, and `ps_interp_f16_high` passes through the f16 fallback that `run_gpu_tests.py` turns on
669by itself ([#166 entry](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7109387712)). Other GCN 5 GPUs
670are not covered: none has been measured.
666 671
667## Macs: 16-bit interpolation without PerVertexKHR 672## Macs: 16-bit interpolation without PerVertexKHR
668 673
@@ -785,6 +790,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin
785| `d3d12_descriptor_test` reports that the set had room for fewer than 5001 2D views and 2100 samplers, and the device logs that the bindless set holds fewer samplers than a full shader-visible sampler heap | The device's descriptor limits, or its `vkGetDescriptorSetLayoutSupport`, allow no bigger bindless set ([d3d12_vulkan.md](d3d12_vulkan.md) section 5). MoltenVK's answer is ignored, since it rejects every layout of `maxPerSetDescriptors` (1212) or more although it runs the full set | Expected where the limits are low. The test still checks the last index of each array and that the next view and sampler are refused | 790| `d3d12_descriptor_test` reports that the set had room for fewer than 5001 2D views and 2100 samplers, and the device logs that the bindless set holds fewer samplers than a full shader-visible sampler heap | The device's descriptor limits, or its `vkGetDescriptorSetLayoutSupport`, allow no bigger bindless set ([d3d12_vulkan.md](d3d12_vulkan.md) section 5). MoltenVK's answer is ignored, since it rejects every layout of `maxPerSetDescriptors` (1212) or more although it runs the full set | Expected where the limits are low. The test still checks the last index of each array and that the next view and sampler are refused |
786| `cs_dpp_ops` fails on a Mac with MoltenVK 1.4.2: `out[0..7] = 100 100 11 ...`, want `100 10 11 ...` | MoltenVK 1.4.2's SPIRV-Cross moves the DPP lowering's subgroup ballot and shuffle into a short-circuiting `&&` and `?:`, so only some lanes run them and lane 1 sees its source lane 0 as inactive. SPIRV-Cross `5c372ffb` (in MoltenVK `main`) keeps them out of `?:`; a ballot on the right of `&&` is still moved there in SPIRV-Cross `57e4efcc` | Fixed in the translator (SHADER-529, #3227): it stores the ballot and the shuffle to variables of their own, so the MSL that MoltenVK 1.4.2 generates (`MVK_CONFIG_DEBUG=1`) runs each as a statement in every lane. Translate again with current `main`; MoltenVK `main` and KosmicKrisp are no longer needed for it. A pass alone does not show the fix: an Apple M5 Pro (macOS 26.5.1) returns the right words with 1.4.2 even when the ballot is on the right of `&&` | 791| `cs_dpp_ops` fails on a Mac with MoltenVK 1.4.2: `out[0..7] = 100 100 11 ...`, want `100 10 11 ...` | MoltenVK 1.4.2's SPIRV-Cross moves the DPP lowering's subgroup ballot and shuffle into a short-circuiting `&&` and `?:`, so only some lanes run them and lane 1 sees its source lane 0 as inactive. SPIRV-Cross `5c372ffb` (in MoltenVK `main`) keeps them out of `?:`; a ballot on the right of `&&` is still moved there in SPIRV-Cross `57e4efcc` | Fixed in the translator (SHADER-529, #3227): it stores the ballot and the shuffle to variables of their own, so the MSL that MoltenVK 1.4.2 generates (`MVK_CONFIG_DEBUG=1`) runs each as a statement in every lane. Translate again with current `main`; MoltenVK `main` and KosmicKrisp are no longer needed for it. A pass alone does not show the fix: an Apple M5 Pro (macOS 26.5.1) returns the right words with 1.4.2 even when the ballot is on the right of `&&` |
787| `check.py`'s `cs_fma_fused` fails on a Mac with MoltenVK 1.4.2: word 7 reads `15360` (`0x3c00`), want `29521` (`0x7351`) | The f16 multiply-add (round to odd). The MSL of 1.4.2 and of MoltenVK `main` differ only in SPIRV-Cross's precise-arithmetic helpers (`[[clang::optnone]]` and `fma(l, r, 0)` against `math_mode(safe)` and `fma(l, r, -0.0)`, the SHADER-182 / SHADER-234 change) | Expected with MoltenVK 1.4.2; it passes with MoltenVK `main` | 792| `check.py`'s `cs_fma_fused` fails on a Mac with MoltenVK 1.4.2: word 7 reads `15360` (`0x3c00`), want `29521` (`0x7351`) | The f16 multiply-add (round to odd). The MSL of 1.4.2 and of MoltenVK `main` differ only in SPIRV-Cross's precise-arithmetic helpers (`[[clang::optnone]]` and `fma(l, r, 0)` against `math_mode(safe)` and `fma(l, r, -0.0)`, the SHADER-182 / SHADER-234 change) | Expected with MoltenVK 1.4.2; it passes with MoltenVK `main` |
793| `ps_imgatomic` fails in about two of three runs on a Mac with MoltenVK 1.4.2: 1 to 6 of the 256 image-atomic texels are wrong while the render target is exact, for example `2D umax texel 48: got 0x00000d45, want 0x00000dc7` | MoltenVK 1.4.2 lowers the four `OpAtomic*` on image texels to Metal's texture atomics (`atomic_fetch_max`, `atomic_fetch_min` and `atomic_fetch_or` on `access::read_write` textures), and the texels read back the way a read-modify-write that is not atomic between two groups of fragment threads leaves them. A wrong `umax` texel always holds the id of one of its own 64 pixels, the largest of only some of them: on an Apple M5 it was the last pixel of the texel's first four rows in 43 of 90 cases, with all 32 larger ids gone. A wrong `umin` texel mirrors that (the first pixel of its last four rows in 39 of 48). The `or` image did not differ in 150 runs there. It is not the translator's first-lane broadcast of the descriptor index (54 of 60 runs fail with the index used directly) and not the readback (42 of 60 fail with the copies in a submission of their own after the draw). Measured on an Apple M5 (macOS 27.2.1, 101 of 150 runs fail) and an M5 Pro (#543) | Expected with MoltenVK 1.4.2. KosmicKrisp passed the same module and binary 10 times of 10 on the M5 Pro (#543). The macOS CI job does not reach it: on the runner's paravirtual device the test skips because its bindless set does not fit the descriptor limits. Do not weaken the test's expected texels |
788| `gs_tri` and `ms_tri` fail on a Mac | MoltenVK has no geometry stage and no `VK_EXT_mesh_shader` | Current `main` reports them as skipped | 794| `gs_tri` and `ms_tri` fail on a Mac | MoltenVK has no geometry stage and no `VK_EXT_mesh_shader` | Current `main` reports them as skipped |
789| With `LEONIDA_W64_EMULATE=1` on llvmpipe, the `ms_*` tests fail. Measured with Mesa 26.3.1: on x86_64 at 256-bit vectors (the default there) all six abort with "LLVM ERROR: Cannot emit physreg copy instruction"; on arm64 (128-bit) `ms_tri` draws nothing (the frame stays at the clear color); on x86_64 at 128 bits (`LP_NATIVE_VECTOR_WIDTH=128`) `ms_tri` happened to draw correctly, but with Mesa 26.0.3 `ms_wave_info_s3` and `ms_v5_workgroup` draw nothing there (4 of 6 pass, [measured by @TreXito](https://github.com/ItsNotRexed/Leonida/pull/3838#issuecomment-7086696759)) ([measured runs](https://github.com/ItsNotRexed/Leonida/issues/3127#issuecomment-7086469679)) | An llvmpipe bug: a mesh shader's runtime `CullPrimitiveEXT` is stored through an invalid `bitcast <N x i1> to <N x float>` (TEST-782, #3127; see "Without a GPU: Mesa llvmpipe") | Run the mesh tests on llvmpipe without `LEONIDA_W64_EMULATE`, or add `LEONIDA_MESH_COMPUTE=1` (the compute fallback): with it all 6 `ms_*` pass emulated on llvmpipe (x86_64, 256-bit) | 795| With `LEONIDA_W64_EMULATE=1` on llvmpipe, the `ms_*` tests fail. Measured with Mesa 26.3.1: on x86_64 at 256-bit vectors (the default there) all six abort with "LLVM ERROR: Cannot emit physreg copy instruction"; on arm64 (128-bit) `ms_tri` draws nothing (the frame stays at the clear color); on x86_64 at 128 bits (`LP_NATIVE_VECTOR_WIDTH=128`) `ms_tri` happened to draw correctly, but with Mesa 26.0.3 `ms_wave_info_s3` and `ms_v5_workgroup` draw nothing there (4 of 6 pass, [measured by @TreXito](https://github.com/ItsNotRexed/Leonida/pull/3838#issuecomment-7086696759)) ([measured runs](https://github.com/ItsNotRexed/Leonida/issues/3127#issuecomment-7086469679)) | An llvmpipe bug: a mesh shader's runtime `CullPrimitiveEXT` is stored through an invalid `bitcast <N x i1> to <N x float>` (TEST-782, #3127; see "Without a GPU: Mesa llvmpipe") | Run the mesh tests on llvmpipe without `LEONIDA_W64_EMULATE`, or add `LEONIDA_MESH_COMPUTE=1` (the compute fallback): with it all 6 `ms_*` pass emulated on llvmpipe (x86_64, 256-bit) |
790| On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` | 796| On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` |
@@ -797,7 +803,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin
797| A Windows CI artifact run under Wine by hand: `d3d12_compute` and the other tests that read `LEONIDA_TEST_*_SPV` end with exit 3 and no message | The `.spv` paths are compiled in as `D:/a/Leonida/Leonida/runtime/build/generated/...`; the prefix has no `D:` drive and the test isn't run from the artifact folder | Run it from the artifact folder (the tests then find `generated/<name>.spv` there) or through `scripts/run_wine_tests.py`, which maps that drive for the run; current `main` names the file it couldn't copy (`cannot copy ...: File not found`) | 803| A Windows CI artifact run under Wine by hand: `d3d12_compute` and the other tests that read `LEONIDA_TEST_*_SPV` end with exit 3 and no message | The `.spv` paths are compiled in as `D:/a/Leonida/Leonida/runtime/build/generated/...`; the prefix has no `D:` drive and the test isn't run from the artifact folder | Run it from the artifact folder (the tests then find `generated/<name>.spv` there) or through `scripts/run_wine_tests.py`, which maps that drive for the run; current `main` names the file it couldn't copy (`cannot copy ...: File not found`) |
798| Linux cross-build: CMake can't find `clang-cl-19` (or another versioned `clang-cl-<N>`) although `clang-19` and `lld-19` are installed | On Debian and Ubuntu, the versioned `clang-cl-<N>` link is in the `clang-tools-<N>` package, not in `clang-<N>` (`/usr/lib/llvm-<N>/bin/clang-cl` comes from it too); `lld-link-<N>`, `llvm-lib`, `llvm-rc` and `llvm-mt` come from `lld-<N>` and `llvm-<N>` | `sudo apt-get install clang-tools-19 lld-19 llvm-19` (Ubuntu 24.04 has 19 and 20), then pass the versioned names as in [the cross-build](#the-windows-runtime-on-linux-under-wine-or-proton) | 804| Linux cross-build: CMake can't find `clang-cl-19` (or another versioned `clang-cl-<N>`) although `clang-19` and `lld-19` are installed | On Debian and Ubuntu, the versioned `clang-cl-<N>` link is in the `clang-tools-<N>` package, not in `clang-<N>` (`/usr/lib/llvm-<N>/bin/clang-cl` comes from it too); `lld-link-<N>`, `llvm-lib`, `llvm-rc` and `llvm-mt` come from `lld-<N>` and `llvm-<N>` | `sudo apt-get install clang-tools-19 lld-19 llvm-19` (Ubuntu 24.04 has 19 and 20), then pass the versioned names as in [the cross-build](#the-windows-runtime-on-linux-under-wine-or-proton) |
799| Under Ubuntu's Wine 9.0, `wineboot --init` (and every Wine program after it) stops at once with `free(): invalid pointer` or a segmentation fault, before printing anything else; the prefix holds only a `wineserver` file | That Wine opens `/run/user/<uid>` for its server directory, whether `XDG_RUNTIME_DIR` is set or not, and aborts when the folder doesn't exist. The login manager makes it for a desktop session; a container or a shell started without a login session (a root shell in Docker, a CI runner image) has none | Create it before starting Wine: `mkdir -p /run/user/$(id -u) && chmod 700 /run/user/$(id -u)` (setting `XDG_RUNTIME_DIR` alone doesn't help), delete the half-made prefix, and run `wineboot --init` again | 805| Under Ubuntu's Wine 9.0, `wineboot --init` (and every Wine program after it) stops at once with `free(): invalid pointer` or a segmentation fault, before printing anything else; the prefix holds only a `wineserver` file | That Wine opens `/run/user/<uid>` for its server directory, whether `XDG_RUNTIME_DIR` is set or not, and aborts when the folder doesn't exist. The login manager makes it for a desktop session; a container or a shell started without a login session (a root shell in Docker, a CI runner image) has none | Create it before starting Wine: `mkdir -p /run/user/$(id -u) && chmod 700 /run/user/$(id -u)` (setting `XDG_RUNTIME_DIR` alone doesn't help), delete the half-made prefix, and run `wineboot --init` again |
800| `run_gpu_tests.py` fails on a `dict \| None` annotation | Python older than 3.10 | Use Python 3.11+ | 806| `run_gpu_tests.py` fails on a `dict \| None` annotation | Python older than 3.10 | Use Python 3.12+ |
801| `vulkaninfo` lists `Microsoft Direct3D12 (<gpu>)` next to the real GPU and the tests run on it | The Windows "OpenCL™, OpenGL® and Vulkan® Compatibility Pack" installs Mesa's Dozen, a Vulkan-on-D3D12 layer that reports `DISCRETE_GPU` like the native card | Current `main` prefers a native ICD over Microsoft's vendor (`0x1414`) in the runtime and every harness; set `LEONIDA_VK_DEVICE=<part of the real GPU name>` to select explicitly. See #915. | 807| `vulkaninfo` lists `Microsoft Direct3D12 (<gpu>)` next to the real GPU and the tests run on it | The Windows "OpenCL™, OpenGL® and Vulkan® Compatibility Pack" installs Mesa's Dozen, a Vulkan-on-D3D12 layer that reports `DISCRETE_GPU` like the native card | Current `main` prefers a native ICD over Microsoft's vendor (`0x1414`) in the runtime and every harness; set `LEONIDA_VK_DEVICE=<part of the real GPU name>` to select explicitly. See #915. |
802| A GPU test that uses `image_load` (or lighting built from real shaders) reads zeros from its image; @Silliana saw every texel except pixel (0,0) come back zero in their own layer (#603, not reproduced here) | In this runtime the shader turns the T# words into an index through the descriptor hash table (`runtime/src/descriptor_table.h`: a miss gives index 0), and index 0 is a 1×1 image of zeros (`runtime/src/vulkan_bindless.h`), so a hand-built or zeroed T# that was never registered reads zeros even at (0,0). The translator does not compare coordinates with the T# size, and `cs_imgload.asm` only uses its T# words as a hash key | Register the descriptor through the runtime (for D3D12, create it with `CreateShaderResourceView`) so its T# hits the table, with the image's real width and height (stored as size − 1, see `runtime/src/gfx10_descriptors.h`) | 808| A GPU test that uses `image_load` (or lighting built from real shaders) reads zeros from its image; @Silliana saw every texel except pixel (0,0) come back zero in their own layer (#603, not reproduced here) | In this runtime the shader turns the T# words into an index through the descriptor hash table (`runtime/src/descriptor_table.h`: a miss gives index 0), and index 0 is a 1×1 image of zeros (`runtime/src/vulkan_bindless.h`), so a hand-built or zeroed T# that was never registered reads zeros even at (0,0). The translator does not compare coordinates with the T# size, and `cs_imgload.asm` only uses its T# words as a hash key | Register the descriptor through the runtime (for D3D12, create it with `CreateShaderResourceView`) so its T# hits the table, with the image's real width and height (stored as size − 1, see `runtime/src/gfx10_descriptors.h`) |
803| `cs_sample_lz_int_d16`, `ps_sample_implicit_sint`, `ps_ssharp`, `ps_tex`, `ps_texture_mip0`, `ps_texture_sample` and `ps_texture_sample_d16` crash (exit -11 or 139) on an Intel GPU on Linux, while NVIDIA and llvmpipe pass them (TEST-399) | A bug in Mesa ANV's shader compiler: compiling these texture-sampling shaders, `nir_opt_gcm` (`nir_opt_gcm.c:430`, `gcm_schedule_early_src`) dereferences a phi source an earlier pass has freed. The SPIR-V passes `spirv-val`. Seen with Mesa 26.1.6 (Arrow Lake) and 26.2.7 (Iris Xe, ADL GT2); Mesa 26.3.1 and `main` (bb98606) pass the whole suite on the same Iris Xe | Use Mesa 26.3.1 or newer. To check a newer Mesa without installing it, build its Intel Vulkan driver and point `VK_DRIVER_FILES` at its `src/intel/vulkan/intel_devenv_icd.x86_64.json` | 809| `cs_sample_lz_int_d16`, `ps_sample_implicit_sint`, `ps_ssharp`, `ps_tex`, `ps_texture_mip0`, `ps_texture_sample` and `ps_texture_sample_d16` crash (exit -11 or 139) on an Intel GPU on Linux, while NVIDIA and llvmpipe pass them (TEST-399) | A bug in Mesa ANV's shader compiler: compiling these texture-sampling shaders, `nir_opt_gcm` (`nir_opt_gcm.c:430`, `gcm_schedule_early_src`) dereferences a phi source an earlier pass has freed. The SPIR-V passes `spirv-val`. Seen with Mesa 26.1.6 (Arrow Lake) and 26.2.7 (Iris Xe, ADL GT2); Mesa 26.3.1 and `main` (bb98606) pass the whole suite on the same Iris Xe | Use Mesa 26.3.1 or newer. To check a newer Mesa without installing it, build its Intel Vulkan driver and point `VK_DRIVER_FILES` at its `src/intel/vulkan/intel_devenv_icd.x86_64.json` |
diff --git a/docs/world.md b/docs/world.md
index 7d0951465..84ce585ff 100644
--- a/docs/world.md
+++ b/docs/world.md
@@ -784,7 +784,12 @@ joaat of the GTA V class names, and every member below is named by the resource'
784 784
785Two more grass-list members are named by joaat from a brute force over common engine words: `slodID` (0xB0, member hash `9fe78fd1`) and `SLODArchetypeList` (0x158, `b451fc98`), so grass lists carry their own link to an SLOD archetype set next to `IsSLODList`. The other unnamed members stay as hashes in the schema. 785Two more grass-list members are named by joaat from a brute force over common engine words: `slodID` (0xB0, member hash `9fe78fd1`) and `SLODArchetypeList` (0x158, `b451fc98`), so grass lists carry their own link to an SLOD archetype set next to `IsSLODList`. The other unnamed members stay as hashes in the schema.
786 786
787An `InstanceList` is a u64 (low 12 bits: 1-based block index; bits 20+: offset in that block) and a u16 count. 787An `InstanceList` is a u64 (low 20 bits: 1-based block index; bits 20+: offset in that block) and a u16 count.
788That is the pointer form of [psin.md](psin.md) and [ped_catalogues.md](ped_catalogues.md); `instance_lists.py`,
789`world_interior_names.py`, `world_lights_paths.py` and `world_index.py` read it through
790`world_index.split_pointer`. Bits 12-19 are the block number's high bits, so they stay zero below 4,096 blocks. Over the 232,846 `0x7a` resources of `levels.rpf`, `story000.rpf`, `shared_minigame000.rpf` and
791`packs.rpf`, the most blocks one has is 1,760. Every non-null array (`0x52`) and string (`0x42`) pointer there
792has bits 12-19 at zero, so a 12-bit reading would find the same block for each of them.
788Instance blocks are usually in the physical buffer, so the tool joins each resource's virtual and physical 793Instance blocks are usually in the physical buffer, so the tool joins each resource's virtual and physical
789streams from its block map (+0x08 -> +8 virtual count, +9 physical count). 794streams from its block map (+0x08 -> +8 virtual count, +9 physical count).
790 795
diff --git a/docs/world_lights_paths.md b/docs/world_lights_paths.md
index f619f9a33..ca5595cb1 100644
--- a/docs/world_lights_paths.md
+++ b/docs/world_lights_paths.md
@@ -52,8 +52,8 @@ archetype; entity lights belong to one entity.
52`lightFadeDistance` `+0x28d`, `shadowFadeDistance` `+0x28e`, `lightType` `+0x291` (1 point, 2 spot, 4 capsule, 32 seen but not named), 52`lightFadeDistance` `+0x28d`, `shadowFadeDistance` `+0x28e`, `lightType` `+0x291` (1 point, 2 spot, 4 capsule, 32 seen but not named),
53`groupId` `+0x292`. Its member table has 100 entries. 53`groupId` `+0x292`. Its member table has 100 entries.
54 54
55Pointers are pool references (1-based block number in bits 0..11, byte offset from bit 20) or `0x5xxxxxxx` 55Pointers are pool references (1-based block number in bits 0..19, byte offset from bit 20, as in
56system pointers. A pool reference whose offset is `0x500`..`0x5ff` also has 56[world.md](world.md#instanced-props-and-grass)) or `0x5xxxxxxx` system pointers. A pool reference whose offset is `0x500`..`0x5ff` also has
57the shape of a `0x5xxxxxxx` pointer, so the reader tries the pool form first and only then a system pointer. 57the shape of a `0x5xxxxxxx` pointer, so the reader tries the pool form first and only then a system pointer.
58 58
59| Measure | Count | 59| Measure | Count |
diff --git a/docs/xcl_compare.md b/docs/xcl_compare.md
index 07d3e42e4..cd7a0b6a0 100644
--- a/docs/xcl_compare.md
+++ b/docs/xcl_compare.md
@@ -71,5 +71,5 @@ What the differences come down to:
71| XUser, XGameSave folder | #279 and #3363 (open). | 71| XUser, XGameSave folder | #279 and #3363 (open). |
72| `XAudio2Create` | RT-197, #3831 (open). | 72| `XAudio2Create` | RT-197, #3831 (open). |
73| `d3d12_xs.dll!D3D12CreateDevice` not found (16 D3D12.X checks) | The runtime serves the console's `D3D12XboxCreateDevice`; the title asks for `D3D12CreateDevice`. Whether the console's `d3d12_xs.dll` exports that name is not measured here. | 73| `d3d12_xs.dll!D3D12CreateDevice` not found (16 D3D12.X checks) | The runtime serves the console's `D3D12XboxCreateDevice`; the title asks for `D3D12CreateDevice`. Whether the console's `d3d12_xs.dll` exports that name is not measured here. |
74| `kernelx.dll` imports `XMemAlloc`, `XMemVirtualAlloc`, `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName`; `xmem.dll` physical pages; `xcrdapi.dll!DStorageGetFactory`; `MFResetDXGIDeviceManagerX` | Unimplemented here. None is in the measured imports of the shipped modules ([runtime_imports.md](runtime_imports.md)), and the executable is not available to measure, so they are leads, not known needs. `xmem.dll!XMemAlloc` is served; the same name under `kernelx.dll` is not. | 74| `kernelx.dll` imports `XMemAlloc`, `XMemVirtualAlloc`, `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName`; `xmem.dll` physical pages; `xcrdapi.dll!DStorageGetFactory`; `MFResetDXGIDeviceManagerX` | These are the XCL title's bindings, not the game's. The executable's own import table and call sites are measured at `1cc6e3c1` ([runtime_imports.md](runtime_imports.md#the-retail-executable-rt-5)): `xmem.dll!XMemAlloc`, `XMemFree` and `XMemVirtualAlloc` bind (the last at 23 measured call sites), and the four `xmem.dll` physical-page calls (`XMemAllocatePhysicalPages`, `XMemFreePhysicalPages`, `XMemMapPhysicalPages`, `XMemMapPhysicalPagesScatter`) are served; the same names under `kernelx.dll` are not. `XCRDAPI.dll!DStorageGetFactory` is a measured import served by `dstorage.cpp` (since `2d7be48de`). `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName` and `MFResetDXGIDeviceManagerX` are not in that table, so they remain leads, not known needs. |
75| The title's window is not a hidden 1920x1080 tool window | An XCL design choice (its console screen), not a console fact. | 75| The title's window is not a hidden 1920x1080 tool window | An XCL design choice (its console screen), not a console fact. |
diff --git a/docs/xdxr.md b/docs/xdxr.md
index 1b8a4cc27..24e9429f0 100644
--- a/docs/xdxr.md
+++ b/docs/xdxr.md
@@ -132,7 +132,7 @@ static reference, reached through a table (#7516), so 2 of them are calls of ano
132| `GetRaytracingAccelerationStructurePrebuildInfo(INPUTS*, XDXR_STREAM_DESC*, PREBUILD_INFO*)` | 3 | the layer's sizes | 132| `GetRaytracingAccelerationStructurePrebuildInfo(INPUTS*, XDXR_STREAM_DESC*, PREBUILD_INFO*)` | 3 | the layer's sizes |
133| `BuildRaytracingAccelerationStructureBatched2X(GCL6*, UINT, BATCHED_DESC2*)` | 6 (8) | one layer build per element (§1), with its postbuild descriptions | 133| `BuildRaytracingAccelerationStructureBatched2X(GCL6*, UINT, BATCHED_DESC2*)` | 6 (8) | one layer build per element (§1), with its postbuild descriptions |
134| `CopyRaytracingAccelerationStructure(GCL4*, dest, source, mode)` | 2 | the layer's copy | 134| `CopyRaytracingAccelerationStructure(GCL4*, dest, source, mode)` | 2 | the layer's copy |
135| `RehydrateRaytracingAccelerationStructureBatched2X(GCL8*, UINT, BUILD_DESC*, UINT64*)` | 4 | `E_NOTIMPL` for now | 135| `RehydrateRaytracingAccelerationStructureBatched2X(GCL8*, UINT, BUILD_DESC*, UINT64*)` | 4 | rebuilds each structure from source geometry; refuses source-only stream without geometry |
136 136
137**Where it differs from the DLL:** 137**Where it differs from the DLL:**
138- **Stream records (§3):** they tune the console builder's heuristics, so they are ignored (logged once). The result 138- **Stream records (§3):** they tune the console builder's heuristics, so they are ignored (logged once). The result
@@ -140,8 +140,23 @@ static reference, reached through a table (#7516), so 2 of them are calls of ano
140- **Validation errors:** the DLL throws them as C++ exceptions. A shim must not throw into the title, so an element 140- **Validation errors:** the DLL throws them as C++ exceptions. A shim must not throw into the title, so an element
141 the DLL would refuse is skipped with a log line. The offline-statistics postbuild type (`0x10`, §4) is one of 141 the DLL would refuse is skipped with a log line. The offline-statistics postbuild type (`0x10`, §4) is one of
142 those. 142 those.
143- **Rehydration** is the next step: rebuild each structure on the GPU from the source geometry its description 143- **Rehydration (`RehydrateRaytracingAccelerationStructureBatched2X`):** Rebuilds each structure on the GPU from
144 carries ([bvh.md](bvh.md) §4a), in the leaf frame `compressionParams` gives. 144 the source geometry its description carries ([bvh.md](bvh.md) §4a). The leaf frame `compressionParams` gives is
145 **not applied yet**: the leaves are built from the geometry as the description has it.
146 What the 4th parameter (`const UINT64* source_data`, mangling `PEB_K`) conveys is a **hypothesis**: it points to
147 the array of source buffer addresses for offline dehydrated console streams (e.g. rehydration inputs).
148 When geometry is provided (`NumDescs > 0`), the shim issues `BuildRaytracingAccelerationStructure` to construct
149 traversable GPU BVH nodes. That is a fresh build: the title sets `SourceAccelerationStructureData` to the
150 dehydrated stream, so the shim clears it and the `PERFORM_UPDATE` flag (logged once), which would otherwise make
151 the layer refit from the stream's bytes. The title passes `ScratchAccelerationStructureData = 0` (measured on the retail
152 title), so the shim supplies scratch, or the layer would reject the build: one new buffer per call, in which each
153 element has its own 256-byte-aligned region sized via `GetRaytracingAccelerationStructurePrebuildInfo`. The
154 layer's XDXR builder leaves the dependency between builds to the caller's barrier and the title puts none between
155 the elements of a batch, so no two builds, in a batch, on one list or on lists recorded in parallel, share scratch
156 bytes. The layer's command list holds the buffer until it is Reset or released, and the layer destroys it after
157 the submission that used it has retired. When `source_data` is supplied without geometry, the shim logs once and
158 refuses with `E_NOTIMPL`: offline console dehydrated streams cannot be directly deserialized by PC Vulkan/D3D12
159 drivers ([bvh.md](bvh.md) §4/§4a). Empty structures (`NumDescs == 0` without source) are logged and skipped.
145 160
146`xbox_bvh_builder_test` calls every export through the shim registry, the way the title's imports bind, and 161`xbox_bvh_builder_test` calls every export through the shim registry, the way the title's imports bind, and
147`xdxr_bvh.py check-build` checks the BLAS, TLAS and compacted BLAS it builds (ctest `xbox_bvh_builder_check`). 162`xdxr_bvh.py check-build` checks the BLAS, TLAS and compacted BLAS it builds (ctest `xbox_bvh_builder_check`).
diff --git a/docs/xmem_exe_calls.md b/docs/xmem_exe_calls.md
index 99b62fbe1..071cb6b7f 100644
--- a/docs/xmem_exe_calls.md
+++ b/docs/xmem_exe_calls.md
@@ -1,11 +1,12 @@
1# XMem: how the retail executable calls it (RT-5) 1# XMem: how the retail executable calls it (RT-5)
2 2
3`game_scarlett_master.exe` imports 12 functions from `xmem.dll` (`docs/runtime_imports.md`, "The retail executable"). 3`game_scarlett_master.exe` imports 12 functions from `xmem.dll` (`docs/runtime_imports.md`, "The retail executable").
4Seven have no shim yet. This page records, from the file alone, how the executable calls them: how many call sites each 4This page records, from the file alone, how the executable calls them: how many call sites each has and the constant
5has and the constant arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and 5arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and the instructions
6the instructions that load the argument registers before each call were read by hand. No code or data of the executable 6that load the argument registers before each call were read by hand. No code or data of the executable is quoted, only
7is quoted, only the constants a call passes and the counts. Measured at `main` `1cc6e3c1`, SHA-256 7the constants a call passes and the counts. The call sites were measured at `main` `1cc6e3c1`, SHA-256
8`e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993`. 8`e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993`; the shim column below is the current state, and
9it has moved since then: `042c5f378` (#6919) gave every one of the 12 imports a shim (seven had none at `1cc6e3c1`).
9 10
10```powershell 11```powershell
11python -I tools/import_call_sites.py game_scarlett_master.exe --dll xmem.dll --dll d3d12_xs.dll --dll xg_xs.dll 12python -I tools/import_call_sites.py game_scarlett_master.exe --dll xmem.dll --dll d3d12_xs.dll --dll xg_xs.dll
@@ -15,19 +16,19 @@ The tool finds each import's thunk (`jmp [rip+disp32]` through its address-table
15instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are 16instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are
16bounds, not a proof that every site is reached. 17bounds, not a proof that every site is reached.
17 18
18| Import | Call sites | Shim at `main` `1cc6e3c1` | 19| Import | Call sites | Shim at `main` (since #6919) |
19|---|---:|---| 20|---|---:|---|
20| `XMemVirtualAlloc` | 23 | yes, refuses every one of these 23 (below) | 21| `XMemVirtualAlloc` | 23 | yes, all 23 types served (below) |
21| `XMemMapPhysicalPages` | 12 | no | 22| `XMemMapPhysicalPages` | 12 | yes (pagefile-backed 64 KiB pool) |
22| `XMemAllocatePhysicalPages` | 4 | no | 23| `XMemAllocatePhysicalPages` | 4 | yes |
23| `XMemFreePhysicalPages` | 3 | no | 24| `XMemFreePhysicalPages` | 3 | yes |
24| `XMemMapPhysicalPagesScatter` | 2 | no | 25| `XMemMapPhysicalPagesScatter` | 2 | yes |
25| `XMemAlloc` | 3 | yes | 26| `XMemAlloc` | 3 | yes |
26| `XMemFree` | 3 (2 calls, 1 tail jump) | yes | 27| `XMemFree` | 3 (2 calls, 1 tail jump) | yes |
27| `XMemGetWorkingSetStatistics` | 3 | yes | 28| `XMemGetWorkingSetStatistics` | 3 | yes |
28| `XMemTransferMemory` | 1 | yes | 29| `XMemTransferMemory` | 1 | yes |
29| `XMemIsToolsMemAvailable` | 1 | no | 30| `XMemIsToolsMemAvailable` | 1 | yes (returns `FALSE`) |
30| `XMemAllocDefault`, `XMemFreeDefault` | 1 tail jump each, no call | no | 31| `XMemAllocDefault`, `XMemFreeDefault` | 1 tail jump each, no call | yes |
31 32
32The executable also exports one symbol, `__XMemAllocationHooks__`. 33The executable also exports one symbol, `__XMemAllocationHooks__`.
33 34
@@ -50,10 +51,16 @@ The 23 sites pass these constants (`allocation_type`, `attributes`, `protect`; t
50| `0x20406000` | `0x27` | `0x1004`, `0x1404`, `0x8404`, `0x2404`, `0x2004` | 5 (one each) | 51| `0x20406000` | `0x27` | `0x1004`, `0x1404`, `0x8404`, `0x2404`, `0x2004` | 5 (one each) |
51| `0x42000` | `0x7` | `0x1` | 1 | 52| `0x42000` | `0x7` | `0x1` | 1 |
52 53
53Every `attributes` value is nonzero, and `runtime/shims/xmem.cpp` returns `ERROR_NOT_SUPPORTED` for a nonzero value 54Every `attributes` value is nonzero. Since #6919 `runtime/shims/xmem.cpp` does not decode them: `XMemVirtualAlloc`
54("until their host mapping is known"), so none of the 23 calls succeeds there. Past that check the shim would also 55records the word (`xmem_attributes` in the startup trace) and accepts it. All 23 allocation types are served as well.
55refuse the calls with `allocation_type` `0x20003000` (5 sites: the 2 MiB page mode) and those with bits it does not 56The page-mode mask is `kXmem64kPages` `0x20400000`, which *is* `MEM_LARGE_PAGES | MEM_PHYSICAL`, so `0x20406000`
56know: `0x4000` in `0x20406000` (5 sites) and `0x40000` in `0x42000` (1 site). 57(`0x20400000 | MEM_RESERVE | MEM_REPLACE_PLACEHOLDER`) selects the 64 KiB page mode and replaces part of the
58placeholder — `test_placeholders` in `runtime/test/xmem_test.cpp` allocates that exact shape and maps physical pages
59into the carved window. The 23 sites divide as 17 in the 64 KiB mode (3 committed, 8 reserve-only windows, 1 plain
60commit, 5 placeholder replacements), five in the 2 MiB mode `0x20000000` (committed 2 MiB-aligned through
61`VirtualAlloc2`), and one `0x42000` = `MEM_RESERVE | MEM_RESERVE_PLACEHOLDER`, the ~185 MiB reservation the five
62windows are carved out of (`docs/retail_boot_chain.md`, stops 10-11). That agrees with `docs/runtime_imports.md`
63("The retail executable", `xmem.dll` notes), which records the same 2 MiB and placeholder paths.
57 64
58The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections 65The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections
59the high bits match: `PAGE_GRAPHICS_NOACCESS` `0x800`, `_READONLY` `0x1000`, `_READWRITE` `0x2000`, `_EXECUTE_READ` 66the high bits match: `PAGE_GRAPHICS_NOACCESS` `0x800`, `_READONLY` `0x1000`, `_READWRITE` `0x2000`, `_EXECUTE_READ`
@@ -81,13 +88,14 @@ those two facts. The meaning of `flags`, and whether the page numbers in `pageAr
81are **unmeasured**. 88are **unmeasured**.
82 89
83The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range 90The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range
84with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. So the physical-page calls depend on the 91with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. That path no longer
85attribute check above: until `XMemVirtualAlloc` accepts these attribute words, the map calls are never reached from 92stops at `XMemVirtualAlloc`: since #6919 it accepts that attribute word and the reserve-only 64 KiB window.
86there. 93
87 94The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so the shim emulates
88The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so a shim would 95the pool rather than forwarding (#6919): a pagefile-backed section in 64 KiB pages, committed at once on Wine (and on demand on native Windows) and given
89emulate the pool (a pagefile-backed section of 64 KiB pages, with views placed at the reserved range) instead of 96physical memory as it is touched, with views placed at the reserved range. Pages keep their contents while unmapped or
90forwarding. That is a design note, not a measurement. 97mapped elsewhere, and one page can be mapped at several addresses. The attribute word is recorded, still not decoded,
98and every page is 64 KiB, which all four callers' arithmetic agrees with (`runtime/shims/xmem.cpp`).
91 99
92## The other imports 100## The other imports
93 101