diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 19:04:24 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 19:04:24 -0500 |
| commit | 8d832fd10913064e1c8aec74191e3ba8f70211c8 (patch) | |
| tree | e365199d7d86ebf592a5a0dc2f07cda4b74b58a7 /docs | |
| parent | 5da3b6be3cefc1499452ba8c8370a50092674d61 (diff) | |
| parent | c50ed94b35b37b697ab9c5fd176f3738480b4db5 (diff) | |
Merge main into rt-title-every-budget (#2122)
#2098 split the every-pass loop of refresh_title_textures by mode: with
LEONIDA_TEXTURE_REFRESH_ASYNC every persistent mapping is polled each
pass and only stale unmapped textures are visited, without it all mapped
or stale ones are. The async branch is kept as main has it.
LEONIDA_TITLE_EVERY_BUDGET_US applies to the synchronous pass, the one
before a submission on the submitting thread; under async the pass runs
on the refresh worker and the limit does not apply (README says so).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs')
36 files changed, 912 insertions, 149 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 | |||
| 164 | The prefix has to supply a `d3d12.dll` that exports `D3D12SerializeVersionedRootSignature`, because the executable | ||
| 165 | imports it. Wine's own `d3d12.dll` does not answer that export for the runtime's shim, and the failure is quiet: | ||
| 166 | the D3D12 trace ends at about 1,658 calls, the startup trace ends in an access violation inside the executable, | ||
| 167 | and 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 | |||
| 171 | Copying the DLLs a Proton prefix installs is not enough on its own: Wine keeps preferring its own copy next to | ||
| 172 | them. Name them in the overrides. | ||
| 173 | |||
| 174 | ```bash | ||
| 175 | GE=$HOME/GE-Proton11-13-x86_64/files/lib/wine | ||
| 176 | cp "$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/" | ||
| 179 | export WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n,b" | ||
| 180 | export LEONIDA_D3D12=vulkan | ||
| 181 | export LEONIDA_SHADERS='Z:\path\to\shaders\spirv' | ||
| 182 | wine ./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 | |||
| 186 | With those three DLLs and the override, the same prefix reaches the frame loop: about 1.4 million D3D12 calls in | ||
| 187 | 90 s, no exception, `PresentX ready`, against 1,658 calls and an access violation without them, measured on Wine | ||
| 188 | 11.13 (GE-Proton 11-13) with an RDNA2 iGPU. A prefix that Proton itself created already carries these files and | ||
| 189 | needs 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/buffer_bounds.md b/docs/buffer_bounds.md index f5b4e6a55..a2d566bc1 100644 --- a/docs/buffer_bounds.md +++ b/docs/buffer_bounds.md | |||
| @@ -23,6 +23,11 @@ API-created CBVs mirror the observed inline console descriptor (mode 0, 16-byte | |||
| 23 | 23 | ||
| 24 | - **RDNA2 follows Mesa's GFX11 column**, not the GFX10 one: of 732 cases, 729 match GFX11 and 696 match GFX10. | 24 | - **RDNA2 follows Mesa's GFX11 column**, not the GFX10 one: of 732 cases, 729 match GFX11 and 696 match GFX10. |
| 25 | Every GFX10 miss is an access that only partly fits, for example a raw buffer with `N = 3` read at offset 0. | 25 | Every GFX10 miss is an access that only partly fits, for example a raw buffer with `N = 3` read at offset 0. |
| 26 | - **The offset is not cut to 32 bits.** `index * stride` is a full product and `soffset` is added in 64 bits, so | ||
| 27 | index 0xFFFFFFFF with a 20-byte stride lands tens of GiB past the base and the access has no effect; in 32 bits it | ||
| 28 | would be the 20 bytes below the base, which modes 2 and 3 do not refuse. The translator treats an offset above | ||
| 29 | 0xFFFFFFFF as out of range in every mode. Observed on hardware by five-star-recomp (commit `b9b57e2`), not measured | ||
| 30 | here; `tests/semantic/test_buffer_offset_wrap.py`. | ||
| 26 | - **In raw mode `soffset` is part of the checked offset.** The 3 cases that match neither column are raw reads at | 31 | - **In raw mode `soffset` is part of the checked offset.** The 3 cases that match neither column are raw reads at |
| 27 | offset 8 with `soffset` 8 and `N = 18`: 8 + 8 + 4 > 18, out of range on hardware. | 32 | offset 8 with `soffset` 8 and `N = 18`: 8 + 8 + 4 > 18, out of range on hardware. |
| 28 | - Loads and stores agree in every case. | 33 | - Loads and stores agree in every case. |
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 |
| 124 | primitive remap table either, and the element region allocates 64 bytes per element, `numElements` of them, padded | 124 | primitive remap table either, and the element region allocates 64 bytes per element, `numElements` of them, padded |
| 125 | to 128 bytes (a stride, not a record layout: section 4a describes the packed arrays inside it). | 125 | to 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 |
| 127 | or `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 | ||
| 129 | parent 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 | |||
| 146 | Measured 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 | ||
| 160 | updatable or top-level structures. Every measured stream has `flags` `0x81020006`, a BLAS without the updatable | ||
| 161 | bit `0x00040000`, so where an updatable structure keeps its leaves' entries is not measured. | ||
| 128 | 162 | ||
| 129 | The `flags` word has version `6` in its low 16 bits. It also sets `0x80000000` (bottom level), `0x00020000` | 163 | The `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 | ||
| 71 | Not measured: which of these sites a boot reaches, and in which order. | 71 | Not measured: which of these sites a boot reaches, and in which order. |
| 72 | |||
| 73 | ### Hosts without AVX | ||
| 74 | |||
| 75 | Measured 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 | |||
| 90 | Not 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 | ||
| 137 | So the four slots' callers are in the game executable, which the package does not contain (the | 137 | So the four slots' callers are in the game executable, which the package does not contain (the |
| 138 | same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is | 138 | same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is |
| 139 | still the SDK baseline. Once the executable is available, `tools/d3d12_iid_scan.py` run on it | 139 | still the SDK baseline. |
| 140 | shows 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 | ||
| 142 | the Windows SDK 10.0.26100 `d3d12.h`): the image carries 13 of them, and it carries the whole | ||
| 143 | queue/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 | |||
| 154 | The 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 | ||
| 161 | why both `d3d12_iid_scan.py` and `is_device_iid` in `runtime/shims/d3d12_xs_device.cpp` recognise | ||
| 162 | it during [retail_boot_chain.md](retail_boot_chain.md). | ||
| 163 | |||
| 164 | A carried IID is necessary but not sufficient: it says the binary can ask for the interface, not | ||
| 165 | where it does. The slots stay **Open** until a call site is followed. | ||
| 166 | |||
| 167 | One console command-list IID is outside `d3d12.h`, so the scan cannot see it, and a proxy has to | ||
| 168 | answer 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 | ||
| 170 | at `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..2fe3697c4 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 |
| 789 | aspect, in its float-typed sampled arrays like other single-sampled UINT views. Other gaps include descriptors | 789 | aspect, in its float-typed sampled arrays like other single-sampled UINT views. Other gaps include descriptors |
| 790 | the game writes itself, which need | 790 | the game writes itself, which need |
| 791 | the 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), | 791 | the execute-time scan of section 3.4 (only descriptors made through the device are registered). A retail |
| 792 | descriptor heap census (BL-4, measuring the primary 1,245,184-slot console CBV/SRV/UAV heap across submissions | ||
| 793 | 50, 500, and 5000 on RTX 5070 / Windows 11) confirms the slot distribution: 910,244 empty slots; 327,543 single-dword | ||
| 794 | free-list links (`value = slot_index + 1`, ending at `0xFFFFFFFF`); 261 T# with layer-assigned addresses above 4 GiB; | ||
| 795 | 5,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; | ||
| 797 | buffer 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), | ||
| 792 | which `rt::d3d12::register_samplers` registers without a heap slot but which nothing passes to it yet (the call at | 799 | which `rt::d3d12::register_samplers` registers without a heap slot but which nothing passes to it yet (the call at |
| 793 | pipeline creation comes with the shader index, #291); | 800 | pipeline creation comes with the shader index, #291); |
| 794 | custom border colours without VK_EXT_custom_border_color, and minimum/maximum filters, anisotropy or mirror-once addressing without the Vulkan | 801 | custom border colours without VK_EXT_custom_border_color, and minimum/maximum filters, anisotropy or mirror-once addressing without the Vulkan |
| @@ -1283,11 +1290,18 @@ and any validation error fails them. | |||
| 1283 | `d3d12_stateful_indirect_counted_pixels`: positive D3D12-to-Vulkan graphics tests. Compare every readback | 1290 | `d3d12_stateful_indirect_counted_pixels`: positive D3D12-to-Vulkan graphics tests. Compare every readback |
| 1284 | pixel with both a direct-draw reference and a known pattern for each draw kind; the counted variant fills | 1291 | pixel with both a direct-draw reference and a known pattern for each draw kind; the counted variant fills |
| 1285 | its argument and count buffers by GPU copy before use. | 1292 | its argument and count buffers by GPU copy before use. |
| 1286 | - `d3d12_indirect_rt_test`: a native Vulkan counted-draw reference (count 0 leaves the clear colour, | 1293 | - `d3d12_indirect_rt_test`: validates `ID3D12Device::CreateCommandSignature` + `ExecuteIndirect` with a GPU |
| 1287 | count 1 renders), a D3D12 command-signature creation check, and optional | 1294 | `CountBuffer` (`vkCmdDrawIndirectCount`, `count = 0` skipped and `count = 1` rendered), a draw whose record asks |
| 1295 | for four billion instances (clamped on the GPU, section 4.7), and a native Vulkan counted-draw reference over the | ||
| 1296 | same suballocated argument/count offsets (`count = 0` leaves the clear colour, `count = 1` renders; it is | ||
| 1297 | independent of the D3D12 command replay); optional | ||
| 1288 | `VK_KHR_acceleration_structure` + `VK_KHR_ray_query` (`GetRaytracingAccelerationStructurePrebuildInfo`, BLAS + TLAS | 1298 | `VK_KHR_acceleration_structure` + `VK_KHR_ray_query` (`GetRaytracingAccelerationStructurePrebuildInfo`, BLAS + TLAS |
| 1289 | `BuildRaytracingAccelerationStructure`, and a `RayQueryKHR` compute shader verifying hit vs. miss; clean SKIP on | 1299 | `BuildRaytracingAccelerationStructure`, and a `RayQueryKHR` compute shader verifying hit vs. miss; clean SKIP on |
| 1290 | GPUs without RT). | 1300 | GPUs without RT). |
| 1301 | - `indirect_clamp_test`: the `ExecuteIndirect` argument clamp pass itself (section 4.7), with no game files: every | ||
| 1302 | argument kind (draw, draw indexed, dispatch, mesh dispatch) and the counted variants, in-range records | ||
| 1303 | bit-identical, garbage records bounded, records and counts past `max_command_count` empty, and the per-batch work | ||
| 1304 | budget saturating; clean SKIP without a Vulkan device. | ||
| 1291 | - `d3d12_gcl8_test`: the public `ID3D12GraphicsCommandList8` surface: `QueryInterface` for its IID, | 1305 | - `d3d12_gcl8_test`: the public `ID3D12GraphicsCommandList8` surface: `QueryInterface` for its IID, |
| 1292 | `OMSetFrontAndBackStencilRef(1, 2)` with the recorded values, and the reference count around the query. It | 1306 | `OMSetFrontAndBackStencilRef(1, 2)` with the recorded values, and the reference count around the query. It |
| 1293 | creates only an allocator and a list, so it needs no GPU or Vulkan loader. | 1307 | creates only an allocator and a list, so it needs no GPU or Vulkan loader. |
| @@ -1837,7 +1851,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 | 1851 | 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. | 1852 | 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 | 1853 | 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 | 1854 | arguments for direct and indirect compute dispatches with an inline signature. Bound console descriptor heap |
| 1855 | base addresses are remapped through `console_descriptor_table_va` so that user SGPRs receive the arena copy's | ||
| 1856 | shader virtual address (where GPU descriptor reads land, preventing `READ_INVALID` device loss during world | ||
| 1857 | 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, | 1858 | 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 | 1859 | 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. | 1860 | `LEONIDA_COMPUTE_DIRECT_HEAPS=0` to restore the previous compute arguments. |
| @@ -2158,7 +2175,21 @@ sets them, and it does so twice. | |||
| 2158 | 2175 | ||
| 2159 | `amd_fidelityfx_upscaler_xbox.dll` does neither. Its 29 `RTS0` parts carry `Flags = 0`, and no instruction in it uses | 2176 | `amd_fidelityfx_upscaler_xbox.dll` does neither. Its 29 `RTS0` parts carry `Flags = 0`, and no instruction in it uses |
| 2160 | the constant `0x3000000`. So the bits are not a property of every console root signature; this builder adds them. The | 2177 | the constant `0x3000000`. So the bits are not a property of every console root signature; this builder adds them. The |
| 2161 | game executable is not in the package, so whether its root signatures carry them is open. | 2178 | retail executable's root signatures do not carry them either (old upstream PR 7140): its direct call passes a 1.1 |
| 2179 | description with `Flags = 0x80` (`LOCAL_ROOT_SIGNATURE`), and its root-signature decoder reads `Flags` as a | ||
| 2180 | zero-extended 16-bit value. | ||
| 2181 | |||
| 2182 | The mask stays unconditional, because it can't touch a public flag: it clears bits 24-31 | ||
| 2183 | (`kXboxRootSignatureFlagHighByte`, `runtime/shims/d3d12_xs_rootsig.h`), and every public | ||
| 2184 | `D3D12_ROOT_SIGNATURE_FLAGS` value is in bits 0-11 (the highest is `SAMPLER_HEAP_DIRECTLY_INDEXED`, `0x800`). So it is | ||
| 2185 | safe on every descriptor and blob, whatever built it. `root_sig_public_flags_test` pins this: | ||
| 2186 | |||
| 2187 | - the helpers keep every flag value in `[0, 0xFFFF]`; | ||
| 2188 | - the shims' serializers give the host's blob byte for byte for each public flag the host takes. Where the host | ||
| 2189 | refuses only `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` or `SAMPLER_HEAP_DIRECTLY_INDEXED` (Windows 10's in-box `d3d12.dll`), | ||
| 2190 | they serialize on purpose: the blob is the host's blob without those bits, with the full flags in `RTS0` and a valid | ||
| 2191 | container hash (`kDirectlyIndexedFlags`, `runtime/shims/d3d12_xs_rootsig.h`); | ||
| 2192 | - a blob with `0x03000080` comes back as `0x80`. | ||
| 2162 | 2193 | ||
| 2163 | **Version 1.2 on older runtimes.** The in-box `d3d12.dll` of Windows 10 (measured on 22H2, 10.0.19045, without the | 2194 | **Version 1.2 on older runtimes.** The in-box `d3d12.dll` of Windows 10 (measured on 22H2, 10.0.19045, without the |
| 2164 | Agility SDK) and of Windows 11 23H2 (#361) serializes root signatures only up to 1.1. On Windows 10 it rejects even an | 2195 | Agility SDK) and of Windows 11 23H2 (#361) serializes root signatures only up to 1.1. On Windows 10 it rejects even an |
| @@ -2391,13 +2422,104 @@ Pipeline creation: | |||
| 2391 | has no active builds. These snapshots have an additional 512 MiB ceiling. The driver fills a mapped staging | 2422 | has no active builds. These snapshots have an additional 512 MiB ceiling. The driver fills a mapped staging |
| 2392 | file directly. A successful snapshot atomically replaces the session. An interrupted write preserves the | 2423 | file directly. A successful snapshot atomically replaces the session. An interrupted write preserves the |
| 2393 | previous cache; the next launch removes unheld staging files older than ten minutes. | 2424 | previous cache; the next launch removes unheld staging files older than ten minutes. |
| 2425 | While the compute warm-up has builds queued that idle checkpoint never starts, and a boot that ends by a crash, | ||
| 2426 | a device loss or a kill never reaches teardown, so neither file used to keep that boot's compute pipelines. | ||
| 2427 | Compute pipelines are therefore journaled one file each (`src/pipeline_cache_journal.h`): | ||
| 2428 | `pipeline_cache.d/cs-<hash>.bin` beside the session file, named by a hash of the SPIR-V words, the stage flags and | ||
| 2429 | subgroup request, the push-constant range and the bindless layout. A build creates a `VkPipelineCache` from its | ||
| 2430 | file (if the header names this device and pipeline-cache UUID) and creates the pipeline against it; when the | ||
| 2431 | driver reports a compile (creation feedback without `APPLICATION_PIPELINE_CACHE_HIT`, or no file), that cache is | ||
| 2432 | written back to the file at once, through a staging file renamed over it. Without a file, and with | ||
| 2433 | `pipelineCreationCacheControl`, the shared cache is first asked with | ||
| 2434 | `VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT` when it was seeded from a file, so the offline seed | ||
| 2435 | still serves a first boot. NVIDIA 630.20 answers that flag with a compiled pipeline (seconds) instead of | ||
| 2436 | `VK_PIPELINE_COMPILE_REQUIRED`, so the first answer that took 250 ms or more without the cache-hit bit stops the | ||
| 2437 | asking, and that pipeline is built again against its journal cache so it gets a file (a fast answer without the | ||
| 2438 | bit is the driver's own disk cache, and a valid one; `LEONIDA_PIPELINE_JOURNAL_ASK_SHARED=0`: never ask). All | ||
| 2439 | driver calls of a compute build (shader module, journal cache, pipeline) run in one turn of the compile gate, with | ||
| 2440 | no file I/O in it: from the journal a build takes milliseconds, the warm-up worker makes them back to back, and | ||
| 2441 | three warm boots whose cache and module calls were outside the gate lost the device in a `vkQueueSubmit` 20-25 s | ||
| 2442 | in (no GPU fault, no TDR). The files take 2-3 MiB a pipeline on that driver (about 3.6 GiB for the 1700 a boot | ||
| 2443 | builds); `LEONIDA_PIPELINE_JOURNAL_BYTES` (32 GiB by default) caps them. At a device's first pipeline, staging files | ||
| 2444 | older than ten minutes are removed and, past the budget, the least recently used files until three quarters of it | ||
| 2445 | is left: a file's modification time is its last use (written, or touched, at most hourly, when a build finds its | ||
| 2446 | pipeline there), so files no build names any more after a translator regeneration go first. | ||
| 2447 | Measured on an RTX 4070 Ti (driver 630.20): 17 compute modules of 0.6-0.7 MB SPIR-V took 222 s to compile and | ||
| 2448 | 0.04 s to create from their cache; a boot's ~1000 warm-up builds of 128 KiB or more took 81 s cold and 1.8 s from | ||
| 2449 | the journal, and the submissions' compile-gate waits went from 77 s to none. Nsight Aftermath crash dumps | ||
| 2450 | (`LEONIDA_AFTERMATH=1`) appear to make the driver compile again whatever the caches hold: boots loading the same | ||
| 2451 | 317 MB session file logged no compute build of 2 s or more without Aftermath and 88-95 with it. The | ||
| 2452 | VK_NV_device_diagnostics_config flags alone do not (vk_pipeline_check `--nv-diagnostics`: 17 of 17 cache hits). | ||
| 2453 | `LEONIDA_PIPELINE_JOURNAL=0` (or `LEONIDA_PIPELINE_CACHE_BYTES=0`) turns the journal off. | ||
| 2454 | `LEONIDA_PIPELINE_CACHE_DIR=<folder>` moves the journal with the other files, so builds of gta6rt in several | ||
| 2455 | folders can share one; the file names and the driver's checks keep a pipeline from one build from being taken | ||
| 2456 | for another's. | ||
| 2457 | `gta6rt --precompile-pipelines [--threads N] [--big-threads N] [--all] [--smallest-first] [--limit N] | ||
| 2458 | [--min-bytes N] [--max-bytes N] [--filter PART]... [--list]` fills the journal ahead of play, with no game: it | ||
| 2459 | creates the Vulkan device as `--run` does (so the same environment gives the same journal names and driver keys: | ||
| 2460 | LEONIDA_SHADERS, LEONIDA_PIPELINE_CACHE_DIR, and LEONIDA_DEVICE_FAULT/LEONIDA_AFTERMATH, whose diagnostics config | ||
| 2461 | makes other pipelines) and builds every compute entry of the library through the dispatch path | ||
| 2462 | (`build_compute_pipeline`), largest first, on below-normal-priority threads. Entries with a usable journal file are | ||
| 2463 | skipped (only their header is read), so it can be stopped and started again. Running as gta6rt.exe it also fills | ||
| 2464 | NVIDIA's disk cache, which that driver keys by the executable's name. Measured on an RTX 4070 Ti (driver 630.20), | ||
| 2465 | 4 threads: modules of 3.6-5.8 MB took 46-145 s each, 12 in 312 s, about 3.5 GB of host memory each while in the | ||
| 2466 | driver (14.5 GB peak for four). Graphics pipelines are not covered: they are built at a title's draw from its PSO | ||
| 2467 | description and the bound formats, and take milliseconds. | ||
| 2468 | `LEONIDA_COMPILE_HELPER=1` (`shims/d3d12_compile_helper.h`) keeps first-ever compiles out of the title's process: | ||
| 2469 | the driver's locks, which a long `vkCreateComputePipelines` holds and a `vkQueueSubmit` of the same process waits | ||
| 2470 | for, are per process. A compute build of `LEONIDA_COMPILE_HELPER_MIN_BYTES` or more (128 KiB) with no journal file | ||
| 2471 | writes a request beside the journal (`requests/<name>.req`: the entry and a priority, 0 for a use, the module size | ||
| 2472 | for a warm-up) and starts the helper at the first one (`gta6rt --compile-server --parent <pid>`, the same executable | ||
| 2473 | and environment, so the same device and journal names). With asynchronous builds (`LEONIDA_ASYNC_PIPELINES=1`, the | ||
| 2474 | intended mode) nothing waits: the build answers deferred, the variant goes back to idle, the dispatch is skipped and | ||
| 2475 | counted, and each later use looks at the request (a file check, the module is not read again) until the journal | ||
| 2476 | file is there and the pipeline is created from it, a cache hit. A warm-up only asks, in either mode, so the warm-up | ||
| 2477 | worker writes its requests ahead and the helper's threads (`LEONIDA_COMPILE_HELPER_THREADS`, 2) build them in | ||
| 2478 | parallel, the most urgent first; a warm-up the helper builds is never held back while the title submits. Without | ||
| 2479 | asynchronous builds a dispatch waits for its file, holding nothing of the driver's (`LEONIDA_COMPILE_HELPER_WAIT_MS`, | ||
| 2480 | default 120 s, 0 for no limit). A failure (`requests/<name>.failed`, the helper gone) builds the pipeline here as | ||
| 2481 | before, and so does a request that is no longer listed (`<name>.req` gone with no answer) or one still pending after | ||
| 2482 | `LEONIDA_COMPILE_HELPER_PENDING_MS` (default 120 s): the helper cannot hold a dispatch forever. The helper | ||
| 2483 | checks that its journal name is the one asked for before it compiles (the name is a hash of the module and the | ||
| 2484 | device, no driver call), ends with the process that started it, runs alone per journal, | ||
| 2485 | and with nothing asked fills the rest of the library, smallest module first, on | ||
| 2486 | `LEONIDA_COMPILE_HELPER_IDLE_THREADS` (1, always one fewer than its threads) at idle priority; the journal names it | ||
| 2487 | worked out are kept in `requests/names.idx` (with each module's size and time and what the names depend on), so a | ||
| 2488 | later helper does not read every module again. `requests/<name>.building` is a lock file a process holds for the | ||
| 2489 | whole build (no sharing, deleted by the OS when that process ends, killed or not), whose contents name the process: | ||
| 2490 | the helper and `--precompile-pipelines` leave an entry its holder is building to it, and a file no process holds is | ||
| 2491 | stale whatever process id it names. Measured, RTX 4070 Ti, | ||
| 2492 | driver 630.20, a boot with an empty journal and the helper waiting (no asynchronous builds): the helper compiled 171 | ||
| 2493 | pipelines of 128 KiB or more (148 s in its driver), every one of them was a hit in the title's process (at most | ||
| 2494 | 2 ms), and no submission waited at the compile gate. | ||
| 2495 | Under Proton, pass a Wine path, for example | ||
| 2496 | `LEONIDA_PIPELINE_CACHE_DIR='Z:\opt\leonida\cache'`. Async warm-up workers publish to the same directory. | ||
| 2497 | For a disposable session, `LEONIDA_PIPELINE_JOURNAL_SEED_DIR=<absolute existing directory>` can name a separate, | ||
| 2498 | trusted read-only set of per-key compute journal files. The runtime prefers a compatible writable entry, then tries | ||
| 2499 | the same key in the seed; both use the existing size and device/driver header checks. A seed hit neither copies an | ||
| 2500 | entry nor refreshes its mtime. All writes, LRU touches, staging cleanup, eviction and byte accounting belong to the | ||
| 2501 | writable journal only, including replacement of an incompatible local file. The seed must be distinct from the | ||
| 2502 | writable `pipeline_cache.d`, not its ancestor or descendant; an explicitly unusable or overlapping root disables | ||
| 2503 | the journal. This setting does not grant access or authenticate cache data. Use only trusted, privately produced | ||
| 2504 | files on a read-only mount/ACL with stable, disjoint directories and no linked files between them. Leave unset for | ||
| 2505 | the original single-directory behavior. Per-key names are unchanged: externally precompiled files for the same | ||
| 2506 | pipeline identity can be read without a persistent *writable* shared journal. | ||
| 2507 | During normal runtime, a compatible local or external entry is used before requesting the helper. | ||
| 2508 | The offline precompiler and compile-server instead read and populate only the writable journal, even | ||
| 2509 | when a separate seed is configured. An external hit is not a published response to a helper request; | ||
| 2510 | its readiness check still requires a compatible file at the requested writable path. Both modes validate | ||
| 2511 | the configured directory pair before enabling journaling. | ||
| 2512 | To check the two tiers without game files, build `d3d12_compute_journal_test`, then run | ||
| 2513 | `python scripts/check_compute_journal_overlay.py <path-to-d3d12_compute_journal_test.exe> --require-hit`. | ||
| 2514 | This uses four fresh processes, two authored compute shaders and a disposable cache. It checks dispatch results, | ||
| 2515 | reported application-cache hits (where supported), local publications, and that old seed contents/mtime stay put. | ||
| 2394 | `LEONIDA_TRACE_PIPELINE_COMPILE=1` records each graphics and compute build's trigger, thread, elapsed time, | 2516 | `LEONIDA_TRACE_PIPELINE_COMPILE=1` records each graphics and compute build's trigger, thread, elapsed time, |
| 2395 | SPIR-V size, shader names and Vulkan application-cache feedback (1 hit, 0 miss, -1 unavailable). It also | 2517 | SPIR-V size, shader names and Vulkan application-cache feedback (1 hit, 0 miss, -1 unavailable). It also |
| 2396 | times cache reads, merges, writes and draw/dispatch pipeline lookups that take at least 1 ms. | 2518 | times cache reads, merges, writes and draw/dispatch pipeline lookups that take at least 1 ms. |
| 2397 | `LEONIDA_ASYNC_PIPELINES=1` schedules cold first-use builds on the warm-up worker ahead of speculative work. | 2519 | `LEONIDA_ASYNC_PIPELINES=1` schedules cold first-use builds on the warm-up worker ahead of speculative work; how long |
| 2398 | Replay skips a draw or dispatch while its pipeline is pending. Later uses find the completed handle. | 2520 | a submission waits for them, and what is skipped, is "Pipelines still being built" below. Strict replay builds |
| 2399 | A skipped dispatch can lose a one-time resource update. Synchronous first use is the default and strict | 2521 | synchronously and waits for every build. `LEONIDA_COMPUTE_WARMUP=0` restricts the worker to pipelines requested by |
| 2400 | replay always uses it. `LEONIDA_COMPUTE_WARMUP=0` restricts the worker to pipelines requested by the title. | 2522 | the title. |
| 2401 | A queued build holds no reference to its PSO or device (`PipelineCompiler`, `runtime/shims/d3d12_pipeline_compile.h`). | 2523 | A queued build holds no reference to its PSO or device (`PipelineCompiler`, `runtime/shims/d3d12_pipeline_compile.h`). |
| 2402 | A PSO's last release drops its queued builds and returns at once; one already running is left to finish, and the | 2524 | A PSO's last release drops its queued builds and returns at once; one already running is left to finish, and the |
| 2403 | worker deletes the PSO after it (`PipelineState::last_release`). The PSO's device reference goes at the release, so | 2525 | worker deletes the PSO after it (`PipelineState::last_release`). The PSO's device reference goes at the release, so |
| @@ -2439,9 +2561,7 @@ Pipeline creation: | |||
| 2439 | is when each is compiled alone, so a PSO released meanwhile waits for the submission. The workers have ended before | 2561 | 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 | 2562 | 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. | 2563 | 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`), | 2564 | 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 | 2565 | `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, | 2566 | 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 | 2567 | three runs each): the first submission of 192 graphics pipelines takes 126 to 143 ms instead of 861 to 882, of 192 |
| @@ -2449,6 +2569,51 @@ Pipeline creation: | |||
| 2449 | holds about 50 MiB more (the driver keeps memory for each thread that compiles). One `VkPipelineCache` is enough: one | 2569 | 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 | 2570 | cache per thread, merged, was about as fast. Tested by `pipeline_workers`, `replay_pipeline_compiles` and |
| 2451 | `d3d12_pipeline_workers`. | 2571 | `d3d12_pipeline_workers`. |
| 2572 | - Large pipelines: a compile takes the driver some hundred bytes of memory for each byte of SPIR-V | ||
| 2573 | ([pipeline_check.md](pipeline_check.md), "Limiting concurrent compilation of large modules"), so compute modules over | ||
| 2574 | 128 KiB and graphics pipelines of 1 MiB or more compile side by side only while their estimates (512 bytes for each | ||
| 2575 | byte of SPIR-V) fit a budget: three quarters of the smaller of the free RAM and the room under the commit limit, read | ||
| 2576 | again whenever a place at the gate (`runtime/src/large_module_gate.h`, one for the process) is given or returned. One | ||
| 2577 | always gets in when none is, so a pipeline larger than the budget compiles alone. An estimate counts in full until | ||
| 2578 | the compile ends, although the driver has taken part of it by then. They get in in the order they came; while the | ||
| 2579 | 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 | ||
| 2580 | budget together with it, so that a stream of small ones does not keep it out. The ones a submission waits for (and | ||
| 2581 | those of `LEONIDA_ASYNC_PIPELINES`) go before the warm-up's, which take a quarter of the budget at most and none while | ||
| 2582 | a submission that has large ones is compiling on its workers. A thread that waits for its place holds no PSO's lock, | ||
| 2583 | and one that has a place waits for none. `PipelineCompiles::build` gives a submission | ||
| 2584 | as many jobs for large ones as its smallest could be in at once, largest first; where the next one does not fit, the | ||
| 2585 | job compiles small ones in the meantime. `LEONIDA_SERIAL_BIG_COMPILES=1` compiles them one after another instead, as | ||
| 2586 | before there was a budget, `=0` has no limit, `LEONIDA_BIG_COMPILE_BUDGET_MB` fixes the budget. Measured with | ||
| 2587 | synthetic integer modules never compiled before and the warm-up off (RTX 3080, NVIDIA 621.24, Ryzen 7 5800X3D, 8 | ||
| 2588 | workers and the submitting thread, three alternating runs each): the first submission of 16 modules of 256 KiB takes | ||
| 2589 | 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 | ||
| 2590 | 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 | ||
| 2591 | 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 | ||
| 2592 | of SPIR-V here, and the driver keeps memory for each thread that compiles). With a budget of 1536 MiB, two at once, | ||
| 2593 | they take 18.5 s and peak 202 MiB over. Not measured: other drivers, and the title. Tested by `big_compile_gate`, | ||
| 2594 | `replay_pipeline_compiles` and `d3d12_big_compute`. | ||
| 2595 | |||
| 2596 | **Pipelines still being built** (`PipelineState::queue_build` in `runtime/shims/d3d12_vulkan_device.cpp`). Lazy | ||
| 2597 | pipelines are built at first use, and on the 4070 Ti (NVIDIA 630.20) a large compute pipeline takes the driver 3-10 s, | ||
| 2598 | some 37 s. A submission builds the ones it needs through `PipelineCompiles` and `PipelineWorkers` (above), with | ||
| 2599 | `resource_mutex_` released while they compile and the large ones within the memory budget of `LargeModuleGate`. | ||
| 2600 | #2098 had a second path here, a pre-pass in `VulkanQueue::execute` that built them one after another on the | ||
| 2601 | submitting thread; at the maintainers' decision it was replaced by this one when #2098 was merged. | ||
| 2602 | |||
| 2603 | - **Asynchronous builds** (`LEONIDA_ASYNC_PIPELINES=1`). Prepare asks `queue_build`, which answers the handle once | ||
| 2604 | built and otherwise queues one compile-worker job at replay's priority and answers null: the draw or dispatch is | ||
| 2605 | skipped, the list's other commands replay as recorded, and a later submission uses the pipeline. The job also starts | ||
| 2606 | at record time already: at `SetPipelineState` for compute and at each draw for graphics, with the variant its bound | ||
| 2607 | targets give (`request_pipeline_build`). A compute build the compile helper is still making (`LEONIDA_COMPILE_HELPER`) | ||
| 2608 | publishes nothing, so its next use asks again. | ||
| 2609 | - **Warm-ups while the title submits.** A compute warm-up holds the compile gate for its whole create, and every | ||
| 2610 | submission waits behind it: a native boot's submissions waited 140 s in all at the gate behind compute warm-ups, and | ||
| 2611 | past the story load the worker went through 694 warm-ups of modules over 128 KiB (those over 640 KiB take 4-25 s | ||
| 2612 | each) against 25 such builds a dispatch asked for (measured with a 128 KiB limit). With | ||
| 2613 | `LEONIDA_COMPUTE_WARMUP_LIVE_MAX_BYTES=<n>` a warm-up of a module over n bytes of SPIR-V is not started while the | ||
| 2614 | title submits (a submission in the last second, `src/pipeline_wait.h`); the pipeline is built at its first use | ||
| 2615 | instead. Opt-in: unset or 0, every warm-up runs, as on `main`, and `LargeModuleGate` (#1889) orders them behind a | ||
| 2616 | submission's compiles. Smaller warm-ups, and every warm-up before the first submission, run as before. | ||
| 2452 | 2617 | ||
| 2453 | **Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear. | 2618 | **Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear. |
| 2454 | The trace will enumerate them. | 2619 | The trace will enumerate them. |
| @@ -3508,7 +3673,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 | 3673 | `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 | 3674 | 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: | 3675 | 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 | 3676 | blank presents of a loading screen do not delay the first wait. At most `latency` frames are in flight once the event |
| 3677 | is armed: a present into a full queue (several presents with no wait between them) replaces the newest queued frame | ||
| 3678 | and takes its vblank, like a mailbox, so the replaced frame is never shown (no display statistic) and the older ones | ||
| 3679 | keep their vblanks. However many presents come between two waits, the next wait passes when the oldest frame is | ||
| 3680 | shown. A wait that comes late returns at once | ||
| 3512 | with the newest passed origin; the missed ones are skipped. A finite timeout gives | 3681 | 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)`. | 3682 | `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 | 3683 | `LEONIDA_PRESENT_UNCAP` (any non-empty value other than "0", read when the object is made) takes the frame-rate |
| @@ -3524,8 +3693,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 | 3693 | `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, | 3694 | 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` | 3695 | `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, | 3696 | 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 | 3697 | replaced in a full queue (see the latency limit above) still counts as a present with its real interval, so the |
| 3698 | percentiles describe the title's present cadence, and a burst of presents between two waits shows up as short | ||
| 3699 | intervals. Confirmed on a fake clock by `frame_pacer_test` (known 100-frame distribution, | ||
| 3700 | positive and negative drift, ring-buffer wrap-around, suspend/resume exclusion, uncapped mode, replaced frames) and by | ||
| 3529 | `tests/test_boot_trace.py`. | 3701 | `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 | 3702 | - *`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 | 3703 | single-sample 2D colour texture in `PRESENT`) to the swapchain image, limited to `pSrcViewRects[0]` when set |
| @@ -3721,8 +3893,11 @@ will forward to. The queue-side calls ignore which queue they came on (one `VkQu | |||
| 3721 | - *Frame capture* (`LEONIDA_CAPTURE=<dir>`, `LEONIDA_CAPTURE_EVERY=<n>`, `LEONIDA_CAPTURE_LIMIT=<n>`): writes | 3893 | - *Frame capture* (`LEONIDA_CAPTURE=<dir>`, `LEONIDA_CAPTURE_EVERY=<n>`, `LEONIDA_CAPTURE_LIMIT=<n>`): writes |
| 3722 | every n-th presented frame (default 30, at most 24) to `<dir>/frame_NNNNN.ppm`, a binary P6 of the swapchain image | 3894 | every n-th presented frame (default 30, at most 24) to `<dir>/frame_NNNNN.ppm`, a binary P6 of the swapchain image |
| 3723 | converted to 8-bit RGB, and appends one line per frame to `<dir>/index.txt` with the extent and the mean RGB. Off | 3895 | converted to 8-bit RGB, and appends one line per frame to `<dir>/index.txt` with the extent and the mean RGB. Off |
| 3724 | unless the variable is set, and the folder is created. This is what a check reads when it has to know what the | 3896 | unless the variable is set, and the folder is created. Disk-only sampling copies frames 1, 1+n, 1+2n, … to host |
| 3725 | layer actually presented: the window is not readable in every setup (under Wine it is not even mapped), and the | 3897 | staging until the file limit is reached; intervening frames still present normally. This avoids a full-image |
| 3898 | transfer on every present when only occasional samples were requested. An explicit continuous readback request | ||
| 3899 | and the temporary splash inspection still copy each frame they need. This lets a check inspect what the layer | ||
| 3900 | actually presented: the window is not readable in every setup (under Wine it is not even mapped), and the | ||
| 3726 | mean is enough to tell a real frame from a black one. `d3d12_present_test` turns it on and checks the files against | 3901 | mean is enough to tell a real frame from a black one. `d3d12_present_test` turns it on and checks the files against |
| 3727 | the colour it clears to. | 3902 | the colour it clears to. |
| 3728 | - *`SuspendX`/`ResumeX`*: suspend drops the interval, the origin event and the frames in flight, wakes blocked waits | 3903 | - *`SuspendX`/`ResumeX`*: suspend drops the interval, the origin event and the frames in flight, wakes blocked waits |
| @@ -3744,7 +3919,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, | 3919 | (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 | 3920 | 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 | 3921 | 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`. | 3922 | time; skipped, exit 77, without a Vulkan device). `frame_pacer_test` also sweeps `decide_present_sync`, and checks |
| 3923 | that 1000 presents between two waits leave at most `latency` frames in flight (latency 1, 2 and 3). | ||
| 3748 | 3924 | ||
| 3749 | ### 4.6 Queries | 3925 | ### 4.6 Queries |
| 3750 | 3926 | ||
| @@ -3767,15 +3943,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 | 3943 | (`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 | 3944 | 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`. | 3945 | 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` | 3946 | - **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 | 3947 | `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 | 3948 | (`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 | 3949 | real `VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT` pool begun and ended indexed on the stream |
| 3950 | (`vkCmdBeginQueryIndexedEXT` / `vkCmdEndQueryIndexedEXT`), and `ResolveQueryData` copies the two 64-bit results per | ||
| 3951 | query (16 bytes: `NumPrimitivesWritten`, `PrimitivesStorageNeeded`), in the same order; with no stream output they | ||
| 3952 | are 0. A stream at or above the device's `maxTransformFeedbackStreams` runs nothing and resolves zero, as if the | ||
| 3953 | heap had no pool. Without the feature, the property, or a nonzero `maxTransformFeedbackStreams`, the heap is made | ||
| 3954 | 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 | 3955 | 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 | 3956 | 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 | 3957 | 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 | 3958 | (`VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753`), so `prepare()` refuses such a list |
| 3778 | results are in the same order. | 3959 | (`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 | 3960 | - **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 | 3961 | 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 | 3962 | it runs; resolve offsets are multiples of 8. A list closed with a query still running reports `E_INVALIDARG` and |
| @@ -3912,6 +4093,26 @@ Not implemented yet: | |||
| 3912 | one Vulkan indirect call. Use a compute expansion pass that writes a Vulkan-shaped indirect buffer, or | 4093 | one Vulkan indirect call. Use a compute expansion pass that writes a Vulkan-shaped indirect buffer, or |
| 3913 | `VK_NV_device_generated_commands` on NVIDIA. Start with the simple signatures; the trace will show which | 4094 | `VK_NV_device_generated_commands` on NVIDIA. Start with the simple signatures; the trace will show which |
| 3914 | signatures the game creates. | 4095 | signatures the game creates. |
| 4096 | - The indirect arguments are clamped on the GPU before the command reads them (D3D-17's replay, | ||
| 4097 | `runtime/src/vulkan_indirect_clamp.h`, shader `runtime/src/indirect_clamp.comp`). The title's own compute writes | ||
| 4098 | them, and a pass the replay drops (an async pipeline that is not built yet, a stub pipeline, | ||
| 4099 | `LEONIDA_SKIP_COMPUTE`) or mistranslates leaves whatever the memory held: a dispatch of billions of groups or a | ||
| 4100 | draw of four billion vertices runs until the host resets the display driver. One small compute pass per | ||
| 4101 | `ExecuteIndirect` call copies the active records into device-local scratch with their values bounded - 2^24 | ||
| 4102 | vertices or indices, 2^26 vertex instances (count times instances), 65 535 groups per dimension, 2^20 groups per | ||
| 4103 | dispatch and a 2^27-unit work budget per call that saturates through an atomic compare-and-swap - and writes an | ||
| 4104 | empty record past `min(count, max_command_count)` and past the budget, and the clamped count word a `*Count` draw | ||
| 4105 | then reads (so the count is at most `maxDrawCount`, VUID-vkCmdDrawIndirectCount-countBuffer-02717). The indirect | ||
| 4106 | command reads that scratch. A draw emits the pass before its rendering scope opens: `vkCmdCopyBuffer` and a | ||
| 4107 | memory barrier with a transfer access are not allowed inside a dynamic-rendering scope. The records are | ||
| 4108 | bit-identical to the application's when they are within the limits, the argument and count buffers are left | ||
| 4109 | untouched, and the scratch comes from a per-submission pool (`vulkan_scratch.h`) that a list with many indirect | ||
| 4110 | calls reuses. `LEONIDA_INDIRECT_CLAMP=0` reads the application's buffer again, as before. The pass's counters | ||
| 4111 | (records checked, records clamped, counts clamped, records past the budget) are copied to one host-visible slot | ||
| 4112 | per call, read once the submission completes, logged in full at the first use and then rate-limited. Covered by | ||
| 4113 | `indirect_clamp_test` (every kind and the counted variants, | ||
| 4114 | in-range and garbage records, the budget), by `d3d12_m4_compute_test` (a garbage dispatch record beside the | ||
| 4115 | in-range one) and by `d3d12_indirect_rt_test` (a draw whose instance count is garbage). | ||
| 3915 | - Predication (`SetPredication`) maps to `VK_EXT_conditional_rendering` (D3D-18). Done: `GraphicsCommandList:: | 4116 | - Predication (`SetPredication`) maps to `VK_EXT_conditional_rendering` (D3D-18). Done: `GraphicsCommandList:: |
| 3916 | SetPredication` records a `Predication` command (`runtime/src/command_list.h`; offset 8-byte aligned, op | 4117 | SetPredication` records a `Predication` command (`runtime/src/command_list.h`; offset 8-byte aligned, op |
| 3917 | `EQUAL_ZERO` or `NOT_EQUAL_ZERO`, a null buffer turns it off). The replay (`runtime/src/vulkan_replay.h`) begins | 4118 | `EQUAL_ZERO` or `NOT_EQUAL_ZERO`, a null buffer turns it off). The replay (`runtime/src/vulkan_replay.h`) begins |
| @@ -4171,7 +4372,8 @@ uint32 mask; // slot count - 1 | |||
| 4171 | struct entry { // 10 uints = 40 bytes | 4372 | struct entry { // 10 uints = 40 bytes |
| 4172 | uint32 key[8]; // T#: 8 dwords; S#: 4 dwords then 0xFFFFFFFF x4 | 4373 | uint32 key[8]; // T#: 8 dwords; S#: 4 dwords then 0xFFFFFFFF x4 |
| 4173 | uint32 index; // bindless index | 4374 | uint32 index; // bindless index |
| 4174 | uint32 pad; // unused by the shader | 4375 | uint32 kind; // 0 empty; bit 31 occupied; bits 0..5 the sampled arrays the index is bound in, |
| 4376 | // bits 8..11 its storage arrays (one bit per ImageDimension) | ||
| 4175 | } entries[mask + 1]; | 4377 | } entries[mask + 1]; |
| 4176 | ``` | 4378 | ``` |
| 4177 | 4379 | ||
| @@ -4184,6 +4386,18 @@ struct entry { // 10 uints = 40 bytes | |||
| 4184 | `runtime/test/descriptor_table_test.cpp`. | 4386 | `runtime/test/descriptor_table_test.cpp`. |
| 4185 | - Probe: `slot = (h + k) & mask` for `k = 0..7`; the first entry whose eight key dwords match yields its | 4387 | - Probe: `slot = (h + k) & mask` for `k = 0..7`; the first entry whose eight key dwords match yields its |
| 4186 | `index`; no match yields 0. | 4388 | `index`; no match yields 0. |
| 4389 | - `kind` says which arrays that index is good for, because it was given out in the T#'s own dimension's index space | ||
| 4390 | (`runtime/src/vulkan_bindless.h`, `ImageDimension`): bit `d` is dimension `d`'s sampled array, bit `8 + d` its | ||
| 4391 | storage arrays. A module whose `index.json` meta says `"descriptor_table": "tagged"` reads it and uses the index | ||
| 4392 | only in an array the entry names, else index 0 of the array its instruction reads; an absent key is the old plain | ||
| 4393 | layout, which reads only the index. `DescriptorTable::insert` takes the kind, and `BindlessSet::image_kind_at` | ||
| 4394 | derives it from what was bound at the index (its own arrays, storage views, and the 2D copy of a 2D-array image's | ||
| 4395 | first layer, whose slot records that image as its owner so another dimension's image with the same slot number does | ||
| 4396 | not inherit it). One layout serves the device: any module whose meta says `tagged` makes the table tagged, because | ||
| 4397 | the kind word is additive (a plain module ignores the word and reads the index, which the tagged layout keeps at | ||
| 4398 | the same place), so a plain majority never turns it off; no tagged module is the old plain layout. | ||
| 4399 | `LEONIDA_DESCRIPTOR_TABLE=plain|tagged` overrides, and the runtime says so loudly when an override forces plain | ||
| 4400 | while tagged modules exist. | ||
| 4187 | - The layer must keep the table sparse enough that no live key needs more than eight probes. When all eight slots are occupied, | 4401 | - The layer must keep the table sparse enough that no live key needs more than eight probes. When all eight slots are occupied, |
| 4188 | the runtime tries to move one resident to the next empty slot within that resident's own probe window. | 4402 | the runtime tries to move one resident to the next empty slot within that resident's own probe window. |
| 4189 | A relocation requires an idle flush because it overwrites a live slot. Grow when this fails or when the next | 4403 | A relocation requires an idle flush because it overwrites a live slot. Grow when this fails or when the next |
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 | |||
| 450 | GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the | 450 | GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the |
| 451 | wrong slot. Leonida's public-chain command list already has it at GCL8. | 451 | wrong 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 | |||
| 455 | These six offsets are called in the title's executable; five reach the device and `+0x418` (131) | ||
| 456 | does not. `+0x2B0`, `+0x328`, `+0x360` and `+0x418`-`+0x428` are past every published interface, | ||
| 457 | so they are console slots on whatever object the call is made on, and the receiver is not | ||
| 458 | automatically the device: the console runtime repeats offsets across object vtables. The whole | ||
| 459 | image has **243** indirect calls `call [reg+disp]` at these six offsets; most of them are *not* on | ||
| 460 | the device, and a count that ignores the receiver overstates the device surface by an order of | ||
| 461 | magnitude. | ||
| 462 | |||
| 463 | The receiver is proven by a backward definition chain from the `call` that ends in a full-width load | ||
| 464 | of 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 | ||
| 467 | chain ends in one of those globals is a device site. A site whose chain ends in a *different* | ||
| 468 | global, in an argument of unknown provenance or in the return of a helper is counted but not | ||
| 469 | attributed. | ||
| 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 | |||
| 480 | Per 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 | |||
| 548 | The 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 | ||
| 551 | argument (`rdx` = the struct that carries the size/VA). None of those receivers is proven to be | ||
| 552 | the device, so the pairing says "one feature area", not "same arity" and not "device slot". | ||
| 553 | |||
| 554 | What 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 | ||
| 455 | The one measured console command-list rule, quoted from the UMD: | 573 | The 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 | ||
| 695 | The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives | 813 | The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives |
| 696 | a **name-level map** of the extension surface. It does not close presentation, slots, struct | 814 | a **name-level map** of the extension surface. It does not close presentation, the slot map, |
| 697 | layouts, numeric flags or tiling. | 815 | struct layouts, numeric flags or tiling; §5.2 adds five device slots to what the game itself |
| 816 | answers (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..ebee74ad0 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 | ||
| 69 | 1. **Section entropy.** Sections near 8.0 bits/byte are still encrypted or compressed. If `.text` is one of them, | 69 | 1. **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. |
| 71 | 2. **Import table.** Each DLL is marked `bundled` (in the game folder), `system` (present on this Windows), or | 71 | 2. **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. | ||
| 73 | 3. **.pdata function count.** This gives function boundaries for patching and later analysis. | 77 | 3. **.pdata function count.** This gives function boundaries for patching and later analysis. |
| 74 | 4. **Inline command-list writes.** `python -I tools/inline_scan.py <game>\game_scarlett_master.exe --sites` (a few | 78 | 4. **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 | |||
| 91 | Then `runtime\build\gta6rt.exe --dry-run <exe>` maps the image and binds every import to the shim table without | 95 | Then `runtime\build\gta6rt.exe --dry-run <exe>` maps the image and binds every import to the shim table without |
| 92 | running any game code. It reports what it couldn't bind. | 96 | running any game code. It reports what it couldn't bind. |
| 93 | 97 | ||
| 98 | The PE report's `resources` field (the Markdown's "Resources" section) lists the resource types with entry and | ||
| 99 | byte 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 | ||
| 101 | table (`lang_codepage`) each standard key with its value's length (`chars`) and SHA-256 (of the value as UTF-8, | ||
| 102 | without its NUL). The values are never written, as they can name the title: two builds compare by hash. A key | ||
| 103 | outside 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 | ||
| 105 | gets one line per image with a version block: its two versions and its key count. The 1.0.2.1 executable has no | ||
| 106 | resource directory (data directory 2 is zero and no `VS_VERSION_INFO` key is anywhere in the file), so its report | ||
| 107 | says `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 | ||
| 96 | Build the hand-written tests where LLVM supports AMDGPU and SPIRV-Tools is available. Run the generated shaders | 111 | Build the hand-written tests where LLVM supports AMDGPU and SPIRV-Tools is available. Run the generated shaders |
| @@ -309,9 +324,10 @@ How the generated SPIR-V expects the runtime to work: | |||
| 309 | | Scalar/buffer memory | `s_load*`, `s_buffer_load*`, `buffer_load*` and `buffer_store*` use buffer device addresses (`PhysicalStorageBuffer64`). LLVM `VCCTuple` scalar register lists ending in `vcc_lo,vcc_hi` (e.g. `[s100,s101,s102,s103,s104,s105,vcc_lo,vcc_hi]`, `[s92,...,s105,vcc_lo,vcc_hi]`, seen in 6 FidelityFX FSPX shaders) are parsed as `slist` operands in `tools/shader_ir.py`, clear `vcc` from the lane-mask state in `tools/lane_masks.py`, and route `sN` slots to `%sgpr` and `vcc_lo`/`vcc_hi` to `%vcc`/`%vcc_hi` across SMEM loads, T#/S#/V# descriptor reads, and `global_*` `saddr`. `src_scc` reads `%scc` (0 or 1, RDNA2 inline constant 253), matching `scc`. `image_atomic_*` and `image_atomic_cmpswap` accept `a16` packed 16-bit unsigned coordinates (low half first, matching `image_store`). CPU-checked by `tests/semantic/test_fspx_rules.py` and validated with `spirv-val` (native and `--wave64-emulate`). **Not GPU-verified.** The base comes from the 64-bit SGPR pointer or the V# (dword0 \ \| dword1[15:0] << 32), and the stride is V# dword1[29:16]. **The runtime must put the game's GPU heap in buffer-device-addressable memory at the same addresses the game writes into descriptors** (or remap them). `s_load*` and `s_buffer_load*` take an immediate or an SGPR offset, or both at once (llvm-mc prints `sOFF offset:IMM`). Rules, 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): **address** = (base & ~3) + (sOFF & ~3) + (IMM & ~3) + 4·i for dword i: base, sOFF and IMM are each truncated to a multiple of 4, then added (`s_buffer_load_dword s9, s[24:27], 0x3` with base & 3 = 1 reads +0, not bytes 4..7; sOFF 3 + IMM 3 reads +0 and sOFF 2 + IMM 6 reads +4, where truncating the sum gives +4 and +8; sOFF 8 + IMM 4 reads +12; the same for `s_load*` with pointer & 3 = 1 or 3). **`s_buffer_load*` bound**: dword i is 0, and memory is not read, when (sOFF & ~3) + (IMM & ~3) + 4·i + 4 > limit, with limit = NUM_RECORDS (V# dword2) bytes when the stride is 0 and NUM_RECORDS × stride bytes when it is not. Per dword (x4 at 0xc with NUM_RECORDS 21: data, data, 0, 0; x8 at 0 with 21: five data, three 0), on the truncated offset (IMM 0x10 with NUM_RECORDS 18: 0; IMM 0x13 with 21: the dword at +0x10; sOFF 0xe + IMM 2 with 16: the dword at +0xc; sOFF 0x10 + IMM 4 with 20: 0), not seeing base & 3 (base & 3 = 3, IMM 0x13, NUM_RECORDS 20: data); with a stride the test is still on bytes (stride 4, NUM_RECORDS 5: IMM 0x10 data, 0x14 0; stride 1, NUM_RECORDS 17: IMM 0x10 is 0, so it is not an index test). IMM is unsigned (0xffffc reads +0xffffc). OOB_SELECT (V# word3[29:28]) 0, 1, 2 and 3 gave the same pattern (7 probes per value). **`s_load*`**: no bound (+0x1ffffc reads the dword there); IMM is sign-extended from 21 bits and added in 64 bits (sOFF 8 + IMM −4 reads +4 where zero-extension reads 4 GiB further; sOFF 0xb + IMM −1 reads +4, so the negative IMM is truncated on its own: −1 → −4). **Negative sums** (SHADER-336), measured on the integrated GPU of a Ryzen 9 9950X3D (gfx1036, RDNA2, Windows driver 32.0.21045.16010) with `tools/smem_neg_probe.py --oracle hw`, wave32 = wave64: `s_load` with IMM −4 or −0x40 and no sOFF, sOFF 4 + IMM −8, sOFF 0xc + IMM −0x20 and the x2 form with sOFF 4 + IMM −0x10 read below the pointer at the 64-bit signed sum, and sOFF 6 + IMM −1 reads +0 (4 + −4, each term truncated on its own). `s_buffer_load` adds sOFF and IMM without wrapping at 32 bits: sOFF 0xfffffffc + IMM 8 and sOFF 0xfffffff0 + IMM 0x20 give 0 (past NUM_RECORDS 0x100), and sOFF 0xfffffffc, 0x80000000 and 0x7ffffffc alone give 0 (the translator has the same rule in both offset forms since #1686). An `s_buffer_load` IMM with bit 20 set (llvm-mc rejects it; −4, −0x10, 0x100000 and 0x100004 were encoded by hand) reads data that is neither 0 nor the buffer's own words, differently in wave32 and wave64: the bound does not hold for that encoding, so no compiler output uses it and the translator does not model it. `SmemHardwareRuleTests` in `tests/semantic/test_scalar_mem_smem.py` runs these rows with sOFF in a register and with sOFF known. **Measured since** on native RDNA2 (gfx1036, the Radeon iGPU of a Ryzen 7 9800X3D, Windows driver 32.0.21042.62) through `tools/hw_oracle`, one raw kernel, wave32 = wave64 in every dword (22 cases): **`x16`** takes the per-dword bound like x8 (`s_buffer_load_dwordx16` at offset 0 with NUM_RECORDS 0x24 gives nine data dwords and seven 0; offset 0x20 with 0x40 gives eight and eight; offset 4 with 0x3d gives fourteen and two; stride 4 with NUM_RECORDS 9 gives nine and seven), and `s_load_dwordx16` reads all sixteen; **NUM_RECORDS ≥ 2^31** is compared unsigned (0x80000000 and 0xffffffff with offset 0x10, and 0x80000000 with an x4 at 0x2f0, all read data); **NUM_RECORDS × stride ≥ 2^32** does not wrap (stride 4 × 0x40000001, stride 0x100 × 0x01000001 and stride 0x40 × 0x04000004 wrap to 4, 0x100 and 0x100 in 32 bits, yet offsets 0x10, 0x200 and 0x2f0 read data), as the translator's 64-bit product assumes; **V# dword1[31:30]** = 1, 2 or 3 changes nothing (a dword at 0x10, an x4 at 0xf8 with NUM_RECORDS 0x100 giving two data and two 0, and the same with stride 8 and NUM_RECORDS 4 at 0x18). Not measured: gfx1013 (PS5) itself. **Bound edges**, measured on the same GPU and driver with `tools/hw_oracle` (wave32 = wave64, every read inside a seeded region): `s_buffer_load_dwordx16` is bounded per dword like x8 (NUM_RECORDS 0x14 gives d0..d4 and 0 for d5..d15; 0x20 with IMM or sOFF 8 gives d0..d5); NUM_RECORDS × stride is not cut to 32 bits (stride 0x1000 × 0x100000 and 0x2000 × 0x80000 = 2^32, stride 8 × 0x20000001 = 2^32 + 8: all four dwords of an x4 at 0 are data; stride 8 × 1 gives two); NUM_RECORDS 0x80000000 and 0xFFFFFFFF are unsigned (an x4 at 0 reads all four). These are the rules the translator already used; `SmemHardwareRuleTests` pins them too (a 32-bit product, a signed NUM_RECORDS or one bound for the whole load each fail a test). Not measured: `x16` (gets the x8 rule), NUM_RECORDS ≥ 2^31 and NUM_RECORDS × stride ≥ 2^32, V# dword1[31:30], and gfx1013 (PS5) itself. `s_load`/`s_buffer_load` with sOFF + IMM < 0 (a negative IMM without sOFF included; the translator uses the 64-bit signed sum, an inference), an `s_buffer_load` IMM with bit 20 set (llvm-mc rejects it) or a negative one (kept as the 32-bit value: for stride 0 that is past any NUM_RECORDS below 4 GiB), `x16` (gets the x8 rule), sOFF ≥ 2^31, NUM_RECORDS ≥ 2^31 and NUM_RECORDS × stride ≥ 2^32, V# dword1[31:30], and gfx1013 (PS5) itself. The translator checks each `s_buffer_load` dword with its own structured `if` and an `OpPhi` with 0, so an out-of-range dword issues no load (when descriptor limit and offset are compile-time constants, in-range dwords fold to straight-line loads and out-of-range dwords emit constant zero without branches); `s_load` stays straight-line. Before this the translator added base + sOFF + IMM unaligned, had no `s_buffer_load` bound and zero-extended a negative `s_load` IMM. Checked by `tests/semantic/test_scalar_mem_smem.py` (`SmemHardwareRuleTests`, the measurement's rows, values and the addresses read; `SmemSoffsetImmTranslatorTests`) and by the GPU tests `runtime/test/shaders/cs_smem_soffset_imm.asm`, `cs_smem_bounds.asm`, `cs_smem_stride_align.asm` and `cs_smem_sload_neg.asm` (never run that one with a translator that zero-extends the immediate: it reads 4 GiB past the heap), all in `check.py` and `scripts/run_gpu_tests.py`, which pass on the RX 6800 (Vulkan, driver 26.11.2). See *Buffer bounds checking* below for the MUBUF `num_records` checks. **A constant SGPR offset** (`s_mov_b32 s12, C`, folded at translate time) is added as the run-time path adds `sOFF`: zero-extended, `& ~3`, after the immediate has been normalised (unsigned for `s_buffer_load`, 21-bit signed for `s_load`), with no 32-bit wrap. Until 2026-11-22 (#1686) the fold added it before the truncation, so `s12 = -4` with `offset:20` read byte 16 instead of being out of range, and an `s_load` `sOFF` of 2^20 or more was sign-extended from 21 bits (found by @Impre-visible; hardware measured by @Pierre-Kookis on gfx1036: 0xFFFFFFFC + 20 reads 0). CPU-checked by `tests/semantic/test_smem_const_offset.py` (each case constant vs run-time offset, and against the measured rule). Where llvm-mc rejects such a tuple, `restore_vcc_tuples` decodes it from the blob, and with it the instructions its junk text swallowed, up to the next instruction llvm-mc printed (corpus count: `docs/shader_library.md`, section 5). | | 324 | | Scalar/buffer memory | `s_load*`, `s_buffer_load*`, `buffer_load*` and `buffer_store*` use buffer device addresses (`PhysicalStorageBuffer64`). LLVM `VCCTuple` scalar register lists ending in `vcc_lo,vcc_hi` (e.g. `[s100,s101,s102,s103,s104,s105,vcc_lo,vcc_hi]`, `[s92,...,s105,vcc_lo,vcc_hi]`, seen in 6 FidelityFX FSPX shaders) are parsed as `slist` operands in `tools/shader_ir.py`, clear `vcc` from the lane-mask state in `tools/lane_masks.py`, and route `sN` slots to `%sgpr` and `vcc_lo`/`vcc_hi` to `%vcc`/`%vcc_hi` across SMEM loads, T#/S#/V# descriptor reads, and `global_*` `saddr`. `src_scc` reads `%scc` (0 or 1, RDNA2 inline constant 253), matching `scc`. `image_atomic_*` and `image_atomic_cmpswap` accept `a16` packed 16-bit unsigned coordinates (low half first, matching `image_store`). CPU-checked by `tests/semantic/test_fspx_rules.py` and validated with `spirv-val` (native and `--wave64-emulate`). **Not GPU-verified.** The base comes from the 64-bit SGPR pointer or the V# (dword0 \ \| dword1[15:0] << 32), and the stride is V# dword1[29:16]. **The runtime must put the game's GPU heap in buffer-device-addressable memory at the same addresses the game writes into descriptors** (or remap them). `s_load*` and `s_buffer_load*` take an immediate or an SGPR offset, or both at once (llvm-mc prints `sOFF offset:IMM`). Rules, 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): **address** = (base & ~3) + (sOFF & ~3) + (IMM & ~3) + 4·i for dword i: base, sOFF and IMM are each truncated to a multiple of 4, then added (`s_buffer_load_dword s9, s[24:27], 0x3` with base & 3 = 1 reads +0, not bytes 4..7; sOFF 3 + IMM 3 reads +0 and sOFF 2 + IMM 6 reads +4, where truncating the sum gives +4 and +8; sOFF 8 + IMM 4 reads +12; the same for `s_load*` with pointer & 3 = 1 or 3). **`s_buffer_load*` bound**: dword i is 0, and memory is not read, when (sOFF & ~3) + (IMM & ~3) + 4·i + 4 > limit, with limit = NUM_RECORDS (V# dword2) bytes when the stride is 0 and NUM_RECORDS × stride bytes when it is not. Per dword (x4 at 0xc with NUM_RECORDS 21: data, data, 0, 0; x8 at 0 with 21: five data, three 0), on the truncated offset (IMM 0x10 with NUM_RECORDS 18: 0; IMM 0x13 with 21: the dword at +0x10; sOFF 0xe + IMM 2 with 16: the dword at +0xc; sOFF 0x10 + IMM 4 with 20: 0), not seeing base & 3 (base & 3 = 3, IMM 0x13, NUM_RECORDS 20: data); with a stride the test is still on bytes (stride 4, NUM_RECORDS 5: IMM 0x10 data, 0x14 0; stride 1, NUM_RECORDS 17: IMM 0x10 is 0, so it is not an index test). IMM is unsigned (0xffffc reads +0xffffc). OOB_SELECT (V# word3[29:28]) 0, 1, 2 and 3 gave the same pattern (7 probes per value). **`s_load*`**: no bound (+0x1ffffc reads the dword there); IMM is sign-extended from 21 bits and added in 64 bits (sOFF 8 + IMM −4 reads +4 where zero-extension reads 4 GiB further; sOFF 0xb + IMM −1 reads +4, so the negative IMM is truncated on its own: −1 → −4). **Negative sums** (SHADER-336), measured on the integrated GPU of a Ryzen 9 9950X3D (gfx1036, RDNA2, Windows driver 32.0.21045.16010) with `tools/smem_neg_probe.py --oracle hw`, wave32 = wave64: `s_load` with IMM −4 or −0x40 and no sOFF, sOFF 4 + IMM −8, sOFF 0xc + IMM −0x20 and the x2 form with sOFF 4 + IMM −0x10 read below the pointer at the 64-bit signed sum, and sOFF 6 + IMM −1 reads +0 (4 + −4, each term truncated on its own). `s_buffer_load` adds sOFF and IMM without wrapping at 32 bits: sOFF 0xfffffffc + IMM 8 and sOFF 0xfffffff0 + IMM 0x20 give 0 (past NUM_RECORDS 0x100), and sOFF 0xfffffffc, 0x80000000 and 0x7ffffffc alone give 0 (the translator has the same rule in both offset forms since #1686). An `s_buffer_load` IMM with bit 20 set (llvm-mc rejects it; −4, −0x10, 0x100000 and 0x100004 were encoded by hand) reads data that is neither 0 nor the buffer's own words, differently in wave32 and wave64: the bound does not hold for that encoding, so no compiler output uses it and the translator does not model it. `SmemHardwareRuleTests` in `tests/semantic/test_scalar_mem_smem.py` runs these rows with sOFF in a register and with sOFF known. **Measured since** on native RDNA2 (gfx1036, the Radeon iGPU of a Ryzen 7 9800X3D, Windows driver 32.0.21042.62) through `tools/hw_oracle`, one raw kernel, wave32 = wave64 in every dword (22 cases): **`x16`** takes the per-dword bound like x8 (`s_buffer_load_dwordx16` at offset 0 with NUM_RECORDS 0x24 gives nine data dwords and seven 0; offset 0x20 with 0x40 gives eight and eight; offset 4 with 0x3d gives fourteen and two; stride 4 with NUM_RECORDS 9 gives nine and seven), and `s_load_dwordx16` reads all sixteen; **NUM_RECORDS ≥ 2^31** is compared unsigned (0x80000000 and 0xffffffff with offset 0x10, and 0x80000000 with an x4 at 0x2f0, all read data); **NUM_RECORDS × stride ≥ 2^32** does not wrap (stride 4 × 0x40000001, stride 0x100 × 0x01000001 and stride 0x40 × 0x04000004 wrap to 4, 0x100 and 0x100 in 32 bits, yet offsets 0x10, 0x200 and 0x2f0 read data), as the translator's 64-bit product assumes; **V# dword1[31:30]** = 1, 2 or 3 changes nothing (a dword at 0x10, an x4 at 0xf8 with NUM_RECORDS 0x100 giving two data and two 0, and the same with stride 8 and NUM_RECORDS 4 at 0x18). Not measured: gfx1013 (PS5) itself. **Bound edges**, measured on the same GPU and driver with `tools/hw_oracle` (wave32 = wave64, every read inside a seeded region): `s_buffer_load_dwordx16` is bounded per dword like x8 (NUM_RECORDS 0x14 gives d0..d4 and 0 for d5..d15; 0x20 with IMM or sOFF 8 gives d0..d5); NUM_RECORDS × stride is not cut to 32 bits (stride 0x1000 × 0x100000 and 0x2000 × 0x80000 = 2^32, stride 8 × 0x20000001 = 2^32 + 8: all four dwords of an x4 at 0 are data; stride 8 × 1 gives two); NUM_RECORDS 0x80000000 and 0xFFFFFFFF are unsigned (an x4 at 0 reads all four). These are the rules the translator already used; `SmemHardwareRuleTests` pins them too (a 32-bit product, a signed NUM_RECORDS or one bound for the whole load each fail a test). Not measured: `x16` (gets the x8 rule), NUM_RECORDS ≥ 2^31 and NUM_RECORDS × stride ≥ 2^32, V# dword1[31:30], and gfx1013 (PS5) itself. `s_load`/`s_buffer_load` with sOFF + IMM < 0 (a negative IMM without sOFF included; the translator uses the 64-bit signed sum, an inference), an `s_buffer_load` IMM with bit 20 set (llvm-mc rejects it) or a negative one (kept as the 32-bit value: for stride 0 that is past any NUM_RECORDS below 4 GiB), `x16` (gets the x8 rule), sOFF ≥ 2^31, NUM_RECORDS ≥ 2^31 and NUM_RECORDS × stride ≥ 2^32, V# dword1[31:30], and gfx1013 (PS5) itself. The translator checks each `s_buffer_load` dword with its own structured `if` and an `OpPhi` with 0, so an out-of-range dword issues no load (when descriptor limit and offset are compile-time constants, in-range dwords fold to straight-line loads and out-of-range dwords emit constant zero without branches); `s_load` stays straight-line. Before this the translator added base + sOFF + IMM unaligned, had no `s_buffer_load` bound and zero-extended a negative `s_load` IMM. Checked by `tests/semantic/test_scalar_mem_smem.py` (`SmemHardwareRuleTests`, the measurement's rows, values and the addresses read; `SmemSoffsetImmTranslatorTests`) and by the GPU tests `runtime/test/shaders/cs_smem_soffset_imm.asm`, `cs_smem_bounds.asm`, `cs_smem_stride_align.asm` and `cs_smem_sload_neg.asm` (never run that one with a translator that zero-extends the immediate: it reads 4 GiB past the heap), all in `check.py` and `scripts/run_gpu_tests.py`, which pass on the RX 6800 (Vulkan, driver 26.11.2). See *Buffer bounds checking* below for the MUBUF `num_records` checks. **A constant SGPR offset** (`s_mov_b32 s12, C`, folded at translate time) is added as the run-time path adds `sOFF`: zero-extended, `& ~3`, after the immediate has been normalised (unsigned for `s_buffer_load`, 21-bit signed for `s_load`), with no 32-bit wrap. Until 2026-11-22 (#1686) the fold added it before the truncation, so `s12 = -4` with `offset:20` read byte 16 instead of being out of range, and an `s_load` `sOFF` of 2^20 or more was sign-extended from 21 bits (found by @Impre-visible; hardware measured by @Pierre-Kookis on gfx1036: 0xFFFFFFFC + 20 reads 0). CPU-checked by `tests/semantic/test_smem_const_offset.py` (each case constant vs run-time offset, and against the measured rule). Where llvm-mc rejects such a tuple, `restore_vcc_tuples` decodes it from the blob, and with it the instructions its junk text swallowed, up to the next instruction llvm-mc printed (corpus count: `docs/shader_library.md`, section 5). | |
| 310 | | 2D array resource dimensions | For `image_get_resinfo` on a 2D array, X/Y are the width/height at the requested mip, Z is the view layer count and W is its mip count. The query reads the sampled array at binding 3. A native gfx1036 kernel returned (19,11,5,3), (9,5,5,3) and (4,2,5,3) for the three mips of a synthetic array. On RTX 5080 and Radeon Graphics the translated query matched those tuples and returned (4,2,3,2) at relative mip 1 with a view starting at mip 1 and covering three layers. The registered `ps_array_resinfo` draw checks all 4096 pixels against (8,8,12,1). | | 325 | | 2D array resource dimensions | For `image_get_resinfo` on a 2D array, X/Y are the width/height at the requested mip, Z is the view layer count and W is its mip count. The query reads the sampled array at binding 3. A native gfx1036 kernel returned (19,11,5,3), (9,5,5,3) and (4,2,5,3) for the three mips of a synthetic array. On RTX 5080 and Radeon Graphics the translated query matched those tuples and returned (4,2,3,2) at relative mip 1 with a view starting at mip 1 and covering three layers. The registered `ps_array_resinfo` draw checks all 4096 pixels against (8,8,12,1). | |
| 311 | | Images and samplers | `image_sample_l` on 2D arrays used to read its LOD from the array layer; it now reads the LOD after all coordinates. `image_get_lod` and `image_gather4_lz` also work on 2D arrays. With `d16` every sample result is f16, packed two to a VGPR from the low half (the packed D16 of GFX10, as LLVM returns D16 image data); `image_sample_c_lz`/`_c_lz_o` follow it too, and until 2026-11-21 their compare result was written as f32 bits, which read as 0 in the low half. Checked by `tests/test_translate.py` (`test_depth_compare_sample_result_width`) and GPU-checked with `runtime/test/shaders/ps_sample_c_lz.asm` (`vk_texture_test dref`: a D32 texture and a LESS_OR_EQUAL compare sampler) on an NVIDIA GeForce RTX 2060 SUPER (Linux, driver 620.70.06): 4096/4096 pixels exact for f32 and `d16`; with the old translator the `d16` result read 0 in the 2048 pixels whose compare passes. | | 326 | | Images and samplers | `image_sample_l` on 2D arrays used to read its LOD from the array layer; it now reads the LOD after all coordinates. `image_get_lod` and `image_gather4_lz` also work on 2D arrays. With `d16` every sample result is f16, packed two to a VGPR from the low half (the packed D16 of GFX10, as LLVM returns D16 image data); `image_sample_c_lz`/`_c_lz_o` follow it too, and until 2026-11-21 their compare result was written as f32 bits, which read as 0 in the low half. Checked by `tests/test_translate.py` (`test_depth_compare_sample_result_width`) and GPU-checked with `runtime/test/shaders/ps_sample_c_lz.asm` (`vk_texture_test dref`: a D32 texture and a LESS_OR_EQUAL compare sampler) on an NVIDIA GeForce RTX 2060 SUPER (Linux, driver 620.70.06): 4096/4096 pixels exact for f32 and `d16`; with the old translator the `d16` result read 0 in the 2048 pixels whose compare passes. | |
| 327 | | Images and samplers (T# dimension) | The hardware addresses an image with the T#'s own TYPE (`SQ_IMG_RSRC_WORD3` [31:28]); an instruction's `DIM` only says which coordinates it supplies. The bindless set therefore gives each image its index in **its** dimension's array (`runtime/src/vulkan_bindless.h`), and an instruction of another dimension must not use that index blindly. Pairs: a **2D-array or cube T# read by a 2D instruction** is its slice 0 (legal; the runtime binds a 2D view of the T#'s first layer at the image's own index in the 2D arrays, `BindlessSet::MirrorViews`, and the entry's kind names 2D; the mirror records that image as its owner, so an image of another dimension at the same slot number does not inherit it); every other mismatch - a **2D T# read by a 2D-array instruction** (it has one layer but no 2D-array view), a **3D T# read by a 2D op**, a 1D T#, a multisample T# read by a single-sample op, a 2D T# read by a 3D op - has no view of the instruction's shape and reads that dimension's fallback (index 0, a 1x1 image of zeros), never another image. So each entry carries a kind word next to its index: the translator reads it from the table (`%desc_lookup_fn` returns (index, kind) as a `uvec2` in a `descriptor_table` tagged module), tests the bit for the array its instruction reads with `OpBitFieldUExtract` and picks index 0 otherwise (`Gen.desc_sampled_index`). A store, atomic or `glc` coherent read follows the storage bits instead (`Gen.desc_storage_index`): a T# of another dimension, or one whose image has only a sampled view, goes to that dimension's storage fallback, where writes and atomics are dropped (a null descriptor with `VK_EXT_robustness2`, else a 1x1 image apart from the sampled fallbacks). Checked by `tests/semantic/test_tsharp_dimension.py` (each dimension's bit, the storage rule, the fallback operand, the plain layout and the meta marker) and by `runtime/test/vk_bindless_test.cpp`, which draws a 2D sampling shader with a 3D T# whose index equals a 2D image's: 0 bad pixels with tagged modules, 4096 per pass with plain ones (that module reads the 2D image at that index); it also binds a 2D-array T# whose mirror it reads, removes it, and puts a 3D T# at the same slot number to show the two index spaces stay separate. GPU-checked on an NVIDIA GeForce RTX 4070 Ti (driver 32.0.16.3020). `image_get_lod`, `image_load_mip` and `image_get_resinfo` name the bit but read the fallback on a mismatch. **Not measured on native RDNA2**: the pair table follows the ISA's TYPE addressing and Mesa's `ac_nir_lower_*` views; `tools/hw_oracle` was not used. | | ||
| 312 | | Images and samplers (core) | Bindless. Set 0: binding 0 = 2D sampled images, 1 = samplers, 2 = descriptor hash table (storage buffer), 3 = 2D-array images (**cube textures are bound here as 6-layer 2D-array views**, cube arrays as 6N layers: the shader already selected the face with `v_cube*`), 4 = r32ui storage images, 5 = 1D, 6 = 3D. A cube sample's s and t come in [1, 2] and its third coordinate is 8·slice + face, as the hardware takes them (Mesa `ac_nir_lower_tex_coords.c`, LLPC `ImageBuilder.cpp`); the view is read at (s − 1, t − 1), layer 6·slice + face. GPU-checked with `runtime/test/shaders/ps_cube_sample.asm` (`vk_texture_test cube`). For a native Metal path, `tools/spirv_metal_set0.py` sizes set 0's runtime arrays from `vulkan_bindless.h` and moves each binding to its own argument-buffer ID range (binding b starts at the capacities of bindings 0..b-1 added up), to convert with SPIRV-Cross `--msl-decoration-binding`: SPIRV-Cross 1.4.363.0 otherwise puts every runtime array at one ID and comments all but one out as "Overlapping binding" (SHADER-161). `cs_imgstore` converted this way writes all 3×64 texels correctly in a native Metal dispatch on an Apple A18 Pro. | | 328 | | Images and samplers (core) | Bindless. Set 0: binding 0 = 2D sampled images, 1 = samplers, 2 = descriptor hash table (storage buffer), 3 = 2D-array images (**cube textures are bound here as 6-layer 2D-array views**, cube arrays as 6N layers: the shader already selected the face with `v_cube*`), 4 = r32ui storage images, 5 = 1D, 6 = 3D. A cube sample's s and t come in [1, 2] and its third coordinate is 8·slice + face, as the hardware takes them (Mesa `ac_nir_lower_tex_coords.c`, LLPC `ImageBuilder.cpp`); the view is read at (s − 1, t − 1), layer 6·slice + face. GPU-checked with `runtime/test/shaders/ps_cube_sample.asm` (`vk_texture_test cube`). For a native Metal path, `tools/spirv_metal_set0.py` sizes set 0's runtime arrays from `vulkan_bindless.h` and moves each binding to its own argument-buffer ID range (binding b starts at the capacities of bindings 0..b-1 added up), to convert with SPIRV-Cross `--msl-decoration-binding`: SPIRV-Cross 1.4.363.0 otherwise puts every runtime array at one ID and comments all but one out as "Overlapping binding" (SHADER-161). `cs_imgstore` converted this way writes all 3×64 texels correctly in a native Metal dispatch on an Apple A18 Pro. | |
| 313 | | Typed buffer loads | The format is V# word3[18:12] (GFX10_FORMAT, from Mesa's `gfx10-rsrc.json`, saved as `tools\gfx10_formats.json`). Supported: f32 ×1–4, u32 ×1–4, i32 ×1–4 (formats 21/63/73/76), f16 ×1/2/4, unorm8 ×1/2/4, snorm8 ×1/2/4, uint8 ×1/2/4, sint8 ×1/2/4, unorm16 ×1/2/4, snorm16 ×1/2/4, uint16 ×1/2/4, sint16 ×1/2/4, 10-10-10-2 and 2-10-10-10 unorm, and, since 2026-11-22, the other GFX10 buffer codes 1–77 (every USCALED/SSCALED, 10_11_11 and 11_11_10 FLOAT, the 10_10_10_2 and 2_10_10_10 families, 8_8_8_8 and 16_16_16_16 SINT and SCALED; see *Typed buffer formats*). Others (code 0 and 78 up) give 0. The 8- and 16-bit UINT/SINT formats 5, 6, 11, 12, 18, 19, 28, 61 and 70 were missing until 2026-11-22 and read 0: UINT channels zero-extend, SINT channels sign-extend, d16 packs them as 16-bit integers, measured natively on gfx1036 (wave32 and wave64) with `tools/hw_oracle` and checked word for word by `tests/semantic/test_buffer_format_narrow_int.py`; GPU-checked by `runtime/test/shaders/cs_fmt_int_narrow.asm`, whose 136 expected words are the same program run natively on gfx1036 (exact on an RTX 5080 and on the gfx1036 iGPU through Vulkan). Full-width SINT accesses preserve integer bits. D16 SINT loads saturate to signed 16-bit and D16 stores sign-extend, covered by the synthetic `cs_fmt_sint32.asm` readback. DST_SEL swizzle is applied (0→0, 1→1.0f for float/norm or integer 1 for UINT/SINT, 4..7→X..W). Missing channels repeat the format's own (component *c* = *c* mod *n*), measured on an RX 6700 (SHADER-86). UNORM/SNORM give the correctly rounded quotient by (2ⁿ−1), as the hardware does (0 mismatches vs hardware over 395,776 conversions on that GPU). It is built with integer ops (`Gen.norm_bits`): x/(2ⁿ−1) in binary is x's bits repeated, so a 64-bit multiply by the repeat pattern, `FindUMsb` and the round bit give the f32 exactly (the tail never ends, so there are no ties). `OpFDiv` is not enough on the GPU: Vulkan allows it 2.5 ULP, and on an RX 6700 (AMD Windows 26.11.2) and an RTX 5090 it returned the reciprocal-multiply bits (8_UNORM 130/256 exact, #599). Checked against exact values in `tests/semantic/test_norm_decode.py` (every value up to 8 bits, edges and the reciprocal-multiply misses for 10, 15 and 16 bits). 8_SNORM (2), 16_SNORM (8) and 8_8_SNORM (15) were missing until 2026-11-22 and decoded to 0. Format names list the channel widths from the top bit, so `2_10_10_10` (50) is R10G10B10A2 and `10_10_10_2` (44) has a 2-bit x (Mesa `gfx10_format_table.py`, `ac_formats.c`). Until 2026-11-22 the two were swapped, in stores too. Until 2026-11-21 an element that started mid-dword re-read dword 0 for its tail (`need` was `ceil(size/4)` and only the first dword was shifted); loads now take `need = ceil((byte_shift + size) / 4)` dwords and shift the whole window so the packed stream starts at the element (FUZZ-5, leftover from #234). The 10:10:10:2 order is checked by `cs_fmt_1010102` in `tests/semantic/test_value_semantics.py` (the shader decodes the format, so a GPU run can't check it). Mid-dword spanning elements are checked by `tests/semantic/test_buffer_load_format.py` (`CrossingDwordBoundary`); repeat / UNORM / DST_SEL 1 by the SHADER-86 cases in the same file. The `_xy` and `_xyz` forms (buffer and tbuffer) are GPU-checked by `cs_fmt_xy_xyz.asm`, whose words were measured natively on a Radeon 680M (gfx1035, RDNA2): they write only their 2 or 3 VGPRs, and missing channels repeat there too (TEST-185). | | 329 | | Typed buffer loads | The format is V# word3[18:12] (GFX10_FORMAT, from Mesa's `gfx10-rsrc.json`, saved as `tools\gfx10_formats.json`). Supported: f32 ×1–4, u32 ×1–4, i32 ×1–4 (formats 21/63/73/76), f16 ×1/2/4, unorm8 ×1/2/4, snorm8 ×1/2/4, uint8 ×1/2/4, sint8 ×1/2/4, unorm16 ×1/2/4, snorm16 ×1/2/4, uint16 ×1/2/4, sint16 ×1/2/4, 10-10-10-2 and 2-10-10-10 unorm, and, since 2026-11-22, the other GFX10 buffer codes 1–77 (every USCALED/SSCALED, 10_11_11 and 11_11_10 FLOAT, the 10_10_10_2 and 2_10_10_10 families, 8_8_8_8 and 16_16_16_16 SINT and SCALED; see *Typed buffer formats*). Others (code 0 and 78 up) give 0. The 8- and 16-bit UINT/SINT formats 5, 6, 11, 12, 18, 19, 28, 61 and 70 were missing until 2026-11-22 and read 0: UINT channels zero-extend, SINT channels sign-extend, d16 packs them as 16-bit integers, measured natively on gfx1036 (wave32 and wave64) with `tools/hw_oracle` and checked word for word by `tests/semantic/test_buffer_format_narrow_int.py`; GPU-checked by `runtime/test/shaders/cs_fmt_int_narrow.asm`, whose 136 expected words are the same program run natively on gfx1036 (exact on an RTX 5080 and on the gfx1036 iGPU through Vulkan). Full-width SINT accesses preserve integer bits. D16 SINT loads saturate to signed 16-bit and D16 stores sign-extend, covered by the synthetic `cs_fmt_sint32.asm` readback. DST_SEL swizzle is applied (0→0, 1→1.0f for float/norm or integer 1 for UINT/SINT, 4..7→X..W). Missing channels repeat the format's own (component *c* = *c* mod *n*), measured on an RX 6700 (SHADER-86). UNORM/SNORM give the correctly rounded quotient by (2ⁿ−1), as the hardware does (0 mismatches vs hardware over 395,776 conversions on that GPU). It is built with integer ops (`Gen.norm_bits`): x/(2ⁿ−1) in binary is x's bits repeated, so a 64-bit multiply by the repeat pattern, `FindUMsb` and the round bit give the f32 exactly (the tail never ends, so there are no ties). `OpFDiv` is not enough on the GPU: Vulkan allows it 2.5 ULP, and on an RX 6700 (AMD Windows 26.11.2) and an RTX 5090 it returned the reciprocal-multiply bits (8_UNORM 130/256 exact, #599). Checked against exact values in `tests/semantic/test_norm_decode.py` (every value up to 8 bits, edges and the reciprocal-multiply misses for 10, 15 and 16 bits). 8_SNORM (2), 16_SNORM (8) and 8_8_SNORM (15) were missing until 2026-11-22 and decoded to 0. Format names list the channel widths from the top bit, so `2_10_10_10` (50) is R10G10B10A2 and `10_10_10_2` (44) has a 2-bit x (Mesa `gfx10_format_table.py`, `ac_formats.c`). Until 2026-11-22 the two were swapped, in stores too. Until 2026-11-21 an element that started mid-dword re-read dword 0 for its tail (`need` was `ceil(size/4)` and only the first dword was shifted); loads now take `need = ceil((byte_shift + size) / 4)` dwords and shift the whole window so the packed stream starts at the element (FUZZ-5, leftover from #234). The 10:10:10:2 order is checked by `cs_fmt_1010102` in `tests/semantic/test_value_semantics.py` (the shader decodes the format, so a GPU run can't check it). Mid-dword spanning elements are checked by `tests/semantic/test_buffer_load_format.py` (`CrossingDwordBoundary`); repeat / UNORM / DST_SEL 1 by the SHADER-86 cases in the same file. The `_xy` and `_xyz` forms (buffer and tbuffer) are GPU-checked by `cs_fmt_xy_xyz.asm`, whose words were measured natively on a Radeon 680M (gfx1035, RDNA2): they write only their 2 or 3 VGPRs, and missing channels repeat there too (TEST-185). | |
| 314 | | Descriptor hash table | `uint mask; entries[mask+1] of 10 uints: key[0..7], index, pad`. The key is a T# or a padded S#. FNV-1a over the eight key words selects the first slot by default. With `--descriptor-hash=fnv1a_fmix32` the shader applies MurmurHash3 fmix32 before masking the slot. Every translated module then records `"descriptor_hash": "fnv1a_fmix32"` in its index entry. An absent key means `fnv1a`. The runtime and shader must select the same hash. The shared SPIR-V lookup probes up to eight slots and returns index 0 on a miss. The runtime supplies a fallback at index 0 and maps live descriptor keys to bindless indices. Outside the wave64 emulation, the lookup's result goes through `OpGroupNonUniformBroadcastFirst` before it indexes the image or sampler array. The lookup key words come from SGPRs, so every invocation in a subgroup has the same index; the broadcast is an identity on all drivers and marks the value uniform for the compiler. It declares `GroupNonUniform` and `GroupNonUniformBallot`, without a shuffle capability or subgroup-lane input. The shader index records the capabilities; its `features` field lists optional Vulkan device features. Mesa ANV 26.2.7 on an Intel Alder Lake-S UHD (Xe-LP, Linux) segfaults in `vkCreate*Pipelines` on a sampler index taken straight from the probe loop when that sampler serves both a float and an integer image (`cs_sample_lz_int_d16`, `ps_ssharp`); with the broadcast both pass. Checked by the unit test `test_lookup_result_is_broadcast_before_use` in `tests/test_desc_cache.py` (standard library only: no GPU, LLVM or SPIRV-Tools). | | 330 | | Descriptor hash table | `uint mask; entries[mask+1] of 10 uints: key[0..7], index, kind`. The last word is 0 in an empty slot; otherwise bit 31 marks it occupied and bits 0..5 / 8..11 name the sampled / storage arrays the index is bound in (docs/d3d12_vulkan.md section 5.1, "Images and samplers (T# dimension)" below). A module reads it only when its index entry says `"descriptor_table": "tagged"`; `--descriptor-table plain` leaves the word unread and gives byte-identical modules to the translator before the marker (checked with a 5-instruction pixel shader: old and plain output are the same bytes). The key is a T# or a padded S#. FNV-1a over the eight key words selects the first slot by default. With `--descriptor-hash=fnv1a_fmix32` the shader applies MurmurHash3 fmix32 before masking the slot. Every translated module then records `"descriptor_hash": "fnv1a_fmix32"` in its index entry. An absent key means `fnv1a`. The runtime and shader must select the same hash. The shared SPIR-V lookup probes up to eight slots and returns index 0 on a miss. The runtime supplies a fallback at index 0 and maps live descriptor keys to bindless indices. Outside the wave64 emulation, the lookup's result goes through `OpGroupNonUniformBroadcastFirst` before it indexes the image or sampler array. The lookup key words come from SGPRs, so every invocation in a subgroup has the same index; the broadcast is an identity on all drivers and marks the value uniform for the compiler. It declares `GroupNonUniform` and `GroupNonUniformBallot`, without a shuffle capability or subgroup-lane input. The shader index records the capabilities; its `features` field lists optional Vulkan device features. Mesa ANV 26.2.7 on an Intel Alder Lake-S UHD (Xe-LP, Linux) segfaults in `vkCreate*Pipelines` on a sampler index taken straight from the probe loop when that sampler serves both a float and an integer image (`cs_sample_lz_int_d16`, `ps_ssharp`); with the broadcast both pass. Checked by the unit test `test_lookup_result_is_broadcast_before_use` in `tests/test_desc_cache.py` (standard library only: no GPU, LLVM or SPIRV-Tools). | |
| 315 | | Run-time format decode cost | A `buffer_load_format_*` whose format comes from the V# is decoded by table, without a branch: one shared function per output component (`%fmt_dec_c0`…`%fmt_dec_c3`) reads the format's kind, channel count and channel widths from the module table `%fmt_desc_tab`, and the kind picks the conversion with `OpSelect`; the exact UNORM/SNORM quotient comes from the shared `%fmt_norm_bits`, whose width's 64-bit repeat constant is read from `%fmt_norm_rep_tab`. A code outside the table gives zeros, a format with fewer channels repeats its own (component *c* = *c* mod *n*), and the element size is selected from the format alone (`%fmt_size_tab`), the per-lane byte offset added once. Until 2026-11-23 the shared function instead held every format's decode and a binary search over the codes (`OpSelectionMerge` with `DontFlatten`): 3,498 instructions and 306 branches in the module of a shader with one dynamic-format load (250,869 bytes). Now the four functions hold 565 instructions and no branch, and that module is 56,763 bytes. The decode functions take the format code and the element's four dwords as a `v4uint`, so their function type has a structure of its own: a type of `uint` × 5 repeats the type of the `x_round` helpers, and SPIR-V forbids two non-aggregate types with the same structure. Over the 1.0.2.1 corpus the 11,400 shaders that use this path all translate and pass \spirv-val\ (the previous translator included), and their modules shrink from 11,163,872,428 to 10,454,474,528 bytes (-6.35%). The 15,103 shaders without a run-time FORMAT come out byte for byte identical (checked on a 297-shader sample, every 51st of them). The values are unchanged: every one of the 128 codes gives the same words as the branch search, checked by `tests/semantic/test_format_decode_table.py` (each code against a reference decoded from the raw bits with exact quotients, plus the branch-free and shared-per-component shape). The old translation was confirmed on an RTX 4090 (621.01) against the decode-everything translation: identical output buffers for all 128 codes in four configurations (four byte alignments, out-of-range records, constant DST_SEL), xyzw and d16_xyzw. The branch-free decode costs more ALU per load than the search (every kind's conversion is computed and one is kept), so it trades run time for module size and compile time. | | 331 | | Run-time format decode cost | A `buffer_load_format_*` whose format comes from the V# is decoded by table, without a branch: one shared function per output component (`%fmt_dec_c0`…`%fmt_dec_c3`) reads the format's kind, channel count and channel widths from the module table `%fmt_desc_tab`, and the kind picks the conversion with `OpSelect`; the exact UNORM/SNORM quotient comes from the shared `%fmt_norm_bits`, whose width's 64-bit repeat constant is read from `%fmt_norm_rep_tab`. A code outside the table gives zeros, a format with fewer channels repeats its own (component *c* = *c* mod *n*), and the element size is selected from the format alone (`%fmt_size_tab`), the per-lane byte offset added once. Until 2026-11-23 the shared function instead held every format's decode and a binary search over the codes (`OpSelectionMerge` with `DontFlatten`): 3,498 instructions and 306 branches in the module of a shader with one dynamic-format load (250,869 bytes). Now the four functions hold 565 instructions and no branch, and that module is 56,763 bytes. The decode functions take the format code and the element's four dwords as a `v4uint`, so their function type has a structure of its own: a type of `uint` × 5 repeats the type of the `x_round` helpers, and SPIR-V forbids two non-aggregate types with the same structure. Over the 1.0.2.1 corpus the 11,400 shaders that use this path all translate and pass \spirv-val\ (the previous translator included), and their modules shrink from 11,163,872,428 to 10,454,474,528 bytes (-6.35%). The 15,103 shaders without a run-time FORMAT come out byte for byte identical (checked on a 297-shader sample, every 51st of them). The values are unchanged: every one of the 128 codes gives the same words as the branch search, checked by `tests/semantic/test_format_decode_table.py` (each code against a reference decoded from the raw bits with exact quotients, plus the branch-free and shared-per-component shape). The old translation was confirmed on an RTX 4090 (621.01) against the decode-everything translation: identical output buffers for all 128 codes in four configurations (four byte alignments, out-of-range records, constant DST_SEL), xyzw and d16_xyzw. The branch-free decode costs more ALU per load than the search (every kind's conversion is computed and one is kept), so it trades run time for module size and compile time. | |
| 316 | | 3D explicit-gradient texture samples | For `image_sample_d` and `image_sample_d_cl` on a 3D view, the first six address VGPRs contain dP/dx.xyz and dP/dy.xyz. XYZ and the optional minimum LOD follow. With `a16`, the six derivative VGPRs still hold f32; the following two words contain packed f16 coordinates and the optional clamp. The hand-written `tests/semantic/fixtures/volume_gradients.asm` checks the source registers of both gradients, coordinates and clamp. LLVM gfx1030 assembles all four forms and their modules validate for Vulkan 1.2. [LLVM GFX10 address sizing](https://reviews.llvm.org/D102231) and [SPIR-V Grad operands](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Image_Operands) | | 332 | | 3D explicit-gradient texture samples | For `image_sample_d` and `image_sample_d_cl` on a 3D view, the first six address VGPRs contain dP/dx.xyz and dP/dy.xyz. XYZ and the optional minimum LOD follow. With `a16`, the six derivative VGPRs still hold f32; the following two words contain packed f16 coordinates and the optional clamp. The hand-written `tests/semantic/fixtures/volume_gradients.asm` checks the source registers of both gradients, coordinates and clamp. LLVM gfx1030 assembles all four forms and their modules validate for Vulkan 1.2. [LLVM GFX10 address sizing](https://reviews.llvm.org/D102231) and [SPIR-V Grad operands](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Image_Operands) | |
| 317 | | `image_sample_c_l` | Scalar 2D depth comparison (`dmask:0x1`) takes the f32 reference, XY coordinates and explicit mip in that order. Under A16 the reference stays full-width; XY share a VGPR and LOD uses the next low half. D16 returns the comparison in the low half of the destination. Confirmed against LLVM AMDGPU's `llvm.amdgcn.image.sample[.a16].dim.ll` lowering and synthetic Vulkan 1.2 modules in `test_explicit_mip_depth_compare`. | | 333 | | `image_sample_c_l` | Scalar 2D depth comparison (`dmask:0x1`) takes the f32 reference, XY coordinates and explicit mip in that order. Under A16 the reference stays full-width; XY share a VGPR and LOD uses the next low half. D16 returns the comparison in the low half of the destination. Confirmed against LLVM AMDGPU's `llvm.amdgcn.image.sample[.a16].dim.ll` lowering and synthetic Vulkan 1.2 modules in `test_explicit_mip_depth_compare`. | |
| @@ -418,6 +434,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`. | | 434 | | 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`. | | 435 | | 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.** | | 436 | | 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.** | |
| 437 | | 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. | | 438 | | 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. | | 439 | | 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. | | 440 | | 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,10 +533,10 @@ 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`. | | 533 | | 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.** | | 534 | | `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. | | 535 | | 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`. | | 536 | | 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. | | 537 | | 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. | | 538 | | 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. | | 539 | | 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. **Offsets that do not fit 32 bits**: the hardware adds `idx * stride` (a full product) and soffset to the 48-bit base without wrapping, so `idx` 0xFFFFFFFF with a 20-byte stride lands tens of GiB past the base and has no effect, where a 32-bit offset would turn it into base − 20, inside a view that covers a whole pool (mode 3 does not check the index, mode 2 checks nothing). The translator forms `off + soffset + idx * stride` (and the swizzled offset) in 64 bits as well and treats a value above 0xFFFFFFFF as out of range in every mode; literal modes 0 and 1 without soffset skip it, their index check already bounds the product. Rule and hardware observation from five-star-recomp (ThatRecompDev, GPL-3, commit `b9b57e2`), not measured by us; CPU-checked by `tests/semantic/test_buffer_offset_wrap.py` (raw and disabled, literal and run-time V#, index −1 and off 0xFFFFFFF0 + soffset 0x20; each fails with 32-bit arithmetic). Until 2026-11-24 the offset was 32-bit. `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. | |
| 523 | | 8/16-bit MUBUF d16 loads and stores | (The plain `buffer_load_{u,s}byte`/`{u,s}short` are `Gen.buffer_load_sub`'s; `tests/semantic/test_buffer_sub_dword.py` checks them too.) The `_d16` loads (`buffer_load_{u,s}byte_d16[_hi]`, `buffer_load_short_d16[_hi]`) write one 16-bit half of `vdata` (`_hi` the high one; a byte zero- or sign-extended to 16 bits) and keep the other. `buffer_store_byte`/`short` write the low 8/16 bits of `vdata` (the `_d16_hi` forms its high half). The address is `buffer_address`'s, and the bounds check covers the access's own size, 1 or 2 bytes, as for a typed element of that size (`elem="fmt"`, format 1 or 7). Out of range, a load gives 0 (in the half it writes, for d16; **not measured** for d16) and a store writes nothing. Each byte is its own access, so a 16-bit one that crosses a dword is exact; in a swizzled buffer the next dword is `step` bytes on. A store merges each byte into its dword with atomic and/or, as buffer byte format stores do. Inactive lanes neither load nor store, and the first-read analysis counts a d16 load's `vdata` as read. Until 2026-11-22 these ten raised `Unsupported`. CPU-checked by `tests/semantic/test_buffer_sub_dword.py` (every op at byte offsets 0 to 7, the edge of `num_records`, an inactive lane, rejected forms). GPU fixture `cs_w32_buffer_sub16` (the six d16 loads with their kept half and the sign extension, the two `_d16_hi` stores taking bits 23:16 / 31:16), passes on llvmpipe (Mesa 26.0.8) and on an NVIDIA RTX 5090 (595.99.02, @tylerstraub on #1864), all eight words; GPU fixture `cs_w32_buffer_store_sub` for the plain `buffer_store_byte`/`buffer_store_short` (Box16Rehydration's blocker, @YaBulochka on #1864), including a short at byte 3 that writes its high byte into the next dword, passes on llvmpipe with LLVM 21 and 23, and on an Apple M4 (MoltenVK 1.4.2) once the second dword of a 16-bit load is indexed from the first one's pointer instead of a second pointer converted from the same address, which Apple's compiler read as 0 (@sovljanskii on #1864). | | 540 | | 8/16-bit MUBUF d16 loads and stores | (The plain `buffer_load_{u,s}byte`/`{u,s}short` are `Gen.buffer_load_sub`'s; `tests/semantic/test_buffer_sub_dword.py` checks them too.) The `_d16` loads (`buffer_load_{u,s}byte_d16[_hi]`, `buffer_load_short_d16[_hi]`) write one 16-bit half of `vdata` (`_hi` the high one; a byte zero- or sign-extended to 16 bits) and keep the other. `buffer_store_byte`/`short` write the low 8/16 bits of `vdata` (the `_d16_hi` forms its high half). The address is `buffer_address`'s, and the bounds check covers the access's own size, 1 or 2 bytes, as for a typed element of that size (`elem="fmt"`, format 1 or 7). Out of range, a load gives 0 (in the half it writes, for d16; **not measured** for d16) and a store writes nothing. Each byte is its own access, so a 16-bit one that crosses a dword is exact; in a swizzled buffer the next dword is `step` bytes on. A store merges each byte into its dword with atomic and/or, as buffer byte format stores do. Inactive lanes neither load nor store, and the first-read analysis counts a d16 load's `vdata` as read. Until 2026-11-22 these ten raised `Unsupported`. CPU-checked by `tests/semantic/test_buffer_sub_dword.py` (every op at byte offsets 0 to 7, the edge of `num_records`, an inactive lane, rejected forms). GPU fixture `cs_w32_buffer_sub16` (the six d16 loads with their kept half and the sign extension, the two `_d16_hi` stores taking bits 23:16 / 31:16), passes on llvmpipe (Mesa 26.0.8) and on an NVIDIA RTX 5090 (595.99.02, @tylerstraub on #1864), all eight words; GPU fixture `cs_w32_buffer_store_sub` for the plain `buffer_store_byte`/`buffer_store_short` (Box16Rehydration's blocker, @YaBulochka on #1864), including a short at byte 3 that writes its high byte into the next dword, passes on llvmpipe with LLVM 21 and 23, and on an Apple M4 (MoltenVK 1.4.2) once the second dword of a 16-bit load is indexed from the first one's pointer instead of a second pointer converted from the same address, which Apple's compiler read as 0 (@sovljanskii on #1864). | |
| 524 | | Swizzled buffer addressing (V# SWIZZLE_ENABLE, ADD_TID_ENABLE) | MUBUF/MTBUF `buffer_load*`, `buffer_store*`, `buffer_atomic*`, `buffer_load_format_*`/`buffer_store_format_*` and `tbuffer_load/store_format_*` follow the rules measured natively on RDNA2 (`AMD Radeon(TM) Graphics`, gfx1036, Windows driver `32.0.21042.62`, wave32 and wave64; `tools/buffer_swizzle_probe.py`, SHADER-343). MUBUF/MTBUF `buffer_load*`, `buffer_store*`, `buffer_atomic*`, `buffer_load_format_*`/`buffer_store_format_*` and `tbuffer_load_format_*` follow the RDNA2 ISA ("RDNA 2" Instruction Set Architecture, 8.1.5 Buffer Addressing, "Swizzled Buffer Addressing" and tables 33, 35 and 37). Fields, Mesa 24.0.6 `src/amd/registers/gfx10-rsrc.json` (`SQ_BUF_RSRC_WORD1`, `SQ_BUF_RSRC_WORD3` and its `_gfx103` twin, the same bits): `SWIZZLE_ENABLE` word1 bit 31, `STRIDE` word1 `[29:16]`, `INDEX_STRIDE` word3 `[22:21]` (`IS = 8 << n`, i.e., 8, 16, 32 or 64), `ADD_TID_ENABLE` word3 bit 23; element size is fixed at 4 bytes (`word3[20:19]` and `word1[30]` do not alter addressing or stepping). **Effective index:** `index = idxen ? vindex : 0)`, where `lane` is the wave lane (`thread_id[5:0]` within the wave, wrapping at 32 in wave32 and 64 in wave64; `Gen.wave_lane`); **`idxen = 1` completely ignores `ADD_TID_ENABLE`** (linear or swizzled, address and bounds, loads/stores/typed/atomics). **Activation:** `SWIZZLE_ENABLE` activates (`swz_active`) only when `idxen = 1` or `ADD_TID_ENABLE = 1`; with neither, addressing is linear (`base + soffset + off`) and `OOB_SELECT 3` stays RAW even when `stride ≠ 0`. **Address formula (when `swz_active`):** `off = uint32((offen ? vaddr : 0) + inst_offset)` (32-bit wrap), `buffer_offset = (index / IS · stride + (off & ~3)) · IS + (index % IS) · 4 + (off & 3)`, `address = base + soffset + buffer_offset` (confirmed byte-exact for IS 8/16/32/64, non-4-multiple strides, stride 0, and unaligned offsets). **Two swizzle sub-modes:** (1) **Scratch swizzle** (`SWIZZLE_ENABLE = 1`, `idxen = 0`, `ADD_TID_ENABLE = 1`): raw multi-dword `buffer_load/store_dwordx2..x4` step by **`+4 · IS`** bytes per dword (and unaligned 4-byte raw accesses crossing a dword boundary split across `+4 · IS` on hardware), while **typed formats > 4 bytes** (8/12/16-byte MUBUF and MTBUF loads/stores, regardless of component count) and **8-byte `buffer_atomic_*_x2`** are **suppressed** (loads return 0, stores/atomics are no-ops, even in `OOB_SELECT 2`); typed formats ≤ 4 bytes work normally. (2) **Indexed swizzle** (`SWIZZLE_ENABLE = 1`, `idxen = 1`, regardless of `ADD_TID_ENABLE`): raw `x2..x4`, typed formats (8/12/16 bytes), and `buffer_atomic_*_x2` step **linearly by `+4` bytes** from the swizzled base address, even across `IS` boundaries, and typed formats > 4 bytes execute normally. **Bounds (`OOB_SELECT`):** modes 0, 1 and 2 follow the Buffer bounds checking row with `idx = index`; **`OOB_SELECT 3` with `swz_active` and `stride ≠ 0`** checks **`uint64(index) + uint64(soffset) >= num_records` or `off + payload > stride`** (per-dword for raw `x1..x4`, whole element for typed), while inactive swizzle or `stride = 0` keeps the RAW check `uint64(off) + uint64(soffset) + payload > num_records` (no 32-bit wrap on `off + soffset`, whereas `vaddr + inst_offset` wraps at 32 bits before bounds checking). A literal word1 / word3 (`s_mov_b32` earlier in the block) folds each bit; a run-time V# selects dynamically with `L = swz_u · (3 + INDEX_STRIDE)` (IS = 1 gives the linear address). Until 2026-11-22 the translator added `vindex + lane` when `idxen = 1` and `ADD_TID_ENABLE = 1`, swizzled even when both were 0, stepped all swizzled multi-dword/typed accesses by `4 · IS`, allowed > 4-byte typed/atomic_x2 accesses in scratch-swizzle mode, omitted `soffset` from swizzled mode 3's index check, and wrapped `off + soffset` at 32 bits in RAW mode 3. **How confirmed:** native RDNA2 measurement on `AMD Radeon(TM) Graphics` (gfx1036, Windows driver `32.0.21042.62`, wave32 & wave64) via `tools/buffer_swizzle_probe.py --oracle both` (22/22 cases across 8 groups match bit-exactly, 0 unexpected mismatches, 0 unexpected wave32/64 diffs, 64-thread `ADD_TID_ENABLE` wave-lane wrap verified at both wave sizes); CPU semantic tests `tests/semantic/test_buffer_swizzle.py` (literal and run-time V#, both sub-modes, mode 3 `soffset`, 32-bit wrap, typed/`atomic_x2` suppression, and `cs_buf_swizzle.asm`); `tests/test_buffer_swizzle_probe.py`. **Remaining approximations / unmeasured:** unaligned raw accesses splitting across `+4 · IS` in scratch-swizzle mode (the translator uses `Aligned 4` PSB loads/stores), general typed-format / `buffer_atomic_*_x2` natural alignment suppression (`16_UINT` at odd offsets, `32_*` at non-4B offsets, `atomic_*_x2` at non-8B addresses, observed on gfx1036 in both linear and swizzled modes), and GFX11's two-bit `SWIZZLE_ENABLE` (`word1[31:30]`). SWIZZLE_ENABLE word1 bit 31, STRIDE word1 [29:16], INDEX_STRIDE word3 [22:21] (IS = 8, 16, 32 or 64 indices), ADD_TID_ENABLE word3 bit 23; there is no ELEMENT_SIZE field, the element is fixed at 4 bytes (ISA 8.1.5; LLVM `SIInstrInfo::getScratchRsrcWords23` sets it only up to GFX8). `index` = (idxen ? vindex : 0) + (ADD_TID_ENABLE ? lane : 0), where the lane is thread_id[5:0] within the wave (`Gen.wave_lane`), swizzled or not: table 33 adds the thread id with no swizzle condition and table 36's ring column is linear with add_tid. `offset` = (offen ? vaddr : 0) + inst_offset, without soffset. Swizzled: buffer_offset = (index / IS · stride + offset / 4 · 4) · IS + index % IS · 4 + offset % 4, address = base + soffset + buffer_offset, so dword k of a multi-dword access (and of a typed element over 4 bytes) is 4 · IS bytes after dword k − 1, not 4. Bounds as in Buffer bounds checking, with `idx` = `index` (the lane included), except that OOB_SELECT 3 with SWIZZLE_ENABLE and stride ≠ 0 checks `index >= num_records` or `off + 4k + 4 > stride` (table 35), like mode 0; stride 0 keeps the raw check. A literal word1 / word3 (`s_mov_b32` earlier in the block) folds each bit. A run-time word1 makes IS = 2^(SWIZZLE_ENABLE · (3 + INDEX_STRIDE)): IS = 1 is the linear address, so one formula serves both and nothing is selected but the mode 3 check; a run-time word3 multiplies the lane by ADD_TID_ENABLE. Cost, measured on the 116 shaders of `runtime/test/shaders` that both versions translate (all `spirv-val` clean before and after): the 56 with a MUBUF access through a run-time V# grow by 15.1 % in SPIR-V lines (+10.4 % over all 116), 30 to 45 instructions per access (address, lane, 4 per extra dword, a select per dword of the bounds check); a literal linear V# gives the same SPIR-V as before. Outside compute and mesh shaders the lane is `SubgroupLocalInvocationId`, so a VS, PS or GS with a run-time V# now declares `GroupNonUniform`. The offset arithmetic is 32-bit, like the linear address. Until 2026-11-22 a literal V# with either bit was `Unsupported` and a run-time one was translated unswizzled. **How confirmed**: Mesa/LLVM and AMD's ISA reference (fields and formula), not measured on hardware; `tests/semantic/test_buffer_swizzle.py` (hand-worked addresses for IS 8/16/64, index msb/lsb, soffset after the swizzle, the mode 3 rule with and without a stride, per-dword x2/x3/x4 loads and stores, a 16-byte typed element, ADD_TID on lane 5 linear and swizzled, each with a literal and a run-time V#); GPU test `runtime/test/shaders/cs_buf_swizzle.asm` (check.py, `scripts/run_gpu_tests.py`), which checks the translation, not RDNA2. **Unmeasured**: the swizzled layout on RDNA2 hardware, offsets that are not dword aligned (the ISA requires alignment for swizzled accesses; the translation adds offset % 4), wrap of the 32-bit offset, and GFX11's two-bit SWIZZLE_ENABLE (word1 [31:30]). **Unmeasured** (the layout itself is measured: `docs/shader_validation.md`, SHADER-343, gfx1036, 22 of 22 cases bit-exact): offsets that are not dword aligned (the ISA requires alignment for swizzled accesses; the translation adds offset % 4), wrap of the 32-bit offset, and GFX11's two-bit SWIZZLE_ENABLE (word1 [31:30]). In the corpus `SCRATCH_EN` is 0 in every CS, so a swizzled V# can only come from a descriptor the game writes itself. | | 541 | | Swizzled buffer addressing (V# SWIZZLE_ENABLE, ADD_TID_ENABLE) | MUBUF/MTBUF `buffer_load*`, `buffer_store*`, `buffer_atomic*`, `buffer_load_format_*`/`buffer_store_format_*` and `tbuffer_load/store_format_*` follow the rules measured natively on RDNA2 (`AMD Radeon(TM) Graphics`, gfx1036, Windows driver `32.0.21042.62`, wave32 and wave64; `tools/buffer_swizzle_probe.py`, SHADER-343). MUBUF/MTBUF `buffer_load*`, `buffer_store*`, `buffer_atomic*`, `buffer_load_format_*`/`buffer_store_format_*` and `tbuffer_load_format_*` follow the RDNA2 ISA ("RDNA 2" Instruction Set Architecture, 8.1.5 Buffer Addressing, "Swizzled Buffer Addressing" and tables 33, 35 and 37). Fields, Mesa 24.0.6 `src/amd/registers/gfx10-rsrc.json` (`SQ_BUF_RSRC_WORD1`, `SQ_BUF_RSRC_WORD3` and its `_gfx103` twin, the same bits): `SWIZZLE_ENABLE` word1 bit 31, `STRIDE` word1 `[29:16]`, `INDEX_STRIDE` word3 `[22:21]` (`IS = 8 << n`, i.e., 8, 16, 32 or 64), `ADD_TID_ENABLE` word3 bit 23; element size is fixed at 4 bytes (`word3[20:19]` and `word1[30]` do not alter addressing or stepping). **Effective index:** `index = idxen ? vindex : 0)`, where `lane` is the wave lane (`thread_id[5:0]` within the wave, wrapping at 32 in wave32 and 64 in wave64; `Gen.wave_lane`); **`idxen = 1` completely ignores `ADD_TID_ENABLE`** (linear or swizzled, address and bounds, loads/stores/typed/atomics). **Activation:** `SWIZZLE_ENABLE` activates (`swz_active`) only when `idxen = 1` or `ADD_TID_ENABLE = 1`; with neither, addressing is linear (`base + soffset + off`) and `OOB_SELECT 3` stays RAW even when `stride ≠ 0`. **Address formula (when `swz_active`):** `off = uint32((offen ? vaddr : 0) + inst_offset)` (32-bit wrap), `buffer_offset = (index / IS · stride + (off & ~3)) · IS + (index % IS) · 4 + (off & 3)`, `address = base + soffset + buffer_offset` (confirmed byte-exact for IS 8/16/32/64, non-4-multiple strides, stride 0, and unaligned offsets). **Two swizzle sub-modes:** (1) **Scratch swizzle** (`SWIZZLE_ENABLE = 1`, `idxen = 0`, `ADD_TID_ENABLE = 1`): raw multi-dword `buffer_load/store_dwordx2..x4` step by **`+4 · IS`** bytes per dword (and unaligned 4-byte raw accesses crossing a dword boundary split across `+4 · IS` on hardware), while **typed formats > 4 bytes** (8/12/16-byte MUBUF and MTBUF loads/stores, regardless of component count) and **8-byte `buffer_atomic_*_x2`** are **suppressed** (loads return 0, stores/atomics are no-ops, even in `OOB_SELECT 2`); typed formats ≤ 4 bytes work normally. (2) **Indexed swizzle** (`SWIZZLE_ENABLE = 1`, `idxen = 1`, regardless of `ADD_TID_ENABLE`): raw `x2..x4`, typed formats (8/12/16 bytes), and `buffer_atomic_*_x2` step **linearly by `+4` bytes** from the swizzled base address, even across `IS` boundaries, and typed formats > 4 bytes execute normally. **Bounds (`OOB_SELECT`):** modes 0, 1 and 2 follow the Buffer bounds checking row with `idx = index`; **`OOB_SELECT 3` with `swz_active` and `stride ≠ 0`** checks **`uint64(index) + uint64(soffset) >= num_records` or `off + payload > stride`** (per-dword for raw `x1..x4`, whole element for typed), while inactive swizzle or `stride = 0` keeps the RAW check `uint64(off) + uint64(soffset) + payload > num_records` (no 32-bit wrap on `off + soffset`, whereas `vaddr + inst_offset` wraps at 32 bits before bounds checking). A literal word1 / word3 (`s_mov_b32` earlier in the block) folds each bit; a run-time V# selects dynamically with `L = swz_u · (3 + INDEX_STRIDE)` (IS = 1 gives the linear address). Until 2026-11-22 the translator added `vindex + lane` when `idxen = 1` and `ADD_TID_ENABLE = 1`, swizzled even when both were 0, stepped all swizzled multi-dword/typed accesses by `4 · IS`, allowed > 4-byte typed/atomic_x2 accesses in scratch-swizzle mode, omitted `soffset` from swizzled mode 3's index check, and wrapped `off + soffset` at 32 bits in RAW mode 3. **How confirmed:** native RDNA2 measurement on `AMD Radeon(TM) Graphics` (gfx1036, Windows driver `32.0.21042.62`, wave32 & wave64) via `tools/buffer_swizzle_probe.py --oracle both` (22/22 cases across 8 groups match bit-exactly, 0 unexpected mismatches, 0 unexpected wave32/64 diffs, 64-thread `ADD_TID_ENABLE` wave-lane wrap verified at both wave sizes); CPU semantic tests `tests/semantic/test_buffer_swizzle.py` (literal and run-time V#, both sub-modes, mode 3 `soffset`, 32-bit wrap, typed/`atomic_x2` suppression, and `cs_buf_swizzle.asm`); `tests/test_buffer_swizzle_probe.py`. **Remaining approximations / unmeasured:** unaligned raw accesses splitting across `+4 · IS` in scratch-swizzle mode (the translator uses `Aligned 4` PSB loads/stores), general typed-format / `buffer_atomic_*_x2` natural alignment suppression (`16_UINT` at odd offsets, `32_*` at non-4B offsets, `atomic_*_x2` at non-8B addresses, observed on gfx1036 in both linear and swizzled modes), and GFX11's two-bit `SWIZZLE_ENABLE` (`word1[31:30]`). SWIZZLE_ENABLE word1 bit 31, STRIDE word1 [29:16], INDEX_STRIDE word3 [22:21] (IS = 8, 16, 32 or 64 indices), ADD_TID_ENABLE word3 bit 23; there is no ELEMENT_SIZE field, the element is fixed at 4 bytes (ISA 8.1.5; LLVM `SIInstrInfo::getScratchRsrcWords23` sets it only up to GFX8). `index` = (idxen ? vindex : 0) + (ADD_TID_ENABLE ? lane : 0), where the lane is thread_id[5:0] within the wave (`Gen.wave_lane`), swizzled or not: table 33 adds the thread id with no swizzle condition and table 36's ring column is linear with add_tid. `offset` = (offen ? vaddr : 0) + inst_offset, without soffset. Swizzled: buffer_offset = (index / IS · stride + offset / 4 · 4) · IS + index % IS · 4 + offset % 4, address = base + soffset + buffer_offset, so dword k of a multi-dword access (and of a typed element over 4 bytes) is 4 · IS bytes after dword k − 1, not 4. Bounds as in Buffer bounds checking, with `idx` = `index` (the lane included), except that OOB_SELECT 3 with SWIZZLE_ENABLE and stride ≠ 0 checks `index >= num_records` or `off + 4k + 4 > stride` (table 35), like mode 0; stride 0 keeps the raw check. A literal word1 / word3 (`s_mov_b32` earlier in the block) folds each bit. A run-time word1 makes IS = 2^(SWIZZLE_ENABLE · (3 + INDEX_STRIDE)): IS = 1 is the linear address, so one formula serves both and nothing is selected but the mode 3 check; a run-time word3 multiplies the lane by ADD_TID_ENABLE. Cost, measured on the 116 shaders of `runtime/test/shaders` that both versions translate (all `spirv-val` clean before and after): the 56 with a MUBUF access through a run-time V# grow by 15.1 % in SPIR-V lines (+10.4 % over all 116), 30 to 45 instructions per access (address, lane, 4 per extra dword, a select per dword of the bounds check); a literal linear V# gives the same SPIR-V as before. Outside compute and mesh shaders the lane is `SubgroupLocalInvocationId`, so a VS, PS or GS with a run-time V# now declares `GroupNonUniform`. The offset arithmetic is 32-bit, like the linear address. Until 2026-11-22 a literal V# with either bit was `Unsupported` and a run-time one was translated unswizzled. **How confirmed**: Mesa/LLVM and AMD's ISA reference (fields and formula), not measured on hardware; `tests/semantic/test_buffer_swizzle.py` (hand-worked addresses for IS 8/16/64, index msb/lsb, soffset after the swizzle, the mode 3 rule with and without a stride, per-dword x2/x3/x4 loads and stores, a 16-byte typed element, ADD_TID on lane 5 linear and swizzled, each with a literal and a run-time V#); GPU test `runtime/test/shaders/cs_buf_swizzle.asm` (check.py, `scripts/run_gpu_tests.py`), which checks the translation, not RDNA2. **Unmeasured**: the swizzled layout on RDNA2 hardware, offsets that are not dword aligned (the ISA requires alignment for swizzled accesses; the translation adds offset % 4), wrap of the 32-bit offset, and GFX11's two-bit SWIZZLE_ENABLE (word1 [31:30]). **Unmeasured** (the layout itself is measured: `docs/shader_validation.md`, SHADER-343, gfx1036, 22 of 22 cases bit-exact): offsets that are not dword aligned (the ISA requires alignment for swizzled accesses; the translation adds offset % 4), wrap of the 32-bit offset, and GFX11's two-bit SWIZZLE_ENABLE (word1 [31:30]). In the corpus `SCRATCH_EN` is 0 in every CS, so a swizzled V# can only come from a descriptor the game writes itself. | |
| 525 | | `v_permlane16_b32` / `v_permlanex16_b32` with the source lane off in EXEC (SHADER-74) | The VOP3 modifier `op_sel:[FI, BOUND_CTRL]` decides what a lane gets when the lane it reads is off in EXEC. **FI=1** (`op_sel` bit 0, encoding 0x0800): the source lane's value, as before. **FI=0** (the default): the destination lane is not written and keeps its old value when BOUND_CTRL=0, and gets 0 when BOUND_CTRL=1 (`op_sel` bit 1, 0x1000). A source lane that is on gives its value whatever FI / BOUND_CTRL are, and a lane that is itself off is never written (normal EXEC rule). The translator shuffles the active bit with the same selector as the value (also in `--wave64-emulate`, where it is a second exchange). On a native subgroup the two shuffles are combined with bitwise masks, not a scalar select: absent source lanes are redirected to the calling lane first (as `ds_lane_read`), the value and the activity bit are fetched through the redirected index, and `ok` masks the shuffled value over the old one (over zero with BOUND_CTRL=1) and the destination write is masked too, so the ballot and both shuffles run before lane predication — MoltenVK 1.4.2 and MoltenVK main at SPIRV-Cross aa217aeb lowered the scalar select to a short-circuiting Metal ternary and the FI=0 lanes read the source lane's value instead, which `cs_w32_permlane_fi` caught on an Apple M1 Max (#5895); `v_permlanex16_b32` pairs the rows 0↔1 and 2↔3 of a wave64 as before. Until SHADER-74 every case returned the source value (right only for FI=1). Source of the bit mapping: LLVM `llvm.amdgcn.permlane16/permlanex16 <old> <src0> <src1> <src2> <fi> <bound_control>` (IntrinsicsAMDGPU.td) is selected in `VOP3Instructions.td` (`PermlanePat`) with `fi` as the `src0` op_sel bit and `bound_control` as the `src1` one, and the CodeGen tests `llvm.amdgcn.permlane.ll` print `op_sel:[1,0]` for FI and `op_sel:[0,1]` for BOUND_CTRL; `llvm-mc -mcpu=gfx1013` encodes `op_sel:[1,0]` as 0x0800 and `op_sel:[0,1]` as 0x1000 in the second byte pair of the first word (0xD777 / 0xD778). Behaviour: hardware measurement on RDNA2 (Ryzen 7950X3D iGPU, raw kernel, wave64 and wave32 consistent; the same on RDNA3.5) by aslan2142 in [#374](https://github.com/ItsNotRexed/Leonida/issues/374#issuecomment-7071597516). Pinned by `runtime/test/shaders/cs_w32_permlane_fi.asm` (EXEC 0x55555555, every active lane's source is off; out[0..7] = 1000 0 4 1 1000 0 52 49) in `check.py` and `scripts/run_gpu_tests.py`, and on the CPU by `tests/semantic/test_permlane_fi.py`. | | 542 | | `v_permlane16_b32` / `v_permlanex16_b32` with the source lane off in EXEC (SHADER-74) | The VOP3 modifier `op_sel:[FI, BOUND_CTRL]` decides what a lane gets when the lane it reads is off in EXEC. **FI=1** (`op_sel` bit 0, encoding 0x0800): the source lane's value, as before. **FI=0** (the default): the destination lane is not written and keeps its old value when BOUND_CTRL=0, and gets 0 when BOUND_CTRL=1 (`op_sel` bit 1, 0x1000). A source lane that is on gives its value whatever FI / BOUND_CTRL are, and a lane that is itself off is never written (normal EXEC rule). The translator shuffles the active bit with the same selector as the value (also in `--wave64-emulate`, where it is a second exchange). On a native subgroup the two shuffles are combined with bitwise masks, not a scalar select: absent source lanes are redirected to the calling lane first (as `ds_lane_read`), the value and the activity bit are fetched through the redirected index, and `ok` masks the shuffled value over the old one (over zero with BOUND_CTRL=1) and the destination write is masked too, so the ballot and both shuffles run before lane predication — MoltenVK 1.4.2 and MoltenVK main at SPIRV-Cross aa217aeb lowered the scalar select to a short-circuiting Metal ternary and the FI=0 lanes read the source lane's value instead, which `cs_w32_permlane_fi` caught on an Apple M1 Max (#5895); `v_permlanex16_b32` pairs the rows 0↔1 and 2↔3 of a wave64 as before. Until SHADER-74 every case returned the source value (right only for FI=1). Source of the bit mapping: LLVM `llvm.amdgcn.permlane16/permlanex16 <old> <src0> <src1> <src2> <fi> <bound_control>` (IntrinsicsAMDGPU.td) is selected in `VOP3Instructions.td` (`PermlanePat`) with `fi` as the `src0` op_sel bit and `bound_control` as the `src1` one, and the CodeGen tests `llvm.amdgcn.permlane.ll` print `op_sel:[1,0]` for FI and `op_sel:[0,1]` for BOUND_CTRL; `llvm-mc -mcpu=gfx1013` encodes `op_sel:[1,0]` as 0x0800 and `op_sel:[0,1]` as 0x1000 in the second byte pair of the first word (0xD777 / 0xD778). Behaviour: hardware measurement on RDNA2 (Ryzen 7950X3D iGPU, raw kernel, wave64 and wave32 consistent; the same on RDNA3.5) by aslan2142 in [#374](https://github.com/ItsNotRexed/Leonida/issues/374#issuecomment-7071597516). Pinned by `runtime/test/shaders/cs_w32_permlane_fi.asm` (EXEC 0x55555555, every active lane's source is off; out[0..7] = 1000 0 4 1 1000 0 52 49) in `check.py` and `scripts/run_gpu_tests.py`, and on the CPU by `tests/semantic/test_permlane_fi.py`. | |
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 |
| 72 | harness that exits 0 without writing, an all-opaque image and a swapped-U/V image all exit 1. The test has | 72 | harness that exits 0 without writing, an all-opaque image and a swapped-U/V image all exit 1. The test has |
| 73 | twenty-five cases: the two package-gated draw/manifest checks, the `--check` command, four oracle fixtures, the | 73 | 48 cases; `python -I tests/test_first_light.py -v` prints each one. |
| 74 | mesh depth fit, a preview with non-finite readback channels, the stage files of two shaders with the same name, two | ||
| 75 | OBJ 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 |
| 78 | the OBJ to the harness's mesh file (`u32 vertex_count, u32 index_count`, `(x,y,z,u,v) f32` vertices, `u32` | 76 | the 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 |
| 141 | magenta unbound-texture fallback and wrong-colour probes). Verified on Windows 11 with an NVIDIA GeForce RTX 3060 | 139 | magenta 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 |
| 145 | built `vk_harness`; the 4 `OracleTests` and the other 11 `TexturedOracleTests` run without a package). With | 143 | built `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 |
| 149 | python -I tools/first_light.py --game "<package>" --work ~/leonida-work \ | 147 | python -I tools/first_light.py --game "<package>" --work ~/leonida-work \ |
diff --git a/docs/gameinput.md b/docs/gameinput.md index 06c2013a5..1301a4a49 100644 --- a/docs/gameinput.md +++ b/docs/gameinput.md | |||
| @@ -113,7 +113,8 @@ The title reads gamepads only, so keyboard input has to arrive as a gamepad. Wit | |||
| 113 | shim attaches one SDL virtual gamepad named `Keyboard pad (Leonida)` and presses its buttons from the keyboard on | 113 | shim attaches one SDL virtual gamepad named `Keyboard pad (Leonida)` and presses its buttons from the keyboard on |
| 114 | every poll. It then goes through the same path as a real pad: a device object, the next free player slot, readings, | 114 | every poll. It then goes through the same path as a real pad: a device object, the next free player slot, readings, |
| 115 | reading and device callbacks, and UI navigation derived from its buttons. It reports no rumble motors. It is off by | 115 | reading and device callbacks, and UI navigation derived from its buttons. It reports no rumble motors. It is off by |
| 116 | default. | 116 | default. If SDL fails to attach or open the keyboard pad, the shim retries after one second while the pad is |
| 117 | enabled. Only the first failure in a continuous series is logged; turning the pad off and back on retries immediately. | ||
| 117 | 118 | ||
| 118 | | key | button | | 119 | | key | button | |
| 119 | |---|---| | 120 | |---|---| |
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 | ||
| 89 | python -I tools/gbuffer_census.py <work>\shaders\dxbc [--disasm <dir>] [--payload-coverage] | ||
| 90 | ``` | ||
| 91 | |||
| 92 | Reads `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 | ||
| 94 | names, case-sensitive `Deferred` stems, and `PS_DeferredTextured` stems) with declared target counts, signature | ||
| 95 | layouts, and observed `exp mrtN` export modes (`compr` vs `uncompressed`). With `--payload-coverage`, it also counts | ||
| 96 | distinct whole FSSM payloads per cohort and histograms how many indexed entries share each payload. Standard library | ||
| 97 | only; 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). | |||
| 37 | AI-assisted (Hermes Agent): built `main` at `05961f0`, ran `build.py`, `check.py` and | 42 | AI-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 | ``` |
| 43 | GPU: AMD Radeon RX 9070 XT (RDNA4 / GFX1201, Navi 48, PCI 1002:7550), subgroup 32..64 | 48 | GPU: AMD Radeon RX 9070 XT (RDNA4 / GFX1201, Navi 48, PCI 1002:7550), subgroup 32..64 |
| 44 | Driver: AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359 | 49 | Driver: AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359 |
| 45 | Subgroup: 32..64 (minSubgroupSize 32, maxSubgroupSize 64; default 64, subgroupSizeControl) | 50 | Subgroup: 32..64 (minSubgroupSize 32, maxSubgroupSize 64; default 64, subgroupSizeControl) |
| 46 | OS: Windows 11, 10.0.26300.9550 | 51 | OS: Windows 11, 10.0.26200.9974 |
| 47 | Commit: 5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (main, 2026-11-23) | 52 | Commit: 58be9cdf8df9a31bc7f6c068991f1aed381f7f4d (main, 2026-11-24) |
| 48 | Tools: llvm-mc from ROCm/AOMP 18.0-12 (LLVM 19.0.0git), SPIRV-Tools v2026.4, | 53 | Tools: 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 |
| 50 | run_gpu_tests.py: 247 shaders: 247 translated, 247 pass spirv-val | 55 | run_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 |
| 53 | Failed: ms_wave_info_s3: at (0,0) got (-1,-1,-1,-1), want (0.0078,0.0078,0.5,1.0). | 58 | build.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 | 59 | check.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 | 60 | Failed: 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. | ||
| 58 | Skipped: 16 skips are the documented "run by d3d12_*_test / w64_graphics.py" cases. | 61 | Skipped: 16 skips are the documented "run by d3d12_*_test / w64_graphics.py" cases. |
| 59 | ``` | 62 | ``` |
| 60 | 63 | ||
| 61 | Setup: `cmake -S runtime -B runtime/build` (default Visual Studio 17 2022 generator) and | 64 | Setup: `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 |
| 63 | the 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 |
| 64 | beyond the Vulkan SDK's. Every other pixel and compute case was exact. | 67 | ran on the AMD LLPC driver with the project's own `vk_harness`, `vk_compute_test` and `vk_store_test` binaries; no |
| 65 | 68 | implicit layer beyond the Vulkan SDK's. | |
| 66 | The 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 | 70 | This replaces the 2026-11-23 record (`5d74c27`), which had `ms_wave_info_s3` failing on every native run and |
| 68 | the 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 |
| 69 | reproduces with an AMD proprietary driver, so the symptom is not tied to RADV or to Mesa's shader | 72 | both full runs and in 3 of 3 isolated `--filter` reruns each way, and the D3D12-side columns are measured for the |
| 70 | cache. | 73 | first 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 | 75 | AI-assisted: built `main` at `58be9cd` with MSVC, ran the three scripts native and under `LEONIDA_W64_EMULATE=1`, |
| 73 | come from `run_gpu_tests.py`, which builds and translates the same fixtures. | 76 | and reran `ms_wave_info_s3` in isolation three times each way. |
| 74 | |||
| 75 | AI-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 | ||
| 98 | La 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. | 98 | La 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 |
| 100 | avvio 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 | ||
| 97 | Etap `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 | 97 | Etap `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 |
| 98 | tworzy każdy przetłumaczony shader na sterowniku Twojej karty graficznej i zapisuje cache potoków, żeby pierwsze | 98 | tworzy każdy przetłumaczony shader na sterowniku Twojej karty graficznej i zapisuje cache potoków |
| 99 | uruchomienie nie musiało ich kompilować. Tłumaczenie shaderów trwa najdłużej i domyślnie używa połowy wątków | 99 | w `pipeline_cache.bin` (w `--out`). Tłumaczenie shaderów trwa najdłużej i domyślnie używa połowy wątków |
| 100 | procesora (można to zmienić przez `--jobs`). | 100 | procesora (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 | |||
| 112 | python -I make_game.py --wave64-emulate off # auto (по умолчанию), on или off | 112 | python -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 |
| 121 | the GPU. | 121 | the GPU. |
| 122 | |||
| 123 | ### Without root (micromamba) | ||
| 124 | |||
| 125 | If you cannot install distribution packages (no `sudo`), you can install `llvm-tools` and `spirv-tools` into a | ||
| 126 | user-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 | ||
| 128 | CMake fetch its pinned, hash-checked Vulkan headers if the system does not provide them: | ||
| 129 | |||
| 130 | ```bash | ||
| 131 | LEO=$HOME/leonida-tools | ||
| 132 | mkdir -p "$LEO/bin" "$LEO/mamba" | ||
| 133 | # Note: `latest` is unpinned and downloaded without signature verification; inspect or pin per the micromamba guide. | ||
| 134 | curl -fsSLo "$LEO/micromamba.tar.bz2" https://micro.mamba.pm/api/micromamba/linux-64/latest | ||
| 135 | tar -xjf "$LEO/micromamba.tar.bz2" -C "$LEO/bin" --strip-components=1 bin/micromamba | ||
| 136 | |||
| 137 | export MAMBA_ROOT_PREFIX="$LEO/mamba" | ||
| 138 | "$LEO/bin/micromamba" create -y -n leonida -c conda-forge --override-channels "llvm-tools>=21" spirv-tools | ||
| 139 | export PATH="$LEO/mamba/envs/leonida/bin:$PATH" | ||
| 140 | |||
| 141 | cmake -S runtime -B runtime/build/linux -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_VULKAN_HEADERS_FETCH=ON | ||
| 142 | cmake --build runtime/build/linux --parallel "$(nproc)" | ||
| 143 | LLVM_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" | ||
| 145 | echo "runner exit: ${PIPESTATUS[0]}" | ||
| 146 | ``` | ||
| 147 | |||
| 148 | Notes: | ||
| 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 | |||
| 799 | in [character_skeleton.md](character_skeleton.md#skinned-glb-export). On the 1.0.2.1 package, the | 799 | in [character_skeleton.md](character_skeleton.md#skinned-glb-export). On the 1.0.2.1 package, the |
| 800 | head (8,983 v) and biker jacket (9,818 v) produce one skin with 596 ped joints (703 with the | 800 | head (8,983 v) and biker jacket (9,818 v) produce one skin with 596 ped joints (703 with the |
| 801 | jacket's `GM_U01_*` helpers); every weight sums to 255 and the rest-pose reconstruction error is | 801 | jacket's `GM_U01_*` helpers); every weight sums to 255 and the rest-pose reconstruction error is |
| 802 | 6e-8 m. `python -I tests/test_skinned_glb.py` runs 24 synthetic tests and needs no game files. | 802 | 6e-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 |
| 805 | before it is opened in a viewer: | 805 | before 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 | ||
| 115 | On this archive both tools find the same 515 streams, the same 8,831,336,892 bytes, 1,094,744 bytes of zero | 115 | On this archive both tools find the same 515 streams, the same 8,831,336,892 bytes, 1,094,744 bytes of zero |
| 116 | padding and 22,812 bytes after the last stream. Those 22,812 are 3,884 zero bytes and the 18,928-byte RPF trailer | 116 | padding 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 |
| 118 | this 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 | 118 | confirmed 1,098,628 bytes of zero padding, 18,928 trailer bytes and 0 unread bytes. The archive matched the |
| 119 | 1.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 d5d76cb93..4d5be5e35 100644 --- a/docs/pipeline_check.md +++ b/docs/pipeline_check.md | |||
| @@ -256,7 +256,7 @@ acceptance only. | |||
| 256 | 256 | ||
| 257 | A SPIR-V module larger than 4 MiB is "large". [#884](https://github.com/ItsNotRexed/Leonida/issues/884) | 257 | A SPIR-V module larger than 4 MiB is "large". [#884](https://github.com/ItsNotRexed/Leonida/issues/884) |
| 258 | showed why that matters: several compiles that each needed gigabytes of host RAM ran at the same time. Large | 258 | showed why that matters: several compiles that each needed gigabytes of host RAM ran at the same time. Large |
| 259 | modules now share a memory budget (`runtime/test/large_module_gate.h`): each one reserves 512 bytes of RAM per | 259 | modules now share a memory budget (`runtime/src/large_module_gate.h`): each one reserves 512 bytes of RAM per |
| 260 | SPIR-V byte, and they enter the driver while their reservations fit three quarters of the memory available when | 260 | SPIR-V byte, and they enter the driver while their reservations fit three quarters of the memory available when |
| 261 | the run starts, up to `--jobs` of them. One large module always gets in when none is compiling, so a module | 261 | the run starts, up to `--jobs` of them. One large module always gets in when none is compiling, so a module |
| 262 | bigger than the whole budget still compiles, alone among the large ones. Small modules are never held back. On | 262 | bigger than the whole budget still compiles, alone among the large ones. Small modules are never held back. On |
| @@ -457,6 +457,10 @@ driver gives it the same cache key in both programs. Measured on Windows with an | |||
| 457 | `VK_KHR_maintenance8` into the pipeline cache key even for compute shaders, so the checker enables both whenever | 457 | `VK_KHR_maintenance8` into the pipeline cache key even for compute shaders, so the checker enables both whenever |
| 458 | supported and keeps `meshShaderQueries` on. | 458 | supported and keeps `meshShaderQueries` on. |
| 459 | - 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. | 459 | - 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. |
| 460 | - On Windows with an AMD Radeon RX 7900 XT, `VK_EXT_transform_feedback` (with `transformFeedback` enabled, and | ||
| 461 | `geometryStreams` when the device offers it) is part of the key: the runtime enables it whenever the extension is | ||
| 462 | present (D3D-302), so the checker enables it too. Without it, `pipeline_cache_seed` failed 3 of 3 on that GPU and | ||
| 463 | 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. | ||
| 460 | - The executable's file name is part of the key; its folder is not. A copy of the checker under another name | 464 | - The executable's file name is part of the key; its folder is not. A copy of the checker under another name |
| 461 | misses the cache the original wrote, and the runtime's device hits the checker's cache only from a program | 465 | misses the cache the original wrote, and the runtime's device hits the checker's cache only from a program |
| 462 | with the checker's file name. So on this driver a cache written by `vk_pipeline_check.exe` does not hit in | 466 | 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 | |||
| 13 | The page is one self-contained HTML file: no network, no packages, it opens from disk. The project logo | 13 | The 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 | ||
| 16 | Use a CTest JUnit report when the run includes tests configured with `SKIP_RETURN_CODE`. CTest can log those | ||
| 17 | skips as `Test Passed.` in `LastTest.log`. `--ctest-junit` replaces the local log with the report, which preserves | ||
| 18 | the skipped status. Use `--junit` to add independent runs. A new file name for each run keeps an aborted CTest run | ||
| 19 | from reusing an older report. | ||
| 20 | |||
| 21 | ```powershell | ||
| 22 | $report = Join-Path $env:TEMP ("leonida-ctest-{0}.xml" -f [guid]::NewGuid()) | ||
| 23 | ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure --output-junit $report | ||
| 24 | if (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 | ||
| 18 | Each source is optional. A missing one is listed under "Sources" on the page; it is never counted as zero or as a failure. | 33 | Each 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` | |||
| 139 | confirmed by the lane-graph heights. The label is consistent with the count, but not settled by it: nine in ten | 139 | confirmed by the lane-graph heights. The label is consistent with the count, but not settled by it: nine in ten |
| 140 | lane nodes stand on polygons with both bit 8 and bit 13, and which bit or combination means road surface is open. | 140 | lane 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 | |||
| 146 | A Windows compatibility project for Xbox Series. Its GPU layer translates console command streams to host | ||
| 147 | Direct3D 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 | ||
| 153 | completed, as discussed in [#622](https://github.com/ubiquitarianism/leonida/pull/622). That PR uses synthetic | ||
| 154 | tests 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 | ||
| 107 | These are one run's first failures, not a list of what is missing. Every stand-in above is local and untested | 107 | These are one run's first failures, not a list of what is missing. Every stand-in above is local and untested |
| 108 | beyond "the title goes on to the next call". Nothing has reached a draw or a present yet. | 108 | beyond "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 | |||
| 112 | The chain above finds the next slot by running the title; `tools/d3d12_device_calls.py` reads the file alone, | ||
| 113 | without running anything, and reports the statically resolved `ID3D12Device` vtable call sites for the device paths | ||
| 114 | it follows: | ||
| 115 | |||
| 116 | ```sh | ||
| 117 | python -I tools/d3d12_device_calls.py <game>/game_scarlett_master.exe --out <work>/device_calls | ||
| 118 | ``` | ||
| 119 | |||
| 120 | It writes `<exe>.device_calls.txt` (slot numbers and counts only) and `.json` (the same, plus each site's RVA for | ||
| 121 | local follow-up; don't paste that part) into the `--out` folder. It reads the executable only, so a slot called only | ||
| 122 | from a bundled DLL is absent from it: slot 76, for one, isn't in the census, yet `docs/d3d12_vulkan.md` (the slot 76 | ||
| 123 | row of its contract table, and §4.2) records the FidelityFX upscaler DLL creating its resources through it. A slot | ||
| 124 | missing 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 | ||
| 126 | globals 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 | ||
| 128 | dispatch routine counts only when its code reaches `jmp rax` or `call rax` without writing `rax`, calling or | ||
| 129 | returning first; a call to any other target with a method in `rax` is reported as not resolved. Per slot it shows | ||
| 130 | calls and tail jumps, whether the device is in `rcx` or in `rdx` (the return-buffer form of §3.1), and an | ||
| 131 | argument-count estimate. Slots 0-43 carry the PC method names, which the console keeps where measured (8, 9, 14, 26, | ||
| 132 | 36); past 43 only the slots `runtime/shims/d3d12_xs_device.h` and §3 name are named. | ||
| 133 | |||
| 134 | The walk follows forward branches within a function (a `jmp rel32` there is a branch, not a tail call) and keeps | ||
| 135 | a fact at a join only when both paths agree. What it doesn't see, and says so: the device reached through an object | ||
| 136 | member, a function parameter or a getter's return value; a path it loses, such as a loop's back edge; an indexed | ||
| 137 | method load. The report counts the vtable loads with no matched call, the calls with a method in `rax` | ||
| 138 | to a target that isn't a verified dispatch routine, the calls that are handed the device (not followed into), and | ||
| 139 | the stores of the device to non-stack memory. A slot can be called more often than the report says, or on a | ||
| 140 | path it doesn't follow, so a slot with no row (12 and 51, for example) isn't shown to be uncalled. | ||
| 141 | |||
| 142 | On the 1.0.2.1 executable it finds one `D3D12XboxCreateDevice` call site writing a global and 95 sites across | ||
| 143 | 42 slots: 94 indirect vtable calls and one indirect vtable tail jump (at slot 2), with no dispatch call resolved; | ||
| 144 | the `rdx` form at slots 25, 26 and 108 only; and 12 sites it reports as not resolved. Every device slot | ||
| 145 | the chain above reached (8, 26, 48, 73, 133) is among them; slots like 49, 55, 57, 61, 70, 71, 74, 81, 86, 101, | ||
| 146 | 108, 119, 127 and 132 are called but have no name in this repository yet. | ||
| 147 | |||
| 148 | For some of the unnamed slots there is a call shape from an independent static read with a different scanner, by | ||
| 149 | TreXito (in the review of old upstream PR 7998), with the same site counts for 49, 50, 55, 57, 71 and 81. These | ||
| 150 | are 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 | |||
| 129 | The carve is read-only and works on any `.rpf`, `.ttpf` or archive-like file. It does not decrypt the TOC, use | 129 | The carve is read-only and works on any `.rpf`, `.ttpf` or archive-like file. It does not decrypt the TOC, use |
| 130 | keys, or write anything outside the output directory. | 130 | keys, or write anything outside the output directory. |
| 131 | 131 | ||
| 132 | Once one or more archives have been carved under `<work>\carve`, `tools/classify_carve.py` groups every entry by | ||
| 133 | signature using only the per-archive `index.json` files (no carved payload reads): | ||
| 134 | |||
| 135 | ```powershell | ||
| 136 | python -I tools/classify_carve.py <work>\carve | ||
| 137 | ``` | ||
| 138 | |||
| 139 | It classifies each entry as `bink2` (`KB2x`), `rbf0` (`52424630`), `respage` (`42400000`), `gpu-zerohdr` (16+ leading | ||
| 140 | zero bytes), or `other:<hex>` (first 4 bytes), prints a summary table, and writes `<work>\carve\types.json` with | ||
| 141 | overall 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 |
| 412 | measurement in `d3d12_vulkan.md`, because its page could not be found. | 421 | measurement 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 | ||
| 416 | Not every console module is reached through an import table. `libHttpClient.GDK.dll` and `XCurl.dll` both use the | 441 | Not every console module is reached through an import table. `libHttpClient.GDK.dll` and `XCurl.dll` both use the |
diff --git a/docs/shader_library.md b/docs/shader_library.md index 8cf131ca4..41cea0685 100644 --- a/docs/shader_library.md +++ b/docs/shader_library.md | |||
| @@ -178,7 +178,7 @@ them and the state key is the record's state blob. The step is redone as a whole | |||
| 178 | `llvm-mc`, the wave64 mode or the flags change (`library_build.json`, written last), and a clash of both keys between | 178 | `llvm-mc`, the wave64 mode or the flags change (`library_build.json`, written last), and a clash of both keys between |
| 179 | different modules fails it, as for the FSPX step. Graphics pipelines are not translated by the build. | 179 | different modules fails it, as for the FSPX step. Graphics pipelines are not translated by the build. |
| 180 | 180 | ||
| 181 | ### Resuming a compute-only batch on Linux | 181 | ### Resuming a compute-only batch on Linux or native Windows |
| 182 | 182 | ||
| 183 | Run `tools/shader_library.py` with `--stages cs --disasm --jobs 2` and the carved containers, or select the | 183 | Run `tools/shader_library.py` with `--stages cs --disasm --jobs 2` and the carved containers, or select the |
| 184 | kind-6 hashes with `--compute-hashes`. For an unpacked library with its input `index.json`, use the compute batch. | 184 | kind-6 hashes with `--compute-hashes`. For an unpacked library with its input `index.json`, use the compute batch. |
| @@ -187,14 +187,27 @@ kind-6 hashes with `--compute-hashes`. For an unpacked library with its input `i | |||
| 187 | python3 -I scripts/translate_pipeline_compute.py /path/to/unpacked --out /path/to/spirv/library --wave64-emulate | 187 | python3 -I scripts/translate_pipeline_compute.py /path/to/unpacked --out /path/to/spirv/library --wave64-emulate |
| 188 | ``` | 188 | ``` |
| 189 | 189 | ||
| 190 | Use a dedicated output folder. The two workers run at nice 19. Each has a 768 MiB address-space limit and uses one | 190 | Use a dedicated output folder and a stable, trusted SPIRV-Tools installation on PATH. On Linux the two workers |
| 191 | SPIRV-Tools process at a time (four processes total). `--jobs 1` uses a single worker and `--memory-mib` changes | 191 | run at nice 19. Each has a 768 MiB address-space limit and uses one SPIRV-Tools process at a time (four processes |
| 192 | the per-process limit. A rerun checks each module against its checksum and the listing, source container, FSPX | 192 | total). On native Windows CPython, a BelowNormal coordinator and up to two gated workers run with a 768 MiB |
| 193 | **committed memory** cap per process (not total virtual address space). Each worker's kill-on-close Job permits | ||
| 194 | only itself and one tool process. The parent verifies job membership before sending work; the child rechecks the | ||
| 195 | effective limits. A no-share file open keeps the pack exclusive through worker exit. An incompatible outer Job | ||
| 196 | or a failed limit/lock check stops the build; there is no unbounded Windows mode. A hard stop can leave temporary | ||
| 197 | scratch files, but cannot partially replace the index. `--jobs 1` uses a single translating worker and | ||
| 198 | `--memory-mib` changes the per-process limit. A rerun checks each module against its checksum and the listing, source container, FSPX | ||
| 193 | sidecars, toolchain and wave mode. It retries failures. Only validated modules enter the runtime index. Its | 199 | sidecars, toolchain and wave mode. It retries failures. Only validated modules enter the runtime index. Its |
| 194 | atomic replacement follows both workers, so an interrupted run leaves the previous index readable. A partial | 200 | atomic replacement follows both workers, so an interrupted run leaves the previous index readable. A partial |
| 195 | run exits nonzero and writes the reasons to `failures.json`, keyed by kind-6 and kind-0 SHA-256. Old modules | 201 | run exits nonzero and writes the reasons to `failures.json`, keyed by kind-6 and kind-0 SHA-256. Old modules |
| 196 | can still be used by a runtime that already opened the preceding index. | 202 | can still be used by a runtime that already opened the preceding index. |
| 197 | 203 | ||
| 204 | The coordinator and each shard explicitly apply `--wave64-emulate`, `--loop-limit`, `--descriptor-hash` and | ||
| 205 | `--compact-spirv`; requesting compaction requires both translator support and `spirv-opt`. The cache key includes | ||
| 206 | those settings, compiler sources, builder and tool hashes. `.compute-cache/worker-receipt.json` records the exact | ||
| 207 | options and input-name digest for each shard; compare its `index_sha256` with the actual published index before | ||
| 208 | using it. This is an audit file, not a completion marker. A pre-upgrade cache key is not reused as evidence for | ||
| 209 | a new builder. | ||
| 210 | |||
| 198 | Among 2,680 compute programs, 46 start with two 12-byte literal-bearing VOP3 NOP hash carriers. Their body | 211 | Among 2,680 compute programs, 46 start with two 12-byte literal-bearing VOP3 NOP hash carriers. Their body |
| 199 | starts at byte 24. The three-record form starts at byte 36. The no-op measurements are in `docs/fspx.md`. | 212 | starts at byte 24. The three-record form starts at byte 36. The no-op measurements are in `docs/fspx.md`. |
| 200 | A hash literal can resemble an instruction. `shader_library.py` excludes both complete carrier records before | 213 | A hash literal can resemble an instruction. `shader_library.py` excludes both complete carrier records before |
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 | |||
| 1668 | each value is staged once, and that the kernels assemble for gfx1031. A fake oracle plays the GPU to check the exit | 1668 | each value is staged once, and that the kernels assemble for gfx1031. A fake oracle plays the GPU to check the exit |
| 1669 | codes. On a GFX10 GPU the test runs UNORM8 and checks the controls. | 1669 | codes. 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 | |||
| 1673 | The image counterpart to `tools/d16_format_probe.py` checks how a GFX10 GPU (RDNA1/RDNA2, through `tools/hw_oracle`) | ||
| 1674 | rounds 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 | ||
| 1676 | wave64. 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). | ||
| 1678 | Point 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 | ||
| 1680 | hardware's own f32 bilinear sample rounded to nearest even or toward zero. | ||
| 1681 | |||
| 1682 | ``` | ||
| 1683 | python -I tools/d16_image_probe.py --formats unorm8,unorm16 --waves 32,64 --frac 0.5 --json out.json | ||
| 1684 | python -I tools/d16_image_probe.py --hw-arch gfx1031 --json out.json | ||
| 1685 | python -I tools/d16_image_probe.py --self-test | ||
| 1686 | python -I tests/test_d16_image_probe.py | ||
| 1687 | ``` | ||
| 1688 | |||
| 1689 | Exit status is 0 when the sweep ran, 1 when wave32 and wave64 disagree, 2 on a harness or control error (f32 load | ||
| 1690 | mismatch, point sample differing from load, `float16` mismatch, or misaligned texture), and 77 when the hardware oracle | ||
| 1691 | is unavailable or the GPU is not GFX10. `tests/test_d16_image_probe.py` covers the rules, texel generators, descriptors, | ||
| 1692 | and 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 | ||
| 1673 | A typed buffer load of a half NaN had never been measured: `tools/mem_diff.py` decoded 16_FLOAT with | 1696 | A 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 |
| 2330 | bit-for-bit identically (`3/3` draws, `11/11` targets) against `default` on the RX 6650 XT. | 2353 | bit-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 | ||
| 2358 | miss. 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 | ||
| 2360 | signedness flips, `self.cu(N)` off-by-one constants, swapped `OpSelect` arms, and duplicated trailing operands) in a | ||
| 2361 | private temporary copy of `tools/` and runs the test file against each copy through `LEONIDA_TOOLS_DIR` (the same hook | ||
| 2362 | used by `tests/semantic/test_mutations.py`), leaving the repository untouched. | ||
| 2363 | |||
| 2364 | ``` | ||
| 2365 | python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8 | ||
| 2366 | python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8 --list | ||
| 2367 | python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8 --timeout 120 | ||
| 2368 | python -I tests/test_semantic_mutants.py | ||
| 2369 | ``` | ||
| 2370 | |||
| 2371 | Any mutant the test file still passes is reported as `SURVIVED` (read each lead before adding cases, since some mutants | ||
| 2372 | are equivalent). Exit status is 0 when every mutant is caught, 1 when any survives, and 2 on a usage error or when the | ||
| 2373 | unmutated baseline fails. Synthetic only (no GPU or game files); `tests/test_semantic_mutants.py` covers mutant | ||
| 2374 | generation, scoping, and CLI exit codes. | ||
| 2375 | |||
| 2332 | ## Coverage plan and cost | 2376 | ## Coverage plan and cost |
| 2333 | 2377 | ||
| 2334 | Start with straight-line scalar/vector ALU because it is deterministic, needs no descriptors and | 2378 | Start 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 | ||
| 10 | This page collects the setup steps and the problems testers have run into so far. | 10 | This 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, | |||
| 661 | expected (#5933: Vega 8, PCI 1002:15E7, driver 31.0.21921.13001). `ps_bary`, `ps_persp_bary` and `ps_ij_computed` | 662 | expected (#5933: Vega 8, PCI 1002:15E7, driver 31.0.21921.13001). `ps_bary`, `ps_persp_bary` and `ps_ij_computed` |
| 662 | fail natively; through the fallback `ps_bary` and `ps_persp_bary` pass. `tools/vk_subgroup_info.py` reports | 663 | fail 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 |
| 665 | other 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 | ||
| 669 | by itself ([#166 entry](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7109387712)). Other GCN 5 GPUs | ||
| 670 | are 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 | ||
| 785 | Two 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. | 785 | Two 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 | ||
| 787 | An `InstanceList` is a u64 (low 12 bits: 1-based block index; bits 20+: offset in that block) and a u16 count. | 787 | An `InstanceList` is a u64 (low 20 bits: 1-based block index; bits 20+: offset in that block) and a u16 count. |
| 788 | That 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 | ||
| 792 | has bits 12-19 at zero, so a 12-bit reading would find the same block for each of them. | ||
| 788 | Instance blocks are usually in the physical buffer, so the tool joins each resource's virtual and physical | 793 | Instance blocks are usually in the physical buffer, so the tool joins each resource's virtual and physical |
| 789 | streams from its block map (+0x08 -> +8 virtual count, +9 physical count). | 794 | streams 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 | ||
| 55 | Pointers are pool references (1-based block number in bits 0..11, byte offset from bit 20) or `0x5xxxxxxx` | 55 | Pointers are pool references (1-based block number in bits 0..19, byte offset from bit 20, as in |
| 56 | system 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 |
| 57 | the shape of a `0x5xxxxxxx` pointer, so the reader tries the pool form first and only then a system pointer. | 57 | the 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"). |
| 4 | Seven have no shim yet. This page records, from the file alone, how the executable calls them: how many call sites each | 4 | This page records, from the file alone, how the executable calls them: how many call sites each has and the constant |
| 5 | has and the constant arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and | 5 | arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and the instructions |
| 6 | the instructions that load the argument registers before each call were read by hand. No code or data of the executable | 6 | that load the argument registers before each call were read by hand. No code or data of the executable is quoted, only |
| 7 | is quoted, only the constants a call passes and the counts. Measured at `main` `1cc6e3c1`, SHA-256 | 7 | the 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 |
| 9 | it 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 |
| 11 | python -I tools/import_call_sites.py game_scarlett_master.exe --dll xmem.dll --dll d3d12_xs.dll --dll xg_xs.dll | 12 | python -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 | |||
| 15 | instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are | 16 | instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are |
| 16 | bounds, not a proof that every site is reached. | 17 | bounds, 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 | ||
| 32 | The executable also exports one symbol, `__XMemAllocationHooks__`. | 33 | The 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 | ||
| 53 | Every `attributes` value is nonzero, and `runtime/shims/xmem.cpp` returns `ERROR_NOT_SUPPORTED` for a nonzero value | 54 | Every `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 | 55 | records the word (`xmem_attributes` in the startup trace) and accepts it. All 23 allocation types are served as well. |
| 55 | refuse the calls with `allocation_type` `0x20003000` (5 sites: the 2 MiB page mode) and those with bits it does not | 56 | The page-mode mask is `kXmem64kPages` `0x20400000`, which *is* `MEM_LARGE_PAGES | MEM_PHYSICAL`, so `0x20406000` |
| 56 | know: `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 |
| 58 | placeholder — `test_placeholders` in `runtime/test/xmem_test.cpp` allocates that exact shape and maps physical pages | ||
| 59 | into the carved window. The 23 sites divide as 17 in the 64 KiB mode (3 committed, 8 reserve-only windows, 1 plain | ||
| 60 | commit, 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 | ||
| 62 | windows 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 | ||
| 58 | The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections | 65 | The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections |
| 59 | the high bits match: `PAGE_GRAPHICS_NOACCESS` `0x800`, `_READONLY` `0x1000`, `_READWRITE` `0x2000`, `_EXECUTE_READ` | 66 | the 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 | |||
| 81 | are **unmeasured**. | 88 | are **unmeasured**. |
| 82 | 89 | ||
| 83 | The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range | 90 | The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range |
| 84 | with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. So the physical-page calls depend on the | 91 | with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. That path no longer |
| 85 | attribute check above: until `XMemVirtualAlloc` accepts these attribute words, the map calls are never reached from | 92 | stops at `XMemVirtualAlloc`: since #6919 it accepts that attribute word and the reserve-only 64 KiB window. |
| 86 | there. | 93 | |
| 87 | 94 | The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so the shim emulates | |
| 88 | The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so a shim would | 95 | the 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 |
| 89 | emulate the pool (a pagefile-backed section of 64 KiB pages, with views placed at the reserved range) instead of | 96 | physical memory as it is touched, with views placed at the reserved range. Pages keep their contents while unmapped or |
| 90 | forwarding. That is a design note, not a measurement. | 97 | mapped elsewhere, and one page can be mapped at several addresses. The attribute word is recorded, still not decoded, |
| 98 | and 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 | ||