upleb.uk

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

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCodex <codex@openai.com>2026-11-25 21:56:35 +0000
committerCodex <codex@openai.com>2026-11-25 21:56:35 +0000
commitf7e422ee8a307ced9a41e11fb02330b4cb7abdaa (patch)
tree23c1aacc48c0f66b559d0525f2567cdf77e9c1bd /docs
parenta05f1f3cdbb534d3261f8c557f39b637ac240ca8 (diff)
parentcb699500acb724f4ffa2873ee61b578e9d3e8627 (diff)
Merge upstream main into gameinput-hotplug
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md4
-rw-r--r--docs/boot.md44
-rw-r--r--docs/cpu_features.md19
-rw-r--r--docs/d3d12_command_objects.md55
-rw-r--r--docs/d3d12_vulkan.md204
-rw-r--r--docs/d3d12_xs_console_abi.md83
-rw-r--r--docs/d3d12_xs_surface.md125
-rw-r--r--docs/design.md7
-rw-r--r--docs/first_light.md8
-rw-r--r--docs/first_run_ui.md2
-rw-r--r--docs/fspx.md84
-rw-r--r--docs/gamedata.md7
-rw-r--r--docs/gameinput.md50
-rw-r--r--docs/gbuffer.md13
-rw-r--r--docs/gpu_test_results.md58
-rw-r--r--docs/i18n/README.md5
-rw-r--r--docs/i18n/it/quickstart.md4
-rw-r--r--docs/i18n/ja/quickstart.md4
-rw-r--r--docs/i18n/pl-PL/quickstart.md4
-rw-r--r--docs/i18n/ru/quickstart.md10
-rw-r--r--docs/linux.md34
-rw-r--r--docs/linux_proton.md55
-rw-r--r--docs/models.md2
-rw-r--r--docs/movies.md5
-rw-r--r--docs/progress_dashboard.md15
-rw-r--r--docs/related_projects.md51
-rw-r--r--docs/rpf.md11
-rw-r--r--docs/runtime_imports.md49
-rw-r--r--docs/shader_library.md9
-rw-r--r--docs/shader_validation.md44
-rw-r--r--docs/testing.md16
-rw-r--r--docs/xcl_compare.md2
-rw-r--r--docs/xdxr.md21
-rw-r--r--docs/xmem_exe_calls.md56
34 files changed, 1003 insertions, 157 deletions
diff --git a/docs/README.md b/docs/README.md
index 685634912..d6bca1754 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -81,14 +81,14 @@ method, scope and caveats. No game data is included.
81| [d3d12_command_objects.md](d3d12_command_objects.md) | Measured command queue/list/fence/`PresentX` surface; verified vs prior art vs open. | 81| [d3d12_command_objects.md](d3d12_command_objects.md) | Measured command queue/list/fence/`PresentX` surface; verified vs prior art vs open. |
82| [xbox_d3d12_xs.md](xbox_d3d12_xs.md) | The `d3d12_xs` graphics ABI quoted from Microsoft's public GDK reference: root signatures, state objects, DXIL libraries, hit groups, shader cache sessions; which pages are missing or NDA-gated. | 82| [xbox_d3d12_xs.md](xbox_d3d12_xs.md) | The `d3d12_xs` graphics ABI quoted from Microsoft's public GDK reference: root signatures, state objects, DXIL libraries, hit groups, shader cache sessions; which pages are missing or NDA-gated. |
83| [runtime_imports.md](runtime_imports.md) | The 16 shipped modules' measured imports and shim/host/unimplemented split. | 83| [runtime_imports.md](runtime_imports.md) | The 16 shipped modules' measured imports and shim/host/unimplemented split. |
84| [linux_proton.md](linux_proton.md) | Building and booting under Proton/Wine on Linux, a healthy boot's timeline, and the test report of one Linux and two Windows machines | 84| [linux_proton.md](linux_proton.md) | Building and booting under Proton/Wine on Linux, one bounded game run with `scripts/run_game_wine.sh`, a healthy boot's timeline, and the test report of one Linux and two Windows machines |
85| [xmem_exe_calls.md](xmem_exe_calls.md) | How the retail executable calls `xmem.dll`: call sites and constant arguments per import (`tools/import_call_sites.py`), the 23 `XMemVirtualAlloc` calls that all pass an attribute word, and the inferred shape of the physical-page family. | 85| [xmem_exe_calls.md](xmem_exe_calls.md) | How the retail executable calls `xmem.dll`: call sites and constant arguments per import (`tools/import_call_sites.py`), the 23 `XMemVirtualAlloc` calls that all pass an attribute word, and the inferred shape of the physical-page family. |
86| [exe_fail_fast.md](exe_fail_fast.md) | Where the retail executable stops itself (`int3`) on an import's result: 78 sites over 27 imports (`tools/import_fail_fast.py`), grouped by how `main` binds each import (all 13 non-host fatal-checked imports now bind to shims; 0 unbound). | 86| [exe_fail_fast.md](exe_fail_fast.md) | Where the retail executable stops itself (`int3`) on an import's result: 78 sites over 27 imports (`tools/import_fail_fast.py`), grouped by how `main` binds each import (all 13 non-host fatal-checked imports now bind to shims; 0 unbound). |
87| [audio_hal_exe_calls.md](audio_hal_exe_calls.md) | How the retail executable calls the 22 audio coprocessor, texture layout and DirectStorage imports that have no shim: call sites, constant arguments, and the four calls with a negative-result branch. | 87| [audio_hal_exe_calls.md](audio_hal_exe_calls.md) | How the retail executable calls the 22 audio coprocessor, texture layout and DirectStorage imports that have no shim: call sites, constant arguments, and the four calls with a negative-result branch. |
88| [directstorage.md](directstorage.md) | Console DirectStorage: the DLL and ABI the title is expected to use (`DStorageGetFactory`, `dstorage_xs`, `XCRDAPI`), how sure that is and the evidence for it, and what `runtime/shims/dstorage.cpp` serves on the PC. The executable's own imports are unmeasured. | 88| [directstorage.md](directstorage.md) | Console DirectStorage: the DLL and ABI the title is expected to use (`DStorageGetFactory`, `dstorage_xs`, `XCRDAPI`), how sure that is and the evidence for it, and what `runtime/shims/dstorage.cpp` serves on the PC. The executable's own imports are unmeasured. |
89| [cpu_features.md](cpu_features.md) | CPU instructions in the executable a desktop CPU may lack (`tools/cpu_feature_scan.py`): 19 SSE4a, 10 CLZERO and 4 MONITORX/MWAITX sites (AMD only) and 8 CLWB sites (Intel since Ice Lake), all real code; `#UD` on hosts without them. | 89| [cpu_features.md](cpu_features.md) | CPU instructions in the executable a desktop CPU may lack (`tools/cpu_feature_scan.py`): 19 SSE4a, 10 CLZERO and 4 MONITORX/MWAITX sites (AMD only) and 8 CLWB sites (Intel since Ice Lake), all real code; `#UD` on hosts without them. |
90| [xcl_compare.md](xcl_compare.md) | XCL's synthetic test title under `gta6rt --run` and under XCL (`tools/xcl_compare.py`): 5 of 50 checks pass here, both hangs are the documented manual-queue terminate deadlock, and each other difference mapped to an open item or a lead. | 90| [xcl_compare.md](xcl_compare.md) | XCL's synthetic test title under `gta6rt --run` and under XCL (`tools/xcl_compare.py`): 5 of 50 checks pass here, both hangs are the documented manual-queue terminate deadlock, and each other difference mapped to an open item or a lead. |
91| [gameinput.md](gameinput.md) | The GameInput shim on SDL3: `GameInputCreate` and the v0 `IGameInput`/`IGameInputDevice`/`IGameInputReading`/`IGameInputDispatcher` surface on any SDL gamepad, DualSense adaptive-trigger approximation and lightbar, force-feedback motors and trigger haptics through SDL's haptic API; 261 checks on virtual joysticks and a fake haptic backend; by hand on an Xbox Series X pad (Bluetooth) and a DualSense (USB). 261 checks on virtual joysticks and a fake haptic backend, not yet tried on a real pad. | 91| [gameinput.md](gameinput.md) | The GameInput shim on SDL3: `GameInputCreate` and the v0 `IGameInput`/`IGameInputDevice`/`IGameInputReading`/`IGameInputDispatcher` surface on any SDL gamepad, DualSense adaptive-trigger approximation and lightbar, force-feedback motors and trigger haptics through SDL's haptic API; without SDL3, one scripted pad for `LEONIDA_INPUT_SCRIPT`; 261 checks on virtual joysticks and a fake haptic backend; by hand on an Xbox Series X pad (Bluetooth) and a DualSense (USB). 261 checks on virtual joysticks and a fake haptic backend, not yet tried on a real pad. |
92| [saves.md](saves.md) | Save containers: `JSAV` (index + JSON story save, byte-exact rebuild), `ASAV` header, `SLAYER1` packed copy (not decoded); `tools/saves.py` and import into the offline `XGameSave` folder; key hashes are case-sensitive joaat (`tools/save_keys.py`). | 92| [saves.md](saves.md) | Save containers: `JSAV` (index + JSON story save, byte-exact rebuild), `ASAV` header, `SLAYER1` packed copy (not decoded); `tools/saves.py` and import into the offline `XGameSave` folder; key hashes are case-sensitive joaat (`tools/save_keys.py`). |
93| [pipeline_check.md](pipeline_check.md) | Driver-level corpus check: the full corpus, 26,503 of 26,503 modules and pipelines, 0 failures (RTX 4060 Ti); an earlier 10/12-shard run, 22,092 modules and 2,217 compute pipelines, also had 0 failures. Driver-level corpus check: 10/12 shards, 22,092 modules, 2,217 compute pipelines, 0 failures. | 93| [pipeline_check.md](pipeline_check.md) | Driver-level corpus check: the full corpus, 26,503 of 26,503 modules and pipelines, 0 failures (RTX 4060 Ti); an earlier 10/12-shard run, 22,092 modules and 2,217 compute pipelines, also had 0 failures. Driver-level corpus check: 10/12 shards, 22,092 modules, 2,217 compute pipelines, 0 failures. |
94| [multi_gpu_validation.md](multi_gpu_validation.md) | Running disjoint shards on eight identical RDNA1/RADV GPUs: PCI-BDF pinning, base controls, per-card logs, the V540 farm's aggregate results and its known driver limitations. | 94| [multi_gpu_validation.md](multi_gpu_validation.md) | Running disjoint shards on eight identical RDNA1/RADV GPUs: PCI-BDF pinning, base controls, per-card logs, the V540 farm's aggregate results and its known driver limitations. |
diff --git a/docs/boot.md b/docs/boot.md
index 2b7186e30..4bc580c75 100644
--- a/docs/boot.md
+++ b/docs/boot.md
@@ -95,7 +95,8 @@ 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).
101 Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file 102 Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file
@@ -116,6 +117,18 @@ Useful switches:
116 diagnostic). 117 diagnostic).
117* `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first 118* `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first
118 observed loss prints a `[rt] device-fault:` report to stderr. 119 observed loss prints a `[rt] device-fault:` report to stderr.
120* `LEONIDA_TITLE_HUD=1` shows live counters in the title bar of the window the title presents in
121 (`runtime/shims/title_hud.h`). It updates twice a second with:
122 - the frame rate and the average and worst frame time from PresentX, or, when no frame came in that half
123 second, how long since the last one (a hang reads "0 fps, no frame for 12.5 s");
124 - the process's private memory and working set;
125 - its local GPU memory against the DXGI budget, and its shared GPU memory;
126 - the graphics and compute pipelines created, and the seconds spent in `vkCreate*Pipelines` in the last half
127 second. A pipeline compiled in the frame shows up there as a hitch. This needs `LEONIDA_MEM_PROBE`; without it
128 the field reads `PSO -`.
129 - the time since the first present.
130
131 A thread of its own sets the text with `SendMessageTimeout`, so a busy window thread never holds a present.
119* `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their 132* `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their
120 implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known 133 implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known
121 problems"). 134 problems").
@@ -124,6 +137,35 @@ Useful switches:
124 for one run (it wins over `--overlay`). For a fresh first-run profile, also set `LEONIDA_SAVE_DIR` to a separate 137 for one run (it wins over `--overlay`). For a fresh first-run profile, also set `LEONIDA_SAVE_DIR` to a separate
125 empty directory for the local game-save provider. 138 empty directory for the local game-save provider.
126 139
140### Under Wine on Linux
141
142The prefix has to supply a `d3d12.dll` that exports `D3D12SerializeVersionedRootSignature`, because the executable
143imports it. Wine's own `d3d12.dll` does not answer that export for the runtime's shim, and the failure is quiet:
144the D3D12 trace ends at about 1,658 calls, the startup trace ends in an access violation inside the executable,
145and the one line that names the cause is
146`[rt] d3d12_xs: host d3d12.dll has no D3D12SerializeVersionedRootSignature`. The run never reaches
147`CreateRootSignature`.
148
149Copying the DLLs a Proton prefix installs is not enough on its own: Wine keeps preferring its own copy next to
150them. Name them in the overrides.
151
152```bash
153GE=$HOME/GE-Proton11-13-x86_64/files/lib/wine
154cp "$GE/vkd3d-proton/x86_64-windows/d3d12.dll" \
155 "$GE/vkd3d-proton/x86_64-windows/d3d12core.dll" \
156 "$GE/dxvk/x86_64-windows/dxgi.dll" "$WINEPREFIX/drive_c/windows/system32/"
157export WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n,b"
158export LEONIDA_D3D12=vulkan
159export LEONIDA_SHADERS='Z:\path\to\shaders\spirv'
160wine ./gta6rt.exe --run 'Z:\path\to\game_scarlett_master.exe' --game-dir 'Z:\path\to\the\package' \
161 --trace /tmp/boot.jsonl --trace-d3d12
162```
163
164With those three DLLs and the override, the same prefix reaches the frame loop: about 1.4 million D3D12 calls in
16590 s, no exception, `PresentX ready`, against 1,658 calls and an access violation without them, measured on Wine
16611.13 (GE-Proton 11-13) with an RDNA2 iGPU. A prefix that Proton itself created already carries these files and
167needs no override.
168
127## 3. Triage order 169## 3. Triage order
128 170
129Read the startup trace first; the first event that is not the expected one is the run's first fact. 171Read the startup trace first; the first event that is not the expected one is the run's first fact.
diff --git a/docs/cpu_features.md b/docs/cpu_features.md
index 5ecea005f..47ffd81dc 100644
--- a/docs/cpu_features.md
+++ b/docs/cpu_features.md
@@ -69,3 +69,22 @@ in the image.
69 answers is not measured here. 69 answers is not measured here.
70 70
71Not measured: which of these sites a boot reaches, and in which order. 71Not measured: which of these sites a boot reaches, and in which order.
72
73### Hosts without AVX
74
75Measured on one host: Intel Xeon X5675 (Westmere, SSE4.2; no AVX, AVX2, FMA, BMI2 or XSAVE), Fedora 44,
76`wine-11.21 (Staging)`, Intel SDE 10.13.1, and a local `gta6rt.exe` build from 2026-11-24.
77
78- **What works without AVX:** building the native Linux runtime and Vulkan test tools (`ctest`), running the Vulkan GPU
79 suite (`scripts/run_gpu_tests.py`), shader translation and asset export (`make_game.py` stages).
80- **Running `gta6rt` directly:** `--init` and `--run` exit 4 at the AVX preflight. With `LEONIDA_SKIP_CPU_CHECK=1`,
81 the preflight is skipped and the guest faults on its first AVX instruction.
82- **Under Intel SDE (`sde64 -hsw`):** without `-chip_check_disable 1`, SDE aborts on `clzero` instead of raising
83 `SIGILL` for `gta6rt`'s handler. With `-chip_check_disable 1`, the guest passes its first AVX instruction and reaches
84 `InitializeApiImplEx2` (offline) after ~110 s, then stops before any window or D3D12 call: SDE traps an `int 3`
85 without `-raise-int3`, and with `-raise-int3` the process terminates with `SIGSEGV` (`LEONIDA_SKIP_INT3=1` with
86 `--trace` did not change this, recording `0` `int3_skipped` events). Adding `-ptr-raise` causes Pin to abort with an
87 internal instrumentation error under Wine's exception handling.
88- **Outcome on this host:** no useful path to boot `gta6rt --run` was found under SDE + Wine.
89
90Not measured: other emulators (such as QEMU TCG with AVX2) or Rosetta 2.
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md
index 1aef12206..eea693c70 100644
--- a/docs/d3d12_command_objects.md
+++ b/docs/d3d12_command_objects.md
@@ -136,8 +136,41 @@ following each `0x40`/`0x48`/`0x60`/`0x120` call back to its receiver.
136 136
137So the four slots' callers are in the game executable, which the package does not contain (the 137So the four slots' callers are in the game executable, which the package does not contain (the
138same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is 138same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is
139still the SDK baseline. Once the executable is available, `tools/d3d12_iid_scan.py` run on it 139still the SDK baseline.
140shows whether it carries these IIDs, and its call sites through them give the slots. 140
141**Measured on the retail executable** (`python -I tools/d3d12_iid_scan.py`, 80 SDK IIDs read from
142the Windows SDK 10.0.26100 `d3d12.h`): the image carries 13 of them, and it carries the whole
143queue/allocator/list/fence set except the two base/second-generation names:
144
145| IID | In the executable |
146|---|---|
147| `ID3D12CommandQueue` | present |
148| `ID3D12CommandAllocator` | present |
149| `ID3D12GraphicsCommandList` | present (one slot-73 site; startup lists use the console IID below) |
150| `ID3D12Fence` | present |
151| `ID3D12CommandList` (base) | absent |
152| `ID3D12Fence1` | absent |
153
154The other carried IIDs are `ID3D12CommandSignature`, `ID3D12DescriptorHeap`, `ID3D12Device11`,
155`ID3D12PipelineState`, `ID3D12QueryHeap`, `ID3D12Resource`, `ID3D12RootSignature`,
156`ID3D12StateObject` and `ID3D12StateObjectProperties`; the image imports only
157`D3D12ConfigureVirtualMemoryX`, `D3D12SerializeVersionedRootSignature` and
158`D3D12XboxCreateDevice` from `d3d12_xs.dll`. `ID3D12Device11`
159(`{5405C344-D457-444E-B4DD-2366E45AEE39}`, `d3d12.h:24502,35748`, `.rdata` `0x1461E0638`) is the
160`riid` the executable passes to `D3D12XboxCreateDevice` (`0x14247856C` → `0x1424785B7`), which is
161why both `d3d12_iid_scan.py` and `is_device_iid` in `runtime/shims/d3d12_xs_device.cpp` recognise
162it during [retail_boot_chain.md](retail_boot_chain.md).
163
164A carried IID is necessary but not sufficient: it says the binary can ask for the interface, not
165where it does. The slots stay **Open** until a call site is followed.
166
167One console command-list IID is outside `d3d12.h`, so the scan cannot see it, and a proxy has to
168answer it rather than forward it to the PC device: `{C3827890-4024-474C-98CF-645B51DC4874}`
169(`.rdata` `0x1461E0668`), passed to Xbox device slot 73 (`CreateCommandListX`) in renderer startup
170at `0x142478B56` → `0x142478B71` ([retail_boot_chain.md](retail_boot_chain.md) §3.3,
171[#523](https://github.com/ubiquitarianism/leonida/issues/523)); the carried
172`IID_ID3D12GraphicsCommandList` (`0x1461ECFA0`) is passed to slot 73 at a separate site
173(`0x1417F6D1D` → `0x1417F6D34`).
141 174
142### 2.2 Queue, allocator and fence 175### 2.2 Queue, allocator and fence
143 176
@@ -565,6 +598,10 @@ shape and the shift around them, but the shape alone does not single the method
565| 55 (`+0x1b8`) | **51** | `DiscardResource` | `(resource, null)` at `0x6dcb`, after the pending barriers are flushed through slot 26 | 598| 55 (`+0x1b8`) | **51** | `DiscardResource` | `(resource, null)` at `0x6dcb`, after the pending barriers are flushed through slot 26 |
566| 59 (`+0x1d8`) | — | console only (shape) | four calls, two shapes: `(1, blob, size)` at `0x6b5a` and `0x6d53`, the blob a run of qwords whose first is `0xf3080 \| (qword count & 0x7f)`; and `(0, &qword, 8)` with the qword 1 at `0x6e52` and `0x6eb8`, only when a profiling bit of the context is set (`0x6e2a`). The first argument is set as a byte (`mov dl, 1` / `xor edx, edx`). It looks like one slot for both ends of a GPU event; no public method takes a bool first. With 55 at +4 and 61 at +2, the two slots the console lacks are among 56–60 | 599| 59 (`+0x1d8`) | — | console only (shape) | four calls, two shapes: `(1, blob, size)` at `0x6b5a` and `0x6d53`, the blob a run of qwords whose first is `0xf3080 \| (qword count & 0x7f)`; and `(0, &qword, 8)` with the qword 1 at `0x6e52` and `0x6eb8`, only when a profiling bit of the context is set (`0x6e2a`). The first argument is set as a byte (`mov dl, 1` / `xor edx, edx`). It looks like one slot for both ends of a GPU event; no public method takes a bool first. With 55 at +4 and 61 at +2, the two slots the console lacks are among 56–60 |
567| 61 (`+0x1e8`) | **59** | `ExecuteIndirect` | `(signature, 1, argument buffer, offset, null, 0)` at `0x59a0` | 600| 61 (`+0x1e8`) | **59** | `ExecuteIndirect` | `(signature, 1, argument buffer, offset, null, 0)` at `0x59a0` |
601| 71 (`+0x238`) | — | console only | `Write32BitValueBottomOfPipeX(address, u32 value, flush, flags)`: the 32-bit value, written into the title's memory once the list's work has run (the list values, [d3d12_xs_console_abi.md §5.5](d3d12_xs_console_abi.md)) |
602| 72 (`+0x240`) | — | console only | `Write64BitValueBottomOfPipeX(address, u64 value, flush, flags)`: the 64-bit value; flags 1 ask for a GPU timestamp and 2 for a system timestamp instead of the value the call carried |
603| 73 (`+0x248`) | — | console only | `Wait32BitValueX`: a wait on the 32-bit value; the list values hold the queue until it compares true or times out (§5.5 there) |
604| 74 (`+0x250`) | — | console only | `Wait64BitValueX`: the same on the 64-bit value |
568| 85 (`+0x2a8`) | — | `CopyTextureRegion` shape (inferred) | run: `(stack pointer, 0, 0)`, twice per dispatch. Statically six arguments, `(&dst, 0, 0, 0, &src, null)`: the public `CopyTextureRegion` (PC 16) with two `D3D12_TEXTURE_COPY_LOCATION`s, not one pointer. At `0x7147` dst is `{texture, SUBRESOURCE_INDEX, 0}` and src `{buffer, PLACED_FOOTPRINT, footprint}`, the footprint from device slot 38 (`GetCopyableFootprints`, `0x708b`); at `0x7191` both are subresource 0 (texture to texture). The caller also clears the next stack argument (`0x70e7`); whether the method takes a seventh is open, as is what console slot 16 is | 605| 85 (`+0x2a8`) | — | `CopyTextureRegion` shape (inferred) | run: `(stack pointer, 0, 0)`, twice per dispatch. Statically six arguments, `(&dst, 0, 0, 0, &src, null)`: the public `CopyTextureRegion` (PC 16) with two `D3D12_TEXTURE_COPY_LOCATION`s, not one pointer. At `0x7147` dst is `{texture, SUBRESOURCE_INDEX, 0}` and src `{buffer, PLACED_FOOTPRINT, footprint}`, the footprint from device slot 38 (`GetCopyableFootprints`, `0x708b`); at `0x7191` both are subresource 0 (texture to texture). The caller also clears the next stack argument (`0x70e7`); whether the method takes a seventh is open, as is what console slot 16 is |
569| 141 (`+0x468`) | — | console only | `(2, GPU VA, size, n)` at `0x65f8`: binds a buffer the DLL names `FFX_XBox_ComputeScratch`; `n` is the bound pipeline's scratch value from pipeline slot 11 (see above) | 606| 141 (`+0x468`) | — | console only | `(2, GPU VA, size, n)` at `0x65f8`: binds a buffer the DLL names `FFX_XBox_ComputeScratch`; `n` is the bound pipeline's scratch value from pipeline slot 11 (see above) |
570 607
@@ -573,6 +610,20 @@ So the console list has four more methods than the PC list between `ResourceBarr
573Mapping the console list as "PC plus a constant" is wrong. The BVH builder adds 37, 39, 43 and 45 (the rest of the 610Mapping the console list as "PC plus a constant" is wrong. The BVH builder adds 37, 39, 43 and 45 (the rest of the
574+4 root group) and the console-only 71, 73, 80, 146 (`Barrier`) and 148 (sections 3.3 and 3.3a). 611+4 root group) and the console-only 71, 73, 80, 146 (`Barrier`) and 148 (sections 3.3 and 3.3a).
575 612
613**The two value-write slots.** Slots 71 and 72 are the console's value writes and 73 and 74 the waits that go with
614them. The slot numbers are measured, not read: the retail title's own trace calls slot 71 with a title address and
615a value, slot 72 with a title address and the flags word and slot 74 with a wait's arguments, and the value writes
616are at 71/72 rather than at 69/70; and `XboxBvhBuilder.dll` reads a 32-bit value write at `+0x238` (slot 71) and a masked wait at `+0x248`
617(slot 73). The call shapes are xcl's (crates/xcl/src/hle/d3d12x/list_x.rs, GPL-2.0) and the deferred
618bottom-of-pipe write model is VIctory's (crates/victory-gpu/src/list.rs, GPL-3.0): the write is not a GPU command,
619it is a CPU write into the title's memory, made after the submission that recorded it has run. Both projects are
620cited for facts and for the model only, no code copied. The runtime has two writers for them, one per list: the list
621values (`runtime/shims/d3d12_xs_list_values.h`, on by default) for the lists they track, with the waits of slots 73
622and 74; and the GPU-label path (`runtime/src/vulkan_gpu_labels.h`, `LEONIDA_GPU_LABELS=1`) for the others. Both
623land a write whose address is a GPU address arena offset in the arena, never at that number in host memory, and one
624on a page of xmem's that the title's view keeps `PAGE_NOACCESS` through xmem's own mapping of the physical page
625(`runtime/src/value_write_sink.h`).
626
576**The list object is wider than its vtable, and this is what that width is for.** Before a root-argument or dispatch 627**The list object is wider than its vtable, and this is what that width is for.** Before a root-argument or dispatch
577call the DLL checks a write cursor at `+0x18` against a limit (`+0x30` for root arguments, `+0x28` for a dispatch). While there is room, 628call the DLL checks a write cursor at `+0x18` against a limit (`+0x30` for root arguments, `+0x28` for a dispatch). While there is room,
578it writes the command into that buffer itself instead of calling: a root argument is a header word from the 629it writes the command into that buffer itself instead of calling: a root argument is a header word from the
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md
index e23985ecb..6b5820c02 100644
--- a/docs/d3d12_vulkan.md
+++ b/docs/d3d12_vulkan.md
@@ -337,16 +337,17 @@ What is implemented (all of it testable without the game):
337- **UAV clears** (`ClearUnorderedAccessViewUint` / `ClearUnorderedAccessViewFloat`). The CPU handle's slot is read 337- **UAV clears** (`ClearUnorderedAccessViewUint` / `ClearUnorderedAccessViewFloat`). The CPU handle's slot is read
338 while recording as the GFX10 descriptor a shader would load (section 3.4), so the clear works with any 338 while recording as the GFX10 descriptor a shader would load (section 3.4), so the clear works with any
339 view-creation code that writes them and with descriptors the game builds itself; the GPU handle is not needed. 339 view-creation code that writes them and with descriptors the game builds itself; the GPU handle is not needed.
340 A T# gives the view's format (FORMAT plus DST_SEL, which tells BGRA from RGBA), mip and layers; a 3D view clears 340 A T# gives the view's format (FORMAT plus DST_SEL, which tells BGRA from RGBA), mip and layers. A tagged 3D
341 every slice of its mip. A V# gives a byte range: its address minus the resource's `GetGPUVirtualAddress`, and 341 UAV selects `FirstWSlice` and `WSize`. An untagged 3D T# covers every slice of the bound resource's selected
342 mip. A V# gives a byte range: its address minus the resource's `GetGPUVirtualAddress`, and
342 NUM_RECORDS bytes (stride 0, no format: raw), records (a stride: structured) or elements (a format: typed). A view 343 NUM_RECORDS bytes (stride 0, no format: raw), records (a stride: structured) or elements (a format: typed). A view
343 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.
344 - 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
345 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
346 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
347 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
348 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
349 hand-computed elements in `d3d12_uav_clear_test`. 350 result is defined. These are checked against hand-computed elements in `d3d12_uav_clear_test`.
350 - 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
351 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
352 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
@@ -366,16 +367,18 @@ What is implemented (all of it testable without the game):
366 - Textures: the values become one element of the view's format, and that element is cleared into the image as 367 - Textures: the values become one element of the view's format, and that element is cleared into the image as
367 the value that decodes it in the image's own format, so a typeless texture viewed as UINT gets exactly the bits 368 the value that decodes it in the image's own format, so a typeless texture viewed as UINT gets exactly the bits
368 asked for. Exact for every typed-UAV format except the SNORM pattern `0x80..` (Vulkan writes -1.0 as `0x81..`) 369 asked for. Exact for every typed-UAV format except the SNORM pattern `0x80..` (Vulkan writes -1.0 as `0x81..`)
369 and NaN payloads. A whole view is `vkCmdClearColorImage`; rectangles are `vkCmdClearAttachments` in a 370 and NaN payloads on the Vulkan color-clear paths. A whole, matching-format 3D mip uses `vkCmdClearColorImage`.
370 dynamic-rendering scope, so a texture created with `ALLOW_UNORDERED_ACCESS` also gets `COLOR_ATTACHMENT` usage 371 Direct lists can use `vkCmdClearAttachments` for rectangles on attachment-capable 1D/2D images.
371 when its format supports it. Both run in place in `GENERAL`, the UAV layout. Rectangle clears of volumes, or of 372 Unpredicated partial 3D W ranges (`FirstWSlice`/`WSize`) and 3D XY rectangles use the same transfer path
372 formats without attachment support, are refused as `unsupported`. 373 on direct and compute lists. It encodes the clear value in the view format, fills up to 64 KiB of scratch,
374 and copies tiles one Z slice at a time in `GENERAL`. This requires matching view and backing formats, with
375 the existing exception for emulated `R9G9B9E5` on `R32_UINT`.
373 - The clear is fenced as the UAV state widened to transfers, so a following UAV barrier, transition, or enhanced 376 - The clear is fenced as the UAV state widened to transfers, so a following UAV barrier, transition, or enhanced
374 barrier from `SYNC_CLEAR_UNORDERED_ACCESS_VIEW` sees it. 377 barrier from `SYNC_CLEAR_UNORDERED_ACCESS_VIEW` sees it.
375 - Under `SetPredication`, a whole-view texture clear runs as one rectangle through the attachment path, as 378 - Under `SetPredication`, a direct list clears an attachment-capable 1D/2D UAV through its attachment view.
376 render-target clears do, so conditional rendering applies. Buffer clears, and texture clears that cannot use an 379 A whole view becomes one rectangle so conditional rendering applies. Buffer clears and the direct-list
377 attachment, are transfers that conditional rendering does not cover; they run unconditionally and are counted 380 whole-mip transfer fallback run unconditionally and count toward `unpredicated_copies`. Direct and compute
378 with the copies (`unpredicated_copies`). 381 lists refuse predicated partial-W or rectangular 3D clears before submission.
379- **Layout tracking** (`LayoutTracker`): the current Vulkan layout of every image subresource, so barriers start 382- **Layout tracking** (`LayoutTracker`): the current Vulkan layout of every image subresource, so barriers start
380 from the real layout instead of the application's `before`. This is how implicit promotion and decay work: a 383 from the real layout instead of the application's `before`. This is how implicit promotion and decay work: a
381 texture in `COMMON` sits in `GENERAL`, which every promotable access can use, so a later barrier naming the 384 texture in `COMMON` sits in `GENERAL`, which every promotable access can use, so a later barrier naming the
@@ -484,6 +487,13 @@ What is implemented (all of it testable without the game):
484 `E_INVALIDARG` for such a render target, since no other format can view its image. Without that format, 487 `E_INVALIDARG` for such a render target, since no other format can view its image. Without that format,
485 render targets are refused as before; depth-stencil and UAV creation are 488 render targets are refused as before; depth-stencil and UAV creation are
486 unsupported for this format. 489 unsupported for this format.
490 - A `CopyTextureRegion` of the depth plane between two depth formats with the same depth encoding but not the
491 same `VkFormat` (`D32_SFLOAT_S8_UINT` and `D32_SFLOAT`, `D16_UNORM_S8_UINT` and `D16_UNORM`,
492 `D24_UNORM_S8_UINT` and `X8_D24_UNORM_PACK32`) goes image → transfer scratch → image too, depth aspect on both
493 sides (`vulkan_replay.h`, `depth_format_pair`; `replay_copy_offset_test`). `vkCmdCopyImage` requires
494 depth/stencil formats to match exactly (`VUID-vkCmdCopyImage-srcImage-01548`), and an NVIDIA driver (RTX 4070
495 Laptop, 621.40) handed the `D32_SFLOAT_S8_UINT` → `D32_SFLOAT` pair wrote past the end of the `D32_SFLOAT`
496 image: the world-start `WRITE_INVALID` device loss, with the fault at the first byte after the image.
487 - reserved resources and `GetResourceTiling` (section 4.2); 497 - reserved resources and `GetResourceTiling` (section 4.2);
488 - query heaps for occlusion, timestamps and pipeline statistics, and `GetTimestampFrequency` on the queue 498 - query heaps for occlusion, timestamps and pipeline statistics, and `GetTimestampFrequency` on the queue
489 (section 4.6); 499 (section 4.6);
@@ -500,8 +510,36 @@ What is implemented (all of it testable without the game):
500 and the initial state or `D3D12_BARRIER_LAYOUT` is not used, because new textures start `UNDEFINED` and move 510 and the initial state or `D3D12_BARRIER_LAYOUT` is not used, because new textures start `UNDEFINED` and move
501 on first use. The newer arguments are answered as the PC runtime answers them. `d3d12_method_variants_test` 511 on first use. The newer arguments are answered as the PC runtime answers them. `d3d12_method_variants_test`
502 compares each answer below with the host runtime live, measured on an RTX 4090 (driver 621.14): 512 compares each answer below with the host runtime live, measured on an RTX 4090 (driver 621.14):
503 - `CreateCommandSignature` (`ID3D12CommandSignature`) and `ID3D12GraphicsCommandList::ExecuteIndirect` (including 513 - `CreateCommandSignature` and `ExecuteIndirect`: a signature consisting of a single DRAW or DRAW_INDEXED
504 GPU-written `CountBuffer` via Vulkan 1.2 core `vkCmdDrawIndirectCount` / `vkCmdDrawIndexedIndirectCount`). 514 operation inherits the graphics state of its command list. The Vulkan replay snapshots the same pipeline, root
515 data, render targets, IA bindings and raster state as a direct draw, then reads the records on the GPU inside
516 that draw's rendering scope. A padded stride is supported; it is not evidence that a signature is simple.
517 A compound graphics signature still emits no draw, but its written VB/IB and root bindings are reset for the
518 next command, even if no record is interpreted. Untouched slots and previously recorded draws retain their state.
519 See the [D3D12 state-leakage contract](https://microsoft.github.io/DirectX-Specs/d3d/IndirectDrawing.html#state-leakage).
520 Fixed- and GPU-counted batches use the device's enabled indirect features and limits. The current graphics
521 path covers triangle lists on direct command lists. A bundle can defer a single operation with no count
522 buffer: its argument-buffer identity and byte offset are recorded once; each `ExecuteBundle` captures the
523 direct parent's state at that call. Count buffers and compound signatures remain invalid in bundles.
524 `d3d12_bundle_indirect_warp` and `d3d12_bundle_indirect_layer` compare DRAW and DRAW_INDEXED against direct
525 pixels with two different parent bindings; the layer fixture also checks marker order and captured views.
526 Compound graphics signatures, non-unit instance divisors
527 and unsupported capabilities stay guarded. A GPU-counted draw currently requires
528 `maxDrawIndirectCount == UINT32_MAX`: Vulkan also limits the raw counter value, not just the caller's maximum.
529 To omit indirect graphics without changing direct drawing or compute, set
530 `LEONIDA_INDIRECT_DRAWS=off` before starting the process. This applies to the Vulkan-backed D3D12
531 command list, including ordinary bundle draws when replayed on a parent. Validation and compound
532 root/IA resets still happen. Only exact lowercase `off` disables drawing; unset, empty, and other
533 values (including the old `raw` spelling) retain the normal capability-checked path. There is no
534 bare draw mode. The former `raw` setting logs an obsolescence notice on first policy use.
535 Each skip reason logs once. Progress lines give cumulative recorded commands, Vulkan emissions,
536 recording skips and replay skips. Replaying a command list can emit a recorded command more than once.
537 By default, a GPU pass bounds draw vertex/index and instance counts, dispatch group counts, and total
538 work across each command list (2^27 units). Unfilled all-ones records produce zero work and spend no budget.
539 Cumulative observed clamp and zero counts are reported every 60 presented frames. Counted calls read at most MaxCommandCount records. The stateful draw or dispatch reads
540 private scratch. Exhausting the diagnostic counter slots only disables readback of those counters.
541 `LEONIDA_INDIRECT_CLAMP=0` disables this pass. `LEONIDA_INDIRECT_GROUP_BUDGET=N` further bounds each
542 indirect dispatch, preserving X first, then Y and Z (1–65535 groups). It also works with the clamp disabled.
505 - Optional `VK_KHR_acceleration_structure` + `VK_KHR_deferred_host_operations` + `VK_KHR_ray_query`: 543 - Optional `VK_KHR_acceleration_structure` + `VK_KHR_deferred_host_operations` + `VK_KHR_ray_query`:
506 `ID3D12Device5::GetRaytracingAccelerationStructurePrebuildInfo`, `ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure` 544 `ID3D12Device5::GetRaytracingAccelerationStructurePrebuildInfo`, `ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure`
507 (BLAS + TLAS), `vkGetBufferDeviceAddress` in `ID3D12Resource::GetGPUVirtualAddress()`, and RT-aware `UAV` 545 (BLAS + TLAS), `vkGetBufferDeviceAddress` in `ID3D12Resource::GetGPUVirtualAddress()`, and RT-aware `UAV`
@@ -674,7 +712,16 @@ side inwards:
674 storage view gets an index the storage arrays hold, and a read-only one goes above where there is room. 712 storage view gets an index the storage arrays hold, and a read-only one goes above where there is room.
675 Index 0 is reserved, so 256 descriptors hold 255 live views in each 1D-array storage binding. 713 Index 0 is reserved, so 256 descriptors hold 255 live views in each 1D-array storage binding.
676 - Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest clamping sampler), because a miss is 714 - Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest clamping sampler), because a miss is
677 index 0. 715 index 0. It stands for a null descriptor (a zero T#, an empty heap slot, a view the layer refused) and is of
716 the kind the instruction asks for: the translator picks the binding by the instruction's dimension (a cube
717 reads the 2D-array binding) and the view by the T#'s class, so each dimension and class reads zeros. The
718 storage arrays' fallbacks never share an image with the sampled ones, so a store or atomic through a null
719 UAV cannot show in a later read through a null SRV. Where the device has `VK_EXT_robustness2`'s
720 `nullDescriptor` (`VulkanDeviceInfo::null_descriptor`, enabled alone) they are null descriptors, and the
721 store or atomic is dropped and a load reads zero, as on the console; without it they are 1x1 images of their
722 own. A null V# (all zeros) needs no fallback: every access through it is out of range (`NUM_RECORDS` 0), so
723 loads give 0 and stores and atomics do nothing (`tests/semantic/test_null_vsharp.py`). Checked on the GPU by
724 `vk_null_descriptor_test` (every dimension and class, both kinds of storage fallback).
678 - Changes are queued and written by `flush()`, one write a slot, so a view that is removed before the next 725 - Changes are queued and written by `flush()`, one write a slot, so a view that is removed before the next
679 flush is never written. 726 flush is never written.
680 - `flush()` also uploads the table to its buffer: device-local memory, written from a mapped staging copy when 727 - `flush()` also uploads the table to its buffer: device-local memory, written from a mapped staging copy when
@@ -835,6 +882,17 @@ The compute path, end to end:
835 `LEONIDA_ARENA_LOG=1` also logs one line per VA handed out, per refused allocation, and per upload or readback 882 `LEONIDA_ARENA_LOG=1` also logs one line per VA handed out, per refused allocation, and per upload or readback
836 buffer VA outside the arena. 883 buffer VA outside the arena.
837 - Default-heap buffers are 64 KiB-aligned ranges in it, zeroed through its mapping; their console VA is the offset. 884 - Default-heap buffers are 64 KiB-aligned ranges in it, zeroed through its mapping; their console VA is the offset.
885 - Every access to its free-block map is under the arena's mutex, and a walk holds no iterator across a call
886 (`runtime/src/arena_blocks.h`): each step reads a block's offset and size, lets its iterator go, looks the next
887 block up from the map again, and re-finds a candidate by offset before it cuts it. A map access outside the lock
888 makes a concurrent walk step into a node an insert rebalanced away or a release freed — measured once: an access
889 violation reading the nil flag of a null map child at 0x19, inside `arena_allocate` for a slot-133 shadow buffer
890 (the arena's first block used to be inserted by `create_arena` with no lock, and an insert rewrites child links).
891 The arena checks `free + live == size - reserved` on every allocation and release (O(1)) and walks the whole
892 block map only when that fails or `LEONIDA_ARENA_CHECK=1` is set; a `double_free` or a release of a range past
893 the arena (`outside_arena`) is reported instead of being let into the map, and those lines are rate-limited to
894 one per 5 s. `arena_blocks_test` (CPU) covers first fit, coalescing, a title keep-out, the walk cut under it, the
895 bad releases and one lock with many threads.
838 - Shader-visible descriptor heaps also live in it: the CPU handle is its host mapping and the GPU handle is the VA, 896 - Shader-visible descriptor heaps also live in it: the CPU handle is its host mapping and the GPU handle is the VA,
839 so descriptor bytes the application writes itself are what shaders load. 897 so descriptor bytes the application writes itself are what shaders load.
840 - Upload and readback buffers keep their own memory, and their VA is their device address minus the heap base. 898 - Upload and readback buffers keep their own memory, and their VA is their device address minus the heap base.
@@ -1221,8 +1279,12 @@ and any validation error fails them.
1221 `IDXGIFactory4::CreateSwapChainForHwnd`, `IDXGISwapChain3::GetCurrentBackBufferIndex`, `GetBuffer` + `GetDesc()`, 1279 `IDXGIFactory4::CreateSwapChainForHwnd`, `IDXGISwapChain3::GetCurrentBackBufferIndex`, `GetBuffer` + `GetDesc()`,
1222 backbuffer `CreateRenderTargetView` + clear + readback verification + `Present`, and `ResizeBuffers` with 0 1280 backbuffer `CreateRenderTargetView` + clear + readback verification + `Present`, and `ResizeBuffers` with 0
1223 validation errors. 1281 validation errors.
1224- `d3d12_indirect_rt_test`: validates `ID3D12Device::CreateCommandSignature` + `ExecuteIndirect` with a GPU 1282- `d3d12_stateful_indirect_pixels`, `d3d12_stateful_indirect_multi_pixels` and
1225 `CountBuffer` (`vkCmdDrawIndirectCount`, `count = 0` skipped and `count = 1` rendered) and optional 1283 `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
1285 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,
1287 count 1 renders), a D3D12 command-signature creation check, and optional
1226 `VK_KHR_acceleration_structure` + `VK_KHR_ray_query` (`GetRaytracingAccelerationStructurePrebuildInfo`, BLAS + TLAS 1288 `VK_KHR_acceleration_structure` + `VK_KHR_ray_query` (`GetRaytracingAccelerationStructurePrebuildInfo`, BLAS + TLAS
1227 `BuildRaytracingAccelerationStructure`, and a `RayQueryKHR` compute shader verifying hit vs. miss; clean SKIP on 1289 `BuildRaytracingAccelerationStructure`, and a `RayQueryKHR` compute shader verifying hit vs. miss; clean SKIP on
1228 GPUs without RT). 1290 GPUs without RT).
@@ -1621,6 +1683,18 @@ The copies:
1621 cannot fit between the title's address reservations can use a separate mapped buffer. The buffer's device address 1683 cannot fit between the title's address reservations can use a separate mapped buffer. The buffer's device address
1622 must fit as a positive 47-bit offset from the arena base. The same window cap and dirty-page refresh apply. 1684 must fit as a positive 47-bit offset from the arena base. The same window cap and dirty-page refresh apply.
1623 `LEONIDA_STREAM_BUFFER_WINDOWS=0` requires the window to fit in the arena. 1685 `LEONIDA_STREAM_BUFFER_WINDOWS=0` requires the window to fit in the arena.
1686- A **window that is refused** (the budget is spent, the arena is full, or the pages are not committed yet) is backed
1687 by a persistent geometry copy of exactly the requested range (`LEONIDA_GEOMETRY_MB`) instead; when no copy can be
1688 made either, the view is written with **no base and no records** — loads return 0 and stores are dropped. A raw
1689 title address is never left in a V# or a root view: `heap_base + a raw VA` is not an allocation, and a store there
1690 loses the device. The refusal and the count of zero-size views are logged.
1691- A **stream pool** (the title's CPU view paired with a 16-24 GiB GPU-only
1692 alias) is not windowed per request. The GPU-only pages are translated to the CPU view of the same frames (rule B in
1693 that note), and **one mapping serves a page-aligned readable run** of the pool (at most 1 MiB, a geometry copy when
1694 the cap allows, a window otherwise). Both addresses of the pair are entered in the table, so a V# naming either
1695 reaches that one mapping instead of asking for a second one; `LEONIDA_GEOMETRY_MB` is the preferred backing.
1696 Acceleration-structure destinations and scratch also resolve through the table, and a structure no window holds
1697 whole gets a copy of its whole range, so the BVH builder's commands are recorded.
1624- `LEONIDA_GEOMETRY_MB` sets the device-local memory cap for streamed buffer views. The default is 0. 1698- `LEONIDA_GEOMETRY_MB` sets the device-local memory cap for streamed buffer views. The default is 0.
1625 A positive cap enables persistent copies of placed buffer SRVs and buffer descriptors in title memory. 1699 A positive cap enables persistent copies of placed buffer SRVs and buffer descriptors in title memory.
1626 A GPU-only reservation uses its paired CPU mapping. Matching source ranges share one copy. 1700 A GPU-only reservation uses its paired CPU mapping. Matching source ranges share one copy.
@@ -1679,6 +1753,15 @@ The runtime allocates image keys from `0x100000000` (4 GiB) in 256-byte steps, a
1679 heap of 256 MiB or less (214 MiB on an RTX 3090 with driver 616.56), so the 256 MiB default arena lands in 1753 heap of 256 MiB or less (214 MiB on an RTX 3090 with driver 616.56), so the 256 MiB default arena lands in
1680 system memory there. Asking that heap for it broke VUID-vkAllocateMemory-pAllocateInfo-01713 even though the 1754 system memory there. Asking that heap for it broke VUID-vkAllocateMemory-pAllocateInfo-01713 even though the
1681 driver returned `VK_SUCCESS` (reported by CharlyRien). 1755 driver returned `VK_SUCCESS` (reported by CharlyRien).
1756 - With Resizable BAR a driver can still leave the `DEVICE_LOCAL | HOST_VISIBLE` type out of a large buffer's
1757 `memoryTypeBits`. On an RTX 5070 Ti (NVIDIA 617.42, Windows 11) an arena-shaped buffer of 4,090 MiB may use
1758 it and one of 4,092 MiB may not, so `LEONIDA_ARENA_MB=4096` (4,095 MiB) put the whole arena in system memory.
1759 `create_arena` tries smaller sizes in 16 MiB steps, by at most an eighth, and keeps the largest whose
1760 requirements allow that type and fit its heap. Placing the arena in ReBAR does not guarantee a reduction in
1761 host commit. An [RTX 4080 comparison](https://github.com/ubiquitarianism/leonida/pull/1732#issuecomment-7159574385)
1762 confirmed ReBAR placement and measured higher process private bytes. The runtime logs the size cap:
1763 `GPU address arena: 4080 MiB of the 4095 MiB asked for, capped by the device's Resizable BAR memory types`.
1764 Without Resizable BAR nothing changes.
1682- M4+: allocate the arena `DEVICE_LOCAL` and stage CPU writes (descriptor heaps, shader blobs, buffer uploads) 1765- M4+: allocate the arena `DEVICE_LOCAL` and stage CPU writes (descriptor heaps, shader blobs, buffer uploads)
1683 through a host-visible staging buffer, copied before the commands that use them. The hash table is not in the 1766 through a host-visible staging buffer, copied before the commands that use them. The hash table is not in the
1684 arena either: it is a normal storage buffer in `DEVICE_LOCAL` memory, uploaded from a mapped staging copy before 1767 arena either: it is a normal storage buffer in `DEVICE_LOCAL` memory, uploaded from a mapped staging copy before
@@ -1769,11 +1852,18 @@ The game can use D3D12 descriptors in three ways, and the layer must handle all
1769 and mesh from s16 (issue #14, comment 7143020922, on a `boot-prototype` run; not reproduced in this 1852 and mesh from s16 (issue #14, comment 7143020922, on a `boot-prototype` run; not reproduced in this
1770 repository). A mesh signature that fills the window leaves no room there: a heap past s31 of the mesh shader 1853 repository). A mesh signature that fills the window leaves no room there: a heap past s31 of the mesh shader
1771 (push dword 24 or later) is logged once. A signature that keeps the s0 graphics layout, or whose arguments fill 1854 (push dword 24 or later) is logged once. A signature that keeps the s0 graphics layout, or whose arguments fill
1772 s31, gets none (logged once). `d3d12_graphics_direct_heaps_test` checks the recorded draws and what a vertex 1855 s31, gets none (logged once). `d3d12_graphics_direct_heaps_test` checks the recorded draws and reads back
1773 and a pixel shader read, with and without the flags; `d3d12_mesh_test` checks that a mesh draw records the 1856 what vertex and pixel shaders saw with and without the flags. On a mesh-capable device it also checks the
1774 vertex draw's dwords, a resource-only rebind, a signature ending at s30 and one on the s0 layout (recorded 1857 heap pointers read by the mesh and pixel stages after a rebind. `d3d12_mesh_test` checks the recorded dwords
1775 arguments only; no GPU read through a mesh shader). Set `LEONIDA_GRAPHICS_DIRECT_HEAPS=0` to restore the 1858 for a vertex draw, a resource-only rebind, a signature ending at s30 and one on the s0 layout.
1776 previous draw arguments. 1859 Set `LEONIDA_GRAPHICS_DIRECT_HEAPS=0` to restore the previous draw arguments.
1860 Missing console V# backing leaves a settled zero descriptor. Every 32 submissions a heap probes up to
1861 eight of these slots in round-robin order, including independent UAV-counter failures.
1862 Console resource heap copies and shader-visible CBV/SRV/UAV heaps with at least 65,536 slots request
1863 64 MiB of zeroed padding after their last descriptor. `LEONIDA_HEAP_GUARD_MB` sets the padding in MiB
1864 (0 disables it). When arena space is tight, allocation can fall back to the heap alone. Only indices
1865 inside the reserved padding read null slots. Console slots containing data instead of a recognized image
1866 or buffer descriptor have their first 16 bytes cleared in the GPU copy. The title keeps its original bytes.
17773. **Game-built descriptor memory.** The game writes raw T#/S# bytes into a heap itself, without calling 18673. **Game-built descriptor memory.** The game writes raw T#/S# bytes into a heap itself, without calling
1778 `CreateShaderResourceView`. The shaders then read those bytes exactly as in case 1. 1868 `CreateShaderResourceView`. The shaders then read those bytes exactly as in case 1.
1779 1869
@@ -1873,8 +1963,8 @@ The layer's descriptor model:
1873 The emulated RGB9E5 raw `R32_UINT` storage view is formatted and is exempt. Vulkan 1.3 permits these SPIR-V 1963 The emulated RGB9E5 raw `R32_UINT` storage view is formatted and is exempt. Vulkan 1.3 permits these SPIR-V
1874 capabilities even without the legacy `shaderStorageImage{Read,Write}WithoutFormat` feature bits. The 1964 capabilities even without the legacy `shaderStorageImage{Read,Write}WithoutFormat` feature bits. The
1875 caller-owned device test leaves both legacy bits off and masks each per-format bit to verify safe rejection. 1965 caller-owned device test leaves both legacy bits off and masks each per-format bit to verify safe rejection.
1876 `ClearUnorderedAccessView*` refuses partial W ranges and 1D/3D format reinterprets: the transfer clear 1966 `ClearUnorderedAccessView*` reads the W range from these descriptor bytes even after a descriptor copy.
1877 cannot target a slice interval or guarantee preserving the reinterpreted bits. 1967 General 1D/3D backing-format reinterpretation remains unsupported.
1878 Shader access to the new UAVs requires `robustImageAccess` (whole-mip CPU clears do not). 1968 Shader access to the new UAVs requires `robustImageAccess` (whole-mip CPU clears do not).
1879 A separate native D3D12 probe on the RTX 4090 and UHD 770 clipped typed writes to the view's W range. 1969 A separate native D3D12 probe on the RTX 4090 and UHD 770 clipped typed writes to the view's W range.
1880 WARP 10.0.26100.9818 rebased the view but did not clip writes past a finite `WSize` in that probe. The 1970 WARP 10.0.26100.9818 rebased the view but did not clip writes past a finite `WSize` in that probe. The
@@ -2282,7 +2372,12 @@ Pipeline creation:
2282 and pipeline-cache UUID. When the file is absent or incompatible, the runtime starts with an empty cache. 2372 and pipeline-cache UUID. When the file is absent or incompatible, the runtime starts with an empty cache.
2283 The offline checker matches the runtime's layout and subgroup request for compute shaders with no descriptor 2373 The offline checker matches the runtime's layout and subgroup request for compute shaders with no descriptor
2284 bindings and the standard 144-byte push-constant range. 2374 bindings and the standard 144-byte push-constant range.
2285 The runtime writes its own `pipeline_cache.session.bin` on device teardown. A compatible session file 2375 The runtime writes its own `pipeline_cache.session.bin` on device teardown, and, since a title never releases its
2376 device, when `gta6rt` ends with the device alive: at the run's exit, at a console close and from an
2377 unhandled-exception filter (a fault in the title or its DLLs, the int3 after a device loss). The title's own
2378 `SetUnhandledExceptionFilter` is served by the runtime, which keeps its filter first and passes the exception on.
2379 That exit write (`save_pipeline_caches_at_exit`, `shims/d3d12_compile_exit.h`) waits 1 s for a build still running
2380 on a title thread, then writes the pipelines finished so far, with 3 s for the write itself. A compatible session file
2286 initializes the live cache directly if there is no offline seed. With both files present the session cache 2381 initializes the live cache directly if there is no offline seed. With both files present the session cache
2287 merges into the offline seed. `LEONIDA_DIRECT_SESSION_CACHE=0` also uses a merge when only the session exists. 2382 merges into the offline seed. `LEONIDA_DIRECT_SESSION_CACHE=0` also uses a merge when only the session exists.
2288 The files must match the Vulkan vendor, device and pipeline-cache UUID. Vulkan supplies an opaque snapshot. 2383 The files must match the Vulkan vendor, device and pipeline-cache UUID. Vulkan supplies an opaque snapshot.
@@ -2303,6 +2398,14 @@ Pipeline creation:
2303 Replay skips a draw or dispatch while its pipeline is pending. Later uses find the completed handle. 2398 Replay skips a draw or dispatch while its pipeline is pending. Later uses find the completed handle.
2304 A skipped dispatch can lose a one-time resource update. Synchronous first use is the default and strict 2399 A skipped dispatch can lose a one-time resource update. Synchronous first use is the default and strict
2305 replay always uses it. `LEONIDA_COMPUTE_WARMUP=0` restricts the worker to pipelines requested by the title. 2400 replay always uses it. `LEONIDA_COMPUTE_WARMUP=0` restricts the worker to pipelines requested by the title.
2401 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
2403 worker deletes the PSO after it (`PipelineState::last_release`). The PSO's device reference goes at the release, so
2404 the release that tears the device down waits for that build, drops the device's cache checkpoint, and the last
2405 device stops and joins the worker before any Vulkan object goes; the session cache is written after that. gta6rt,
2406 which ends with the device alive, drops the queue and waits up to 2 s for a running build before `ExitProcess` and on
2407 a console Ctrl+C, Ctrl+Break or close; after that nothing is queued, and a first use builds in place
2408 (`d3d12_compile_teardown_test`).
2306 `GetCachedBlob` records the vendor, device, driver version, `pipelineCacheUUID` and a SHA-256 of the description 2409 `GetCachedBlob` records the vendor, device, driver version, `pipelineCacheUUID` and a SHA-256 of the description
2307 without `Flags`, sealed by a checksum (`runtime/src/cached_pso.h`). The answers are the host's, measured on an 2410 without `Flags`, sealed by a checksum (`runtime/src/cached_pso.h`). The answers are the host's, measured on an
2308 RTX 3060 and WARP: the same description is accepted; another 2411 RTX 3060 and WARP: the same description is accepted; another
@@ -2326,6 +2429,26 @@ Pipeline creation:
2326 serialized size and bytes are each device's own (the host's empty library is 900 bytes, the layer's 16). 2429 serialized size and bytes are each device's own (the host's empty library is 900 bytes, the layer's 16).
2327 - Not compared: the calls the host runtime faults on (`Serialize(nullptr, n)`, `StorePipeline` with a null PSO, 2430 - Not compared: the calls the host runtime faults on (`Serialize(nullptr, n)`, `StorePipeline` with a null PSO,
2328 `Load*` with a null name or description); the layer answers `E_INVALIDARG` for each. 2431 `Load*` with a null name or description); the layer answers `E_INVALIDARG` for each.
2432- Compiles at draw time: the first draw of a graphics pipeline, the first dispatch of a compute pipeline the warm-up
2433 has not built, and each variant are compiled for the submission that needs them. `prepare()` leaves each one that is
2434 not built yet to `PipelineCompiles`, once per pipeline and variant; `VulkanQueue::execute_now` then compiles them
2435 side by side on the device's workers (`runtime/src/pipeline_workers.h`), the submitting thread among them, and writes
2436 the command buffer when all are built. Every draw and dispatch has its own pipeline: none is left to a later frame. A
2437 pipeline the driver refuses has the result it had when `prepare()` built it: a draw or an indirect dispatch fails the
2438 submission, a dispatch is dropped (strict replay: fails it too). The resource lock is held while they compile, as it
2439 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
2441 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`),
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
2446 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
2448 variants 124 to 130 instead of 856 to 863, of 96 compute pipelines 74 to 81 instead of 486 to 519, and the process
2449 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
2451 `d3d12_pipeline_workers`.
2329 2452
2330**Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear. 2453**Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear.
2331The trace will enumerate them. 2454The trace will enumerate them.
@@ -2784,11 +2907,20 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv
2784 allocations. `LEONIDA_TITLE_IMAGE_POOL=0` selects individual allocation for every image. With 2907 allocations. `LEONIDA_TITLE_IMAGE_POOL=0` selects individual allocation for every image. With
2785 `LEONIDA_MEM_PROBE` enabled, the texture census also reports logical Vulkan backing bytes for the registered 2908 `LEONIDA_MEM_PROBE` enabled, the texture census also reports logical Vulkan backing bytes for the registered
2786 slot-70 and slot-133 images and the portion on non-device-local types. 2909 slot-70 and slot-133 images and the portion on non-device-local types.
2910- A refresh pass visits a snapshot of the title-image registry, taken under its mutex, instead of walking the
2911 registry itself. Filling a texture can submit, a submission destroys a retired image, and that image's destructor
2912 erases its registry entry. Windows' mutex is recursive for its owner, so the erase lands inside the pass, and a walk
2913 over the map itself would step into a freed node (measured: an access violation reading the nil flag of a null
2914 child, 0x19, in `Device::refresh_title_textures`). The snapshot also holds a reference to each entry, so an entry
2915 retired during the pass is still alive when its turn comes.
2787- Sampled title images can use device-local memory even when Vulkan host image copies require a 2916- Sampled title images can use device-local memory even when Vulkan host image copies require a
2788 host-visible memory type. The runtime queries the same image with and without host-transfer usage. 2917 host-visible memory type. The runtime queries the same image with and without host-transfer usage.
2789 When only the latter permits plain device-local backing, it detiles the complete image into a reusable 2918 When only the latter permits plain device-local backing, it detiles the complete image into a reusable
2790 staging buffer and transfers all its mips and layers together. Linear slot-133 placements retain host 2919 staging buffer and transfers all its mips and layers together. Linear slot-133 placements retain host
2791 copies. An allocation failure retries the original host-copyable image. `LEONIDA_TITLE_IMAGE_STAGING=0` 2920 copies. On a device without `VK_EXT_host_image_copy` every colour title image, linear placements too, takes the
2921 staged upload: the refresh before a submission has no other way to fill one, and without it the title's textures
2922 stayed zero (a flat green intro movie). An allocation failure retries the original host-copyable image.
2923 `LEONIDA_TITLE_IMAGE_STAGING=0`
2792 restores the original placement policy. With `LEONIDA_MEM_PROBE`, each title image class logs its 2924 restores the original placement policy. With `LEONIDA_MEM_PROBE`, each title image class logs its
2793 Vulkan memory type mask, mask without host transfer, and selected type. 2925 Vulkan memory type mask, mask without host transfer, and selected type.
2794- `WriteToSubresource`/`ReadFromSubresource` (implemented in `d3d12_vulkan_device.cpp`) complete before they 2926- `WriteToSubresource`/`ReadFromSubresource` (implemented in `d3d12_vulkan_device.cpp`) complete before they
@@ -2861,6 +2993,17 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv
2861 image when both layouts are opaque, since D3D12 leaves an alias's contents undefined until reinitialized, and is 2993 image when both layouts are opaque, since D3D12 leaves an alias's contents undefined until reinitialized, and is
2862 refused only for a non-opaque layout. Before this, the retail boot stopped on the title's assert while it created 2994 refused only for a non-opaque layout. Before this, the retail boot stopped on the title's assert while it created
2863 its D16 depth targets on an RDNA2 iGPU under RADV. A refused depth placement is logged (no trace line covers it). 2995 its D16 depth targets on an RDNA2 iGPU under RADV. A refused depth placement is logged (no trace line covers it).
2996 Where the provider (`Resource::enable_depth_stencil_uav`) has no unordered-access form of a texture it answers
2997 `E_INVALIDARG` or `E_NOTIMPL`, and slots 76 and 133 then make the texture without unordered access, as before the
2998 provider: slot 76 as a committed depth-stencil texture, slot 133 through its stand-in (the title-placed texture, or
2999 the committed one). The first such refusal per slot is logged. That is the console D16S8 format (118) on a GPU with
3000 D24S8 attachments (every NVIDIA card): `pc_format()` makes it as `D24_UNORM_S8_UINT`, which the provider does not
3001 take; a real boot stopped on an int3 after slot 133 returned that refusal. Its UAVs then write no
3002 descriptor, as for the slot 25 stand-in. Any other failure (out of memory, the backing itself, a refused placement)
3003 is passed on as before. Follow-up: teach `enable_depth_stencil_uav` the D24S8-made form of format 118 (its widened
3004 path already serves a D16S8 target stored as `D32_SFLOAT_S8_UINT`), so these textures keep their UAVs on NVIDIA
3005 too. `xs_proxy_mock` checks the refusal against a mock provider, and `xbox_d16s8_refused_uav` on a GPU with
3006 `LEONIDA_CONSOLE_D16S8=d24`.
2864- Legacy and enhanced texture transitions copy the selected planes and layers to or from their storage images. 3007- Legacy and enhanced texture transitions copy the selected planes and layers to or from their storage images.
2865 Fence-ordered graphics and compute queues can share UAV access. A dedicated compute family can perform 3008 Fence-ordered graphics and compute queues can share UAV access. A dedicated compute family can perform
2866 the plane transfer itself when `VK_KHR_maintenance10` and the format's depth/stencil copy flags allow it. 3009 the plane transfer itself when `VK_KHR_maintenance10` and the format's depth/stencil copy flags allow it.
@@ -4048,8 +4191,9 @@ struct entry { // 10 uints = 40 bytes
4048 the rebuild, at a point where no in-flight command buffer reads the old table. 4191 the rebuild, at a point where no in-flight command buffer reads the old table.
4049- Insert on `CreateShaderResourceView`, `CreateUnorderedAccessView`, `CreateSampler`, `CopyDescriptors` and heap 4192- Insert on `CreateShaderResourceView`, `CreateUnorderedAccessView`, `CreateSampler`, `CopyDescriptors` and heap
4050 scans. A duplicate key updates the index in place. 4193 scans. A duplicate key updates the index in place.
4051- Index 0 is the fallback: a 1×1 texture and a default sampler (and a valid dummy storage image for the storage 4194- Index 0 is the fallback: a 1×1 texture and a default sampler (and, for the storage arrays, a null descriptor
4052 arrays). The translator returns 0 on a miss, so index 0 must always be valid. 4195 with `VK_EXT_robustness2` `nullDescriptor` or else a storage image apart from the sampled ones). The translator
4196 returns 0 on a miss, so index 0 must always be valid.
4053- The table buffer is a normal storage buffer, not part of the arena. It can be host-visible and updated directly 4197- The table buffer is a normal storage buffer, not part of the arena. It can be host-visible and updated directly
4054 (host-coherent, or flushed before submit); if the game is sensitive to PCIe traffic, stage it like any other 4198 (host-coherent, or flushed before submit); if the game is sensitive to PCIe traffic, stage it like any other
4055 upload. The shader only reads it. 4199 upload. The shader only reads it.
diff --git a/docs/d3d12_xs_console_abi.md b/docs/d3d12_xs_console_abi.md
index e1ec05fc7..986acf680 100644
--- a/docs/d3d12_xs_console_abi.md
+++ b/docs/d3d12_xs_console_abi.md
@@ -161,6 +161,7 @@ end; on a full buffer they call the vtable method the record stands for (Package
161| 41, 43, 45 | `Set*RootDescriptor*` / table | Package + sibling layer | 161| 41, 43, 45 | `Set*RootDescriptor*` / table | Package + sibling layer |
162| 48 | `IASetVertexBuffers` | Sibling layer | 162| 48 | `IASetVertexBuffers` | Sibling layer |
163| 51 | `ClearDepthStencilView` | Sibling layer | 163| 51 | `ClearDepthStencilView` | Sibling layer |
164| 71-74 | memory writes and waits (newer layout; 69-72 older) | **Measured here**, §5.5 |
164| 80 | `ExecuteIndirect` | Sibling layer (note: the package measured slot 80 as a console-only call, a `Dispatch`-with-extra-word shape; slot assignments past 61 differ between the two sources — unconfirmed) | 165| 80 | `ExecuteIndirect` | Sibling layer (note: the package measured slot 80 as a console-only call, a `Dispatch`-with-extra-word shape; slot assignments past 61 differ between the two sources — unconfirmed) |
165| 83 | `CopyTextureRegionX` (older layout) | Sibling layer; the package measured a `CopyTextureRegion`-shaped call at slot 85 — consistent with the newer layout (+2) | 166| 83 | `CopyTextureRegionX` (older layout) | Sibling layer; the package measured a `CopyTextureRegion`-shaped call at slot 85 — consistent with the newer layout (+2) |
166| 108 | `ResolveSubresourceRegion` | Sibling layer | 167| 108 | `ResolveSubresourceRegion` | Sibling layer |
@@ -189,6 +190,88 @@ console-shaped either way.
189| 12 | `CopyTextureRegion` | Sibling layer | 190| 12 | `CopyTextureRegion` | Sibling layer |
190| 13 | `CopyResource` | Sibling layer | 191| 13 | `CopyResource` | Sibling layer |
191 192
193### 5.5 Memory writes and waits
194
195The list has bottom-of-pipe writes of a 32- or 64-bit value into title memory and waits that stop the queue until
196a 32- or 64-bit value in memory compares true against a reference. Neither has a D3D12 or Vulkan command; the
197runtime models both (`runtime/shims/d3d12_xs_list_values.h`, the list cut and `execute_with_values` in
198`d3d12_xs_device.cpp`).
199
200| Older slot | Newer slot | Method | Evidence |
201|---:|---:|---|---|
202| 68 | 70 | depth bounds `(min, max)` as floats | Sibling layer; the retail title calls 70 (unmodelled, a no-op) |
203| 69 | 71 | `write32(address, value, flush, flags)` | Sibling layer; **measured here** on retail 1.0.2.1 |
204| 70 | 72 | `write64(address, value, flush, flags)`: flags 1 stores the GPU timestamp, 2 the system one (QPC) | Sibling layer; **measured here** (flags 1 and 0 seen) |
205| 71 | 73 | `wait32(address, comparison, reference, word)` | Sibling layer; not called by the retail title in the boots measured |
206| 72 | 74 | `wait64(address, comparison, reference, word)` | Sibling layer; **measured here** |
207| 73 | 75 | pixel-shader depth order (state) | Sibling layer; the retail title calls 75 (a no-op) |
208
209Measured here (retail 1.0.2.1, boots to the story load; temporary per-call logging, not committed):
210
211- The lists record before the queue proxy has detected the layout (§1.1): the first value calls arrive with the
212 layout still unknown. The runtime takes an undetected layout as the newer one, the title's, as it already does for
213 `ExecuteIndirect` at 61.
214- Up to the story load (~150 s): about 12 000 `write32` (small counters and a constant tag in a ring of 72-byte
215 records), 16 000 `write64` (all with flags 1, GPU timestamps, in begin/end pairs) and 4 100 `wait64`, one per
216 frame, `>=` a reference that rises by one each frame, at the start of a direct list, always met when the list is
217 submitted (the CPU writes that value).
218- From the story load on: job chains across the queues. Compute lists (the title uses five compute queues) and
219 direct lists `wait64(address, >=, tag)`, mostly as their first calls and sometimes after two to five calls of
220 work, for addresses that other lists `write64(address, tag)` with flags 0: direct lists write tags as their first
221 calls and wait for compute results; compute lists wait for those tags and write theirs near their end. Before
222 this runtime modelled the writes, every such wait was unmet at submission and ran on.
223- Comparison code 7 is the only one seen; the codes are taken as `D3D12_COMPARISON_FUNC` (memory OP reference, as
224 the sibling layer does). The wait's fourth word had 1 in its low 32 bits each time; it is not used.
225
226The runtime's model:
227
228- A write lands after the list part it was recorded in has run: the queue proxy signals a fence of its own behind
229 the part and a pump thread stores the value with the CPU once the fence is reached
230 (`leonida::kernel_writes::store`: one locked access for an aligned value, so a title thread polling it never
231 reads half of it, and pinned like any host write, so the slot-133 shadows see it). Later than the console, never
232 earlier. Writes land in submission order across queues: the pump reads the fences newest write first, so a write
233 whose work waited for an older one is never seen done before it.
234- Two targets that store cannot reach (`runtime/src/value_write_sink.h`). An address in the GPU address arena's
235 range is an arena offset, a default-heap buffer, not a host address: it is asked before any host store and lands
236 in the arena's own mapping (one in the arena's reserved start or a sparse buffer is dropped). A page of xmem's that
237 the title's view keeps `PAGE_NOACCESS` (a GPU-only window), where the store faults, lands through xmem's own
238 mapping of the physical page. Counted as `writes_arena` and `writes_title_pages`. In the boots to the story load no
239 write failed the host store (0 of 63 219), so both are a safety net.
240- `write64` flags 1 and 2 take the GPU's timestamp at the write's place in the list: an `EndQuery(TIMESTAMP)` on
241 the real list (the Vulkan layer writes it at the bottom of the pipe) and a `ResolveQueryData` of that one slot into
242 a readback ring of the device's, read when the write lands. Flag 1 lands those ticks, which count at the queue's
243 `GetTimestampFrequency` (what the queue proxy answers the title's frequency query with, newer layout slot 18);
244 flag 2 lands the `QueryPerformanceCounter` value at which the GPU took them, through the queue's clock
245 calibration (renewed every second), never later than the landing. A write that lands before its part has run
246 (recorded before a wait whose gate holds the part) takes the CPU's clock at landing instead, as before. The
247 title's GPU timing reads these values back, in begin/end pairs.
248- A wait recorded before any work of the part stands at the part's start; writes recorded before that first wait
249 land before the queue stands at it (behind the work submitted before the part), as the title's frame lists and
250 job-tag writers need. A wait recorded after work, or after a write that follows a wait, cuts the list:
251 the real list so far is closed as a part, recording goes on in a spare real list on the same allocator, and the
252 state set so far (heaps, root signatures and arguments, pipeline, viewports, scissors, targets, vertex and index
253 buffers, blend factor, stencil reference, predication; what an executed bundle set, and nothing from before a
254 `ClearState`) is set on it again. A cut that would split an open query waits for the query's `EndQuery`.
255 Bundles record neither method (`ExecuteBundle` names one real list, so a bundle cannot be cut).
256- At submission each part's waits are checked: met ones cost nothing; one that a write still in flight will meet
257 becomes a queue `Wait` on that write's fence (the GPU orders the two queues); any other makes the queue `Wait` on
258 a gate fence that is signalled once memory compares true. The Vulkan layer holds the queue's later work behind
259 that wait without blocking the submitting thread (`src/queue_holds.h`). The pump only decides; a second thread,
260 the releaser, signals the gates, because that Signal runs the work the layer held behind them (the held
261 submission, the shadow refresh, a deferred Present), and the pump keeps landing writes and timing gates out
262 meanwhile.
263- A gate opens after `LEONIDA_VALUE_WAIT_TIMEOUT_MS` (default 200) whatever memory holds, counted from when the
264 gates before it on its queue opened, and logged once per address. An address that timed out three times in a row
265 (the last 256 addresses are counted) gets 4 ms. Once four gates in a row timed out, so does every wait for an
266 address no wait was ever met for, until a gate cut short is met within its 4 ms; a wait cut short that memory
267 meets within the rest of the full timeout gives its address the full timeout from then on.
268 `LEONIDA_LIST_VALUES=0` drops both methods, as before. After `stop_list_values` (the process is ending) nothing
269 new is landed or opened.
270- Queue slot 31 (`CopyPageMappingsBatchX`, section 4) waits at most 16 ms for the queue's earlier work. Work held
271 behind a gate takes longer: the remap is then deferred to the releaser, which runs it once the queue's write
272 fence passes the call's point and only then opens a gate the queue's later work waits on, so the GPU sees the
273 order of the call and the title's thread does not wait (the console's CPU does not either).
274
192## 6. Root arguments 275## 6. Root arguments
193 276
194Sibling-layer measurements on retail titles: 277Sibling-layer measurements on retail titles:
diff --git a/docs/d3d12_xs_surface.md b/docs/d3d12_xs_surface.md
index 0cae107f7..460b50d29 100644
--- a/docs/d3d12_xs_surface.md
+++ b/docs/d3d12_xs_surface.md
@@ -450,6 +450,124 @@ before treating it as new. For `OMSetFrontAndBackStencilRef` the signature is id
450GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the 450GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the
451wrong slot. Leonida's public-chain command list already has it at GCL8. 451wrong slot. Leonida's public-chain command list already has it at GCL8.
452 452
453### 5.2 Arity and receiver of device slots 86, 101, 108, 132 and 133 (and offset `+0x418` / 131)
454
455These six offsets are called in the title's executable; five reach the device and `+0x418` (131)
456does not. `+0x2B0`, `+0x328`, `+0x360` and `+0x418`-`+0x428` are past every published interface,
457so they are console slots on whatever object the call is made on, and the receiver is not
458automatically the device: the console runtime repeats offsets across object vtables. The whole
459image has **243** indirect calls `call [reg+disp]` at these six offsets; most of them are *not* on
460the device, and a count that ignores the receiver overstates the device surface by an order of
461magnitude.
462
463The receiver is proven by a backward definition chain from the `call` that ends in a full-width load
464of the device pointer. The title keeps that pointer in a block of `.data` aliases
465(`0x1475DF000`-`0x1475DF048` and `0x148759D00`) that one constructor fills with the same value
466(`0x1424785D4`-`0x142478621` copies the qword at `0x1475DF048` into the other eleven). A site whose
467chain ends in one of those globals is a device site. A site whose chain ends in a *different*
468global, in an argument of unknown provenance or in the return of a helper is counted but not
469attributed.
470
471| Slot | Offset | Raw sites | Sites on the device | Receiver at those sites | Registers / stack at those sites | What the device sites support |
472|---:|---|---:|---:|---|---|---|
473| 86 | `+0x2B0` | 37 | **1** (`0x142479A87`) | `[0x1475DF000]` (alias of the device pointer) | `rcx`=device, `rdx`=&desc (first qword `0x2B0`), `r8`=&`IID_ID3D12PipelineState`, `r9`=&out | three-argument, `riid`-out PSO stream creation (`CreatePipelineState` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
474| 101 | `+0x328` | 28 | **1** (`0x1424813EF`) | `[0x1475DF018]` (alias) | `rcx`=device, `rdx`=&desc (dword 0 = `3`, dword 4 = index, `+8` = pointer), `r8`=&`IID_ID3D12StateObject`, `r9`=&out | three-argument, `riid`-out state-object creation with a leading type word `3` (`CreateStateObject` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
475| 108 | `+0x360` | 31 | **2** (`0x140ABFDA9`, `0x140ABFE07`) | vtable fetched from the device (`[0x1475DF030]` / `[0x1475DF035]`); `rdx` is the device itself: the slot returns a 16-byte struct, so the MSVC x64 ABI puts the hidden return buffer in `rcx` and `this` moves to `rdx` | `rcx`=&16-byte `D3D12_RESOURCE_ALLOCATION_INFO` return, `rdx`=device, `r8d`=1 (`visibleMask`), `r9d`=1 (`numResourceDescs`), `[rsp+0x20]`=&56-byte `D3D12_RESOURCE_DESC`, `[rsp+0x28]`=&24-byte scratch (`D3D12_RESOURCE_ALLOCATION_INFO1`-sized) | allocation-info query over one 56-byte resource description (4 KiB small-resource retry; routed as `GetResourceAllocationInfo2` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
476| 131 | `+0x418` | 26 | **0** | - | - | the offset is called, but only on non-device receivers here; a device form is unproven |
477| 132 | `+0x420` | 47 | **1** (`0x1424745E4`) | `[0x1475DF048]` (the alias the copy loop reads) | `rcx`=device, `edx`=3 | single small enum/int argument |
478| 133 | `+0x428` | 74 | **5** (`0x14006DD85`, `0x14193DFF8`, `0x14193E2D4`, `0x141E8684C`, `0x1456F802B`) | `[0x1475DF048]` or `[0x148759D00]` | `rcx`=device, `rdx`=GPU VA, `r8`=&`D3D12_RESOURCE_DESC`, `r9d`=state (`6`, `0xFFFFFFFF` or a register), `[rsp+0x20]`=clear, `[rsp+0x28]`=&`IID_ID3D12Resource`, `[rsp+0x30]`=&out | six-argument placed-resource creation, stable across all five sites |
479
480Per slot:
481
482- **86.** The `riid` at `0x1461E06B8` is `765a30f3-f624-4c6f-a828-ace948622445`,
483 `IID_ID3D12PipelineState` (§3), so the device form creates a PSO: `(desc, riid, out)`, which
484 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) routes as
485 `CreatePipelineState` to PC slot 47 (`ID3D12Device2::CreatePipelineState`). The
486 descriptor's first qword is the slot number itself (`mov qword ptr [rdx], 0x2B0`), i.e. the
487 caller keeps a command record. A second caller reaches the pair 86/87 on *another* object: at
488 `0x14258FC20`-`0x14258FC56` it loads the vtable into `r8`, sets `edx`, branches on a byte and
489 calls `+0x2B8` or `+0x2B0` with that one argument, then tags the returned qword `4` or `3`. So
490 the recorder form is one argument and a returned value, and the device form is the three-argument
491 creation; do not generalise either to the other. A shim that only knows 86 will miss the 87
492 branch.
493- **101.** The `riid` at `0x1461E06D8` is `47016943-fca8-4594-93ea-af258b55346d`,
494 `IID_ID3D12StateObject` (SDK `d3d12.h:44486`, not in the 28-IID set of §3). The descriptor is
495 `{dword 3, dword index, pointer}`: `[rdx]` is the type word `3` (`D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE`
496 or collection), `[rdx+4]` an index into the table the caller just filled (`0x142481350`-`0x1424813BD`)
497 and `[rdx+8]` a pointer (`rdi`). That is the DXR state-object side of the game, routed in
498 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) as
499 `CreateStateObject(desc, riid, out)` to PC slot 62 (`ID3D12Device5::CreateStateObject`).
500- **108.** No GUID is compared at either site. Both sit in one function, `0x140ABFAE0`-`0x140ABFE6C`
501 (reached through the thunk at `0x140ABFAD0`), which first computes the surface size and then makes
502 the one call twice at most. The 5th argument is a 56-byte `D3D12_RESOURCE_DESC`: the callee reads
503 `Dimension` at `+0`, `Alignment` at `+8`, `Width` at `+0x10`, `Height` at `+0x18`,
504 `DepthOrArraySize` at `+0x1C`, `Format` at `+0x20`, `Layout` at `+0x2C` and `Flags` at `+0x30`, and
505 writes back the 4-texel-aligned `Width`/`Height` for block-compressed formats
506 (`0x140ABFB2B`-`0x140ABFB40`). `Format` becomes bits per pixel through `0x144D9F3C0`, which indexes
507 the 128/96/64/32/16/8/4-bit table at `0x1461ED5B8`; dimension 4 (3D) with `Layout` 0 has `Layout`
508 set to the console word `0x105` (`0x140ABFD4B`-`0x140ABFD57`), dimension 3 (2D) takes the tile-shape
509 table, and a buffer is plain `Width × Height × Depth × bits`. When the whole surface is under
510 `0x80008` bits it writes `Alignment = 0x1000`, asks for that alignment, and if the returned alignment
511 is not `0x1000` clears `Alignment` to 0 and calls again (`0x140ABFDBF`-`0x140ABFE07`) — the retry the
512 SDK's small-resource sample does with `D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT` (4096,
513 `d3d12.h:1304`), and the 4 KiB small-texture alignment the host layer already answers
514 ([d3d12_vulkan.md](d3d12_vulkan.md) §4.2). The 16-byte return is `{SizeInBytes, Alignment}` and the
515 code traps unless the high dword of `SizeInBytes` is 0, so a returned size has to fit 32 bits
516 (`0x140ABFE15`).
517 That is the argument list, return placement and struct use of
518 `ID3D12Device4::GetResourceAllocationInfo1(visibleMask, numResourceDescs, pResourceDescs,
519 pResourceAllocationInfo1)` (`d3d12.h:12418-12422`), including a 24-byte
520 `D3D12_RESOURCE_ALLOCATION_INFO1` buffer as the 4th argument (`d3d12.h:2965-2970`);
521 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) serves it by
522 expanding the 56-byte `D3D12_RESOURCE_DESC` (normalising `0x105` and Xbox flag bits) and routing to
523 PC slot 68 (`ID3D12Device8::GetResourceAllocationInfo2`). **Measured**: the shape, the struct
524 offsets, `0x1000`/`0x105`, the retry and the assert. **Open**: the exact console wire method name
525 (`GetResourceAllocationInfo1` vs `GetResourceAllocationInfoX` / `2`) — no IID or symbol string is
526 present at the sites.
527- **131.** Twenty-six sites, none on the device. Two are on sub-objects reached through another
528 global (`0x1415A487D` indexes a table at `[rax+0x28]`), one at `0x14437CFED` follows slot 130
529 (`+0x410`) on the same receiver and reads the out dword it wrote, and the rest are on arguments
530 whose caller does not carry the device. The shape there is `(dword* out)` with a returned value
531 that a site compares (`0x141F9BE30`), plus a four-argument form
532 (`0xC280`, `0x20000`, `0`, `0xFFFFFFFFFF00` at `0x141560994`). It sits in the 0x400 block with
533 132/133, and both of those do have device sites, so a device form is plausible but not shown:
534 do not implement it on the strength of these sites.
535- **132.** The only device site passes `edx=3` and nothing else. Off the device the same offset is
536 a predicate taking one 32-bit constant (`2`, `3`, `0xFFF7E7A4`, `0xBD8817DB`) and returning in
537 `al` (`test al, al` at `0x14118ABB4`), which reads as a feature or capability query; that family's
538 receiver is not the device, so `3` cannot be read as a capability id for the device form yet.
539- **133.** All five device sites are identical: VA, a console `D3D12_RESOURCE_DESC` (Xbox `Flags`
540 bits above the PC ones), state, clear, `IID_ID3D12Resource`, out. That is the same shape and the
541 same `riid` the retail run logged (`retail_boot_chain.md` §3.4, "device slot 133 places a
542 resource at a virtual address"), measured independently here from the same `riid` constant at
543 `0x1463FA690` in three different sites, all `696442be-a72e-4059-bc79-5b5c98040fad`.
544 Static and run agree on six arguments and on the order. This is the strongest row of the six.
545 Off the device the same offset is a different shape - `this` only, returning an object, at
546 `0x14107D67F`; `this` + `0` at `0x143BF0C50` - so 133 on another receiver is not this method.
547
548The co-occurrence fits the block reading: 108 is called alongside 106/107/109/110/111 in
549`0x140504AB0`, 131 alongside 57 in `0x14123C630`/`0x14123CD70`, and 132 with 133 in
550`0x1403D2260`, `0x14060C420`, `0x14060CA50`, `0x141394800` and `0x141597B60`, always with the same
551argument (`rdx` = the struct that carries the size/VA). None of those receivers is proven to be
552the device, so the pairing says "one feature area", not "same arity" and not "device slot".
553
554What this does not say:
555
556- A raw site count is not a device count. The largest raw buckets are argument-provenance sites
557 (26 of 47 at 132, 40 of 74 at 133), many of them in wrapper code that re-dispatches on an
558 inherited or returned pointer. The same offset also carries a different arity off the device
559 (`0x14107D67F`, `0x143BF0C50` above), so an offset alone never names a method.
560- `rdx`, `r8` and `r9` at a site can be dead for the method; only the setup within the last few
561 instructions is listed. The arity above is the *caller's* setup, not a header.
562- No symbol string appears at any of the six call-site groups. On the device, 86, 101, 108 and
563 133 match the routes in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 and
564 [retail_boot_chain.md](retail_boot_chain.md) §3.4 (`CreatePipelineState`, `CreateStateObject`,
565 `GetResourceAllocationInfo2` and `CreatePlacedResourceX` in
566 `runtime/shims/d3d12_xs_device.cpp`). Offsets `+0x418` (131) and `+0x420` (132) remain unnamed
567 here, and 131 has no device receiver.
568- The proxy table must still be long enough: slot 133 is the highest slot the title reaches, so a
569 128-entry table faults (retail observation) and anything below 134 is a guess.
570
453## 6. Command lists and `CreateCommandList` 571## 6. Command lists and `CreateCommandList`
454 572
455The one measured console command-list rule, quoted from the UMD: 573The one measured console command-list rule, quoted from the UMD:
@@ -675,7 +793,7 @@ evidence.
675| Leonida unknown | Status after SCARAB (and §7.1) | What is actually new | 793| Leonida unknown | Status after SCARAB (and §7.1) | What is actually new |
676|---|---|---| 794|---|---|---|
677| #1 device entry point and 24-word params | **described** | The separate console device export exists at ordinal 13 and is named `D3D12ConsCreateDevice` internally / `D3D12XboxCreateDevice` publicly; the params struct is named `D3D12CONS_CREATE_DEVICE_PARAMETERS`. Public sources name 17 fields and their x64 offsets, plus two more field names; a 24-word block still has at least four words unaccounted (§7.1). | 795| #1 device entry point and 24-word params | **described** | The separate console device export exists at ordinal 13 and is named `D3D12ConsCreateDevice` internally / `D3D12XboxCreateDevice` publicly; the params struct is named `D3D12CONS_CREATE_DEVICE_PARAMETERS`. Public sources name 17 fields and their x64 offsets, plus two more field names; a 24-word block still has at least four words unaccounted (§7.1). |
678| #2 device/heap/queue/command-list slots | **partly measured** | SCARAB has no console slot map. Its appended-after-GCL6 model conflicts with the SDK's GCL8/GCL9 methods (§5.1). Public §7.1 gives the presentation slots (device 78-81, queue 30/32); the heap and command-list slot map is still unknown. Do not use SCARAB as a slot source. | 796| #2 device/heap/queue/command-list slots | **partly measured** | §5.2 measures the arity and receiver of device slots 86, 101, 108, 132 and 133 (86, 101, 108 and 133 match the routes in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 and [retail_boot_chain.md](retail_boot_chain.md) §3.4); offset `+0x418` (131) has no device receiver, so it stays open. SCARAB has no console slot map. Its appended-after-GCL6 model conflicts with the SDK's GCL8/GCL9 methods (§5.1). Public §7.1 gives the presentation slots (device 78-81, queue 30/32); the heap and command-list slot map is still unknown. Do not use SCARAB as a slot source. |
679| #3 root signature → `s0..s31` | **still unknown** | Only flag names (`D3D12CONS_ROOT_SIGNATURE_FLAG_FORCE_MEMORY_BASED_ABI`, `_RAYTRACING`); no mapping. Leonida's own register-based/spill facts already go further. | 797| #3 root signature → `s0..s31` | **still unknown** | Only flag names (`D3D12CONS_ROOT_SIGNATURE_FLAG_FORCE_MEMORY_BASED_ABI`, `_RAYTRACING`); no mapping. Leonida's own register-based/spill facts already go further. |
680| #4 descriptor bytes and increments | **still unknown** | No measured increment. `D3D12CONS_DESCRIPTOR_HEAP_TYPE_SAMPLER_UNBOUNDED` is a new name, not a size. | 798| #4 descriptor bytes and increments | **still unknown** | No measured increment. `D3D12CONS_DESCRIPTOR_HEAP_TYPE_SAMPLER_UNBOUNDED` is a new name, not a size. |
681| #5 VA range / arena capacity | **still unknown** | — | 799| #5 VA range / arena capacity | **still unknown** | — |
@@ -693,8 +811,9 @@ evidence.
693| free-function dispositions | **answered as a list** | 7 standard + 16 console-only; Leonida serves 4 today. | 811| free-function dispositions | **answered as a list** | 7 standard + 16 console-only; Leonida serves 4 today. |
694 812
695The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives 813The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives
696a **name-level map** of the extension surface. It does not close presentation, slots, struct 814a **name-level map** of the extension surface. It does not close presentation, the slot map,
697layouts, numeric flags or tiling. 815struct layouts, numeric flags or tiling; §5.2 adds five device slots to what the game itself
816answers (leaving offset `+0x418` / 131 open with 0 device sites).
698 817
699## 10. Claims that did not hold up 818## 10. Claims that did not hold up
700 819
diff --git a/docs/design.md b/docs/design.md
index daeb4eb42..eecb1cb84 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -287,11 +287,11 @@ How the generated SPIR-V expects the runtime to work:
287| Null sources in 64-bit integer VALU compares | `v_cmp` and `v_cmpx` relations `eq`, `ne`, `lt`, `le`, `gt`, `ge` on `u64` and `i64` read `null` as the 64-bit value 0 in either source, like immediate `0`. Register pairs and immediates retain their existing semantics; `v_cmp` writes the active lane's comparison to VCC/SGPR, while `v_cmpx` narrows EXEC without changing VCC. Source: RDNA2 ISA special operand `null` reads zero; LLVM `llvm-mc -mcpu=gfx1013` accepts the encoding. CPU-checked by `tests/semantic/test_vcmp64_null_src.py` (both sources, signed/unsigned ordering, equality, e32/e64, EXEC and inactive lanes); **not GPU-verified, no corpus count**. | 287| Null sources in 64-bit integer VALU compares | `v_cmp` and `v_cmpx` relations `eq`, `ne`, `lt`, `le`, `gt`, `ge` on `u64` and `i64` read `null` as the 64-bit value 0 in either source, like immediate `0`. Register pairs and immediates retain their existing semantics; `v_cmp` writes the active lane's comparison to VCC/SGPR, while `v_cmpx` narrows EXEC without changing VCC. Source: RDNA2 ISA special operand `null` reads zero; LLVM `llvm-mc -mcpu=gfx1013` accepts the encoding. CPU-checked by `tests/semantic/test_vcmp64_null_src.py` (both sources, signed/unsigned ordering, equality, e32/e64, EXEC and inactive lanes); **not GPU-verified, no corpus count**. |
288| `s_load_dword*` with `vcc` 64-bit base pointer | SMEM `s_load_dword*` accepts `vcc` (`{vcc_lo, vcc_hi}`, hardware `s[106:107]`) as its 64-bit base pointer in `Gen.scalar_load`, loading `%vcc` as the low dword and `%vcc_hi` as the high dword; `s_buffer_load*` still requires a 4-dword V# and rejects 2-dword `vcc`. Source: RDNA2 ISA SMEM `SBASE` encoding (`sbase = 53` -> `s[106:107] = vcc`). Confirmed by corpus count over the 2,684-shader pipeline library compute corpus (79 shaders use `vcc` as the `s_load` base: 72 `s_load_dwordx4 sgpr, vcc`, 6 `s_load_dwordx8 sgpr, vcc`, 1 `s_load_dwordx4 slist, vcc`; all 79 translate and pass `spirv-val` under `--wave64-emulate`) and CPU-checked by `tests/semantic/test_sload_vcc_base.py` (`spirv-as` + `spirv-val`) and `tests/semantic/test_scalar_mem_smem.py` (both halves and the resulting addresses); **not GPU-verified**: the synthetic `runtime/test/shaders/cs_smem_vcc_base.asm` reads back eight seeded words through the pair in the standard GPU runner. | 288| `s_load_dword*` with `vcc` 64-bit base pointer | SMEM `s_load_dword*` accepts `vcc` (`{vcc_lo, vcc_hi}`, hardware `s[106:107]`) as its 64-bit base pointer in `Gen.scalar_load`, loading `%vcc` as the low dword and `%vcc_hi` as the high dword; `s_buffer_load*` still requires a 4-dword V# and rejects 2-dword `vcc`. Source: RDNA2 ISA SMEM `SBASE` encoding (`sbase = 53` -> `s[106:107] = vcc`). Confirmed by corpus count over the 2,684-shader pipeline library compute corpus (79 shaders use `vcc` as the `s_load` base: 72 `s_load_dwordx4 sgpr, vcc`, 6 `s_load_dwordx8 sgpr, vcc`, 1 `s_load_dwordx4 slist, vcc`; all 79 translate and pass `spirv-val` under `--wave64-emulate`) and CPU-checked by `tests/semantic/test_sload_vcc_base.py` (`spirv-as` + `spirv-val`) and `tests/semantic/test_scalar_mem_smem.py` (both halves and the resulting addresses); **not GPU-verified**: the synthetic `runtime/test/shaders/cs_smem_vcc_base.asm` reads back eight seeded words through the pair in the standard GPU runner. |
289| Execution model | One invocation = one lane. Compute and mesh waves derive lanes from the workgroup-local index; other stages use the subgroup lane. A wave = a subgroup, so cross-lane ops (`ds_swizzle`, `v_permlane*`, `v_readlane`/`v_writelane`, `v_mbcnt`) become subgroup shuffles. Wave32 pixel shaders split a 64-lane physical subgroup into two logical waves: lane IDs are `SubgroupLocalInvocationId & 31`, shuffle sources retain the current half (`& 32`), and ballots/votes use that half's 32-bit word. A value the translator knows is uniform (the bindless descriptor index) is read from the half's first running lane, never from a fixed lane, which need not be running (SHADER-1016). Other stage/wave combinations still require subgroup size == wave size or wave64 emulation. **Requires subgroup size == wave size** (wave32 maps directly onto NVIDIA GPUs; wave64 shaders need a 64-wide subgroup or emulation). `v_readlane_b32`/`v_writelane_b32` mask the lane select with 63 in wave64 (`S1[5:0]`) and 31 in wave32 (`S1[4:0]`); until SHADER-52 both used 63, so a wave32 select ≥ 32 pointed past a 32-wide subgroup. GPU-checked with `cs_w32_lane_wrap.asm` (lane 40 → 8). For the fragment-half rule, `ps_bitmask_perm` produced 4096/4096 exact pixels on an AMD Radeon RX 5700 XT; Vulkan reported a default subgroup size of 64 (range 32..64), but does not permit pinning fragment subgroup size on this device. CPU semantic tests compare a 64-lane wave32 pixel subgroup against two 32-lane subgroups for reads/writes, permutations, ballots, and votes. | 289| Execution model | One invocation = one lane. Compute and mesh waves derive lanes from the workgroup-local index; other stages use the subgroup lane. A wave = a subgroup, so cross-lane ops (`ds_swizzle`, `v_permlane*`, `v_readlane`/`v_writelane`, `v_mbcnt`) become subgroup shuffles. Wave32 pixel shaders split a 64-lane physical subgroup into two logical waves: lane IDs are `SubgroupLocalInvocationId & 31`, shuffle sources retain the current half (`& 32`), and ballots/votes use that half's 32-bit word. A value the translator knows is uniform (the bindless descriptor index) is read from the half's first running lane, never from a fixed lane, which need not be running (SHADER-1016). Other stage/wave combinations still require subgroup size == wave size or wave64 emulation. **Requires subgroup size == wave size** (wave32 maps directly onto NVIDIA GPUs; wave64 shaders need a 64-wide subgroup or emulation). `v_readlane_b32`/`v_writelane_b32` mask the lane select with 63 in wave64 (`S1[5:0]`) and 31 in wave32 (`S1[4:0]`); until SHADER-52 both used 63, so a wave32 select ≥ 32 pointed past a 32-wide subgroup. GPU-checked with `cs_w32_lane_wrap.asm` (lane 40 → 8). For the fragment-half rule, `ps_bitmask_perm` produced 4096/4096 exact pixels on an AMD Radeon RX 5700 XT; Vulkan reported a default subgroup size of 64 (range 32..64), but does not permit pinning fragment subgroup size on this device. CPU semantic tests compare a 64-lane wave32 pixel subgroup against two 32-lane subgroups for reads/writes, permutations, ballots, and votes. |
290| DPP | VOP1/VOP2 `_dpp` applies to src0. DPP16 controls (`quad_perm`, `row_shl/shr/ror/share/xmask/mirror/half_mirror`) and DPP8 (`dpp8` + `fi`) select the source lane, then `row_mask` (one bit per 16-lane row) and `bank_mask` (one bit per 4-lane bank) decide which destination lanes update. A lane whose row/bank is off is not written. A source lane outside the row is invalid: `bound_ctrl` 1 uses 0 as src0, otherwise the lane is not written. A source lane inactive under EXEC is used when `fi` is 1; otherwise `bound_ctrl` decides. DPP8 always writes an enabled lane: `fi` 1 reads the inactive source, `fi` 0 uses 0. DPP16/8 never leaves its 16/8-lane group, so this is exact on every subgroup at least that wide; under `--wave64-emulate` the exchange goes through the workgroup buffer like the other cross-lane ops. GPU-checked with `runtime/test/shaders/cs_dpp*.asm` on an RTX 3070 and hardware-measured on an RX 6800. On an RX 6700 XT (gfx1031), `tools/crosslane_fuzz.py --dpp-sweep --oracle hw` checks every DPP16 control × `bound_ctrl` × `fi`, every `row_mask`/`bank_mask` pair and the DPP8 selects in wave32 and wave64: 14,412 cases, all matching these rules (BUILD-162, `docs/shader_validation.md` FUZZ-7). The ballot of the source lanes' EXEC bits and the shuffle are each stored to a Function variable of their own (`Gen.eager`): SPIRV-Cross (MoltenVK) inlines a single-use result into the expression that uses it, which put the ballot on the right of a short-circuiting `&&` and the shuffle in a ternary's arm, so lanes out of their row skipped the ballot and row_shr:1's lane 1 found lane 0 inactive (`cs_dpp_ops` on MoltenVK; SHADER-529). A store is a statement every lane runs. For native FI=0, the source-lane ballot bit also selects the shuffle index: an absent or EXEC-off source is redirected to the current subgroup lane before `OpGroupNonUniformShuffle`, because masking an undefined shuffle result afterwards is not sufficient; FI=1 is unchanged. CPU-checked by `tests/semantic/test_dpp_eager_subgroup.py::test_fi0_shuffle_index_is_ballot_safe` with a hand-written `quad_perm` case whose active lane 6 reads absent lane 7 in a seven-invocation wave; **not GPU-verified**. Checked in SPIRV-Cross 1.3.239's MSL for the `cs_dpp*` tests (each op is now its own statement) and by `tests/semantic/test_dpp_eager_subgroup.py`; not yet run on a Mac. Semantics from the RDNA2 ISA, AMD LLVM modifier syntax and the GPUOpen DPP notes. | 290| DPP | VOP1/VOP2 `_dpp` applies to src0. DPP16 controls (`quad_perm`, `row_shl/shr/ror/share/xmask/mirror/half_mirror`) and DPP8 (`dpp8` + `fi`) select the source lane, then `row_mask` (one bit per 16-lane row) and `bank_mask` (one bit per 4-lane bank) decide which destination lanes update. A lane whose row/bank is off is not written. A source lane outside the row is invalid: `bound_ctrl` 1 uses 0 as src0, otherwise the lane is not written. Hardware applies src0 float modifiers (`neg`/`abs`) after the invalid-lane zero selection, so `-src0` on an invalid lane yields `-0.0f` (`0x80000000`) and `\|src0\|` yields `+0.0f` (HW-DPP-NEG-INVALID-LANE, measured on RDNA3 (gfx1101) RX 7800 XT, RDNA2 not measured; tested by `tests/semantic/test_dpp_bound_ctrl_modifiers.py`). A source lane inactive under EXEC is used when `fi` is 1; otherwise `bound_ctrl` decides. DPP8 always writes an enabled lane: `fi` 1 reads the inactive source, `fi` 0 uses 0. DPP16/8 never leaves its 16/8-lane group, so this is exact on every subgroup at least that wide; under `--wave64-emulate` the exchange goes through the workgroup buffer like the other cross-lane ops. GPU-checked with `runtime/test/shaders/cs_dpp*.asm` on an RTX 3070 and hardware-measured on an RX 6800. On an RX 6700 XT (gfx1031), `tools/crosslane_fuzz.py --dpp-sweep --oracle hw` checks every DPP16 control × `bound_ctrl` × `fi`, every `row_mask`/`bank_mask` pair and the DPP8 selects in wave32 and wave64: 14,412 cases, all matching these rules (BUILD-162, `docs/shader_validation.md` FUZZ-7). The ballot of the source lanes' EXEC bits and the shuffle are each stored to a Function variable of their own (`Gen.eager`): SPIRV-Cross (MoltenVK) inlines a single-use result into the expression that uses it, which put the ballot on the right of a short-circuiting `&&` and the shuffle in a ternary's arm, so lanes out of their row skipped the ballot and row_shr:1's lane 1 found lane 0 inactive (`cs_dpp_ops` on MoltenVK; SHADER-529). A store is a statement every lane runs. For native FI=0, the source-lane ballot bit also selects the shuffle index: an absent or EXEC-off source is redirected to the current subgroup lane before `OpGroupNonUniformShuffle`, because masking an undefined shuffle result afterwards is not sufficient; FI=1 is unchanged. CPU-checked by `tests/semantic/test_dpp_eager_subgroup.py::test_fi0_shuffle_index_is_ballot_safe` with a hand-written `quad_perm` case whose active lane 6 reads absent lane 7 in a seven-invocation wave; **not GPU-verified**. Checked in SPIRV-Cross 1.3.239's MSL for the `cs_dpp*` tests (each op is now its own statement) and by `tests/semantic/test_dpp_eager_subgroup.py`; not yet run on a Mac. Semantics from the RDNA2 ISA, AMD LLVM modifier syntax and the GPUOpen DPP notes. |
291| DPP on a VOPC compare | A VOPC compare whose src0 field is a DPP marker (250 for DPP16, 233/234 for DPP8) takes src0 through the DPP lane selection of the row above and writes VCC: a lane's bit is `compare(src0 of the selected lane, its own src1)`, with 0 for src0 when the selected lane is out of its row or inactive (`bound_ctrl` 1, or DPP8 with `fi` 0). The second word has the layout of a VOP2's DPP word. `llvm-mc` has no decoding for it on gfx10 (LLVM 21.1.8 rejects the first word for `gfx1013`; LLVM defines the form from GFX11 on), so `tools/shader_disasm.py` prints it: it decodes the pair with the first word turned into `v_max_f32` into `v0`, which takes the same second word, and gives the line the compare's name, a `vcc_lo` destination and the real encoding back (`with_vopc_dpp`); `tools/rdna2_decode.py` decodes it directly. **Only the forms where every lane writes its bit are translated**: `row_mask` and `bank_mask` 0xF and either `bound_ctrl` 1 or DPP8. Any other form, and `v_cmpx`, is refused (`DPP compare with lanes that keep their mask bit`), because what a lane DPP leaves unwritten does to its VCC bit is not measured. Found in 3 of the 2,684 pipeline-library compute programs of 1.0.2.1: 4 `v_cmp_gt_f32` each, with `quad_perm:[1,0,3,2]`, `quad_perm:[2,3,0,1]`, `row_ror:8` (all `bound_ctrl:1`, masks 0xF) and `dpp8:[4,5,6,7,0,1,2,3]`, beside `v_min/max_f32_dpp` and `v_mov_b32_dpp` on the same lanes. **Not measured on hardware**: the rule follows from the encoding, from LLVM's GFX11 definition of the same form and from the VOP2 DPP rules measured in the row above; the sweep that measured those (`tools/crosslane_fuzz.py --dpp-sweep --oracle hw`) does not cover compares. Lane values are checked in `tests/semantic/test_dpp_compare.py` (the SPIR-V interpreter) and on a GPU with `runtime/test/shaders/cs_dpp_cmp.asm`. | 291| DPP on a VOPC compare | A VOPC compare whose src0 field is a DPP marker (250 for DPP16, 233/234 for DPP8) takes src0 through the DPP lane selection of the row above and writes VCC: a lane's bit is `compare(src0 of the selected lane, its own src1)`, with 0 for src0 when the selected lane is out of its row or inactive (`bound_ctrl` 1, or DPP8 with `fi` 0). The second word has the layout of a VOP2's DPP word. `llvm-mc` has no decoding for it on gfx10 (LLVM 21.1.8 rejects the first word for `gfx1013`; LLVM defines the form from GFX11 on), so `tools/shader_disasm.py` prints it: it decodes the pair with the first word turned into `v_max_f32` into `v0`, which takes the same second word, and gives the line the compare's name, a `vcc_lo` destination and the real encoding back (`with_vopc_dpp`); `tools/rdna2_decode.py` decodes it directly. **Only the forms where every lane writes its bit are translated**: `row_mask` and `bank_mask` 0xF and either `bound_ctrl` 1 or DPP8. Any other form, and `v_cmpx`, is refused (`DPP compare with lanes that keep their mask bit`), because what a lane DPP leaves unwritten does to its VCC bit is not measured. Found in 3 of the 2,684 pipeline-library compute programs of 1.0.2.1: 4 `v_cmp_gt_f32` each, with `quad_perm:[1,0,3,2]`, `quad_perm:[2,3,0,1]`, `row_ror:8` (all `bound_ctrl:1`, masks 0xF) and `dpp8:[4,5,6,7,0,1,2,3]`, beside `v_min/max_f32_dpp` and `v_mov_b32_dpp` on the same lanes. **Not measured on hardware**: the rule follows from the encoding, from LLVM's GFX11 definition of the same form and from the VOP2 DPP rules measured in the row above; the sweep that measured those (`tools/crosslane_fuzz.py --dpp-sweep --oracle hw`) does not cover compares. Lane values are checked in `tests/semantic/test_dpp_compare.py` (the SPIR-V interpreter) and on a GPU with `runtime/test/shaders/cs_dpp_cmp.asm`. |
292| EXEC | A per-invocation `active` flag. VALU writes and exports are masked by it, scalar ops aren't, and `v_cmpx`, saveexec and EXEC writes update it. Measured on native gfx1100 (8 threads): a `v_mov_b32` under `EXEC=0x0F` leaves the other lanes untouched, `EXEC=0` writes nothing, a store writes only active lanes and `v_cmpx_gt_u32` narrows EXEC (4 of 4 cases); note that AMD clang 20 rejects `v_add_co_u32`, `v_sub_co_u32`, `v_add_co_ci_u32` and `v_mad_u64_u32` for `gfx1100`, `gfx1101` and `gfx1102`, so this toolchain could not reproduce the RX 7600 result below, which leaves open whether those parts support the opcodes and says only that they could not be assembled here. **A pixel is written when its lane was on in EXEC at the last `exp ... vm` the path executed (if it executed one) and at the last export to the color target; a path with no export at all goes by EXEC at the end.** The `vm` half is the RDNA2 ISA reference guide's rule (30-November-2020, §11.1 and §11.2.1: EXEC at the export is the valid mask and the final one sent is used; an `exp null ... vm` carries only the mask). The color half is measured: an export sends data only for the lanes that are on, a later export to the same target replaces the earlier one for the whole wave, and a lane with no data from the last one is not written even when a later `exp null done vm` marks it valid. So `exp mrt0 done` (no `vm`) with every lane on, followed by an EXEC write, still writes every pixel, and EXEC off at that export and back on afterwards writes none. **Measured on RDNA2** (AMD Radeon iGPU, gfx1036, driver 26.10.1) with the pixel-shader oracle of #3061 (`ps_oracle.py`), hand-written ISA as the pixel shader of a real draw (wave64 stage): 18 programs that cut EXEC to half of the target before, between or after `exp mrt0` (with and without `vm` and `done`) and `exp null done vm`; all 18 fit the rule, 6 of them differed from the translator, which until 2026-11-23 discarded by EXEC at the end on a path without `vm` and kept the older export's value (or the output's initial value) for a lane that was off at the last color export. The latches (`%vm_mask`, `%col_mask_mrtN`) are only emitted where a path can write EXEC after a `vm` or color export; everywhere else EXEC at the end is the same mask and the SPIR-V is unchanged. With several color targets a pixel stays when any target got an export from its lane (Vulkan cannot skip one attachment per pixel; not measured, the oracle's pipeline has one target); `mrtz` is not part of the color mask (not measured). **Measuring exports needs `s_waitcnt expcnt(0)` after each one**: an export is asynchronous, and without the wait the hardware takes the data and the EXEC of a later moment (`v_mov v9, A; exp mrt0 v9 done vm; v_mov v9, B` shows B, and an EXEC write right after the export decides which pixels are written, which looks like "EXEC at the end decides"); 64 `s_nop 15` have the same effect as the wait. Checked on the CPU by `tests/semantic/test_export_valid_mask.py` and on the GPU by `runtime/test/shaders/ps_exp_color_mask.asm` (RTX 5080 and the Radeon). VALU scalar lane-mask destinations (`v_cmp_*`, `v_add_co_u32`, `v_add_co_ci_u32`, `v_sub_co_u32`, `v_sub_co_ci_u32`, `v_subrev_co_u32`, `v_subrev_co_ci_u32`, `v_mad_u64_u32`, `v_mad_i64_i32`) write 0 for lanes off in EXEC (`SDST[lane] = EXEC[lane] ? bit : 0`, AMD RDNA2 ISA). Until 2026-11-22 the six `*_co_*` ops and `v_mad_u64_u32`/`v_mad_i64_i32` did not AND the carry/sign bit with `active`, so inactive lanes leaked 1 bits into `VCC`/SGPR masks (`s_bcnt1`, `s_cbranch_vccz`, `v_cndmask_b32`). Checked on the CPU by `tests/semantic/test_carry_exec_mask.py` (wave32, wave64, and `--wave64-emulate` structure), and **hardware-verified on an AMD RX 7600 (gfx1102)** with `v_add_co_u32` and `v_add_co_ci_u32` carrying on every active lane: VCC reads `0xffffffff` with full EXEC, `0x0000ffff` for the mask `0x0000ffff` and `0xaaaaaaaa` for `0xaaaaaaaa` in wave32, `vcc_lo = 0x0000ffff` with `vcc_hi = 0x0000000f` for the same partial mask in wave64, and `0` when EXEC is 0 even with VCC preloaded to all ones; with one carrying lane under mask `0x0000ffff` VCC is `0x00000001`, and `v_sub_co_u32`/`v_subrev_co_u32` with a borrow under that mask give `0x0000ffff` too. The `*_co_ci_` forms, `v_mad_u64_u32` and `v_mad_i64_i32` share the same path but were not measured separately; it is also GPU-verified on native RDNA2 (gfx1036, AMD Radeon Graphics) with partial EXEC masks (inactive lanes write 0 in sdst for `v_add_co_u32` and `v_mad_u64_u32`). In a shader that writes EXEC, a run of two or more lane-local VALU instructions (no cross-lane read, no lane-mask, SCC, carry or EXEC write) sits inside one `if (active)` and writes its VGPRs directly, instead of an `OpSelect(active, new, old)` per write: the same result, but the driver predicates the run with its own EXEC instead of keeping both values live. On an RX 5700 XT (RADV) a pixel shader with 8 divergent if/else regions of `v_fma`/`v_mul`/`v_add`/`v_min`/`v_max` went from 0.85 ms to 0.69 ms (the same program as native SPIR-V: 0.65 ms). Not under `--wave64-emulate`. Checked by `tests/semantic/test_active_runs.py`. | 292| EXEC | A per-invocation `active` flag. VALU writes and exports are masked by it, scalar ops aren't, and `v_cmpx`, saveexec and EXEC writes update it. Measured on native gfx1100 (8 threads): a `v_mov_b32` under `EXEC=0x0F` leaves the other lanes untouched, `EXEC=0` writes nothing, a store writes only active lanes and `v_cmpx_gt_u32` narrows EXEC (4 of 4 cases); note that AMD clang 20 rejects `v_add_co_u32`, `v_sub_co_u32`, `v_add_co_ci_u32` and `v_mad_u64_u32` for `gfx1100`, `gfx1101` and `gfx1102`, so this toolchain could not reproduce the RX 7600 result below, which leaves open whether those parts support the opcodes and says only that they could not be assembled here. **A pixel is written when its lane was on in EXEC at the last `exp ... vm` the path executed (if it executed one) and at the last export to the color target; a path with no export at all goes by EXEC at the end.** The `vm` half is the RDNA2 ISA reference guide's rule (30-November-2020, §11.1 and §11.2.1: EXEC at the export is the valid mask and the final one sent is used; an `exp null ... vm` carries only the mask). The color half is measured: an export sends data only for the lanes that are on, a later export to the same target replaces the earlier one for the whole wave, and a lane with no data from the last one is not written even when a later `exp null done vm` marks it valid. So `exp mrt0 done` (no `vm`) with every lane on, followed by an EXEC write, still writes every pixel, and EXEC off at that export and back on afterwards writes none. **Measured on RDNA2** (AMD Radeon iGPU, gfx1036, driver 26.10.1) with the pixel-shader oracle of #3061 (`ps_oracle.py`), hand-written ISA as the pixel shader of a real draw (wave64 stage): 18 programs that cut EXEC to half of the target before, between or after `exp mrt0` (with and without `vm` and `done`) and `exp null done vm`; all 18 fit the rule, 6 of them differed from the translator, which until 2026-11-23 discarded by EXEC at the end on a path without `vm` and kept the older export's value (or the output's initial value) for a lane that was off at the last color export. The latches (`%vm_mask`, `%col_mask_mrtN`) are only emitted where a path can write EXEC after a `vm` or color export; everywhere else EXEC at the end is the same mask and the SPIR-V is unchanged. With several color targets a pixel stays when any target got an export from its lane (Vulkan cannot skip one attachment per pixel; not measured, the oracle's pipeline has one target); `mrtz` is not part of the color mask (not measured). **Measuring exports needs `s_waitcnt expcnt(0)` after each one**: an export is asynchronous, and without the wait the hardware takes the data and the EXEC of a later moment (`v_mov v9, A; exp mrt0 v9 done vm; v_mov v9, B` shows B, and an EXEC write right after the export decides which pixels are written, which looks like "EXEC at the end decides"); 64 `s_nop 15` have the same effect as the wait. Checked on the CPU by `tests/semantic/test_export_valid_mask.py` and on the GPU by `runtime/test/shaders/ps_exp_color_mask.asm` (RTX 5080 and the Radeon). VALU scalar lane-mask destinations (`v_cmp_*`, `v_add_co_u32`, `v_add_co_ci_u32`, `v_sub_co_u32`, `v_sub_co_ci_u32`, `v_subrev_co_u32`, `v_subrev_co_ci_u32`, `v_mad_u64_u32`, `v_mad_i64_i32`) write 0 for lanes off in EXEC (`SDST[lane] = EXEC[lane] ? bit : 0`, AMD RDNA2 ISA). Until 2026-11-22 the six `*_co_*` ops and `v_mad_u64_u32`/`v_mad_i64_i32` did not AND the carry/sign bit with `active`, so inactive lanes leaked 1 bits into `VCC`/SGPR masks (`s_bcnt1`, `s_cbranch_vccz`, `v_cndmask_b32`). Checked on the CPU by `tests/semantic/test_carry_exec_mask.py` (wave32, wave64, and `--wave64-emulate` structure), and **hardware-verified on an AMD RX 7600 (gfx1102)** with `v_add_co_u32` and `v_add_co_ci_u32` carrying on every active lane: VCC reads `0xffffffff` with full EXEC, `0x0000ffff` for the mask `0x0000ffff` and `0xaaaaaaaa` for `0xaaaaaaaa` in wave32, `vcc_lo = 0x0000ffff` with `vcc_hi = 0x0000000f` for the same partial mask in wave64, and `0` when EXEC is 0 even with VCC preloaded to all ones; with one carrying lane under mask `0x0000ffff` VCC is `0x00000001`, and `v_sub_co_u32`/`v_subrev_co_u32` with a borrow under that mask give `0x0000ffff` too. The `*_co_ci_` forms, `v_mad_u64_u32` and `v_mad_i64_i32` share the same path but were not measured separately; it is also GPU-verified on native RDNA2 (gfx1036, AMD Radeon Graphics) with partial EXEC masks (inactive lanes write 0 in sdst for `v_add_co_u32` and `v_mad_u64_u32`). In a shader that writes EXEC, a run of two or more lane-local VALU instructions (no cross-lane read, no lane-mask, SCC, carry or EXEC write) sits inside one `if (active)` and writes its VGPRs directly, instead of an `OpSelect(active, new, old)` per write: the same result, but the driver predicates the run with its own EXEC instead of keeping both values live. On an RX 5700 XT (RADV) a pixel shader with 8 divergent if/else regions of `v_fma`/`v_mul`/`v_add`/`v_min`/`v_max` went from 0.85 ms to 0.69 ms (the same program as native SPIR-V: 0.65 ms). Not under `--wave64-emulate`. Checked by `tests/semantic/test_active_runs.py`. |
293| `s_*_saveexec_b32/b64`, `s_andn1/andn2_wrexec_b32/b64` | RDNA2 ISA SOP1. saveexec: `D = EXEC; EXEC = f(S0, EXEC); SCC = (EXEC != 0)`. wrexec: `EXEC = f(S0, EXEC); D = EXEC`. `f` is one of `and`, `or`, `xor`, `andn1` (`~S0 & EXEC`), `andn2` (`S0 & ~EXEC`), `orn1` (`~S0 \| EXEC`), `orn2` (`S0 \| ~EXEC`), `nand`, `nor`, `xnor`, the table in `Gen.EXEC_LOGIC`. The definitions match `tools/cf_ref.py` `_SAVEEXEC`, the FUZZ-8 model. Each invocation holds its own lane's bit (0 or ~0), so `f` is the bitwise op on that bit. A lane EXEC had off becomes active when `f` gives 1 for it (`nand`, `nor`, `orn1`, `orn2`, `xnor`, ...), as on hardware, and SCC is the wave vote. Until 2026-11-22 only `and`/`or`/`andn2_saveexec` and `andn2_wrexec` were translated. CPU-checked by `tests/semantic/test_saveexec_variants.py` (all ten saveexec kinds in wave32 and wave64, both wrexec kinds, partial EXEC and S0, an empty result, every lane against `cf_ref._SAVEEXEC`) and by `tools/cf_diff.py` (300 programs × wave32/64 still pass). Hardware-verified on native RDNA2 (`gfx1036`, Windows 11, driver `32.0.21045.29003`, wave32 & wave64, 0 mismatches): all 10 `saveexec` kinds and both `wrexec` kinds (`andn1`/`andn2`) match bit-for-bit on non-symmetric masks (`src0 = 0x0F0F0F0F`, `exec = 0x33333333` in wave32; `0x0F0F0F0F_00FF00FF` / `0x33333333_55555555` in wave64), zero-result `SCC = 0`, wave64 upper-32-bit-only `new_exec = 0x00000001_00000000` setting `SCC = 1`, and `sdst == src0` register aliasing (`s4, s4` and `s[4:5], s[4:5]`) reading original `src0` before writing old `EXEC` to `sdst`. **Not GPU-verified** for the seven new kinds. Measured on native gfx1100 (single 8-lane workgroup, 36 programs): all ten `saveexec` kinds and both `wrexec` forms follow `f` for three `S0`/`EXEC` pairs, including lanes `EXEC` had off being switched back on (`nand` with `S0=0x03`, `EXEC=0x0F` leaves `0xFFFFFFFC`, activating lanes 4-7), `D` holding the old `EXEC` for `saveexec` and the new one for `wrexec`, and `SCC` the `EXEC != 0` vote. | 293| `s_*_saveexec_b32/b64`, `s_andn1/andn2_wrexec_b32/b64` | RDNA2 ISA SOP1. saveexec: `D = EXEC; EXEC = f(S0, EXEC); SCC = (EXEC != 0)`. wrexec: `EXEC = f(S0, EXEC); D = EXEC`. `f` is one of `and`, `or`, `xor`, `andn1` (`~S0 & EXEC`), `andn2` (`S0 & ~EXEC`), `orn1` (`~S0 \| EXEC`), `orn2` (`S0 \| ~EXEC`), `nand`, `nor`, `xnor`, the table in `Gen.EXEC_LOGIC`. The definitions match `tools/cf_ref.py` `_SAVEEXEC`, the FUZZ-8 model. Each invocation holds its own lane's bit (0 or ~0), so `f` is the bitwise op on that bit. A lane EXEC had off becomes active when `f` gives 1 for it (`nand`, `nor`, `orn1`, `orn2`, `xnor`, ...), as on hardware, and SCC is the wave vote. Until 2026-11-22 only `and`/`or`/`andn2_saveexec` and `andn2_wrexec` were translated. CPU-checked by `tests/semantic/test_saveexec_variants.py` (all ten saveexec kinds in wave32 and wave64, both wrexec kinds, partial EXEC and S0, an empty result, every lane against `cf_ref._SAVEEXEC`) and by `tools/cf_diff.py` (300 programs × wave32/64 still pass). Hardware-verified on native RDNA2 (`gfx1036`, Windows 11, driver `32.0.21045.29003`, wave32 & wave64, 0 mismatches): all 10 `saveexec` kinds and both `wrexec` kinds (`andn1`/`andn2`) match bit-for-bit on non-symmetric masks (`src0 = 0x0F0F0F0F`, `exec = 0x33333333` in wave32; `0x0F0F0F0F_00FF00FF` / `0x33333333_55555555` in wave64), zero-result `SCC = 0`, wave64 upper-32-bit-only `new_exec = 0x00000001_00000000` setting `SCC = 1`, and `sdst == src0` register aliasing (`s4, s4` and `s[4:5], s[4:5]`) reading original `src0` before writing old `EXEC` to `sdst`. **Not GPU-verified** for the seven new kinds. Measured on native gfx1100 (single 8-lane workgroup, 36 programs): all ten `saveexec` kinds and both `wrexec` forms follow `f` for three `S0`/`EXEC` pairs, including lanes `EXEC` had off being switched back on (`nand` with `S0=0x03`, `EXEC=0x0F` leaves `0xFFFFFFFC`, activating lanes 4-7), `D` holding the old `EXEC` for `saveexec` and the new one for `wrexec`, and `SCC` the `EXEC != 0` vote. |
294| Control flow | Reducible graphs use structured branches and natural loops. Irreducible graphs use the dispatch-loop form, which can also be forced with `--dispatch-loop` for comparisons. The control-flow unit test checks 18,228 generated graphs. Irreducible graphs use node splitting (`cfg_structure.split_irreducible`, up to `min(2*N, N+64)` blocks) and fall back to the dispatch-loop form when capped; it can also be forced with `--dispatch-loop` for comparisons. `cfg_structure.structure`, `cfg_structure.run`, and `rdna2spirv.assemble`'s structured emitter are iterative and hoist each guarded member's dominated tail continuation out of its enclosing guard (exact by strict dominance: no block outside the guard's subtree can target the continuation), keeping `OpSelectionMerge` nesting O(1) on sequential diamond/loop chains instead of nesting O(N) deep and hitting Python's recursion limit on multi-thousand-block shaders (e.g. 2,000 sequential diamonds nest to depth 2 instead of 2,000). The control-flow unit test (`tests/test_cfg_structure.py`) checks 20,000 generated graphs plus 2,000-diamond, 1,200-loop, and 1,500-early-exit chains. AMD A/B checks compare the two forms for selected pixel shaders with defined test inputs. For shaders that never export colour, the comparison checks pixel coverage. **Nesting is bounded (SHADER-299):** a tree deeper than `MAX_STRUCTURED_DEPTH` (16) is emitted in the dispatch-loop form instead, since `spirv-val` time grows roughly with the cube of the measured nesting depth. **Nesting is bounded (SHADER-299, SHADER-427):** a tree deeper than `MAX_STRUCTURED_DEPTH` (64; `--max-structured-depth N`, 0 = no bound) is emitted in the dispatch-loop form instead, since `spirv-val` time grows roughly with the cube of the measured nesting depth. Before #1904, over the 1.0.2.1 corpus (26,503 modules, `spirv-val` 2026.4): the deepest block of a module is nested 118 constructs deep, 12,963 modules are structured (median 15) and 6,000 of those are deeper than 16; an estimated 85% of the corpus's `spirv-val` time is in modules nested 20 or deeper. Median `spirv-val` time for the same module in each form: depth 20 181 -> 129 ms (1.4x), 30 507 -> 371 (1.4x), 50 1,712 -> 738 (2.3x), 64 2,692 -> 1,163 (2.3x), 77 5,122 -> 1,130 (4.5x), and the deepest (118) 13,683 -> 1,352 ms (10.1x). Depth 5-12 shows no gain (at depth 6 the flat form is slightly slower), which is why the bound first sat at 16. Since #1904 (`cfg_structure` hoists tails) the deepest tree in the corpus is 29: of 12,944 structured modules, 1,031 are deeper than 16 (747 CS, 284 PS), 57 deeper than 20, 24 deeper than 24. For those 1,031 the flat form saves only 12% of `spirv-val` time (1,235 -> 1,091 s summed, slowest module 8.3 -> 5.9 s), while on an RTX 5070 Ti (NVIDIA 621.24) it compiles slower: the 284 pixel shaders 1.67x (827 -> 1,382 s summed, two rounds), four compute modules at depth 19-24 2.0x (297 -> 591 s, 1.6-2.7x each), so the bound now sits above the corpus (SHADER-427). Both forms pass `spirv-val` on a 200-shader slice (200/200 each), and `gen.nesting` records the tree depth. AMD's Windows driver adds a reason to keep the structured form (SHADER-995): on a Radeon gfx1036 iGPU (32.0.21042.62) the dispatch-loop module of `XboxBvhBuilder.dll`'s `LeafRehydration` (tree depth 18, a 581-case switch) takes 34 minutes to create (XXDESIGN), where its structured module is created in 2.9 s; ten other programs of that DLL compile in the dispatch-loop form there in 0.4-40 s, 2.5-5x their structured time ([embedded_shaders.md](embedded_shaders.md), section 7). | 294| Control flow | Reducible graphs use structured branches and natural loops. Irreducible graphs use the dispatch-loop form, which can also be forced with `--dispatch-loop` for comparisons. The control-flow unit test checks 18,228 generated graphs. Irreducible graphs use node splitting (`cfg_structure.split_irreducible`, up to `min(2*N, N+64)` blocks) and fall back to the dispatch-loop form when capped; it can also be forced with `--dispatch-loop` for comparisons. `cfg_structure.structure`, `cfg_structure.run`, and `rdna2spirv.assemble`'s structured emitter are iterative and hoist each guarded member's dominated tail continuation out of its enclosing guard (exact by strict dominance: no block outside the guard's subtree can target the continuation), keeping `OpSelectionMerge` nesting O(1) on sequential diamond/loop chains instead of nesting O(N) deep and hitting Python's recursion limit on multi-thousand-block shaders (e.g. 2,000 sequential diamonds nest to depth 2 instead of 2,000). The control-flow unit test (`tests/test_cfg_structure.py`) checks 20,000 generated graphs plus 2,000-diamond, 1,200-loop, and 1,500-early-exit chains. `capped_tree()` also runs `cfg_structure.unwrap_known_pc_guards` (shared with `wave64_emulate_opt`) to unwrap tautological `("guard", g, ...)` nodes whenever abstract interpretation proves `%pc == g` on all incoming paths (e.g. post-dominating merge blocks after diamonds and loops); this keeps `ms_wave_info_s3`'s `s_barrier` in uniform top-level control flow (fixing an AMD Windows LLPC `0xC0000005` pipeline-creation crash on AMD Ryzen 5 7600 RDNA2 iGPU driver `24.10.24`, `4096/4096` exact on AMD RDNA2 and RTX 4070 SUPER) and avoids false `needs_barrier_rounds` triggers (`SHADER-STRUCTURED-PC-UNWRAP`). AMD A/B checks compare the two forms for selected pixel shaders with defined test inputs. For shaders that never export colour, the comparison checks pixel coverage. **Nesting is bounded (SHADER-299):** a tree deeper than `MAX_STRUCTURED_DEPTH` (16) is emitted in the dispatch-loop form instead, since `spirv-val` time grows roughly with the cube of the measured nesting depth. **Nesting is bounded (SHADER-299, SHADER-427):** a tree deeper than `MAX_STRUCTURED_DEPTH` (64; `--max-structured-depth N`, 0 = no bound) is emitted in the dispatch-loop form instead, since `spirv-val` time grows roughly with the cube of the measured nesting depth. Before #1904, over the 1.0.2.1 corpus (26,503 modules, `spirv-val` 2026.4): the deepest block of a module is nested 118 constructs deep, 12,963 modules are structured (median 15) and 6,000 of those are deeper than 16; an estimated 85% of the corpus's `spirv-val` time is in modules nested 20 or deeper. Median `spirv-val` time for the same module in each form: depth 20 181 -> 129 ms (1.4x), 30 507 -> 371 (1.4x), 50 1,712 -> 738 (2.3x), 64 2,692 -> 1,163 (2.3x), 77 5,122 -> 1,130 (4.5x), and the deepest (118) 13,683 -> 1,352 ms (10.1x). Depth 5-12 shows no gain (at depth 6 the flat form is slightly slower), which is why the bound first sat at 16. Since #1904 (`cfg_structure` hoists tails) the deepest tree in the corpus is 29: of 12,944 structured modules, 1,031 are deeper than 16 (747 CS, 284 PS), 57 deeper than 20, 24 deeper than 24. For those 1,031 the flat form saves only 12% of `spirv-val` time (1,235 -> 1,091 s summed, slowest module 8.3 -> 5.9 s), while on an RTX 5070 Ti (NVIDIA 621.24) it compiles slower: the 284 pixel shaders 1.67x (827 -> 1,382 s summed, two rounds), four compute modules at depth 19-24 2.0x (297 -> 591 s, 1.6-2.7x each), so the bound now sits above the corpus (SHADER-427). Both forms pass `spirv-val` on a 200-shader slice (200/200 each), and `gen.nesting` records the tree depth. AMD's Windows driver adds a reason to keep the structured form (SHADER-995): on a Radeon gfx1036 iGPU (32.0.21042.62) the dispatch-loop module of `XboxBvhBuilder.dll`'s `LeafRehydration` (tree depth 18, a 581-case switch) takes 34 minutes to create (XXDESIGN), where its structured module is created in 2.9 s; ten other programs of that DLL compile in the dispatch-loop form there in 0.4-40 s, 2.5-5x their structured time ([embedded_shaders.md](embedded_shaders.md), section 7). |
295| Loop guard | Each loop counts header visits per invocation and exits through its structured merge at `--loop-limit N` (default 65536, zero disables). Counters reset on entry, including nested EXEC retries and atomic loops. A PC-dispatch visit counts a dispatch iteration. Natural exits within the budget preserve their outputs. Five-star-recomp (b12a952) reported a story-load timeout when the shader input made its exit condition unreachable. | 295| Loop guard | Each loop counts header visits per invocation and exits through its structured merge at `--loop-limit N` (default 65536, zero disables). Counters reset on entry, including nested EXEC retries and atomic loops. A PC-dispatch visit counts a dispatch iteration. Natural exits within the budget preserve their outputs. Five-star-recomp (b12a952) reported a story-load timeout when the shader input made its exit condition unreachable. |
296| User data | **Push constants, 144 bytes:** dwords 0–31 = initial s0–s31 (the user SGPRs the console driver loads from the root signature: descriptor-table pointers, constants and so on), dwords 32–33 = the 64-bit **heap base**, dwords 34–35 = the **code base**: the Xbox VA where the runtime uploaded this shader's whole FSSM blob. `--mesh-compute` modules add dwords 36–37, the output buffer address (152 bytes; see "Mesh shaders as compute"). `--pc-tail-ubo` keeps only dwords 0–31 here (128 bytes) and moves the rest to a uniform block (see "Push-constant tail as a uniform block"). The runtime has to reproduce the console driver's root-signature-to-user-SGPR mapping; that comes from the exe or driver behaviour. **Mesh shaders** read their root SGPRs through the graphics root window: s16..s31 come from dwords 8..23 (where a VS, PS or GS reads s8..s23), s8..s15 are 0, s0..s7 dwords 0..7; the index records `"root_window": {"sgpr": 16, "dword": 8}` (D3D-448-GRAPHICS, `docs/d3d12_vulkan.md` 3.5). Checked by `tests/semantic/test_ms_root_window.py` (MeshEXT and `--mesh-compute`, CPU interpreter) and `d3d12_mesh_test` (RX 9070 XT). | 296| User data | **Push constants, 144 bytes:** dwords 0–31 = initial s0–s31 (the user SGPRs the console driver loads from the root signature: descriptor-table pointers, constants and so on), dwords 32–33 = the 64-bit **heap base**, dwords 34–35 = the **code base**: the Xbox VA where the runtime uploaded this shader's whole FSSM blob. `--mesh-compute` modules add dwords 36–37, the output buffer address (152 bytes; see "Mesh shaders as compute"). `--pc-tail-ubo` keeps only dwords 0–31 here (128 bytes) and moves the rest to a uniform block (see "Push-constant tail as a uniform block"). The runtime has to reproduce the console driver's root-signature-to-user-SGPR mapping; that comes from the exe or driver behaviour. **Mesh shaders** read their root SGPRs through the graphics root window: s16..s31 come from dwords 8..23 (where a VS, PS or GS reads s8..s23), s8..s15 are 0, s0..s7 dwords 0..7; the index records `"root_window": {"sgpr": 16, "dword": 8}` (D3D-448-GRAPHICS, `docs/d3d12_vulkan.md` 3.5). Checked by `tests/semantic/test_ms_root_window.py` (MeshEXT and `--mesh-compute`, CPU interpreter) and `d3d12_mesh_test` (RX 9070 XT). |
297| Direct resource heap | In the matched Prop/Tree BatchCull compute signature the two explicit tables and scalar constant occupy s4–s6. Bind the resource heap's uint32 arena-relative byte address at s7 (push-constant byte 28). The program supplies a zero high word and scales the resource index by 32 bytes. Other stages and signatures consume different SGPRs. See [descriptor heaps and the bindless model](d3d12_vulkan.md#34-descriptor-heaps-and-the-bindless-model) for the evidence and graphics examples. | 297| Direct resource heap | In the matched Prop/Tree BatchCull compute signature the two explicit tables and scalar constant occupy s4–s6. Bind the resource heap's uint32 arena-relative byte address at s7 (push-constant byte 28). The program supplies a zero high word and scales the resource index by 32 bytes. Other stages and signatures consume different SGPRs. See [descriptor heaps and the bindless model](d3d12_vulkan.md#34-descriptor-heaps-and-the-bindless-model) for the evidence and graphics examples. |
@@ -306,7 +306,7 @@ How the generated SPIR-V expects the runtime to work:
306| 8/16-bit global stores and d16 loads | `global_store_byte`/`short` write the low 8/16 bits of the data VGPR (the `_d16_hi` forms its high half). `global_load_{u,s}byte_d16` and `global_load_short_d16` write the low 16 bits of `vdst` (the `_hi` forms the high 16) and keep the other half; `ubyte` zero-extends and `sbyte` sign-extends the byte to 16 bits. The address is the `global_load/store` one (`Gen.global_address`). The access goes one byte at a time, so a 16-bit access that crosses a dword (at byte 3) is exact too. A store merges each byte into its dword with atomic and/or, which keeps neighbouring bytes even when another lane writes them, as buffer byte stores do. A load reads each byte. Inactive lanes neither store nor load. The first-read analysis counts a d16 load's `vdst` as read, for the half it keeps. `global_load/store_dword_addtid` (lane-id and M0 addressing) raise `Unsupported`; until 2026-11-22 they crashed with `IndexError`, and the ten sub-dword ops raised `Unsupported`. CPU-checked by `tests/semantic/test_global_sub_dword.py` (every byte offset 0 to 7 for each op, an inactive lane, rejected forms, the first-read analysis). **Hardware-measured natively on `gfx1100`** (RX 7900 XTX, driver 26.10.1) with `tools/hw_oracle`, 16 cases that use the output buffer as scratch memory (seven stores, nine d16 loads), all matching: `b8`/`b16` change only the addressed bytes (`0x11223344` with `0xbeef` stored at offset 2 reads back `0xbeef3344`), `_d16_hi` stores take the data VGPR's high half (`0x12340000` at offset 0 gives `0x11221234`), a 16-bit store at offset 3 splits across the dword exactly (`0xfe223344` then `0x556677ca`), `ubyte`/`sbyte` d16 loads fill the low 16 bits of `vdst` and keep the other half (`0x85` gives `0xbeefff85` from a `0xbeef0000` vdst, `0x7f` gives `0xbeef007f`), `short`/`short_hi` d16 loads fill the low/high 16 and keep the rest, and both dword-crossing loads at offset 3 are exact (`0xbeef8811`, `0x88110000`). Not measured: an inactive lane. GPU-checked by `runtime/test/shaders/cs_global_mem_ext.asm` for two of the ten ops (one lane, `saddr` addressing, on a Radeon 610M (gfx1036, RADV, Mesa 26.2.6) and an RTX 4070 Ti (NVIDIA 620.70.06), Linux): `global_store_short` at byte 3 of a dword changes only its two bytes, across both dwords, and `global_load_sbyte_d16_hi` sign-extends a byte into the high half of `vdst` and keeps the low half. **Not GPU-verified:** the other eight ops and an inactive lane. | 306| 8/16-bit global stores and d16 loads | `global_store_byte`/`short` write the low 8/16 bits of the data VGPR (the `_d16_hi` forms its high half). `global_load_{u,s}byte_d16` and `global_load_short_d16` write the low 16 bits of `vdst` (the `_hi` forms the high 16) and keep the other half; `ubyte` zero-extends and `sbyte` sign-extends the byte to 16 bits. The address is the `global_load/store` one (`Gen.global_address`). The access goes one byte at a time, so a 16-bit access that crosses a dword (at byte 3) is exact too. A store merges each byte into its dword with atomic and/or, which keeps neighbouring bytes even when another lane writes them, as buffer byte stores do. A load reads each byte. Inactive lanes neither store nor load. The first-read analysis counts a d16 load's `vdst` as read, for the half it keeps. `global_load/store_dword_addtid` (lane-id and M0 addressing) raise `Unsupported`; until 2026-11-22 they crashed with `IndexError`, and the ten sub-dword ops raised `Unsupported`. CPU-checked by `tests/semantic/test_global_sub_dword.py` (every byte offset 0 to 7 for each op, an inactive lane, rejected forms, the first-read analysis). **Hardware-measured natively on `gfx1100`** (RX 7900 XTX, driver 26.10.1) with `tools/hw_oracle`, 16 cases that use the output buffer as scratch memory (seven stores, nine d16 loads), all matching: `b8`/`b16` change only the addressed bytes (`0x11223344` with `0xbeef` stored at offset 2 reads back `0xbeef3344`), `_d16_hi` stores take the data VGPR's high half (`0x12340000` at offset 0 gives `0x11221234`), a 16-bit store at offset 3 splits across the dword exactly (`0xfe223344` then `0x556677ca`), `ubyte`/`sbyte` d16 loads fill the low 16 bits of `vdst` and keep the other half (`0x85` gives `0xbeefff85` from a `0xbeef0000` vdst, `0x7f` gives `0xbeef007f`), `short`/`short_hi` d16 loads fill the low/high 16 and keep the rest, and both dword-crossing loads at offset 3 are exact (`0xbeef8811`, `0x88110000`). Not measured: an inactive lane. GPU-checked by `runtime/test/shaders/cs_global_mem_ext.asm` for two of the ten ops (one lane, `saddr` addressing, on a Radeon 610M (gfx1036, RADV, Mesa 26.2.6) and an RTX 4070 Ti (NVIDIA 620.70.06), Linux): `global_store_short` at byte 3 of a dword changes only its two bytes, across both dwords, and `global_load_sbyte_d16_hi` sign-extends a byte into the high half of `vdst` and keeps the low half. **Not GPU-verified:** the other eight ops and an inactive lane. |
307| Literal samplers | Some shaders build their S# from immediates (for example `0x92, 0xC00000, 0x14500000, 0`). The runtime registers those in the descriptor hash table too, by scanning the translated shaders' constant S# values, not only S#s the game binds. The translator lists them per shader (`literal_samplers` in the index). `CreateGraphicsPipelineState` and `CreateComputePipelineState` register each stage's list in the descriptor hash table, since no heap slot names these S#s. Until 2026-11-22 nothing called `register_samplers` (#1169) outside its test, so such a shader's lookup found the fallback sampler and sampled with the wrong filter. The game's `$PS_PassthroughCopy` drew a coordinate ramp point-sampled: worst error 0.0078, against 0.00049 once registered. Checked by `d3d12_m2_textured_test` (`ps_m2_literal.asm`: no key before the PSO, a sampler index after it). | 307| Literal samplers | Some shaders build their S# from immediates (for example `0x92, 0xC00000, 0x14500000, 0`). The runtime registers those in the descriptor hash table too, by scanning the translated shaders' constant S# values, not only S#s the game binds. The translator lists them per shader (`literal_samplers` in the index). `CreateGraphicsPipelineState` and `CreateComputePipelineState` register each stage's list in the descriptor hash table, since no heap slot names these S#s. Until 2026-11-22 nothing called `register_samplers` (#1169) outside its test, so such a shader's lookup found the fallback sampler and sampled with the wrong filter. The game's `$PS_PassthroughCopy` drew a coordinate ramp point-sampled: worst error 0.0078, against 0.00049 once registered. Checked by `d3d12_m2_textured_test` (`ps_m2_literal.asm`: no key before the PSO, a sampler index after it). |
308| Pipeline-library scalar operands | A scalar load may use VCC as a 64-bit pointer. In wave32 programs using that operand, scalar pair moves and XORs preserve both address words. Read its low and high data words, gathering a native wave's mask bits when a half is mask-valued. An emulated wave64 mask-valued pointer is refused. Where LLVM rejects a scalar, image or buffer tuple ending in VCC, recover the tuple from its original bytes before following branches. Hand-built memory and decoder cases in `test_library_compute_forms.py` and `test_vcc_tuple_fallback.py`. | 308| Pipeline-library scalar operands | A scalar load may use VCC as a 64-bit pointer. In wave32 programs using that operand, scalar pair moves and XORs preserve both address words. Read its low and high data words, gathering a native wave's mask bits when a half is mask-valued. An emulated wave64 mask-valued pointer is refused. Where LLVM rejects a scalar, image or buffer tuple ending in VCC, recover the tuple from its original bytes before following branches. Hand-built memory and decoder cases in `test_library_compute_forms.py` and `test_vcc_tuple_fallback.py`. |
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). | 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). |
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). | 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). |
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. | 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. |
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. | 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. |
@@ -394,6 +394,7 @@ How the generated SPIR-V expects the runtime to work:
394| Denormal flush and special results in `v_rcp_f32`, `v_rsq_f32`, `v_sqrt_f32`, `v_log_f32`, `v_exp_f32`, `v_rcp_iflag_f32` | Measured on an RX 6800 (gfx1030, not the console's gfx1013) with raw kernels in both wave sizes and all four IEEE/DX10_CLAMP combinations: all six read a denormal input as a zero of its sign and flush a denormal result, even with MODE's denormal field set to keep them. `v_rcp_f32(±0)` = ±inf, `v_rsq_f32(-0)` = -inf, `v_sqrt_f32(-0)` = -0, `v_log_f32(±0)` = -inf, `v_rcp_f32(FLT_MAX)` = +0, `v_exp_f32(-127)` = +0, `v_exp_f32(128)` = +inf, and every invalid result (`v_sqrt_f32`/`v_rsq_f32`/`v_log_f32` of a negative, …) is `0xffc00000`. Each is within 1 ulp of correctly rounded on the values tried, and `v_rcp_iflag_f32` is bit-identical to `v_rcp_f32`. **Not modelled yet:** the translator leaves all six on Vulkan's default denormal handling, and the ±0 and negative inputs above stay undefined in the emitted SPIR-V (`OpFDiv` by zero, `Sqrt`/`Log2` of a negative), as listed in the multiply-add and output modifiers row; the `clamp`/`omod` bits on `v_cvt_f32_*` and `v_rcp_iflag_f32` are modelled there. Source: [@shelbykb2's hardware words](https://github.com/ItsNotRexed/Leonida/issues/634#issuecomment-7074348963), not the ISA text. The corpus only ever writes MODE's FP_ROUND field and carries `mul:2`/`mul:4`/`div:2` on 102,365 float instructions (a compiler does not emit one that is ignored), so the inferred f32 state, IEEE off with denormals flushed, is the one to model. Corpus count (`tools/shader_profile.py`, 26,503 shaders; the shader count of each op deduplicates its `_e32`/`_e64` forms): `v_rcp_f32` 17,393 shaders / 424,863 occurrences, `v_rsq_f32` 17,221 / 269,310, `v_sqrt_f32` 14,511 / 201,422, `v_log_f32` 8,454 / 90,199, `v_exp_f32` 8,603 / 148,846, `v_rcp_iflag_f32` 7,395 / 34,852; 20,193 shaders (76.2%) use at least one, 1,169,492 occurrences (2.6% of the corpus's 44,406,870 instructions). | 394| Denormal flush and special results in `v_rcp_f32`, `v_rsq_f32`, `v_sqrt_f32`, `v_log_f32`, `v_exp_f32`, `v_rcp_iflag_f32` | Measured on an RX 6800 (gfx1030, not the console's gfx1013) with raw kernels in both wave sizes and all four IEEE/DX10_CLAMP combinations: all six read a denormal input as a zero of its sign and flush a denormal result, even with MODE's denormal field set to keep them. `v_rcp_f32(±0)` = ±inf, `v_rsq_f32(-0)` = -inf, `v_sqrt_f32(-0)` = -0, `v_log_f32(±0)` = -inf, `v_rcp_f32(FLT_MAX)` = +0, `v_exp_f32(-127)` = +0, `v_exp_f32(128)` = +inf, and every invalid result (`v_sqrt_f32`/`v_rsq_f32`/`v_log_f32` of a negative, …) is `0xffc00000`. Each is within 1 ulp of correctly rounded on the values tried, and `v_rcp_iflag_f32` is bit-identical to `v_rcp_f32`. **Not modelled yet:** the translator leaves all six on Vulkan's default denormal handling, and the ±0 and negative inputs above stay undefined in the emitted SPIR-V (`OpFDiv` by zero, `Sqrt`/`Log2` of a negative), as listed in the multiply-add and output modifiers row; the `clamp`/`omod` bits on `v_cvt_f32_*` and `v_rcp_iflag_f32` are modelled there. Source: [@shelbykb2's hardware words](https://github.com/ItsNotRexed/Leonida/issues/634#issuecomment-7074348963), not the ISA text. The corpus only ever writes MODE's FP_ROUND field and carries `mul:2`/`mul:4`/`div:2` on 102,365 float instructions (a compiler does not emit one that is ignored), so the inferred f32 state, IEEE off with denormals flushed, is the one to model. Corpus count (`tools/shader_profile.py`, 26,503 shaders; the shader count of each op deduplicates its `_e32`/`_e64` forms): `v_rcp_f32` 17,393 shaders / 424,863 occurrences, `v_rsq_f32` 17,221 / 269,310, `v_sqrt_f32` 14,511 / 201,422, `v_log_f32` 8,454 / 90,199, `v_exp_f32` 8,603 / 148,846, `v_rcp_iflag_f32` 7,395 / 34,852; 20,193 shaders (76.2%) use at least one, 1,169,492 occurrences (2.6% of the corpus's 44,406,870 instructions). |
395| f16 transcendentals (`v_exp_f16`, `v_log_f16`, `v_rcp_f16`, `v_rsq_f16`, `v_sqrt_f16`, `v_sin_f16`, `v_cos_f16`) | Measured on an RX 6700 XT (gfx1031, not the console's gfx1013) with `tools/f16_trans_sweep.py`: all 65,536 inputs of each op, wave32 and wave64 (identical on every input), five MODEs (FUZZ-29). With f16 denormals kept (`denorm_mode_16_64 = 3`, the assembler default and what the translator assumes), `v_exp/log/rcp/rsq/sqrt_f16` are **correctly rounded on every input that is not a NaN** (0 ulp). `v_sin/v_cos_f16` take turns and reduce them exactly over the whole f16 range (no ±256 limit): compared with sin/cos(2πx), every result for \|x\| > 1 is bit-exact, and for \|x\| ≤ 1 only 14 (sin) and 4 (cos) of 30,722 are 1 ulp off. So the translator's rule (widen to f32, the GLSL.std.450 function, round to nearest even back to f16) matches the hardware as far as the driver's f32 function is accurate. For sin/cos that holds only once the angle is reduced in turns first (#594): with the f32 product 6.2831855 · x, 16,366 sin and 2,036 cos inputs are more than 1 ulp off, up to 9,944 ulp (sin of 64,640 turns: 0.0267 instead of 0). With `denorm_mode_16_64 = 0`, a denormal operand reads as a zero of its sign, and a denormal result is written as a zero of its sign. That differs from the f32 ops in the row above, which flush in both modes. The f16 field of FP_ROUND is ignored: round toward zero gives the same words as round to nearest on every input. IEEE changes only signalling NaNs. With IEEE off they pass through unchanged; with IEEE on they are quieted (bit 9 set). Payload and sign are kept either way, and quiet NaNs pass unchanged in every mode. Where SPIR-V leaves the result undefined, the hardware gives: log(±0) = -inf, rcp(±0) = ±inf, rsq(+0) = +inf, rsq(-0) = -inf, sqrt(-0) = -0, and `0xfe00` for log/rsq/sqrt of a negative (-inf included) and for sin/cos(±inf). `v_exp_f16`/`v_log_f16` give the same counts on gfx1036 (RDNA2, AMD Windows driver; SHADER-135). Since 2026-11-22 the translator selects those hardware words for `v_rcp_f16`, `v_rsq_f16` and `v_sqrt_f16` itself (the operand is replaced by 1.0 for the f32 `OpFDiv`/`InverseSqrt`/`Sqrt`, which SPIR-V leaves undefined at 0 or below 0) and `0xfe00` is the negative quiet NaN; checked bit for bit through the interpreter by `tests/semantic/test_valu_rcp_f16.py`, `test_valu_rsq_f16.py` and `test_valu_sqrt_f16.py` against exactly rounded references. The undefined cases of `v_exp_f16`/`v_log_f16`/`v_sin_f16`/`v_cos_f16` are still left to the driver. **Not modelled yet:** `Gen.f16_bits` quiets every NaN (the hardware keeps a signalling NaN with IEEE off), and the undefined cases above are left to the driver. | 395| f16 transcendentals (`v_exp_f16`, `v_log_f16`, `v_rcp_f16`, `v_rsq_f16`, `v_sqrt_f16`, `v_sin_f16`, `v_cos_f16`) | Measured on an RX 6700 XT (gfx1031, not the console's gfx1013) with `tools/f16_trans_sweep.py`: all 65,536 inputs of each op, wave32 and wave64 (identical on every input), five MODEs (FUZZ-29). With f16 denormals kept (`denorm_mode_16_64 = 3`, the assembler default and what the translator assumes), `v_exp/log/rcp/rsq/sqrt_f16` are **correctly rounded on every input that is not a NaN** (0 ulp). `v_sin/v_cos_f16` take turns and reduce them exactly over the whole f16 range (no ±256 limit): compared with sin/cos(2πx), every result for \|x\| > 1 is bit-exact, and for \|x\| ≤ 1 only 14 (sin) and 4 (cos) of 30,722 are 1 ulp off. So the translator's rule (widen to f32, the GLSL.std.450 function, round to nearest even back to f16) matches the hardware as far as the driver's f32 function is accurate. For sin/cos that holds only once the angle is reduced in turns first (#594): with the f32 product 6.2831855 · x, 16,366 sin and 2,036 cos inputs are more than 1 ulp off, up to 9,944 ulp (sin of 64,640 turns: 0.0267 instead of 0). With `denorm_mode_16_64 = 0`, a denormal operand reads as a zero of its sign, and a denormal result is written as a zero of its sign. That differs from the f32 ops in the row above, which flush in both modes. The f16 field of FP_ROUND is ignored: round toward zero gives the same words as round to nearest on every input. IEEE changes only signalling NaNs. With IEEE off they pass through unchanged; with IEEE on they are quieted (bit 9 set). Payload and sign are kept either way, and quiet NaNs pass unchanged in every mode. Where SPIR-V leaves the result undefined, the hardware gives: log(±0) = -inf, rcp(±0) = ±inf, rsq(+0) = +inf, rsq(-0) = -inf, sqrt(-0) = -0, and `0xfe00` for log/rsq/sqrt of a negative (-inf included) and for sin/cos(±inf). `v_exp_f16`/`v_log_f16` give the same counts on gfx1036 (RDNA2, AMD Windows driver; SHADER-135). Since 2026-11-22 the translator selects those hardware words for `v_rcp_f16`, `v_rsq_f16` and `v_sqrt_f16` itself (the operand is replaced by 1.0 for the f32 `OpFDiv`/`InverseSqrt`/`Sqrt`, which SPIR-V leaves undefined at 0 or below 0) and `0xfe00` is the negative quiet NaN; checked bit for bit through the interpreter by `tests/semantic/test_valu_rcp_f16.py`, `test_valu_rsq_f16.py` and `test_valu_sqrt_f16.py` against exactly rounded references. The undefined cases of `v_exp_f16`/`v_log_f16`/`v_sin_f16`/`v_cos_f16` are still left to the driver. **Not modelled yet:** `Gen.f16_bits` quiets every NaN (the hardware keeps a signalling NaN with IEEE off), and the undefined cases above are left to the driver. |
396| f64 literal sources | For `v_cvt_f32_f64` and either source of `v_add_f64`, a literal dword supplies bits 63:32 and bits 31:0 are zero. For `v_cvt_f32_f64`, `v_rcp_f64`, `v_rsq_f64`, `v_sqrt_f64`, `v_frexp_mant_f64`, `v_frexp_exp_i32_f64` and either source of `v_add_f64`, a literal dword supplies bits 63:32 and bits 31:0 are zero. Inline integers are sign-extended and inline floats use their binary64 value. For example, gfx1030 `llvm-mc` encodes 1.5 as the literal word `0x3ff80000`. The synthetic `tests/semantic/fixtures/f64_literals.asm` checks both source words in the translated SPIR-V, including the distinction between the printed literal `0x1` and inline `1`. [LLVM AMDGPU operand conversions](https://releases.llvm.org/15.0.0/docs/AMDGPUOperandSyntax.html#integer-literals) In the synthetic `unary_f64_literals.asm`, LLVM gfx1030 encodes the five unary literal sources in trailing dwords. The regression checks the emitted high and low operand words for reciprocal, reciprocal square root and square root. It executes the integer-only frexp paths: for 6.0 the mantissa words are (0, 0x3fe80000) and the exponent is 3. The full fixture passes Vulkan 1.2 validation; the semantic interpreter cannot execute its Float64 instructions. The rule keys on the literal's printed width, not only its value: LLVM pads nothing, so a value that fits one literal dword prints in at most 8 hex digits, and a spelling of more than 8 is the whole binary64 constant (the full-width form `tools/f64_diff.py` writes: `0x0000000012345678` is the low word `0x12345678` and a zero high word, while `0x12345678` stays the high word). gfx1013 `llvm-mc` refuses a literal wider than 32 bits for these ops ("invalid operand"), so a listing from the game carries only the one-dword form and its words do not change. The wider form used to be refused by the four rounding ops; they now read the whole constant, which is what the differential check's generated programs needed. `tests/semantic/test_f64_literal_whole.py` checks those emitted words for `v_sqrt_f64`, `v_rsq_f64`, `v_rcp_f64`, the four rounding ops and the frexp exponent path, next to the one-dword, padded-width and inline-integer controls; `tests/test_f64_diff.py` checks that the CPU reference reads a literal the same way; `tools/f64_diff.py`'s CPU reference judged the whole-literal `v_add_f64`/`v_rsq_f64`/`v_sqrt_f64` programs as mismatches before the change. | 396| f64 literal sources | For `v_cvt_f32_f64` and either source of `v_add_f64`, a literal dword supplies bits 63:32 and bits 31:0 are zero. For `v_cvt_f32_f64`, `v_rcp_f64`, `v_rsq_f64`, `v_sqrt_f64`, `v_frexp_mant_f64`, `v_frexp_exp_i32_f64` and either source of `v_add_f64`, a literal dword supplies bits 63:32 and bits 31:0 are zero. Inline integers are sign-extended and inline floats use their binary64 value. For example, gfx1030 `llvm-mc` encodes 1.5 as the literal word `0x3ff80000`. The synthetic `tests/semantic/fixtures/f64_literals.asm` checks both source words in the translated SPIR-V, including the distinction between the printed literal `0x1` and inline `1`. [LLVM AMDGPU operand conversions](https://releases.llvm.org/15.0.0/docs/AMDGPUOperandSyntax.html#integer-literals) In the synthetic `unary_f64_literals.asm`, LLVM gfx1030 encodes the five unary literal sources in trailing dwords. The regression checks the emitted high and low operand words for reciprocal, reciprocal square root and square root. It executes the integer-only frexp paths: for 6.0 the mantissa words are (0, 0x3fe80000) and the exponent is 3. The full fixture passes Vulkan 1.2 validation; the semantic interpreter cannot execute its Float64 instructions. The rule keys on the literal's printed width, not only its value: LLVM pads nothing, so a value that fits one literal dword prints in at most 8 hex digits, and a spelling of more than 8 is the whole binary64 constant (the full-width form `tools/f64_diff.py` writes: `0x0000000012345678` is the low word `0x12345678` and a zero high word, while `0x12345678` stays the high word). gfx1013 `llvm-mc` refuses a literal wider than 32 bits for these ops ("invalid operand"), so a listing from the game carries only the one-dword form and its words do not change. The wider form used to be refused by the four rounding ops; they now read the whole constant, which is what the differential check's generated programs needed. `tests/semantic/test_f64_literal_whole.py` checks those emitted words for `v_sqrt_f64`, `v_rsq_f64`, `v_rcp_f64`, the four rounding ops and the frexp exponent path, next to the one-dword, padded-width and inline-integer controls; `tests/test_f64_diff.py` checks that the CPU reference reads a literal the same way; `tools/f64_diff.py`'s CPU reference judged the whole-literal `v_add_f64`/`v_rsq_f64`/`v_sqrt_f64` programs as mismatches before the change. |
397| 32-bit literal source of a signed 64-bit vector op (`v_cmp(x)_*_i64`, `v_ashrrev_i64` S1, `v_mad_i64_i32` S2) | A VALU literal is one dword and llvm-mc prints `-100` as `0xffffff9c` (both encode to the same bytes on gfx1030). In an i64 operand that dword is sign-extended to 64 bits (`{-1, num.i32}`), in a u64/b64 operand zero-extended (`{0, num.u32}`) ([LLVM AMDGPU operand syntax, Conversion of Integer Values](https://releases.llvm.org/15.0.0/docs/AMDGPUOperandSyntax.html#integer-literals); `Gen.valu_imm_i64`). So `v_cmp_lt_i64 vcc_lo, 5, 0xffffff9c` = 0, `v_ashrrev_i64 v[10:11], 4, 0xffffff9c` = 0xFFFFFFFF_FFFFFFF9 and `v_mad_i64_i32 v[10:11], vcc_lo, 1, 1, 0xffffff9c` = -99, the same as the decimal spelling and the explicit pair. `v_cmp_*_u64`, `v_lshlrev_b64`, `v_lshrrev_b64` and `v_mad_u64_u32` S2 still zero-extend a literal, a positive literal (`0x7fffffff`) stays positive, and the inline constants (-16..64) were already full-width. f64 literals keep their own rule (row above). The vector half of the scalar rule for `s_ashr_i64`, `s_bfe_i64` and `s_flbit_i32_i64` (#978). Confirmed by `tests/semantic/test_valu_signed_literal64.py` (CPU, the three spellings agree; 5 of its 8 tests fail on the previous translator, which zero-extended the printed literal) and by the llvm-mc gfx1030 encodings of `-100` and `0xffffff9c`. Not measured on hardware. |
397| `v_cvt_f32_f64` output modifiers | Convert to f32, apply `mul:2`, `mul:4`, or `div:2` if present, then apply `clamp` to [0, 1] if requested. [LLVM GFX10 assembler tests](https://github.com/llvm/llvm-project/blob/main/llvm/test/MC/AMDGPU/gfx10_asm_vop1.s#L3044-L3054) confirm the modifier encodings. `tests/test_f64_conversion.py` checks the resulting SPIR-V data flow. | 398| `v_cvt_f32_f64` output modifiers | Convert to f32, apply `mul:2`, `mul:4`, or `div:2` if present, then apply `clamp` to [0, 1] if requested. [LLVM GFX10 assembler tests](https://github.com/llvm/llvm-project/blob/main/llvm/test/MC/AMDGPU/gfx10_asm_vop1.s#L3044-L3054) confirm the modifier encodings. `tests/test_f64_conversion.py` checks the resulting SPIR-V data flow. |
398| 32-bit integers to binary64 | `v_cvt_f64_i32` sign-extends the input value and `v_cvt_f64_u32` treats it as unsigned. Every 32-bit integer is exactly representable in binary64. The low word goes in the first destination VGPR. **The output scaling is gated by `MODE`, measured by @fiestorra**: on a gfx1036 iGPU (Radeon(TM) Graphics, drivers `31.0.24002.92` and `32.0.21045.29003` (the same counts on both), raw ISA through `tools/hw_oracle`, `tools/f64_omod_probe.py`, 6 inputs x 5 modifier forms x 5 MODEs, wave32 and wave64 identical) `mul:2`/`mul:4`/`div:2` scale the binary64 result only under `IEEE=0` with `denorm_mode_16_64=0`; under `denorm_mode_16_64=3`, which is what the translator assumes, and under `IEEE=1` they are ignored, while `clamp` applies in every MODE — so only `clamp` reaches `dst_f64` for these two ops, as `v_ldexp_f64` already does. For input `0x80000001`, SPIRV-Tools constant folding reproduced both words of each result in the synthetic `ps_int32_to_f64.s` fixture. [AMD RDNA 2 ISA, VOP1 conversions](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) | 399| 32-bit integers to binary64 | `v_cvt_f64_i32` sign-extends the input value and `v_cvt_f64_u32` treats it as unsigned. Every 32-bit integer is exactly representable in binary64. The low word goes in the first destination VGPR. **The output scaling is gated by `MODE`, measured by @fiestorra**: on a gfx1036 iGPU (Radeon(TM) Graphics, drivers `31.0.24002.92` and `32.0.21045.29003` (the same counts on both), raw ISA through `tools/hw_oracle`, `tools/f64_omod_probe.py`, 6 inputs x 5 modifier forms x 5 MODEs, wave32 and wave64 identical) `mul:2`/`mul:4`/`div:2` scale the binary64 result only under `IEEE=0` with `denorm_mode_16_64=0`; under `denorm_mode_16_64=3`, which is what the translator assumes, and under `IEEE=1` they are ignored, while `clamp` applies in every MODE — so only `clamp` reaches `dst_f64` for these two ops, as `v_ldexp_f64` already does. For input `0x80000001`, SPIRV-Tools constant folding reproduced both words of each result in the synthetic `ps_int32_to_f64.s` fixture. [AMD RDNA 2 ISA, VOP1 conversions](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) |
399| `v_add_f64` output modifiers | The double sum is scaled by `mul:2`, `mul:4` or `div:2` if present, then clamped to [0, 1] if `clamp` is set, as for f32 (`clamp_mods_f64`, GLSL.std.450 `FClamp` on the double, so a NaN result and the sign of a -0 result are left to the driver, also as for f32). **Until 2026-11-22 both were ignored.** Source: LLVM AMDGPU defines it as `VOP3Inst<"v_add_f64", VOP3_Profile<VOP_F64_F64_F64>>` (VOP3Instructions.td), and `VOPProfile` sets `HasClamp` (f64 is a modifier type) and `HasOMod` (floating-point destination) (SIInstrInfo.td). It is the only f64 arithmetic the translator handles; `v_cvt_f32_f64` has the row above. `tests/test_f64_output_modifiers.py` checks the SPIR-V data flow; `runtime/test/shaders/ps_f64_mods.asm` is the GPU test (needs `shaderFloat64`, which `vk_harness` now enables when the fragment shader declares `Float64`), passed on an NVIDIA RTX 6000 Ada (driver 615.71.09, Linux; 4096/4096 pixels exact, and the `main` translator gives the predicted old words). | 400| `v_add_f64` output modifiers | The double sum is scaled by `mul:2`, `mul:4` or `div:2` if present, then clamped to [0, 1] if `clamp` is set, as for f32 (`clamp_mods_f64`, GLSL.std.450 `FClamp` on the double, so a NaN result and the sign of a -0 result are left to the driver, also as for f32). **Until 2026-11-22 both were ignored.** Source: LLVM AMDGPU defines it as `VOP3Inst<"v_add_f64", VOP3_Profile<VOP_F64_F64_F64>>` (VOP3Instructions.td), and `VOPProfile` sets `HasClamp` (f64 is a modifier type) and `HasOMod` (floating-point destination) (SIInstrInfo.td). It is the only f64 arithmetic the translator handles; `v_cvt_f32_f64` has the row above. `tests/test_f64_output_modifiers.py` checks the SPIR-V data flow; `runtime/test/shaders/ps_f64_mods.asm` is the GPU test (needs `shaderFloat64`, which `vk_harness` now enables when the fragment shader declares `Float64`), passed on an NVIDIA RTX 6000 Ada (driver 615.71.09, Linux; 4096/4096 pixels exact, and the `main` translator gives the predicted old words). |
diff --git a/docs/first_light.md b/docs/first_light.md
index 9eaff8f37..c3cb2bf1d 100644
--- a/docs/first_light.md
+++ b/docs/first_light.md
@@ -70,9 +70,7 @@ python -I tools/first_light.py --check --out ~/leonida-work/first_light/out
70 70
71`--check` on an existing folder re-runs the harness through the same fresh path and `check_image` as the test; a 71`--check` on an existing folder re-runs the harness through the same fresh path and `check_image` as the test; a
72harness that exits 0 without writing, an all-opaque image and a swapped-U/V image all exit 1. The test has 72harness that exits 0 without writing, an all-opaque image and a swapped-U/V image all exit 1. The test has
73twenty-five cases: the two package-gated draw/manifest checks, the `--check` command, four oracle fixtures, the 7348 cases; `python -I tests/test_first_light.py -v` prints each one.
74mesh depth fit, a preview with non-finite readback channels, the stage files of two shaders with the same name, two
75OBJ parsing checks, seven checks of the textured path (section 6) and six CPU checks of `--camera` (section 7).
76 74
77`first_light.py` carves `shaders.rpf` if the work folder does not have it, translates only the chosen pair, converts 75`first_light.py` carves `shaders.rpf` if the work folder does not have it, translates only the chosen pair, converts
78the OBJ to the harness's mesh file (`u32 vertex_count, u32 index_count`, `(x,y,z,u,v) f32` vertices, `u32` 76the OBJ to the harness's mesh file (`u32 vertex_count, u32 index_count`, `(x,y,z,u,v) f32` vertices, `u32`
@@ -140,10 +138,10 @@ The CPU oracle (`check_image`) samples the decoded `R8G8B8A8_UNORM` texture bili
140`centre_uv` and each `uv_probes` entry and requires the GPU readback to match within `0.02` (rejecting the 138`centre_uv` and each `uv_probes` entry and requires the GPU readback to match within `0.02` (rejecting the
141magenta unbound-texture fallback and wrong-colour probes). Verified on Windows 11 with an NVIDIA GeForce RTX 3060 139magenta unbound-texture fallback and wrong-colour probes). Verified on Windows 11 with an NVIDIA GeForce RTX 3060
142(driver 621.24, Vulkan 1.4.357): **12,804/16,384 (0.781)** covered. Without `LEONIDA_FIRST_LIGHT_DIR`, 140(driver 621.24, Vulkan 1.4.357): **12,804/16,384 (0.781)** covered. Without `LEONIDA_FIRST_LIGHT_DIR`,
143`python -I tests/test_first_light.py -v` runs **46 tests: 42 passed, 4 skipped** (the 3 package-gated 141`python -I tests/test_first_light.py -v` runs **48 tests: 44 passed, 4 skipped** (the 3 package-gated
144`FirstLightTests` require `LEONIDA_FIRST_LIGHT_DIR`, and `test_harness_rejects_wrapped_tsharp_va_overflow` needs a 142`FirstLightTests` require `LEONIDA_FIRST_LIGHT_DIR`, and `test_harness_rejects_wrapped_tsharp_va_overflow` needs a
145built `vk_harness`; the 4 `OracleTests` and the other 11 `TexturedOracleTests` run without a package). With 143built `vk_harness`; the 4 `OracleTests` and the other 11 `TexturedOracleTests` run without a package). With
146`LEONIDA_FIRST_LIGHT_DIR` set against a local package run (and `vk_harness` built) none of the 46 is skipped. 144`LEONIDA_FIRST_LIGHT_DIR` set against a local package run (and `vk_harness` built) none of the 48 is skipped.
147 145
148```sh 146```sh
149python -I tools/first_light.py --game "<package>" --work ~/leonida-work \ 147python -I tools/first_light.py --game "<package>" --work ~/leonida-work \
diff --git a/docs/first_run_ui.md b/docs/first_run_ui.md
index d7b2fe5e5..66b147ddb 100644
--- a/docs/first_run_ui.md
+++ b/docs/first_run_ui.md
@@ -30,7 +30,7 @@ Run the title offline. The Winsock shim permits loopback and the WinHTTP shim re
30& (Join-Path $port 'gta6rt.exe') --first-run-ui (Join-Path $game 'game_scarlett_master.exe') 30& (Join-Path $port 'gta6rt.exe') --first-run-ui (Join-Path $game 'game_scarlett_master.exe')
31``` 31```
32 32
33The profile selects Vulkan, a 2 GiB graphics address arena, on-demand pipelines, console root-argument layout, GPU completion labels, frame pacing and the keyboard gamepad. Explicit environment settings take precedence; a variable that is set but empty does not count. Speech synthesis through the host's own runtime is not part of the profile: `LEONIDA_LOCAL_SPEECH=1` turns it on, and without it the silent voice answers. The switches are listed in [`runtime/README.md`](../runtime/README.md). The package directory is the working directory. Guest output goes under `first-run-ui/overlay` beside the runtime, and sparse physical-memory backing uses `first-run-ui/xmem` on that volume. Use `--overlay DIR` or the absolute directory in `LEONIDA_XMEM_BACKING_DIR` to choose other writable locations. 33The profile selects Vulkan, a 2 GiB graphics address arena, on-demand pipelines, console root-argument layout, frame pacing and the keyboard gamepad in its focused mode (`LEONIDA_KEYBOARD_PAD=1`: keys count only while the title window has focus, so typing into another program presses nothing on a consent page; scripted presses still run). GPU completion labels (`LEONIDA_GPU_LABELS`) are not part of it: the list values land the title's list writes, and two writers of one address could rewind a counter. Explicit environment settings take precedence; a variable that is set but empty does not count. Speech synthesis through the host's own runtime is not part of the profile: `LEONIDA_LOCAL_SPEECH=1` turns it on, and without it the silent voice answers. The switches are listed in [`runtime/README.md`](../runtime/README.md). The package directory is the working directory. Guest output goes under `first-run-ui/overlay` beside the runtime, and sparse physical-memory backing uses `first-run-ui/xmem` on that volume. Use `--overlay DIR` or the absolute directory in `LEONIDA_XMEM_BACKING_DIR` to choose other writable locations.
34 34
35## Contributions 35## Contributions
36 36
diff --git a/docs/fspx.md b/docs/fspx.md
index 6fa4a4c8d..a959423e4 100644
--- a/docs/fspx.md
+++ b/docs/fspx.md
@@ -276,12 +276,92 @@ title calls device slot 57 (`+0x1c8`) with `IID_ID3D12PipelineState` (`{765a30f3
276 - `state blob`: `+0x000` version tag (`0x4005d800` in 15,632 records, `0x4005d808` in 9,159, `0x4005d810` in 6), 276 - `state blob`: `+0x000` version tag (`0x4005d800` in 15,632 records, `0x4005d808` in 9,159, `0x4005d810` in 6),
277 `+0x004` family (`4` in 12,735 or `6` in 12,062), `+0x02c = 2`, `+0x07c` (`0xcc0010` / `0` / `0xcc0011`), 277 `+0x004` family (`4` in 12,735 or `6` in 12,062), `+0x02c = 2`, `+0x07c` (`0xcc0010` / `0` / `0xcc0011`),
278 `+0x0f4 = 5`, `+0x0f8 = 1`, `+0x0fc = 0x33333333` (`0.1f`), `+0x100..+0x11c` (`0x00060006` x8), `+0x150 = 0x40`, 278 `+0x0f4 = 5`, `+0x0f8 = 1`, `+0x0fc = 0x33333333` (`0.1f`), `+0x100..+0x11c` (`0x00060006` x8), `+0x150 = 0x40`,
279 `+0x158 = 0xffffffff`, `+0x17c = 0x10000a00`. Unidentified offsets are logged once per offset while safe default 279 `+0x158 = 0xffffffff`, `+0x17c = 0x10000a00`. The colour-target, depth, stencil and raster registers are decoded
280 raster/depth/blend state is used. 280 (next paragraphs); depth bias is not.
281 - `stage blob`: `+0x00 = 2` (graphics stage blob), `+0x04` payload size (`196` in 208 B blobs), `+0x08 = 0x66`, 281 - `stage blob`: `+0x00 = 2` (graphics stage blob), `+0x04` payload size (`196` in 208 B blobs), `+0x08 = 0x66`,
282 `+0x0c = 0x40 | flags`, followed by records `0x41` (32 B input/output signature), `0x42` (32 B output signature) 282 `+0x0c = 0x40 | flags`, followed by records `0x41` (32 B input/output signature), `0x42` (32 B output signature)
283 and `0x43` (20 B: tag + 16 B opaque digest). 283 and `0x43` (20 B: tag + 16 B opaque digest).
284 284
285**State blob A: the colour-target registers (RT-SLOT57-BLEND-STATE).** Blob A is the console driver's serialized
286pipeline state, and its shared block holds context register values in the RDNA2 layout (Mesa's gfx10 register
287headers). Measured on 1.0.2.1 over all 5,680 distinct blobs, which the 25,471 graphics records reference:
288
289- **Shape:** 380 + 8k bytes (k = 0..5) for vertex-shader pipelines, and 464 + 8k (k = 0..7) for mesh pipelines. The
290 mesh pipelines' stage block is 84 bytes longer, so every offset after `+0x28` moves by 84 there; the offsets below
291 are the vertex ones. Word 0 is `0x4005d800` with bits 3 and 4 free in all 25,471 records.
292- **`+0x78` `CB_TARGET_MASK`:** four component bits (R, G, B, A, as in `D3D12_COLOR_WRITE_ENABLE`) per target:
293 `0xf` in 16,650 records, `0xff` in 2,805, `0xffffff` in 2,561. In 17,626 records the targets it enables are exactly
294 `0..rt_count-1` of blob B. In 1,937 it also enables target 1 of a one-target pipeline: those are the dual-source
295 pipelines below. The others leave a target with a format unwritten.
296- **`+0x7c` `CB_COLOR_CONTROL`:** ROP3 `0xcc` (copy) in every record, so no logic op.
297- **`+0xd0..+0xec` `CB_BLEND0..7_CONTROL`:** one word per target. There are 34 distinct values, every one an
298 in-range RDNA2 blend: factors 0 to 20 with neither `BOTH_*` value, `COMB_FCN` 0 to 4, `SEPARATE_ALPHA_BLEND` set
299 wherever `ENABLE` is, and `DISABLE_ROP3` set in all. By target 0: `0x80000000` (blending off) in 15,373 records,
300 `0xe5010504` (colour `SRC_ALPHA`/`INV_SRC_ALPHA`, alpha `ONE`/`INV_SRC_ALPHA`) in 3,456, `0xf1010f01` (colour
301 `ONE`/`SRC1_COLOR`, alpha `ONE`/`SRC1_ALPHA`) in 1,931, and `0xe5040504` in 1,387. 10,135 records blend on at least
302 one of their targets.
303- **`+0x100..+0x11c`:** eight more per-target words that follow `CB_BLENDn` (`0x06000600` where blending is off).
304 They fit `SX_MRTn_BLEND_OPT`, whose `COMB_FCN` 6 is "blend disabled". They aren't read.
305
306`runtime/src/native_pso.h` (`decode_state_a_blend`, `d3d12_blend`) maps each target's `CB_BLENDn_CONTROL` and
307`CB_TARGET_MASK` nibble to a `D3D12_RENDER_TARGET_BLEND_DESC`, and `fill_blend_state` in
308`runtime/shims/d3d12_xs_native_pso.h` uses it for every native PSO:
309
310- **Before:** every target had blending off and wrote every component, so the first-run pages after #939 drew glyph
311 quads solid, artwork hard-edged and composited backgrounds black.
312- **With the decoded state:** the pages, the legal screens and the loading slideshow draw as on console (RTX 4070
313 Laptop).
314- **Integer targets:** a target with a `UINT` or `SINT` format never blends, as the colour block bypasses blending
315 there and D3D12 refuses a PSO that asks for it. One library pipeline enables `MAX` on an `R8_UINT` target beside
316 two others.
317- **Stand-in targets:** where `B4G4R4A4_UNORM` is not renderable, the Vulkan layer draws it into an RGBA8 stand-in
318 and refuses blending there (`E_NOTIMPL`, the output is quantized before it). The factory then retries the pipeline
319 with blending off on those targets only (`shims/d3d12_xs_native_pso_fallback.h`), instead of leaving it to the PC
320 description path. On an RTX 4070 Laptop that is the same library pipeline (the first one the title creates). Only a
321 pipeline that blends a `B4G4R4A4` target is retried: `E_NOTIMPL` also stands for refusals unrelated to blending (a
322 rect list without its geometry stage, mesh limits, `FullyCovered`, a dual-source output that does not fit
323 `Location 0, Index 1`), and those keep the blend the title asked for.
324- **Dual-source:** the 1,937 records that blend with `SRC1` factors get them as `D3D12_BLEND_SRC1_*`. The Vulkan
325 layer then moves the pixel shader's `SV_Target1` from `Location 1` to `Location 0, Index 1`
326 (`runtime/src/dual_source_fragment.h`, RT-DUAL-SOURCE-BLEND).
327- **Kept on the defaults:** a blob of another shape, or a target with a factor or function this path does not take,
328 keeps the whole pipeline on the defaults and is logged.
329
330**State blob A: the depth, stencil and raster registers (RT-SLOT57-DEPTH-RASTER).** The same shared block, at the
331same vertex-pipeline offsets (+84 in mesh pipelines). The register layouts and their checks against blob B are below,
332measured over all 25,471 graphics records:
333
334- **`+0x9c` `PA_CL_CLIP_CNTL`:** `DX_CLIP_SPACE_DEF` set in every record. Both z clips are off in 960 records and on
335 in the rest, so the near and far planes always agree.
336- **`+0xa0` `PA_SU_SC_MODE_CNTL`:** no culling in 13,534 records, back faces in 11,873 and front faces in 62.
337 `FACE` (clockwise is front) is clear in all but 2, `POLY_MODE` is 0 in all, and the polygon-offset enables are set
338 in all.
339- **`+0xb8` `DB_DEPTH_CONTROL`:**
340 - with no DSV in blob B, `Z_ENABLE` is clear in 7,040 of 7,079 records;
341 - `STENCIL_ENABLE` is set only with formats that have stencil;
342 - `DEPTH_BOUNDS_ENABLE` and bits 30-31 are clear in all;
343 - `BACKFACE_ENABLE` is set in all;
344 - the test is off (`0x007007f0`) in 9,062 records, otherwise mostly `GEQUAL` (a reversed depth range), with `LESS`,
345 `LEQUAL`, `EQUAL` and `NOTEQUAL` in some.
346- **`+0xbc` `DB_STENCIL_CONTROL`:** nonzero in 5,512 of the 6,213 records with stencil on, and in 2 without. The ops
347 used are `KEEP`, `REPLACE_TEST`, `ADD_WRAP`, `ZERO` and `INVERT`.
348- **`+0xc0`/`+0xc4` `DB_STENCILREFMASK(_BF)`:** the two faces have the same read and write masks in every stencil
349 record, and `STENCILOPVAL` is 1 in all. `STENCILTESTVAL` (bits 7:0, the reference) is 0 in all 6,213 stencil records, front and
350 back, so the reference always comes from the title (`OMSetStencilRef`) and the PSO does not need it. 245 records use a back-face function of their own.
351
352`runtime/src/native_pso.h` (`decode_state_a_depth_raster`, `d3d12_depth_raster`) maps them to
353`D3D12_DEPTH_STENCIL_DESC` and the cull, front-face and depth-clip fields of `D3D12_RASTERIZER_DESC`, and
354`fill_depth_raster_state` in `runtime/shims/d3d12_xs_native_pso.h` uses them for every native PSO:
355
356- **Before:** depth `ALWAYS` with writes wherever there was a DSV, no stencil, no culling and depth clip on.
357- **With the decoded state:** every one of the 25,471 records maps. A pipeline without a DSV keeps depth and stencil
358 off.
359- **Not decoded:** depth bias (`PA_SU_POLY_OFFSET_*`). Its D3D12 units depend on the depth format, so it stays 0.
360 The polygon-offset enables in `PA_SU_SC_MODE_CNTL` are set in all 25,471 records. The values look like the floats at
361 `+0xac`/`+0xb0` (scale and offset), which are both 0 in 23,987 records and nonzero in about 1,480.
362- **Front face:** `FACE` is the only field whose effect can't be seen before a world frame. It maps to
363 `FrontCounterClockwise = !FACE`, as RADV and PAL program it.
364
285## Translation status 365## Translation status
286 366
287In wave64, VALU compares and carry outputs write both predicate words. Conditional selects and carry inputs 367In wave64, VALU compares and carry outputs write both predicate words. Conditional selects and carry inputs
diff --git a/docs/gamedata.md b/docs/gamedata.md
index a05fd1ea5..bcaa55f4d 100644
--- a/docs/gamedata.md
+++ b/docs/gamedata.md
@@ -1416,7 +1416,8 @@ bounded by the largest field. The generic conversion follows the parser's own co
1416- `x/y/z/w` is a vector tuple. 1416- `x/y/z/w` is a vector tuple.
1417- `content=` is the array body. `short_array`, `float_array` and `float16_array` give number lists; 1417- `content=` is the array body. `short_array`, `float_array` and `float16_array` give number lists;
1418 `vector2_array`, `vec3v_array`, `matrix33` and `matrix34` give tuples. 1418 `vector2_array`, `vec3v_array`, `matrix33` and `matrix34` give tuples.
1419- `type="Class"` is a polymorphic object `{"$type": ...}`, and `type="NULL"` is `None`. 1419- `type="Class"` is a polymorphic object `{"$type": ...}`, including an empty object with no fields or text.
1420 Explicit scalar/vector/array/reference conventions and nonempty text keep their values; `type="NULL"` is `None`.
1420- `ref=` is `{"$ref": ...}`. 1421- `ref=` is `{"$ref": ...}`.
1421- All-`Item` children are a list, or a dict when every one carries `key=`. A repeated tag is a list. A text-only 1422- All-`Item` children are a list, or a dict when every one carries `key=`. A repeated tag is a list. A text-only
1422 element is its text. Any other attribute is kept as `"@name"`. 1423 element is its text. Any other attribute is kept as `"@name"`.
@@ -1440,11 +1441,13 @@ On the 1.0.2.1 carve of `common.rpf` the run takes about 5 s, with 0 conversion
1440| arrays | 13,449 | 1441| arrays | 13,449 |
1441| lists | 13,465 | 1442| lists | 13,465 |
1442| keyed maps | 526 | 1443| keyed maps | 526 |
1443| polymorphic objects | 6,490 (317 `type` classes over 6,903 typed elements) | 1444| polymorphic objects | 6,663 (317 `type` classes over 6,903 typed elements) |
1444| `NULL` pointers | 278 | 1445| `NULL` pointers | 278 |
1445| references | 924 | 1446| references | 924 |
1446| elements with extra attributes | 5,262 | 1447| elements with extra attributes | 5,262 |
1447 1448
1449The object count includes 173 empty instances across 13 documents (54 types).
1450
1448The 7 roots missing from the 118 occur only in documents that are not well-formed. Counts only: the JSON that 1451The 7 roots missing from the 118 occur only in documents that are not well-formed. Counts only: the JSON that
1449`--out` writes is the game's data and stays local. `tests/test_gamedata_reader.py` checks every convention, 1452`--out` writes is the game's data and stays local. `tests/test_gamedata_reader.py` checks every convention,
1450both dispatch tables, that streaming equals a whole-tree conversion, and the CLI, on synthetic XML. 1453both dispatch tables, that streaming equals a whole-tree conversion, and the CLI, on synthetic XML.
diff --git a/docs/gameinput.md b/docs/gameinput.md
index 23a2230ba..3228808b5 100644
--- a/docs/gameinput.md
+++ b/docs/gameinput.md
@@ -37,10 +37,42 @@ SDL3 is available in one of these ways:
37- **A local copy of that tarball**: extract it and pass `-DFETCHCONTENT_SOURCE_DIR_SDL3=<path to SDL3-3.4.20>`; it is 37- **A local copy of that tarball**: extract it and pass `-DFETCHCONTENT_SOURCE_DIR_SDL3=<path to SDL3-3.4.20>`; it is
38 built the same way, without a download. 38 built the same way, without a download.
39 39
40Without any of these, or with `-DLEONIDA_SDL3=OFF`, configure prints a message and `gta6rt` is built without the shim: 40Without any of these, or with `-DLEONIDA_SDL3=OFF`, configure prints a message and `gta6rt` is built without the SDL3
41it has no `GameInputCreate`, as before, so the loader binds it to the host's `GameInput.dll` or the unimplemented 41shim. It links `runtime/shims/gameinput_no_sdl.cpp` instead, which still serves `GameInputCreate` (by name and as
42thunk. `gameinput_test` and `gameinput_probe` are not built, and CTest lists `gameinput` as not run (disabled) rather 42`gameinput.dll!#1`): with no devices, or with `LEONIDA_INPUT_SCRIPT` set with one scripted pad (see
43than failing. 43[Scripted input without SDL3](#scripted-input-without-sdl3)). `gameinput_test` and `gameinput_probe` are not built,
44and CTest lists `gameinput` and `gameinput_script` as not run (disabled) rather than failing; `gameinput_no_sdl` and
45`gameinput_no_sdl_script` run instead.
46
47### Scripted input without SDL3
48
49The Windows artifacts of CI and offline builds have no SDL3. Without a device, the title waits at its first "press A"
50prompt forever, so no headless or CI run could get past it. With `LEONIDA_INPUT_SCRIPT` set, such a build serves one
51scripted pad, driven by the script alone:
52
53- **The device:** an Xbox One gamepad named `Scripted pad (Leonida)`, connected from the first `GameInputCreate`. It
54 is reported by `RegisterDeviceCallback` enumeration (blocking on the caller's thread, async from a thread of the
55 shim, or through `IGameInputDispatcher::Dispatch` once the title made a dispatcher) and found by `FindDeviceFromId`.
56 It is already connected, so a callback registered without enumeration hears nothing.
57- **The readings:** `GetCurrentReading`, `GetNextReading` and `GetPreviousReading`, with gamepad, UI navigation,
58 controller axis and controller button state. A reading is taken when the title asks for one and the script's state
59 has changed since the last, so no thread polls; the history keeps the last 64 readings.
60- **The timeline:** the same as with SDL3 (`runtime/shims/gameinput_script.h` holds the parser, the timeline and the
61 log lines for both): seconds from the first `GameInputCreate`, each press held 300 ms, then released.
62- **Not served:** reading callbacks, aggregate devices, rumble and every other device. Those slots answer `E_NOTIMPL`
63 and log the slot once. Controllers and the [keyboard pad](#keyboard-pad) still need SDL3.
64
65The start of the run logs one line with the counts, and each press logs the same lines as with SDL3:
66
67```text
68[rt] gameinput: served without SDL3: one scripted pad for LEONIDA_INPUT_SCRIPT (3 scripted press(es), 0 rejected); controllers and the keyboard pad need SDL3
69[rt] gameinput: scripted press of button 0 at 40.0 s
70[rt] gameinput: press a@40.0 (Scripted pad (Leonida))
71```
72
73A press is logged when the title reads it, so a press the title never reads is not logged. `LEONIDA_INPUT_LOG=0`
74turns the `press` lines off. Without `LEONIDA_INPUT_SCRIPT`, the shim serves no devices and answers `E_NOTIMPL` for
75every slot past `Release`, as before.
44 76
45`scripts/build_runtime.ps1` (what `make_game.py` runs) builds the shim only on its CMake path, when Visual Studio's 77`scripts/build_runtime.ps1` (what `make_game.py` runs) builds the shim only on its CMake path, when Visual Studio's
46C++ CMake tools are installed. Its direct-`cl.exe` fallback compiles a fixed file list without the shim and warns 78C++ CMake tools are installed. Its direct-`cl.exe` fallback compiles a fixed file list without the shim and warns
@@ -302,7 +334,7 @@ line is logged when it takes effect); tracking goes on underneath, so clearing i
302| `LEONIDA_PROMPTS_SWITCH_MS` | `300` | shortest time between two changes of the active input family, 0..2000 ms | 334| `LEONIDA_PROMPTS_SWITCH_MS` | `300` | shortest time between two changes of the active input family, 0..2000 ms |
303| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) | 335| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) |
304| `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus | 336| `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus |
305| `LEONIDA_INPUT_SCRIPT` | unset | With the keyboard pad enabled, set comma-separated `button@seconds` entries, e.g. `a@2,a@4,start@6`. The first pad update reads the script once at startup and starts the clock. `reload_config()` does not reread it. Each press lasts 300 ms. Buttons are `a b x y start back lb rb up down left right`. Spaces around entries are allowed. Empty entries, unknown buttons and invalid times (including negative or non-finite values) are counted and ignored. | 337| `LEONIDA_INPUT_SCRIPT` | unset | Comma-separated `button@seconds` entries, e.g. `a@2,a@4,start@6`. With SDL3 they drive the keyboard pad, which has to be enabled; without SDL3 they drive [one scripted pad](#scripted-input-without-sdl3), the only device. The first pad update (without SDL3, the first `GameInputCreate`) reads the script once at startup and starts the clock. `reload_config()` does not reread it. Each press lasts 300 ms. Buttons are `a b x y start back lb rb up down left right`. Spaces around entries are allowed. Empty entries, unknown buttons and invalid times (including negative or non-finite values) are counted and ignored. |
306| `LEONIDA_MOUSE_SENSITIVITY` | `1` | scales how far the mouse moves the keyboard pad's right stick, 0.1..10 | 338| `LEONIDA_MOUSE_SENSITIVITY` | `1` | scales how far the mouse moves the keyboard pad's right stick, 0.1..10 |
307 339
308SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to 340SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to
@@ -461,6 +493,14 @@ rests on a transcription rather than on a side-by-side compile.
461 button, the touchpad, a trigger or a stick, stick drift and a one-count mouse jitter ignored, a real mouse movement 493 button, the touchpad, a trigger or a stick, stick drift and a one-count mouse jitter ignored, a real mouse movement
462 counted, the 300 ms window on the real clock, and `LEONIDA_PROMPTS` forcing, changing, ignoring an unknown value 494 counted, the 300 ms window on the real clock, and `LEONIDA_PROMPTS` forcing, changing, ignoring an unknown value
463 and clearing. 495 and clearing.
496- `gameinput_no_sdl_test` (CTest, only in a build without SDL3, no controller): `gameinput_no_sdl` checks the
497 identity-only object (both names served, `AddRef`/`Release`, `E_NOTIMPL` without touching the out-parameter).
498 `gameinput_no_sdl_script` sets `LEONIDA_INPUT_SCRIPT` with overlapping presses, a mixed-case name, `rsup` and three
499 rejected entries, puts the shim on a fake clock and checks the scripted pad: blocking, async and dispatcher
500 enumeration (and none without enumeration, for another status or another kind), the device info, `FindDeviceFromId`,
501 the buttons, UI navigation and right stick read at chosen times (held for 0.3 s, a later press of the same button
502 not cut short, nothing after the script), no new reading without a change, `GetPreviousReading` and
503 `GetNextReading`, no motion, and reading callbacks answering `E_NOTIMPL`.
464- `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through 504- `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through
465 `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony 505 `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony
466 `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick, 506 `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick,
diff --git a/docs/gbuffer.md b/docs/gbuffer.md
index de76f4746..9813a3306 100644
--- a/docs/gbuffer.md
+++ b/docs/gbuffer.md
@@ -82,3 +82,16 @@ captured PSO):
82 verified against the lighting pass). 82 verified against the lighting pass).
83- The runtime must therefore bind the PSO's declared `RTVFormats[]` rather than inferring `R16G16B16A16_FLOAT` for all 83- The runtime must therefore bind the PSO's declared `RTVFormats[]` rather than inferring `R16G16B16A16_FLOAT` for all
84 G-buffer attachments from `OSG1` or `exp ... compr`. 84 G-buffer attachments from `OSG1` or `exp ... compr`.
85
86## 4. Reproducing the census (`tools/gbuffer_census.py`)
87
88```powershell
89python -I tools/gbuffer_census.py <work>\shaders\dxbc [--disasm <dir>] [--payload-coverage]
90```
91
92Reads `index.json`, each pixel shader's `OSG1` output signature, and the matching `.s` listing under `--disasm`
93(default `<dxbc>\disasm`), and prints JSON counts for four cohorts (all indexed PS, case-folded `deferred` entry
94names, case-sensitive `Deferred` stems, and `PS_DeferredTextured` stems) with declared target counts, signature
95layouts, and observed `exp mrtN` export modes (`compr` vs `uncompressed`). With `--payload-coverage`, it also counts
96distinct whole FSSM payloads per cohort and histograms how many indexed entries share each payload. Standard library
97only; outputs counts and layouts only (no shader text).
diff --git a/docs/gpu_test_results.md b/docs/gpu_test_results.md
index 25a73c7f5..1c3d4d894 100644
--- a/docs/gpu_test_results.md
+++ b/docs/gpu_test_results.md
@@ -6,12 +6,17 @@ post counts and pass/fail lines there, never game shaders, logs or private paths
6 6
7| GPU | Driver, OS | Commit | build.py | check.py | run_gpu_tests.py | Failed | Entry | 7| GPU | Driver, OS | Commit | build.py | check.py | run_gpu_tests.py | Failed | Entry |
8|---|---|---|---|---|---|---|---| 8|---|---|---|---|---|---|---|---|
9| NVIDIA GeForce RTX 5070 Ti (Blackwell), subgroup 32 | NVIDIA 621.01, Windows 11 26300.9457 | `e0b08c7` | not run; pre-disassembled subset | run via run_gpu_tests.py | **Subset:** 82/98 passed, 16 skipped (native); 98/98 passed (`LEONIDA_W64_EMULATE=1`); Python assembler, no spirv-val. ctest 280/280 (MSVC) | none in the subset | [local note](../gpu-test-results/RTX5070Ti-62101.txt) |
9| NVIDIA GeForce RTX 3080 Ti (Ampere), subgroup 32..32 | NVIDIA 616.92, Windows 11 26300.9974 | `d478a92` | not run; pre-disassembled subset | run via run_gpu_tests.py | **Subset:** 81/97 passed, 16 skipped (native); 97/97 passed (`LEONIDA_W64_EMULATE=1`); Python assembler, no spirv-val | none in the subset | [local note](../gpu-test-results/RTX3080Ti-61692.txt) | 10| NVIDIA GeForce RTX 3080 Ti (Ampere), subgroup 32..32 | NVIDIA 616.92, Windows 11 26300.9974 | `d478a92` | not run; pre-disassembled subset | run via run_gpu_tests.py | **Subset:** 81/97 passed, 16 skipped (native); 97/97 passed (`LEONIDA_W64_EMULATE=1`); Python assembler, no spirv-val | none in the subset | [local note](../gpu-test-results/RTX3080Ti-61692.txt) |
10| AMD Radeon RX 9070 GRE (RDNA4, GFX1201), subgroup 32..64 | RADV, Mesa 26.3.1-arch3.5, Vulkan 1.4.363, CachyOS | `05961f0` | 264/264 translated and valid | 203/206 pass, 3 skipped | 218/235 passed, 16 skipped (native and emulated) | `ms_wave_info_s3`, flaky (see below) | [local note](../gpu-test-results/RX9070GRE.txt) | 11| AMD Radeon RX 9070 GRE (RDNA4, GFX1201), subgroup 32..64 | RADV, Mesa 26.3.1-arch3.5, Vulkan 1.4.363, CachyOS | `05961f0` | 264/264 translated and valid | 203/206 pass, 3 skipped | 218/235 passed, 16 skipped (native and emulated) | `ms_wave_info_s3`, flaky (see below) | [local note](../gpu-test-results/RX9070GRE.txt) |
11| AMD Radeon RX 9070 XT (RDNA4, GFX1201), subgroup 32..64 | AMD 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 26300.9550 | `5d74c27` | not run | not run | 224/241 passed, 16 skipped, 1 failed (native); 225/241 passed, 0 failed (`LEONIDA_W64_EMULATE=1`) | `ms_wave_info_s3`, every native run, flaky emulated (see below) | [local note](../gpu-test-results/RX9070XT.txt) | 12| AMD Radeon RX 9070 XT (RDNA4, GFX1201), subgroup 32..64 | AMD 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 26200.9974 | `58be9cd` | exit 0 (native and emulated) | 219/222 pass, 3 skipped (mesh fixtures build.py does not build) | 236/252 passed, 16 skipped, 0 failed (native and `LEONIDA_W64_EMULATE=1`) | none | [local note](../gpu-test-results/RX9070XT.txt) |
13| AMD Radeon RX 9070 (RDNA4, GFX1201), subgroup 32..64 | AMD 26.11.2 (LLPC), 32.0.32029.2010, Vulkan 1.4.359, Windows 11 26200.9974 | `d0da7da` | not run | not run | 231/249 passed, 16 skipped, 2 failed (native and `LEONIDA_W64_EMULATE=1` alike) | `cs_imgload_tfe`, `cs_imgload_d16_tfe`: the fixtures' expectation (#98); `ms_wave_info_s3` passes | [local note](../gpu-test-results/RX9070.txt) |
14| AMD Radeon Graphics, Ryzen 5 7600X iGPU (RDNA2, gfx1036), subgroup 32..64 | AMD 26.11.2, 32.0.21045.29003, Vulkan 1.4.315, Windows 11 26200.9974 | `d0da7da` | not run | not run | 224/249 passed, 23 skipped, 2 failed (native and `LEONIDA_W64_EMULATE=1` alike) | `cs_imgload_tfe`, `cs_imgload_d16_tfe`: the fixtures' expectation (#98) | [local note](../gpu-test-results/Raphael-7600X-Win.txt) |
12| AMD Radeon RX 7900 GRE (RDNA3, gfx1100), subgroup 32..64 | AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 x64 | `5d74c27` | 247/247 translated and valid | run via run_gpu_tests.py | 225/241 passed, 16 skipped | none | [#166](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7115041436) | 15| AMD Radeon RX 7900 GRE (RDNA3, gfx1100), subgroup 32..64 | AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359, Windows 11 x64 | `5d74c27` | 247/247 translated and valid | run via run_gpu_tests.py | 225/241 passed, 16 skipped | none | [#166](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7115041436) |
13| Intel Graphics (Meteor Lake, Xe-LPG), subgroup 8..32 | ANV, Mesa 26.2.7, Vulkan 1.4.354, Fedora 45 | `84347bb` | 279/279 translated and valid | 177/219 pass, 40 skipped, 2 failed | 194/248 passed, 52 skipped (native); 226/248 passed, 20 skipped (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31; pass with #98) | [local note](../gpu-test-results/IntelMTL.txt) | 16| Intel Graphics (Meteor Lake, Xe-LPG), subgroup 8..32 | ANV, Mesa 26.2.7, Vulkan 1.4.354, Fedora 45 | `84347bb` | 279/279 translated and valid | 177/219 pass, 40 skipped, 2 failed | 194/248 passed, 52 skipped (native); 226/248 passed, 20 skipped (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31; pass with #98) | [local note](../gpu-test-results/IntelMTL.txt) |
17| NVIDIA GeForce RTX 5070 Ti (Blackwell), subgroup 32..32 | NVIDIA 617.42, Vulkan 1.4.351, Windows 11 Pro 26300 | `21625bc` | 257/257 translated and valid (run_gpu_tests.py) | run via run_gpu_tests.py | 197/248 passed, 49 skipped, 2 failed (native); 229/248 passed, 17 skipped, 2 failed (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31) | [local note](../gpu-test-results/RTX5070Ti.txt) |
14| Apple M5 Pro (16-core GPU, Metal 4), subgroup 4..32 | MoltenVK 1.4.2 (Homebrew), Vulkan 1.4.357, macOS 26.7.3 (25G342) | `d42773d07` | 280/280 translated and valid | 175/219 pass, 39 skipped, 5 failed | 183/248 passed, 61 skipped, 4 failed (native); 214/248 passed, 30 skipped, 4 failed (`LEONIDA_W64_EMULATE=1`) | `cs_fma_fused` (known row), `cs_imgload_tfe`, `cs_imgload_d16_tfe` (pass with #291), `ps_imgatomic` flake (#543) | [local note](../gpu-test-results/AppleM5Pro.txt) | 18| Apple M5 Pro (16-core GPU, Metal 4), subgroup 4..32 | MoltenVK 1.4.2 (Homebrew), Vulkan 1.4.357, macOS 26.7.3 (25G342) | `d42773d07` | 280/280 translated and valid | 175/219 pass, 39 skipped, 5 failed | 183/248 passed, 61 skipped, 4 failed (native); 214/248 passed, 30 skipped, 4 failed (`LEONIDA_W64_EMULATE=1`) | `cs_fma_fused` (known row), `cs_imgload_tfe`, `cs_imgload_d16_tfe` (pass with #291), `ps_imgatomic` flake (#543) | [local note](../gpu-test-results/AppleM5Pro.txt) |
19| NVIDIA GeForce RTX 3080 (Ampere, GA102, 10 GB GDDR6X), subgroup 32..32 | NVIDIA 580.178.04, Vulkan 1.4.312, Ubuntu 26.04 LTS | `d2cd6c0` | not run | not run | 197/248 passed, 49 skipped, 2 failed (native); 229/248 passed, 17 skipped, 2 failed (`LEONIDA_W64_EMULATE=1`) | `cs_imgload_tfe`, `cs_imgload_d16_tfe` (#31; see #280) | [local note](../gpu-test-results/RTX3080.txt) |
15 20
16## AMD Radeon RX 9070 GRE — 2026-11-23 21## AMD Radeon RX 9070 GRE — 2026-11-23
17 22
@@ -37,43 +42,38 @@ Every pixel test other than the flaky mesh fixture was exact (4096/4096).
37AI-assisted (Hermes Agent): built `main` at `05961f0`, ran `build.py`, `check.py` and 42AI-assisted (Hermes Agent): built `main` at `05961f0`, ran `build.py`, `check.py` and
38`run_gpu_tests.py` (native and emulated) on this GPU, and verified the isolated reruns of the one failure. 43`run_gpu_tests.py` (native and emulated) on this GPU, and verified the isolated reruns of the one failure.
39 44
40## AMD Radeon RX 9070 XT — 2026-11-23 45## AMD Radeon RX 9070 XT — 2026-11-24
41 46
42``` 47```
43GPU: AMD Radeon RX 9070 XT (RDNA4 / GFX1201, Navi 48, PCI 1002:7550), subgroup 32..64 48GPU: AMD Radeon RX 9070 XT (RDNA4 / GFX1201, Navi 48, PCI 1002:7550), subgroup 32..64
44Driver: AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359 49Driver: AMD proprietary 26.11.2 (LLPC), Vulkan 1.4.359
45Subgroup: 32..64 (minSubgroupSize 32, maxSubgroupSize 64; default 64, subgroupSizeControl) 50Subgroup: 32..64 (minSubgroupSize 32, maxSubgroupSize 64; default 64, subgroupSizeControl)
46OS: Windows 11, 10.0.26300.9550 51OS: Windows 11, 10.0.26200.9974
47Commit: 5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (main, 2026-11-23) 52Commit: 58be9cdf8df9a31bc7f6c068991f1aed381f7f4d (main, 2026-11-24)
48Tools: llvm-mc from ROCm/AOMP 18.0-12 (LLVM 19.0.0git), SPIRV-Tools v2026.4, 53Tools: llvm-mc LLVM 23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4,
49 CMake 4.4.5, Visual Studio 17 2022 generator, MSVC 19.44.35230.0, Python 3.11.9 54 CMake 4.4.4, Visual Studio 17 2022 generator, MSVC 14.44.35207, Python 3.12.10
50run_gpu_tests.py: 247 shaders: 247 translated, 247 pass spirv-val 55run_gpu_tests.py: 261 shaders: 261 translated, 261 pass spirv-val
51 native: 224/241 passed, 16 skipped, 1 failed 56 native: 236/252 passed, 16 skipped, 0 failed
52 LEONIDA_W64_EMULATE=1: 225/241 passed, 16 skipped, 0 failed 57 LEONIDA_W64_EMULATE=1: 236/252 passed, 16 skipped, 0 failed
53Failed: ms_wave_info_s3: at (0,0) got (-1,-1,-1,-1), want (0.0078,0.0078,0.5,1.0). 58build.py: exit 0, native and emulated (6 mesh fixtures need a DXBC container and are not built)
54 Native: 3 of 3 isolated --filter reruns failed. Emulated: the full-suite 59check.py: 219 of 222 pass, 3 skipped (those mesh fixtures), native and emulated
55 run passed it, then 1 of 3 isolated reruns passed, so the emulated path 60Failed: none
56 is flaky here while native fails every time. Same signature as #6172 /
57 #5273 and as the RTX 4060 record (#8752), where it failed 3 of 3.
58Skipped: 16 skips are the documented "run by d3d12_*_test / w64_graphics.py" cases. 61Skipped: 16 skips are the documented "run by d3d12_*_test / w64_graphics.py" cases.
59``` 62```
60 63
61Setup: `cmake -S runtime -B runtime/build` (default Visual Studio 17 2022 generator) and 64Setup: `cmake -S runtime -B runtime/build` (default Visual Studio 17 2022 generator) and
62`cmake --build runtime/build --config RelWithDebInfo`. The suite ran on the AMD LLPC driver with 65`cmake --build runtime/build --config RelWithDebInfo`; then `run_gpu_tests.py`, and `build.py <out>` with
63the project's own `vk_harness`, `vk_compute_test` and `vk_store_test` binaries; no implicit layer 66`check.py <out> runtime/build/RelWithDebInfo`, each once without and once with `LEONIDA_W64_EMULATE=1`. The suites
64beyond the Vulkan SDK's. Every other pixel and compute case was exact. 67ran on the AMD LLPC driver with the project's own `vk_harness`, `vk_compute_test` and `vk_store_test` binaries; no
65 68implicit layer beyond the Vulkan SDK's.
66The one failure is worth a note for #6172: on this machine the native 64-wide path fails 69
67`ms_wave_info_s3` on every run, while `LEONIDA_W64_EMULATE=1` passes it most of the time, which is 70This replaces the 2026-11-23 record (`5d74c27`), which had `ms_wave_info_s3` failing on every native run and
68the shape a lane-set-dependent race takes rather than a driver-specific miscompile. It also 71`build.py` / `check.py` not run. On `58be9cd` the same driver passes `ms_wave_info_s3` with 4096/4096 exact pixels in
69reproduces with an AMD proprietary driver, so the symptom is not tied to RADV or to Mesa's shader 72both full runs and in 3 of 3 isolated `--filter` reruns each way, and the D3D12-side columns are measured for the
70cache. 73first time on this card. The two `cs_imgload*_tfe` failures of earlier runs are gone with the fixture fix (#892).
71 74
72`build.py` and `check.py` (the D3D12-side rows in the table) were not run here; the counts above 75AI-assisted: built `main` at `58be9cd` with MSVC, ran the three scripts native and under `LEONIDA_W64_EMULATE=1`,
73come from `run_gpu_tests.py`, which builds and translates the same fixtures. 76and reran `ms_wave_info_s3` in isolation three times each way.
74
75AI-assisted (Cline): built `main` at `5d74c27` with MSVC, ran `run_gpu_tests.py` native and under
76`LEONIDA_W64_EMULATE=1`, and reran the failure in isolation three times each way.
77 77
78## AMD Radeon RX 7900 GRE — 2026-11-23 78## AMD Radeon RX 7900 GRE — 2026-11-23
79 79
diff --git a/docs/i18n/README.md b/docs/i18n/README.md
index 35fa1ef96..82cb57c29 100644
--- a/docs/i18n/README.md
+++ b/docs/i18n/README.md
@@ -24,3 +24,8 @@ A language is added when a contributor volunteers to maintain it and keeps the s
24| Deutsch (`de`) | [`de/quickstart.md`](de/quickstart.md) | `aa2988cc` | `@zGLados` | 24| Deutsch (`de`) | [`de/quickstart.md`](de/quickstart.md) | `aa2988cc` | `@zGLados` |
25| Italiano (`it`) | [`it/quickstart.md`](it/quickstart.md) | `49475796` | `@MeNoSkills` | 25| Italiano (`it`) | [`it/quickstart.md`](it/quickstart.md) | `49475796` | `@MeNoSkills` |
26| العربية (`ar`) | [`ar/quickstart.md`](ar/quickstart.md) | `561b65a` | `@Mohamed-Leo` | 26| العربية (`ar`) | [`ar/quickstart.md`](ar/quickstart.md) | `561b65a` | `@Mohamed-Leo` |
27
28## Other community translations
29
30- French translation of [`CONTRIBUTING.md`](../../CONTRIBUTING.md): [`fr/contributing.md`](fr/contributing.md), synced
31 with commit `1ab957b3`. No maintainer is named in the file.
diff --git a/docs/i18n/it/quickstart.md b/docs/i18n/it/quickstart.md
index d42f35727..432b1eb72 100644
--- a/docs/i18n/it/quickstart.md
+++ b/docs/i18n/it/quickstart.md
@@ -96,8 +96,8 @@ python -I make_game.py --wave64-emulate off # auto (predefinito), on
96``` 96```
97 97
98La fase `check` viene eseguita sempre per prima; poi, quando sono selezionate, `shaders`, `assets` e `runtime` vengono eseguite insieme (non dipendono l'una dall'altra). `pipelines` parte quando gli shader tradotti sono pronti. 98La fase `check` viene eseguita sempre per prima; poi, quando sono selezionate, `shaders`, `assets` e `runtime` vengono eseguite insieme (non dipendono l'una dall'altra). `pipelines` parte quando gli shader tradotti sono pronti.
99`pipelines` crea ogni shader tradotto sul driver della tua GPU e salva una cache delle pipeline, così al primo 99`pipelines` crea ogni shader tradotto sul driver della tua GPU e salva una cache delle pipeline in
100avvio non devono essere compilati. La traduzione degli shader è il passaggio più lungo: usa `--jobs` processi 100`pipeline_cache.bin` (in `--out`). La traduzione degli shader è il passaggio più lungo: usa `--jobs` processi
101(per impostazione predefinita metà dei thread della CPU). 101(per impostazione predefinita metà dei thread della CPU).
102 102
103- **`--wave64-emulate`**: traduce gli shader compute e mesh wave64 in modo che siano esatti con qualunque 103- **`--wave64-emulate`**: traduce gli shader compute e mesh wave64 in modo che siano esatti con qualunque
diff --git a/docs/i18n/ja/quickstart.md b/docs/i18n/ja/quickstart.md
index 2924be033..d9a45926f 100644
--- a/docs/i18n/ja/quickstart.md
+++ b/docs/i18n/ja/quickstart.md
@@ -84,8 +84,8 @@ python -I make_game.py --wave64-emulate off # auto(既定)、onã€
84``` 84```
85 85
86`check` ステージは常に最初に実行され、選択した場合は `shaders`、`assets`、`runtime` が同時に実行されます(互いに依存しません)。`pipelines` は翻訳済みのシェーダーが揃い次第開始されます。このステージは 86`check` ステージは常に最初に実行され、選択した場合は `shaders`、`assets`、`runtime` が同時に実行されます(互いに依存しません)。`pipelines` は翻訳済みのシェーダーが揃い次第開始されます。このステージは
87翻訳済みの各シェーダーをあなたの GPU ドライバー上で生成してパイプラインキャッシュを保存するので、初回起動時の 87翻訳済みの各シェーダーをあなたの GPU ドライバー上で生成し、パイプラインキャッシュを `--out` の
88コンパイルが不要になります。最も時間がかかるのはシェーダーの翻訳で、`--jobs` 個のプロセスで実行されます 88`pipeline_cache.bin` に保存します。最も時間がかかるのはシェーダーの翻訳で、`--jobs` 個のプロセスで実行されます
89(既定では CPU スレッド数の半分)。 89(既定では CPU スレッド数の半分)。
90 90
91- **`--wave64-emulate`**: wave64 の compute / mesh シェーダーを、どのサブグループサイズでも正確になるように 91- **`--wave64-emulate`**: wave64 の compute / mesh シェーダーを、どのサブグループサイズでも正確になるように
diff --git a/docs/i18n/pl-PL/quickstart.md b/docs/i18n/pl-PL/quickstart.md
index 29cfb6a08..3bad5af88 100644
--- a/docs/i18n/pl-PL/quickstart.md
+++ b/docs/i18n/pl-PL/quickstart.md
@@ -95,8 +95,8 @@ python -I make_game.py --wave64-emulate off # auto (domyślnie), on l
95``` 95```
96 96
97Etap `check` zawsze wykonuje się pierwszy; następnie, jeśli zostały wybrane, `shaders`, `assets` i `runtime` wykonują się równocześnie (nie zależą od siebie). Etap `pipelines` startuje, gdy przetłumaczone shadery są gotowe. Ten etap 97Etap `check` zawsze wykonuje się pierwszy; następnie, jeśli zostały wybrane, `shaders`, `assets` i `runtime` wykonują się równocześnie (nie zależą od siebie). Etap `pipelines` startuje, gdy przetłumaczone shadery są gotowe. Ten etap
98tworzy każdy przetłumaczony shader na sterowniku Twojej karty graficznej i zapisuje cache potoków, żeby pierwsze 98tworzy każdy przetłumaczony shader na sterowniku Twojej karty graficznej i zapisuje cache potoków
99uruchomienie nie musiało ich kompilować. Tłumaczenie shaderów trwa najdłużej i domyślnie używa połowy wątków 99w `pipeline_cache.bin` (w `--out`). Tłumaczenie shaderów trwa najdłużej i domyślnie używa połowy wątków
100procesora (można to zmienić przez `--jobs`). 100procesora (można to zmienić przez `--jobs`).
101 101
102- **`--wave64-emulate`**: decyduje, czy shadery compute i mesh wave64 są tłumaczone tak, by były dokładne przy 102- **`--wave64-emulate`**: decyduje, czy shadery compute i mesh wave64 są tłumaczone tak, by były dokładne przy
diff --git a/docs/i18n/ru/quickstart.md b/docs/i18n/ru/quickstart.md
index 818e47fe4..4b1d89a80 100644
--- a/docs/i18n/ru/quickstart.md
+++ b/docs/i18n/ru/quickstart.md
@@ -112,10 +112,12 @@ python -I make_game.py --game "D:\путь\к\пакету" --wav # ещё и Op
112python -I make_game.py --wave64-emulate off # auto (по умолчанию), on или off 112python -I make_game.py --wave64-emulate off # auto (по умолчанию), on или off
113``` 113```
114 114
115Этапы идут в таком порядке: `check`, `shaders`, `assets`, `runtime`, `pipelines`. Последний создаёт все 115`check` всегда идёт первым; затем выбранные `shaders`, `assets` и `runtime` выполняются одновременно (они не
116переведённые шейдеры на драйвере вашей видеокарты, проверяет, что они компилируются, сообщает о пропущенных и 116зависят друг от друга). `pipelines` начинается, как только готовы переведённые шейдеры и, если в этот запуск входит
117сохраняет кеш конвейеров в `pipeline_cache.bin` в `--out`. Runtime этот кеш пока не загружает, так что первую 117`runtime`, этот этап закончил пересобирать `vk_pipeline_check`, так что он может идти параллельно с остатком
118загрузку он не ускоряет. Перевод шейдеров самый долгий: он выполняется в `--jobs` процессов (по умолчанию 118`assets`. Этап `pipelines` создаёт все переведённые шейдеры на драйвере вашей видеокарты, проверяет, что они
119компилируются, сообщает о пропущенных и сохраняет кеш конвейеров в `pipeline_cache.bin` в `--out`. Runtime этот
120кеш пока не загружает, так что первую загрузку он не ускоряет. Перевод шейдеров самый долгий: он выполняется в `--jobs` процессов (по умолчанию
119половина потоков процессора). 121половина потоков процессора).
120 122
121- **`--wave64-emulate`**: переводить ли compute- и mesh-шейдеры wave64 так, чтобы они работали точно при любом 123- **`--wave64-emulate`**: переводить ли compute- и mesh-шейдеры wave64 так, чтобы они работали точно при любом
diff --git a/docs/linux.md b/docs/linux.md
index f051ca84a..c9ea03b84 100644
--- a/docs/linux.md
+++ b/docs/linux.md
@@ -16,6 +16,7 @@ names; the build lists anything it can't find before it starts.
16| Shader translator, its tests and the GPU test tools (`vk_harness`, `vk_pipeline_check`, ...) | Native, GCC or Clang | CI (`linux-gpu-tools`: GCC, tests on llvmpipe); Clang builds them too, but no CI job uses it yet | 16| Shader translator, its tests and the GPU test tools (`vk_harness`, `vk_pipeline_check`, ...) | Native, GCC or Clang | CI (`linux-gpu-tools`: GCC, tests on llvmpipe); Clang builds them too, but no CI job uses it yet |
17| `rpf9dump` (asset export) | Native, .NET 8 or newer | CI builds it on Windows only (the `check` job) | 17| `rpf9dump` (asset export) | Native, .NET 8 or newer | CI builds it on Windows only (the `check` job) |
18| `gta6rt`, its shims and their tests | Windows program, under Wine or Proton | Cross-built with clang-cl and xwin; CI runs the Windows build under Wine on pushes to `main` | 18| `gta6rt`, its shims and their tests | Windows program, under Wine or Proton | Cross-built with clang-cl and xwin; CI runs the Windows build under Wine on pushes to `main` |
19| `scripts/run_game_wine.sh`: one retail run under Wine, headless or visible, counts only ([linux_proton.md](linux_proton.md#running-the-game-under-wine-with-one-command)) | Native (`bash`) around the Windows `gta6rt` | `tests/test_run_game_wine.py` and `tests/test_game_run_summary.py`, without the game |
19 20
20## Build the port 21## Build the port
21 22
@@ -118,3 +119,36 @@ python3 -I tests/test_<name>.py # one standard-
118 119
119[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
120the GPU. 121the GPU.
122
123### Without root (micromamba)
124
125If you cannot install distribution packages (no `sudo`), you can install `llvm-tools` and `spirv-tools` into a
126user-owned folder with [micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)
127(x86-64 glibc; for ARM64 use `linux-aarch64` from the micromamba guide; musl/Alpine is not natively supported) and let
128CMake fetch its pinned, hash-checked Vulkan headers if the system does not provide them:
129
130```bash
131LEO=$HOME/leonida-tools
132mkdir -p "$LEO/bin" "$LEO/mamba"
133# Note: `latest` is unpinned and downloaded without signature verification; inspect or pin per the micromamba guide.
134curl -fsSLo "$LEO/micromamba.tar.bz2" https://micro.mamba.pm/api/micromamba/linux-64/latest
135tar -xjf "$LEO/micromamba.tar.bz2" -C "$LEO/bin" --strip-components=1 bin/micromamba
136
137export MAMBA_ROOT_PREFIX="$LEO/mamba"
138"$LEO/bin/micromamba" create -y -n leonida -c conda-forge --override-channels "llvm-tools>=21" spirv-tools
139export PATH="$LEO/mamba/envs/leonida/bin:$PATH"
140
141cmake -S runtime -B runtime/build/linux -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_VULKAN_HEADERS_FETCH=ON
142cmake --build runtime/build/linux --parallel "$(nproc)"
143LLVM_MC=llvm-mc LEONIDA_VK_DEVICE="<part of your GPU name>" \
144 python3 -I scripts/run_gpu_tests.py --build runtime/build/linux --work "$LEO/run" --require-pass | tee "$LEO/run.log"
145echo "runner exit: ${PIPESTATUS[0]}"
146```
147
148Notes:
149- `LEONIDA_VK_DEVICE` selects the physical GPU by substring so the runner does not fall back to Mesa's `llvmpipe`.
150- Keep `$LEO` on a filesystem without `noexec` (`findmnt -no OPTIONS "$LEO"`).
151- System prerequisites still needed: a working Vulkan driver/loader (`vulkaninfo --summary`), `cmake`, `ninja`, `g++`
152 (or `clang++`), `python3`, `curl`, `tar`, and `bzip2`.
153- Cleanup: delete `$LEO` and `runtime/build/linux`. micromamba also writes `~/.conda/environments.txt` and
154 `~/.mamba/pkgs/urls.txt` (delete only those files if you already use conda).
diff --git a/docs/linux_proton.md b/docs/linux_proton.md
index f98aacf14..de4760d70 100644
--- a/docs/linux_proton.md
+++ b/docs/linux_proton.md
@@ -53,12 +53,61 @@ the layout the comments at their top describe (`/opt/leonida` for traces, overla
53 `__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1`. 53 `__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1`.
54- **Input:** a pad through GameInput/SDL3, or the keyboard pad (`LEONIDA_KEYBOARD_PAD=always`), or a script: 54- **Input:** a pad through GameInput/SDL3, or the keyboard pad (`LEONIDA_KEYBOARD_PAD=always`), or a script:
55 `LEONIDA_INPUT_SCRIPT=a@210,a@240` presses A at those seconds (any length since this branch; it was cut at 63 55 `LEONIDA_INPUT_SCRIPT=a@210,a@240` presses A at those seconds (any length since this branch; it was cut at 63
56 characters before). 56 characters before). The script also works in a build without SDL3, where it drives one scripted pad
57 ([docs/gameinput.md](gameinput.md#scripted-input-without-sdl3)); pads and the keyboard pad need SDL3.
57- **Window:** frames are presented in the title's own window; `LEONIDA_PRESENT_WINDOW=own|hidden` chooses otherwise. 58- **Window:** frames are presented in the title's own window; `LEONIDA_PRESENT_WINDOW=own|hidden` chooses otherwise.
58 59
59Three setup mistakes each give a blank or empty picture without an error: the executable's embedded shaders missing 60Three setup mistakes each give a blank or empty picture without an error: the executable's embedded shaders missing
60from the library (`exe/index.json`), a build without SDL3 (no pad), and a BCPack predictor file that was never 61from the library (`exe/index.json`), a build without SDL3 and without `LEONIDA_INPUT_SCRIPT` (no pad, so nothing
61generated (`tools/build_dstorage_history.py`; without it the loading art and most BC7 textures stay empty). 62gets past the first prompt; set a script, or build with SDL3 for a pad or the keyboard pad), and a BCPack predictor
63file that was never generated (`tools/build_dstorage_history.py`; without it the loading art and most BC7 textures
64stay empty).
65
66## Running the game under Wine with one command
67
68`scripts/run_game_wine.sh` makes one bounded, silent run of the retail game under Wine and prints counts only. It
69complements `scripts/run_wine_session.sh` (the runtime's unit tests under Wine) and the `systemd --user` boot
70wrappers described above: it needs no fixed paths, and its output is a summary that can go into an issue.
71
72```sh
73scripts/run_game_wine.sh --build <build folder or checkout> --exe <game executable> --game-dir <package folder> \
74 --shaders <translated library> --out <new run folder> --device 1002:744c --seconds 600
75```
76
77`--help` lists every input. Each path comes from an argument or from `LEONIDA_GAME_EXE`, `LEONIDA_GAME_DIR` and
78`LEONIDA_SHADERS`; `WINE` names another Wine (Proton's `files/bin/wine`), and `WINEPREFIX` (or `--prefix`) a prefix to
79reuse instead of a new one in the run folder.
80
81What it needs:
82
83- **Wine** (the `wine` on `PATH`, or `WINE`), `timeout`, `flock`, `setsid` and Python 3.
84- **A Vulkan driver** for the GPU (Mesa's RADV was tested). `--device VID:DID` pins it through
85 `MESA_VK_DEVICE_SELECT`; without it the script warns that Mesa picks the device.
86- **A display.** By default the run is headless: a private `kwin_wayland --virtual --xwayland` session under
87 `dbus-run-session`, with its own `XDG_RUNTIME_DIR` in the run folder, so nothing appears on the desktop. Its
88 rootless Xwayland offers DRI3, which RADV needs to present; Xvfb has none, so without `kwin_wayland` the script
89 says what is missing instead of falling back. `--visible` opens the window on the current `DISPLAY` instead.
90- **A runtime build**: a folder with `gta6rt.exe` and `gta6rt_tls_host.dll`, or a checkout, whose `runtime/` it
91 cross-builds first with clang-cl and xwin (`XWIN_DIR`, see [linux.md](linux.md#the-runtime-under-wine-or-proton)).
92
93What it does:
94
95- **Sound off:** Wine's audio drivers are disabled through `WINEDLLOVERRIDES`, PulseAudio, PipeWire and ALSA point
96 at nothing, and `LEONIDA_AUDIO=silent` makes the runtime serve its silent output endpoint
97 ([runtime_imports.md](runtime_imports.md)); the summary says whether it was served.
98- **Limits:** a hard time limit (`--seconds`, then SIGTERM and SIGKILL 10 s later), a lock so one run happens at a
99 time (`--lock`, by default in `XDG_RUNTIME_DIR`), and teardown of Wine and the whole session on exit, time-out or
100 signal.
101- **Traces:** `gta6rt --run` with `--trace` and `--trace-d3d12`, a fresh `--overlay` and save folder in the run
102 folder. Every other `LEONIDA_*` variable reaches the runtime unchanged, so `LEONIDA_INPUT_SCRIPT=a@210,a@240`
103 presses A as above. Arguments after `--` go to `gta6rt`.
104- **Summary:** `tools/game_run_summary.py` prints the run time, how it ended, exceptions by code, D3D12 calls by
105 outcome, presents, the most frequent failing calls and the `[rt]` lines by category with numbers masked. It never
106 prints a log line. `--screenshot-every S` captures the game window into the run folder (ImageMagick's `import` and
107 `xprop`).
108
109The run folder's `stderr.log`, `boot.jsonl` and screenshots can show or quote what the title prints, so they stay on
110your machine; share the summary.
62 111
63## What a healthy boot looks like (Linux machine) 112## What a healthy boot looks like (Linux machine)
64 113
diff --git a/docs/models.md b/docs/models.md
index 85b805feb..ba1cd5433 100644
--- a/docs/models.md
+++ b/docs/models.md
@@ -799,7 +799,7 @@ the drawable's local joint palette through the drawable and ped tables, and emit
799in [character_skeleton.md](character_skeleton.md#skinned-glb-export). On the 1.0.2.1 package, the 799in [character_skeleton.md](character_skeleton.md#skinned-glb-export). On the 1.0.2.1 package, the
800head (8,983 v) and biker jacket (9,818 v) produce one skin with 596 ped joints (703 with the 800head (8,983 v) and biker jacket (9,818 v) produce one skin with 596 ped joints (703 with the
801jacket's `GM_U01_*` helpers); every weight sums to 255 and the rest-pose reconstruction error is 801jacket's `GM_U01_*` helpers); every weight sums to 255 and the rest-pose reconstruction error is
8026e-8 m. `python -I tests/test_skinned_glb.py` runs 24 synthetic tests and needs no game files. 8026e-8 m. `python -I tests/test_skinned_glb.py` runs 30 synthetic tests and needs no game files.
803 803
804`tools/glb_inspect.py` reads such a GLB back without a library, so an export can be checked 804`tools/glb_inspect.py` reads such a GLB back without a library, so an export can be checked
805before it is opened in a viewer: 805before it is opened in a viewer:
diff --git a/docs/movies.md b/docs/movies.md
index e8df76d29..252bef758 100644
--- a/docs/movies.md
+++ b/docs/movies.md
@@ -114,8 +114,9 @@ and then only to a temporary file that is deleted.
114 114
115On this archive both tools find the same 515 streams, the same 8,831,336,892 bytes, 1,094,744 bytes of zero 115On this archive both tools find the same 515 streams, the same 8,831,336,892 bytes, 1,094,744 bytes of zero
116padding and 22,812 bytes after the last stream. Those 22,812 are 3,884 zero bytes and the 18,928-byte RPF trailer 116padding and 22,812 bytes after the last stream. Those 22,812 are 3,884 zero bytes and the 18,928-byte RPF trailer
117(counted by reading the tail directly); `bink_index.py` now counts them as zero padding and `rpf_trailer`, which for 117(counted by reading the tail directly). A read-only rerun of `bink_index.py` at `2d53a8055` on 2026-11-23
118this archive gives `unread_bytes` 0 and zero padding 1,098,628 (derived from the measured tail, not a rerun). Running `bink_index.py` on the 515 carved 118confirmed 1,098,628 bytes of zero padding, 18,928 trailer bytes and 0 unread bytes. The archive matched the
1191.0.2.1 manifest by size and SHA-256. Running `bink_index.py` on the 515 carved
119`.bk2` files finds 515 streams with zero unread bytes, which confirms the stored sizes cover each file exactly. 120`.bk2` files finds 515 streams with zero unread bytes, which confirms the stored sizes cover each file exactly.
120 121
121## 4. Decoding 122## 4. Decoding
diff --git a/docs/progress_dashboard.md b/docs/progress_dashboard.md
index 88647e1f0..8a99ebd8b 100644
--- a/docs/progress_dashboard.md
+++ b/docs/progress_dashboard.md
@@ -13,6 +13,21 @@ start ..\leonida_progress\progress.html
13The page is one self-contained HTML file: no network, no packages, it opens from disk. The project logo 13The page is one self-contained HTML file: no network, no packages, it opens from disk. The project logo
14(`assets/logo.png`) is embedded in it, and the page follows the system theme until you pick one with its theme button. 14(`assets/logo.png`) is embedded in it, and the page follows the system theme until you pick one with its theme button.
15 15
16Use a CTest JUnit report when the run includes tests configured with `SKIP_RETURN_CODE`. CTest can log those
17skips as `Test Passed.` in `LastTest.log`. `--ctest-junit` replaces the local log with the report, which preserves
18the skipped status. Use `--junit` to add independent runs. A new file name for each run keeps an aborted CTest run
19from reusing an older report.
20
21```powershell
22$report = Join-Path $env:TEMP ("leonida-ctest-{0}.xml" -f [guid]::NewGuid())
23ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure --output-junit $report
24if (Test-Path -LiteralPath $report -PathType Leaf) {
25 python -I tools/progress_dashboard.py --out ..\leonida_progress --ctest-junit $report
26} else {
27 throw "CTest did not produce a JUnit report (exit $LASTEXITCODE)."
28}
29```
30
16## Sources 31## Sources
17 32
18Each source is optional. A missing one is listed under "Sources" on the page; it is never counted as zero or as a failure. 33Each source is optional. A missing one is listed under "Sources" on the page; it is never counted as zero or as a failure.
diff --git a/docs/related_projects.md b/docs/related_projects.md
index 18bc6afe5..a3a58ff99 100644
--- a/docs/related_projects.md
+++ b/docs/related_projects.md
@@ -85,32 +85,23 @@ fix should go upstream, not into a copy.
85 85
86## meetox80/6stars 86## meetox80/6stars
87 87
88<https://github.com/meetox80/6stars> — a macOS Swift/Metal engine that renders the world out of RPF9,
89with a Swift `RPFKit` format library and 44 Python research scripts. Independent work: it likewise
90does not decode the TOC.
91
92**Licence: none.** The repository has no `LICENSE` file (GitHub reports `license: null`); only the
93vendored cimgui/imgui carry MIT. With no grant, default copyright applies and the project is
94**all rights reserved** — stricter than PercyStar. **No 6stars code, comment, identifier or table may
95be copied into Leonida.**
96
97**What we use it for:** corroboration and a small number of hypotheses. As an independent reading of
98the same formats it matches our `CEntityDef` member hashes (9/9), the PRD0 header, the navmesh tile
99header, the meshlet group header and the PSIN/LSCH field layout. Its stream-role predicates and
100navmesh surface bits are recorded as hypotheses and tested from our own package, never copied.
101Where it disagrees with us (ETPF format and tile mode, the RDS5 codec field, `atArray` type `0x5C`,
102PSO member hashing) our measurements are the validated ones.
103<https://github.com/meetox80/6stars> 88<https://github.com/meetox80/6stars>
104 89
105A macOS Swift/Metal engine that reads the world from RPF9, with its own archive index and format readers. 90A macOS Swift/Metal engine that renders the world out of RPF9, with its own archive index, a Swift `RPFKit` format
91library and 44 Python research scripts. Independent work: it likewise does not decode the TOC.
106 92
107**Licence: none.** There is no `LICENSE` file and GitHub reports no licence, so all rights are reserved. 93**Licence: none.** The repository has no `LICENSE` file (GitHub reports `license: null`); only the vendored
108**No 6stars code, comments, identifiers or tables may be copied into Leonida.** 94cimgui/imgui carry MIT. With no grant, default copyright applies and the project is **all rights reserved** —
95stricter than PercyStar. **No 6stars code, comments, identifiers or tables may be copied into Leonida.**
109 96
110**What we use it for:** corroboration. Its RPF9 stream-boundary predicate and PRD0 member type codes were 97**What we use it for:** corroboration and a small number of hypotheses. As an independent reading of the same formats
98it matches our `CEntityDef` member hashes (9/9), the PRD0 header, the navmesh tile header, the meshlet group header
99and the PSIN/LSCH field layout. Its stream-role predicates and navmesh surface bits are recorded as hypotheses and
100tested from our own package, never copied. Its RPF9 stream-boundary predicate and PRD0 member type codes were
111re-measured against this package before entering [rpf.md](rpf.md) and [world.md](world.md); its navmesh 101re-measured against this package before entering [rpf.md](rpf.md) and [world.md](world.md); its navmesh
112road/pavement bit labels did not reproduce and are not used. The navmesh polygon `+4` packing it reads is the one 102road/pavement bit labels did not reproduce and are not used. The navmesh polygon `+4` packing it reads is the one our
113our decoder already validates ([navmesh.md](navmesh.md)). 103decoder already validates ([navmesh.md](navmesh.md)). Where it disagrees with us (ETPF format and tile mode, the RDS5
104codec field, `atArray` type `0x5C`, PSO member hashing) our measurements are the validated ones.
114 105
115## p-portela/SCARAB 106## p-portela/SCARAB
116 107
@@ -148,6 +139,24 @@ re-measured on this package by `tools/navmesh_nodes.py`
148confirmed by the lane-graph heights. The label is consistent with the count, but not settled by it: nine in ten 139confirmed by the lane-graph heights. The label is consistent with the count, but not settled by it: nine in ten
149lane nodes stand on polygons with both bit 8 and bit 13, and which bit or combination means road surface is open. 140lane nodes stand on polygons with both bit 8 and bit 13, and which bit or combination means road surface is open.
150 141
142## Marvisak/VIctory
143
144<https://github.com/Marvisak/VIctory>
145
146A Windows compatibility project for Xbox Series. Its GPU layer translates console command streams to host
147Direct3D 12.
148
149**Licence:** **GPL-3.0-or-later**, as declared in the [workspace manifest][victory-workspace] and the
150[README][victory-readme]. The [GPU crate][victory-gpu] inherits the workspace licence.
151
152**What we use it for:** prior art for deferring CPU-side value writes until the recorded command-list work has
153completed, as discussed in [#622](https://github.com/ubiquitarianism/leonida/pull/622). That PR uses synthetic
154tests to verify the ordering of submissions and writes in Leonida's own implementation.
155
156[victory-workspace]: https://github.com/Marvisak/VIctory/blob/ffe310eb2098e52169f4c44db5ffdabf43a72622/Cargo.toml
157[victory-readme]: https://github.com/Marvisak/VIctory/blob/ffe310eb2098e52169f4c44db5ffdabf43a72622/README.md#license
158[victory-gpu]: https://github.com/Marvisak/VIctory/blob/ffe310eb2098e52169f4c44db5ffdabf43a72622/crates/victory-gpu/Cargo.toml
159
151## microsoft/libHttpClient 160## microsoft/libHttpClient
152 161
153<https://github.com/microsoft/libHttpClient> 162<https://github.com/microsoft/libHttpClient>
diff --git a/docs/rpf.md b/docs/rpf.md
index 7bc656845..8b374ce42 100644
--- a/docs/rpf.md
+++ b/docs/rpf.md
@@ -129,6 +129,17 @@ scanners on a 48 MiB gap and checks that each one's Python heap peak stays under
129The carve is read-only and works on any `.rpf`, `.ttpf` or archive-like file. It does not decrypt the TOC, use 129The carve is read-only and works on any `.rpf`, `.ttpf` or archive-like file. It does not decrypt the TOC, use
130keys, or write anything outside the output directory. 130keys, or write anything outside the output directory.
131 131
132Once one or more archives have been carved under `<work>\carve`, `tools/classify_carve.py` groups every entry by
133signature using only the per-archive `index.json` files (no carved payload reads):
134
135```powershell
136python -I tools/classify_carve.py <work>\carve
137```
138
139It classifies each entry as `bink2` (`KB2x`), `rbf0` (`52424630`), `respage` (`42400000`), `gpu-zerohdr` (16+ leading
140zero bytes), or `other:<hex>` (first 4 bytes), prints a summary table, and writes `<work>\carve\types.json` with
141overall and per-archive file counts, total bytes, and `min`/`max`/`median` (`median_low`) byte sizes.
142
132## Recovery tools 143## Recovery tools
133 144
134`tools/rpf9dump` is a bulk exporter built on the Core library from 145`tools/rpf9dump` is a bulk exporter built on the Core library from
diff --git a/docs/runtime_imports.md b/docs/runtime_imports.md
index 9c1b28c7b..3d6efb25f 100644
--- a/docs/runtime_imports.md
+++ b/docs/runtime_imports.md
@@ -64,6 +64,16 @@ Since the library-loader shims (`runtime/shims/library_loader.cpp`), a module's
64 64
65The process shim (`runtime/shims/process.cpp`) serves `ExitProcess` and `GetCommandLineA/W` the same way: through `kernel32`, `kernelbase`, and `api-ms-win-core-processthreads-l1-1-0` and `api-ms-win-core-processenvironment-l1-1-0`, the sets the API-set umbrella libraries (`OneCore_apiset.lib`, `mincore.lib`) bind them to. `vcomp140.dll` imports `ExitProcess` from the first of these. The UCRT's `_get_narrow_winmain_command_line` and `_get_wide_winmain_command_line` are served too, so a `WinMain` executable gets the game's command line as `lpCmdLine`. `abort()` raises `SIGABRT` when the guest installed a handler (the guest's `signal()` import binds to the host CRT, so its table is the one raised here); with the default or ignore disposition, or a handler that returns, the run still ends with code 3. `run_tiny_game_abort_exit_codes` compares that with a native run of the stand-in image. The table above is `gta6rt --dry-run` on each DLL at the commit that added this paragraph. 65The process shim (`runtime/shims/process.cpp`) serves `ExitProcess` and `GetCommandLineA/W` the same way: through `kernel32`, `kernelbase`, and `api-ms-win-core-processthreads-l1-1-0` and `api-ms-win-core-processenvironment-l1-1-0`, the sets the API-set umbrella libraries (`OneCore_apiset.lib`, `mincore.lib`) bind them to. `vcomp140.dll` imports `ExitProcess` from the first of these. The UCRT's `_get_narrow_winmain_command_line` and `_get_wide_winmain_command_line` are served too, so a `WinMain` executable gets the game's command line as `lpCmdLine`. `abort()` raises `SIGABRT` when the guest installed a handler (the guest's `signal()` import binds to the host CRT, so its table is the one raised here); with the default or ignore disposition, or a handler that returns, the run still ends with code 3. `run_tiny_game_abort_exit_codes` compares that with a native run of the stand-in image. The table above is `gta6rt --dry-run` on each DLL at the commit that added this paragraph.
66 66
67The lifecycle shim (`runtime/shims/lifecycle.cpp`) serves `RegisterAppStateChangeNotification` and
68`UnregisterAppStateChangeNotification` under `api-ms-win-core-psm-appnotify-l1-1-0`, `-l1-1-1` and `kernelbase.dll`, and
69`CreateWindowExW`/`CreateWindowExA` under `user32.dll` and the two `ext-ms-win-rtcore-ntuser-window-l1-1-*` sets, and
70`CreateWindowExA` under `ext-ms-win-rtcore-ntuser-window-ansi-l1-1-0`. The title's import table names
71`RegisterAppStateChangeNotification` from `api-ms-win-core-psm-appnotify-l1-1-0` and `CreateWindowExA` from that ANSI
72set (`tools/pe_inspect.py`). Only the title's first top-level window (no parent, not a child, not a tool window) is fitted to the work area and hooked: its
73`SC_CLOSE` runs the registered suspend callbacks with `quiesced` TRUE under the registration lock, then the run ends
74through the title's own `ExitProcess`, so the host finishes its cleanup. A 1 s deadline ends the run the same way if the
75callbacks have not returned.
76
67The shims added since account for the rest of the difference from the first version of the table. The UCRT's `_configure_narrow_argv`, `_configure_wide_argv`, `__p___argc`, `__p___wargv` and `abort` are served by `runtime/shims/process.cpp`, which is why almost every DLL gained one or two. The file-system calls listed in *Console paths and the write overlay* below (`CreateFile2`, `CopyFile2`, `CreateDirectoryW`, `FindFirstFileExW`, `SetFileAttributesW` and the rest) account for `msvcp140.dll`, `vcomp140.dll`, `Bink2Scarlett.dll`'s `CreateFile2` and part of the two HTTP clients. `winhttp.dll` is a module the shims own (*WinHTTP offline* below), so every `WinHttp*` import binds to it: 15 in `libHttpClient.GDK.dll` (all 16 but `WinHttpCrackUrl`) and 15 in `XCurl.dll` (all but `WinHttpQueryOption`). That is why the two HTTP clients moved the most: 11 to 26 and 9 to 24 shim imports. 77The shims added since account for the rest of the difference from the first version of the table. The UCRT's `_configure_narrow_argv`, `_configure_wide_argv`, `__p___argc`, `__p___wargv` and `abort` are served by `runtime/shims/process.cpp`, which is why almost every DLL gained one or two. The file-system calls listed in *Console paths and the write overlay* below (`CreateFile2`, `CopyFile2`, `CreateDirectoryW`, `FindFirstFileExW`, `SetFileAttributesW` and the rest) account for `msvcp140.dll`, `vcomp140.dll`, `Bink2Scarlett.dll`'s `CreateFile2` and part of the two HTTP clients. `winhttp.dll` is a module the shims own (*WinHTTP offline* below), so every `WinHttp*` import binds to it: 15 in `libHttpClient.GDK.dll` (all 16 but `WinHttpCrackUrl`) and 15 in `XCurl.dll` (all but `WinHttpQueryOption`). That is why the two HTTP clients moved the most: 11 to 26 and 9 to 24 shim imports.
68 78
69The UCRT argv configuration imports honor the executable's startup mode. Each run starts with `argc == 0` and 79The UCRT argv configuration imports honor the executable's startup mode. Each run starts with `argc == 0` and
@@ -228,6 +238,45 @@ calls succeed and do nothing: there is no audio processor, so the game gets no s
228fail hard, which is why every call succeeds. `acphal_test` covers the call shapes. 238fail hard, which is why every call succeeds. `acphal_test` covers the call shapes.
229The table under [The retail executable](#the-retail-executable-rt-5) was measured before this shim and still lists these nine as unimplemented; they are served now. 239The table under [The retail executable](#the-retail-executable-rt-5) was measured before this shim and still lists these nine as unimplemented; they are served now.
230 240
241## Audio output off the console (WASAPI)
242
243Off the console the title's sound goes out through WASAPI, not through the `AcpHal` path above: it creates an
244`MMDeviceEnumerator` with `CoCreateInstance` (one call, `CLSCTX_ALL`, `IID_IMMDeviceEnumerator`), asks it for the
245default render endpoint and activates `ISpatialAudioClient` on it (measured: the first interface the title asks the
246device for). A console always has an output. A host with none
247answers `GetDefaultAudioEndpoint(eRender, ...)` with `0x80070490` (`ERROR_NOT_FOUND`), and the title's device start
248then takes an error path that leaves its own output-device lock held by a job worker: the audio engine never mixes, a
249main-thread command buffer fills up, and the title stops on an `int3` about 47 s into the boot (measured under Wine with
250its audio drivers disabled; refusing the enumerator itself stops it the same way, and a host null sink removes the stop).
251
252So `CoCreateInstance` of that class goes to `runtime/shims/silent_audio.cpp` (hooked in `shims/com_shim.cpp`). When
253the host's enumerator has a default render endpoint it is returned unchanged. When it has none, or cannot be made, or
254`LEONIDA_AUDIO=silent` is set, the title gets an enumerator whose render answers are a **silent output endpoint** of the
255runtime's own: `GetDefaultAudioEndpoint(eRender)`, `EnumAudioEndpoints(eRender)` (active devices) and `GetDevice` with
256its ID give an active `IMMDevice` whose property store has a friendly name and the device format; `Activate` gives
257`ISpatialAudioClient`, `ISpatialAudioClient2`, `IAudioClient`, `IAudioClient2` or `IAudioClient3` (any other interface
258is `E_NOINTERFACE`, logged once). The spatial client has a 7.1 bed of static objects and no dynamic objects, as an
259endpoint with no spatial sound format turned on; its objects are mono 48 kHz float, and its
260`ISpatialAudioObjectRenderStream` signals the stream's event every 10 ms pass (480 frames) while it runs and hands
261each object a scratch buffer between `BeginUpdatingAudioObjects` and `EndUpdatingAudioObjects`. The client
262takes any PCM or float format in shared mode (event-driven or polled), and `GetService` gives `IAudioRenderClient`
263(a scratch buffer), `IAudioClock`, `ISimpleAudioVolume` and `IAudioStreamVolume`. A clock consumes the written frames
264in real time, so `GetCurrentPadding` drains, and an event-driven stream's event is signalled every 10 ms period
265while it runs, so a title that paces its mixer on the event keeps running. Capture questions keep the host's answer
266(with `LEONIDA_AUDIO=silent` the host's enumerator is only made when one comes). Endpoint notification callbacks are
267accepted and never called. Nothing opens or touches a host audio device, and every sample is discarded. The first
268silent device handed out prints one `[rt] audio: serving the silent output endpoint (<reason>)` line, the reason being
269the host's failed call or `LEONIDA_AUDIO=silent`.
270
271The mix format is 48 kHz, 32-bit float, 7.1 (eight channels, mask `0x63F`). 48 kHz float is the shared-mode
272format of the Windows audio engine and of the console's. 7.1 is the console's case, and a hypothesis, not measured
273here: the console's system mixer takes a 7.1 bed whatever output is plugged in and downmixes it for stereo, so a
274console title is built for eight channels, where stereo would be the usual answer of a PC with headphones. The stream
275itself takes any channel count, so a title that asks for fewer is not refused. `silent_audio_test`
276covers the enumerator over stand-in hosts with and without an endpoint and with none, a render stream run for a
277few periods with its event and padding checked, a spatial stream run for ten passes, and the `CoCreateInstance` hook
278with `LEONIDA_AUDIO=silent`.
279
231## Console paths and the write overlay 280## Console paths and the write overlay
232 281
233A title's file calls name the console's drives, so `GAME:\data\x.sps` is a file inside the installed game folder. 282A title's file calls name the console's drives, so `GAME:\data\x.sps` is a file inside the installed game folder.
diff --git a/docs/shader_library.md b/docs/shader_library.md
index 3ef944a52..8cf131ca4 100644
--- a/docs/shader_library.md
+++ b/docs/shader_library.md
@@ -223,8 +223,13 @@ What stops the rest, by the translator's message:
223 `gfx1030` they don't either. The FSSM shaders don't use these tuples; the pipeline builds use them often. The translator 223 `gfx1030` they don't either. The FSSM shaders don't use these tuples; the pipeline builds use them often. The translator
224 now decodes these words from the blob with `rdna2_decode` (`restore_vcc_tuples`) and reads them as the 224 now decodes these words from the blob with `rdna2_decode` (`restore_vcc_tuples`) and reads them as the
225 `[s100,...,vcc_lo,vcc_hi]` lists it already takes (design.md *Scalar/buffer memory*); synthetic cases are in 225 `[s100,...,vcc_lo,vcc_hi]` lists it already takes (design.md *Scalar/buffer memory*); synthetic cases are in
226 `tests/semantic/test_vcc_tuple_fallback.py`. The count above was measured before this change; it has not been 226 `tests/semantic/test_vcc_tuple_fallback.py`. The junk llvm-mc prints at such a word's second dword is often longer
227 re-run on the real library. 227 than that dword (an 8-byte `exp`, say) and swallows the instruction after the tuple too, so the words after a restored
228 instruction are decoded from the blob until the stream is back at one llvm-mc printed. A word llvm-mc itself rejected
229 is not taken for swallowed code and stays refused. They are decoded for the program's own wave size: in wave64 a
230 swallowed VOP3 compare writes an SGPR pair. The table above was measured before both changes. Measured since,
231 over the 2,684 compute programs (llvm-mc 21.1.8): 1,816 translate with the tuples alone and 2,567 with the swallowed
232 instructions, all of which pass `spirv-val`; the modules of the 1,816 are byte-identical.
228* **443: an instruction llvm-mc prints with another encoding than the blob's** (`v_fma_mix*`, `v_interp_p2_f16`): 233* **443: an instruction llvm-mc prints with another encoding than the blob's** (`v_fma_mix*`, `v_interp_p2_f16`):
229 the existing `check_printed_encodings` refusal. 234 the existing `check_printed_encodings` refusal.
230* **90 CS: "CS thread-group-size SGPR"**: RSRC2 `TG_SIZE_EN`, which no FSSM compute shader sets. 235* **90 CS: "CS thread-group-size SGPR"**: RSRC2 `TG_SIZE_EN`, which no FSSM compute shader sets.
diff --git a/docs/shader_validation.md b/docs/shader_validation.md
index ac33debfa..f97182ee8 100644
--- a/docs/shader_validation.md
+++ b/docs/shader_validation.md
@@ -1668,6 +1668,29 @@ Measured on an RX 6700 (gfx1031, AMD Windows driver 32.0.21045.29003, ROCm wheel
1668each value is staged once, and that the kernels assemble for gfx1031. A fake oracle plays the GPU to check the exit 1668each value is staged once, and that the kernels assemble for gfx1031. A fake oracle plays the GPU to check the exit
1669codes. On a GFX10 GPU the test runs UNORM8 and checks the controls. 1669codes. On a GFX10 GPU the test runs UNORM8 and checks the controls.
1670 1670
1671### d16 rounding of image loads and samples (`tools/d16_image_probe.py`)
1672
1673The image counterpart to `tools/d16_format_probe.py` checks how a GFX10 GPU (RDNA1/RDNA2, through `tools/hw_oracle`)
1674rounds d16 image results to f16 across three paths: `image_load` (unnormalized integer coordinates), point-filtered
1675`image_sample_lz`, and bilinear `image_sample_lz` (`--frac` texels to the right of the texel centre), in wave32 and
1676wave64. It covers `unorm8`, `snorm8`, `unorm16`, `snorm16`, `float16` (control: returns its own bits), and `float32`
1677(1,024 patterns starting with exact f16 halfway points such as `0x3f7ff000` and `0x3f7fb000` plus their neighbours).
1678Point loads and point samples are compared against the candidate rules of `tools/d16_format_probe.py` (`rte`,
1679`f32_rte`, and their toward-zero and denormal-flushing variants), while bilinear d16 samples are compared against the
1680hardware's own f32 bilinear sample rounded to nearest even or toward zero.
1681
1682```
1683python -I tools/d16_image_probe.py --formats unorm8,unorm16 --waves 32,64 --frac 0.5 --json out.json
1684python -I tools/d16_image_probe.py --hw-arch gfx1031 --json out.json
1685python -I tools/d16_image_probe.py --self-test
1686python -I tests/test_d16_image_probe.py
1687```
1688
1689Exit status is 0 when the sweep ran, 1 when wave32 and wave64 disagree, 2 on a harness or control error (f32 load
1690mismatch, point sample differing from load, `float16` mismatch, or misaligned texture), and 77 when the hardware oracle
1691is unavailable or the GPU is not GFX10. `tests/test_d16_image_probe.py` covers the rules, texel generators, descriptors,
1692and exit codes without a GPU or game files.
1693
1671### Widening a 16-bit float NaN in a typed buffer load (`tools/f16_widen_probe.py`) 1694### Widening a 16-bit float NaN in a typed buffer load (`tools/f16_widen_probe.py`)
1672 1695
1673A typed buffer load of a half NaN had never been measured: `tools/mem_diff.py` decoded 16_FLOAT with 1696A typed buffer load of a half NaN had never been measured: `tools/mem_diff.py` decoded 16_FLOAT with
@@ -2329,6 +2352,27 @@ completing draws (`89` non-clear exact + `64` clear-only exact across `573/573`
2329`ps_sweep.py compare --exact`. All `3` whole-corpus shaders combining raw barycentrics and `v_interp_*_f16` also draw 2352`ps_sweep.py compare --exact`. All `3` whole-corpus shaders combining raw barycentrics and `v_interp_*_f16` also draw
2330bit-for-bit identically (`3/3` draws, `11/11` targets) against `default` on the RX 6650 XT. 2353bit-for-bit identically (`3/3` draws, `11/11` targets) against `default` on the RX 6650 XT.
2331 2354
2355### Op-scoped mutation testing for `tests/semantic` (`tools/semantic_mutants.py`)
2356
2357`tools/semantic_mutants.py` checks which one-line bugs in `tools/rdna2spirv.py` a given `tests/semantic` file would
2358miss. You scope the slice by instruction branch (`--op`), translator method (`--function`), or 1-based line range
2359(`--lines`); it generates one-line mutants (swapped SPIR-V and `GLSL.std.450` opcode pairs, comparison polarity and
2360signedness flips, `self.cu(N)` off-by-one constants, swapped `OpSelect` arms, and duplicated trailing operands) in a
2361private temporary copy of `tools/` and runs the test file against each copy through `LEONIDA_TOOLS_DIR` (the same hook
2362used by `tests/semantic/test_mutations.py`), leaving the repository untouched.
2363
2364```
2365python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8
2366python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8 --list
2367python -I tools/semantic_mutants.py tests/semantic/test_alu_sad.py --op v_sad_u8 --timeout 120
2368python -I tests/test_semantic_mutants.py
2369```
2370
2371Any mutant the test file still passes is reported as `SURVIVED` (read each lead before adding cases, since some mutants
2372are equivalent). Exit status is 0 when every mutant is caught, 1 when any survives, and 2 on a usage error or when the
2373unmutated baseline fails. Synthetic only (no GPU or game files); `tests/test_semantic_mutants.py` covers mutant
2374generation, scoping, and CLI exit codes.
2375
2332## Coverage plan and cost 2376## Coverage plan and cost
2333 2377
2334Start with straight-line scalar/vector ALU because it is deterministic, needs no descriptors and 2378Start with straight-line scalar/vector ALU because it is deterministic, needs no descriptors and
diff --git a/docs/testing.md b/docs/testing.md
index ffe729d24..671c5548c 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -9,11 +9,12 @@ issue][claims] helps more.
9 9
10This page collects the setup steps and the problems testers have run into so far. 10This page collects the setup steps and the problems testers have run into so far.
11 11
12[claims]: https://github.com/ubiquitarianism/leonida/issues/14 12[claims]: https://github.com/ubiquitarianism/leonida/issues?q=is%3Aissue%20is%3Aopen%20in%3Atitle%20%22Coordinating%20who%20works%20on%20what%22
13 13
14## What you need 14## What you need
15 15
16- **Python 3.11+.** `scripts/run_gpu_tests.py` needs at least 3.10. 16- **Python 3.12+**, which `make_game.py` requires (it stops with "Python 3.12 or newer is needed" on an older one, so
17 its tests fail there too). `scripts/run_gpu_tests.py` on its own runs on 3.10 or newer.
17- **`llvm-mc` with the AMDGPU target** (LLVM 21+). The official LLVM Windows release has no AMDGPU target. On 18- **`llvm-mc` with the AMDGPU target** (LLVM 21+). The official LLVM Windows release has no AMDGPU target. On
18 Windows, use one of: 19 Windows, use one of:
19 - `scripts\build_llvm_mc.ps1`, which builds a native `llvm-mc.exe` (needs git and the Visual Studio C++ tools); 20 - `scripts\build_llvm_mc.ps1`, which builds a native `llvm-mc.exe` (needs git and the Visual Studio C++ tools);
@@ -661,8 +662,12 @@ also advertises the feature but returns a wrong third `BaryCoordKHR` component,
661expected (#5933: Vega 8, PCI 1002:15E7, driver 31.0.21921.13001). `ps_bary`, `ps_persp_bary` and `ps_ij_computed` 662expected (#5933: Vega 8, PCI 1002:15E7, driver 31.0.21921.13001). `ps_bary`, `ps_persp_bary` and `ps_ij_computed`
662fail natively; through the fallback `ps_bary` and `ps_persp_bary` pass. `tools/vk_subgroup_info.py` reports 663fail natively; through the fallback `ps_bary` and `ps_persp_bary` pass. `tools/vk_subgroup_info.py` reports
663`barycentric_fallback` for these PCI IDs under `VK_DRIVER_ID_AMD_PROPRIETARY`, so `make_game.py` and 664`barycentric_fallback` for these PCI IDs under `VK_DRIVER_ID_AMD_PROPRIETARY`, so `make_game.py` and
664`run_gpu_tests.py` turn the fallback on by themselves there, with the same `LEONIDA_BARY_FALLBACK` override. RADV and 665`run_gpu_tests.py` turn the fallback on by themselves there, with the same `LEONIDA_BARY_FALLBACK` override. RADV
665other GCN 5 GPUs are not covered: none has been measured. 666(Mesa 26.2.6) on the same Vega 8 doesn't list `VK_KHR_fragment_shader_barycentric` at all, though it sets the
667`fragmentShaderBarycentric` feature, so the four raw-barycentric tests skip there and pass with
668`LEONIDA_BARY_FALLBACK=1`, and `ps_interp_f16_high` passes through the f16 fallback that `run_gpu_tests.py` turns on
669by itself ([#166 entry](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7109387712)). Other GCN 5 GPUs
670are not covered: none has been measured.
666 671
667## Macs: 16-bit interpolation without PerVertexKHR 672## Macs: 16-bit interpolation without PerVertexKHR
668 673
@@ -785,6 +790,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin
785| `d3d12_descriptor_test` reports that the set had room for fewer than 5001 2D views and 2100 samplers, and the device logs that the bindless set holds fewer samplers than a full shader-visible sampler heap | The device's descriptor limits, or its `vkGetDescriptorSetLayoutSupport`, allow no bigger bindless set ([d3d12_vulkan.md](d3d12_vulkan.md) section 5). MoltenVK's answer is ignored, since it rejects every layout of `maxPerSetDescriptors` (1212) or more although it runs the full set | Expected where the limits are low. The test still checks the last index of each array and that the next view and sampler are refused | 790| `d3d12_descriptor_test` reports that the set had room for fewer than 5001 2D views and 2100 samplers, and the device logs that the bindless set holds fewer samplers than a full shader-visible sampler heap | The device's descriptor limits, or its `vkGetDescriptorSetLayoutSupport`, allow no bigger bindless set ([d3d12_vulkan.md](d3d12_vulkan.md) section 5). MoltenVK's answer is ignored, since it rejects every layout of `maxPerSetDescriptors` (1212) or more although it runs the full set | Expected where the limits are low. The test still checks the last index of each array and that the next view and sampler are refused |
786| `cs_dpp_ops` fails on a Mac with MoltenVK 1.4.2: `out[0..7] = 100 100 11 ...`, want `100 10 11 ...` | MoltenVK 1.4.2's SPIRV-Cross moves the DPP lowering's subgroup ballot and shuffle into a short-circuiting `&&` and `?:`, so only some lanes run them and lane 1 sees its source lane 0 as inactive. SPIRV-Cross `5c372ffb` (in MoltenVK `main`) keeps them out of `?:`; a ballot on the right of `&&` is still moved there in SPIRV-Cross `57e4efcc` | Fixed in the translator (SHADER-529, #3227): it stores the ballot and the shuffle to variables of their own, so the MSL that MoltenVK 1.4.2 generates (`MVK_CONFIG_DEBUG=1`) runs each as a statement in every lane. Translate again with current `main`; MoltenVK `main` and KosmicKrisp are no longer needed for it. A pass alone does not show the fix: an Apple M5 Pro (macOS 26.5.1) returns the right words with 1.4.2 even when the ballot is on the right of `&&` | 791| `cs_dpp_ops` fails on a Mac with MoltenVK 1.4.2: `out[0..7] = 100 100 11 ...`, want `100 10 11 ...` | MoltenVK 1.4.2's SPIRV-Cross moves the DPP lowering's subgroup ballot and shuffle into a short-circuiting `&&` and `?:`, so only some lanes run them and lane 1 sees its source lane 0 as inactive. SPIRV-Cross `5c372ffb` (in MoltenVK `main`) keeps them out of `?:`; a ballot on the right of `&&` is still moved there in SPIRV-Cross `57e4efcc` | Fixed in the translator (SHADER-529, #3227): it stores the ballot and the shuffle to variables of their own, so the MSL that MoltenVK 1.4.2 generates (`MVK_CONFIG_DEBUG=1`) runs each as a statement in every lane. Translate again with current `main`; MoltenVK `main` and KosmicKrisp are no longer needed for it. A pass alone does not show the fix: an Apple M5 Pro (macOS 26.5.1) returns the right words with 1.4.2 even when the ballot is on the right of `&&` |
787| `check.py`'s `cs_fma_fused` fails on a Mac with MoltenVK 1.4.2: word 7 reads `15360` (`0x3c00`), want `29521` (`0x7351`) | The f16 multiply-add (round to odd). The MSL of 1.4.2 and of MoltenVK `main` differ only in SPIRV-Cross's precise-arithmetic helpers (`[[clang::optnone]]` and `fma(l, r, 0)` against `math_mode(safe)` and `fma(l, r, -0.0)`, the SHADER-182 / SHADER-234 change) | Expected with MoltenVK 1.4.2; it passes with MoltenVK `main` | 792| `check.py`'s `cs_fma_fused` fails on a Mac with MoltenVK 1.4.2: word 7 reads `15360` (`0x3c00`), want `29521` (`0x7351`) | The f16 multiply-add (round to odd). The MSL of 1.4.2 and of MoltenVK `main` differ only in SPIRV-Cross's precise-arithmetic helpers (`[[clang::optnone]]` and `fma(l, r, 0)` against `math_mode(safe)` and `fma(l, r, -0.0)`, the SHADER-182 / SHADER-234 change) | Expected with MoltenVK 1.4.2; it passes with MoltenVK `main` |
793| `ps_imgatomic` fails in about two of three runs on a Mac with MoltenVK 1.4.2: 1 to 6 of the 256 image-atomic texels are wrong while the render target is exact, for example `2D umax texel 48: got 0x00000d45, want 0x00000dc7` | MoltenVK 1.4.2 lowers the four `OpAtomic*` on image texels to Metal's texture atomics (`atomic_fetch_max`, `atomic_fetch_min` and `atomic_fetch_or` on `access::read_write` textures), and the texels read back the way a read-modify-write that is not atomic between two groups of fragment threads leaves them. A wrong `umax` texel always holds the id of one of its own 64 pixels, the largest of only some of them: on an Apple M5 it was the last pixel of the texel's first four rows in 43 of 90 cases, with all 32 larger ids gone. A wrong `umin` texel mirrors that (the first pixel of its last four rows in 39 of 48). The `or` image did not differ in 150 runs there. It is not the translator's first-lane broadcast of the descriptor index (54 of 60 runs fail with the index used directly) and not the readback (42 of 60 fail with the copies in a submission of their own after the draw). Measured on an Apple M5 (macOS 27.2.1, 101 of 150 runs fail) and an M5 Pro (#543) | Expected with MoltenVK 1.4.2. KosmicKrisp passed the same module and binary 10 times of 10 on the M5 Pro (#543). The macOS CI job does not reach it: on the runner's paravirtual device the test skips because its bindless set does not fit the descriptor limits. Do not weaken the test's expected texels |
788| `gs_tri` and `ms_tri` fail on a Mac | MoltenVK has no geometry stage and no `VK_EXT_mesh_shader` | Current `main` reports them as skipped | 794| `gs_tri` and `ms_tri` fail on a Mac | MoltenVK has no geometry stage and no `VK_EXT_mesh_shader` | Current `main` reports them as skipped |
789| With `LEONIDA_W64_EMULATE=1` on llvmpipe, the `ms_*` tests fail. Measured with Mesa 26.3.1: on x86_64 at 256-bit vectors (the default there) all six abort with "LLVM ERROR: Cannot emit physreg copy instruction"; on arm64 (128-bit) `ms_tri` draws nothing (the frame stays at the clear color); on x86_64 at 128 bits (`LP_NATIVE_VECTOR_WIDTH=128`) `ms_tri` happened to draw correctly, but with Mesa 26.0.3 `ms_wave_info_s3` and `ms_v5_workgroup` draw nothing there (4 of 6 pass, [measured by @TreXito](https://github.com/ItsNotRexed/Leonida/pull/3838#issuecomment-7086696759)) ([measured runs](https://github.com/ItsNotRexed/Leonida/issues/3127#issuecomment-7086469679)) | An llvmpipe bug: a mesh shader's runtime `CullPrimitiveEXT` is stored through an invalid `bitcast <N x i1> to <N x float>` (TEST-782, #3127; see "Without a GPU: Mesa llvmpipe") | Run the mesh tests on llvmpipe without `LEONIDA_W64_EMULATE`, or add `LEONIDA_MESH_COMPUTE=1` (the compute fallback): with it all 6 `ms_*` pass emulated on llvmpipe (x86_64, 256-bit) | 795| With `LEONIDA_W64_EMULATE=1` on llvmpipe, the `ms_*` tests fail. Measured with Mesa 26.3.1: on x86_64 at 256-bit vectors (the default there) all six abort with "LLVM ERROR: Cannot emit physreg copy instruction"; on arm64 (128-bit) `ms_tri` draws nothing (the frame stays at the clear color); on x86_64 at 128 bits (`LP_NATIVE_VECTOR_WIDTH=128`) `ms_tri` happened to draw correctly, but with Mesa 26.0.3 `ms_wave_info_s3` and `ms_v5_workgroup` draw nothing there (4 of 6 pass, [measured by @TreXito](https://github.com/ItsNotRexed/Leonida/pull/3838#issuecomment-7086696759)) ([measured runs](https://github.com/ItsNotRexed/Leonida/issues/3127#issuecomment-7086469679)) | An llvmpipe bug: a mesh shader's runtime `CullPrimitiveEXT` is stored through an invalid `bitcast <N x i1> to <N x float>` (TEST-782, #3127; see "Without a GPU: Mesa llvmpipe") | Run the mesh tests on llvmpipe without `LEONIDA_W64_EMULATE`, or add `LEONIDA_MESH_COMPUTE=1` (the compute fallback): with it all 6 `ms_*` pass emulated on llvmpipe (x86_64, 256-bit) |
790| On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` | 796| On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` |
@@ -797,7 +803,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin
797| A Windows CI artifact run under Wine by hand: `d3d12_compute` and the other tests that read `LEONIDA_TEST_*_SPV` end with exit 3 and no message | The `.spv` paths are compiled in as `D:/a/Leonida/Leonida/runtime/build/generated/...`; the prefix has no `D:` drive and the test isn't run from the artifact folder | Run it from the artifact folder (the tests then find `generated/<name>.spv` there) or through `scripts/run_wine_tests.py`, which maps that drive for the run; current `main` names the file it couldn't copy (`cannot copy ...: File not found`) | 803| A Windows CI artifact run under Wine by hand: `d3d12_compute` and the other tests that read `LEONIDA_TEST_*_SPV` end with exit 3 and no message | The `.spv` paths are compiled in as `D:/a/Leonida/Leonida/runtime/build/generated/...`; the prefix has no `D:` drive and the test isn't run from the artifact folder | Run it from the artifact folder (the tests then find `generated/<name>.spv` there) or through `scripts/run_wine_tests.py`, which maps that drive for the run; current `main` names the file it couldn't copy (`cannot copy ...: File not found`) |
798| Linux cross-build: CMake can't find `clang-cl-19` (or another versioned `clang-cl-<N>`) although `clang-19` and `lld-19` are installed | On Debian and Ubuntu, the versioned `clang-cl-<N>` link is in the `clang-tools-<N>` package, not in `clang-<N>` (`/usr/lib/llvm-<N>/bin/clang-cl` comes from it too); `lld-link-<N>`, `llvm-lib`, `llvm-rc` and `llvm-mt` come from `lld-<N>` and `llvm-<N>` | `sudo apt-get install clang-tools-19 lld-19 llvm-19` (Ubuntu 24.04 has 19 and 20), then pass the versioned names as in [the cross-build](#the-windows-runtime-on-linux-under-wine-or-proton) | 804| Linux cross-build: CMake can't find `clang-cl-19` (or another versioned `clang-cl-<N>`) although `clang-19` and `lld-19` are installed | On Debian and Ubuntu, the versioned `clang-cl-<N>` link is in the `clang-tools-<N>` package, not in `clang-<N>` (`/usr/lib/llvm-<N>/bin/clang-cl` comes from it too); `lld-link-<N>`, `llvm-lib`, `llvm-rc` and `llvm-mt` come from `lld-<N>` and `llvm-<N>` | `sudo apt-get install clang-tools-19 lld-19 llvm-19` (Ubuntu 24.04 has 19 and 20), then pass the versioned names as in [the cross-build](#the-windows-runtime-on-linux-under-wine-or-proton) |
799| Under Ubuntu's Wine 9.0, `wineboot --init` (and every Wine program after it) stops at once with `free(): invalid pointer` or a segmentation fault, before printing anything else; the prefix holds only a `wineserver` file | That Wine opens `/run/user/<uid>` for its server directory, whether `XDG_RUNTIME_DIR` is set or not, and aborts when the folder doesn't exist. The login manager makes it for a desktop session; a container or a shell started without a login session (a root shell in Docker, a CI runner image) has none | Create it before starting Wine: `mkdir -p /run/user/$(id -u) && chmod 700 /run/user/$(id -u)` (setting `XDG_RUNTIME_DIR` alone doesn't help), delete the half-made prefix, and run `wineboot --init` again | 805| Under Ubuntu's Wine 9.0, `wineboot --init` (and every Wine program after it) stops at once with `free(): invalid pointer` or a segmentation fault, before printing anything else; the prefix holds only a `wineserver` file | That Wine opens `/run/user/<uid>` for its server directory, whether `XDG_RUNTIME_DIR` is set or not, and aborts when the folder doesn't exist. The login manager makes it for a desktop session; a container or a shell started without a login session (a root shell in Docker, a CI runner image) has none | Create it before starting Wine: `mkdir -p /run/user/$(id -u) && chmod 700 /run/user/$(id -u)` (setting `XDG_RUNTIME_DIR` alone doesn't help), delete the half-made prefix, and run `wineboot --init` again |
800| `run_gpu_tests.py` fails on a `dict \| None` annotation | Python older than 3.10 | Use Python 3.11+ | 806| `run_gpu_tests.py` fails on a `dict \| None` annotation | Python older than 3.10 | Use Python 3.12+ |
801| `vulkaninfo` lists `Microsoft Direct3D12 (<gpu>)` next to the real GPU and the tests run on it | The Windows "OpenCL™, OpenGL® and Vulkan® Compatibility Pack" installs Mesa's Dozen, a Vulkan-on-D3D12 layer that reports `DISCRETE_GPU` like the native card | Current `main` prefers a native ICD over Microsoft's vendor (`0x1414`) in the runtime and every harness; set `LEONIDA_VK_DEVICE=<part of the real GPU name>` to select explicitly. See #915. | 807| `vulkaninfo` lists `Microsoft Direct3D12 (<gpu>)` next to the real GPU and the tests run on it | The Windows "OpenCL™, OpenGL® and Vulkan® Compatibility Pack" installs Mesa's Dozen, a Vulkan-on-D3D12 layer that reports `DISCRETE_GPU` like the native card | Current `main` prefers a native ICD over Microsoft's vendor (`0x1414`) in the runtime and every harness; set `LEONIDA_VK_DEVICE=<part of the real GPU name>` to select explicitly. See #915. |
802| A GPU test that uses `image_load` (or lighting built from real shaders) reads zeros from its image; @Silliana saw every texel except pixel (0,0) come back zero in their own layer (#603, not reproduced here) | In this runtime the shader turns the T# words into an index through the descriptor hash table (`runtime/src/descriptor_table.h`: a miss gives index 0), and index 0 is a 1×1 image of zeros (`runtime/src/vulkan_bindless.h`), so a hand-built or zeroed T# that was never registered reads zeros even at (0,0). The translator does not compare coordinates with the T# size, and `cs_imgload.asm` only uses its T# words as a hash key | Register the descriptor through the runtime (for D3D12, create it with `CreateShaderResourceView`) so its T# hits the table, with the image's real width and height (stored as size − 1, see `runtime/src/gfx10_descriptors.h`) | 808| A GPU test that uses `image_load` (or lighting built from real shaders) reads zeros from its image; @Silliana saw every texel except pixel (0,0) come back zero in their own layer (#603, not reproduced here) | In this runtime the shader turns the T# words into an index through the descriptor hash table (`runtime/src/descriptor_table.h`: a miss gives index 0), and index 0 is a 1×1 image of zeros (`runtime/src/vulkan_bindless.h`), so a hand-built or zeroed T# that was never registered reads zeros even at (0,0). The translator does not compare coordinates with the T# size, and `cs_imgload.asm` only uses its T# words as a hash key | Register the descriptor through the runtime (for D3D12, create it with `CreateShaderResourceView`) so its T# hits the table, with the image's real width and height (stored as size − 1, see `runtime/src/gfx10_descriptors.h`) |
803| `cs_sample_lz_int_d16`, `ps_sample_implicit_sint`, `ps_ssharp`, `ps_tex`, `ps_texture_mip0`, `ps_texture_sample` and `ps_texture_sample_d16` crash (exit -11 or 139) on an Intel GPU on Linux, while NVIDIA and llvmpipe pass them (TEST-399) | A bug in Mesa ANV's shader compiler: compiling these texture-sampling shaders, `nir_opt_gcm` (`nir_opt_gcm.c:430`, `gcm_schedule_early_src`) dereferences a phi source an earlier pass has freed. The SPIR-V passes `spirv-val`. Seen with Mesa 26.1.6 (Arrow Lake) and 26.2.7 (Iris Xe, ADL GT2); Mesa 26.3.1 and `main` (bb98606) pass the whole suite on the same Iris Xe | Use Mesa 26.3.1 or newer. To check a newer Mesa without installing it, build its Intel Vulkan driver and point `VK_DRIVER_FILES` at its `src/intel/vulkan/intel_devenv_icd.x86_64.json` | 809| `cs_sample_lz_int_d16`, `ps_sample_implicit_sint`, `ps_ssharp`, `ps_tex`, `ps_texture_mip0`, `ps_texture_sample` and `ps_texture_sample_d16` crash (exit -11 or 139) on an Intel GPU on Linux, while NVIDIA and llvmpipe pass them (TEST-399) | A bug in Mesa ANV's shader compiler: compiling these texture-sampling shaders, `nir_opt_gcm` (`nir_opt_gcm.c:430`, `gcm_schedule_early_src`) dereferences a phi source an earlier pass has freed. The SPIR-V passes `spirv-val`. Seen with Mesa 26.1.6 (Arrow Lake) and 26.2.7 (Iris Xe, ADL GT2); Mesa 26.3.1 and `main` (bb98606) pass the whole suite on the same Iris Xe | Use Mesa 26.3.1 or newer. To check a newer Mesa without installing it, build its Intel Vulkan driver and point `VK_DRIVER_FILES` at its `src/intel/vulkan/intel_devenv_icd.x86_64.json` |
diff --git a/docs/xcl_compare.md b/docs/xcl_compare.md
index 07d3e42e4..cd7a0b6a0 100644
--- a/docs/xcl_compare.md
+++ b/docs/xcl_compare.md
@@ -71,5 +71,5 @@ What the differences come down to:
71| XUser, XGameSave folder | #279 and #3363 (open). | 71| XUser, XGameSave folder | #279 and #3363 (open). |
72| `XAudio2Create` | RT-197, #3831 (open). | 72| `XAudio2Create` | RT-197, #3831 (open). |
73| `d3d12_xs.dll!D3D12CreateDevice` not found (16 D3D12.X checks) | The runtime serves the console's `D3D12XboxCreateDevice`; the title asks for `D3D12CreateDevice`. Whether the console's `d3d12_xs.dll` exports that name is not measured here. | 73| `d3d12_xs.dll!D3D12CreateDevice` not found (16 D3D12.X checks) | The runtime serves the console's `D3D12XboxCreateDevice`; the title asks for `D3D12CreateDevice`. Whether the console's `d3d12_xs.dll` exports that name is not measured here. |
74| `kernelx.dll` imports `XMemAlloc`, `XMemVirtualAlloc`, `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName`; `xmem.dll` physical pages; `xcrdapi.dll!DStorageGetFactory`; `MFResetDXGIDeviceManagerX` | Unimplemented here. None is in the measured imports of the shipped modules ([runtime_imports.md](runtime_imports.md)), and the executable is not available to measure, so they are leads, not known needs. `xmem.dll!XMemAlloc` is served; the same name under `kernelx.dll` is not. | 74| `kernelx.dll` imports `XMemAlloc`, `XMemVirtualAlloc`, `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName`; `xmem.dll` physical pages; `xcrdapi.dll!DStorageGetFactory`; `MFResetDXGIDeviceManagerX` | These are the XCL title's bindings, not the game's. The executable's own import table and call sites are measured at `1cc6e3c1` ([runtime_imports.md](runtime_imports.md#the-retail-executable-rt-5)): `xmem.dll!XMemAlloc`, `XMemFree` and `XMemVirtualAlloc` bind (the last at 23 measured call sites), and the four `xmem.dll` physical-page calls (`XMemAllocatePhysicalPages`, `XMemFreePhysicalPages`, `XMemMapPhysicalPages`, `XMemMapPhysicalPagesScatter`) are served; the same names under `kernelx.dll` are not. `XCRDAPI.dll!DStorageGetFactory` is a measured import served by `dstorage.cpp` (since `2d7be48de`). `TitleMemoryStatus`, `GetConsoleType`, `SetThreadName`/`GetThreadName` and `MFResetDXGIDeviceManagerX` are not in that table, so they remain leads, not known needs. |
75| The title's window is not a hidden 1920x1080 tool window | An XCL design choice (its console screen), not a console fact. | 75| The title's window is not a hidden 1920x1080 tool window | An XCL design choice (its console screen), not a console fact. |
diff --git a/docs/xdxr.md b/docs/xdxr.md
index 1b8a4cc27..24e9429f0 100644
--- a/docs/xdxr.md
+++ b/docs/xdxr.md
@@ -132,7 +132,7 @@ static reference, reached through a table (#7516), so 2 of them are calls of ano
132| `GetRaytracingAccelerationStructurePrebuildInfo(INPUTS*, XDXR_STREAM_DESC*, PREBUILD_INFO*)` | 3 | the layer's sizes | 132| `GetRaytracingAccelerationStructurePrebuildInfo(INPUTS*, XDXR_STREAM_DESC*, PREBUILD_INFO*)` | 3 | the layer's sizes |
133| `BuildRaytracingAccelerationStructureBatched2X(GCL6*, UINT, BATCHED_DESC2*)` | 6 (8) | one layer build per element (§1), with its postbuild descriptions | 133| `BuildRaytracingAccelerationStructureBatched2X(GCL6*, UINT, BATCHED_DESC2*)` | 6 (8) | one layer build per element (§1), with its postbuild descriptions |
134| `CopyRaytracingAccelerationStructure(GCL4*, dest, source, mode)` | 2 | the layer's copy | 134| `CopyRaytracingAccelerationStructure(GCL4*, dest, source, mode)` | 2 | the layer's copy |
135| `RehydrateRaytracingAccelerationStructureBatched2X(GCL8*, UINT, BUILD_DESC*, UINT64*)` | 4 | `E_NOTIMPL` for now | 135| `RehydrateRaytracingAccelerationStructureBatched2X(GCL8*, UINT, BUILD_DESC*, UINT64*)` | 4 | rebuilds each structure from source geometry; refuses source-only stream without geometry |
136 136
137**Where it differs from the DLL:** 137**Where it differs from the DLL:**
138- **Stream records (§3):** they tune the console builder's heuristics, so they are ignored (logged once). The result 138- **Stream records (§3):** they tune the console builder's heuristics, so they are ignored (logged once). The result
@@ -140,8 +140,23 @@ static reference, reached through a table (#7516), so 2 of them are calls of ano
140- **Validation errors:** the DLL throws them as C++ exceptions. A shim must not throw into the title, so an element 140- **Validation errors:** the DLL throws them as C++ exceptions. A shim must not throw into the title, so an element
141 the DLL would refuse is skipped with a log line. The offline-statistics postbuild type (`0x10`, §4) is one of 141 the DLL would refuse is skipped with a log line. The offline-statistics postbuild type (`0x10`, §4) is one of
142 those. 142 those.
143- **Rehydration** is the next step: rebuild each structure on the GPU from the source geometry its description 143- **Rehydration (`RehydrateRaytracingAccelerationStructureBatched2X`):** Rebuilds each structure on the GPU from
144 carries ([bvh.md](bvh.md) §4a), in the leaf frame `compressionParams` gives. 144 the source geometry its description carries ([bvh.md](bvh.md) §4a). The leaf frame `compressionParams` gives is
145 **not applied yet**: the leaves are built from the geometry as the description has it.
146 What the 4th parameter (`const UINT64* source_data`, mangling `PEB_K`) conveys is a **hypothesis**: it points to
147 the array of source buffer addresses for offline dehydrated console streams (e.g. rehydration inputs).
148 When geometry is provided (`NumDescs > 0`), the shim issues `BuildRaytracingAccelerationStructure` to construct
149 traversable GPU BVH nodes. That is a fresh build: the title sets `SourceAccelerationStructureData` to the
150 dehydrated stream, so the shim clears it and the `PERFORM_UPDATE` flag (logged once), which would otherwise make
151 the layer refit from the stream's bytes. The title passes `ScratchAccelerationStructureData = 0` (measured on the retail
152 title), so the shim supplies scratch, or the layer would reject the build: one new buffer per call, in which each
153 element has its own 256-byte-aligned region sized via `GetRaytracingAccelerationStructurePrebuildInfo`. The
154 layer's XDXR builder leaves the dependency between builds to the caller's barrier and the title puts none between
155 the elements of a batch, so no two builds, in a batch, on one list or on lists recorded in parallel, share scratch
156 bytes. The layer's command list holds the buffer until it is Reset or released, and the layer destroys it after
157 the submission that used it has retired. When `source_data` is supplied without geometry, the shim logs once and
158 refuses with `E_NOTIMPL`: offline console dehydrated streams cannot be directly deserialized by PC Vulkan/D3D12
159 drivers ([bvh.md](bvh.md) §4/§4a). Empty structures (`NumDescs == 0` without source) are logged and skipped.
145 160
146`xbox_bvh_builder_test` calls every export through the shim registry, the way the title's imports bind, and 161`xbox_bvh_builder_test` calls every export through the shim registry, the way the title's imports bind, and
147`xdxr_bvh.py check-build` checks the BLAS, TLAS and compacted BLAS it builds (ctest `xbox_bvh_builder_check`). 162`xdxr_bvh.py check-build` checks the BLAS, TLAS and compacted BLAS it builds (ctest `xbox_bvh_builder_check`).
diff --git a/docs/xmem_exe_calls.md b/docs/xmem_exe_calls.md
index 99b62fbe1..071cb6b7f 100644
--- a/docs/xmem_exe_calls.md
+++ b/docs/xmem_exe_calls.md
@@ -1,11 +1,12 @@
1# XMem: how the retail executable calls it (RT-5) 1# XMem: how the retail executable calls it (RT-5)
2 2
3`game_scarlett_master.exe` imports 12 functions from `xmem.dll` (`docs/runtime_imports.md`, "The retail executable"). 3`game_scarlett_master.exe` imports 12 functions from `xmem.dll` (`docs/runtime_imports.md`, "The retail executable").
4Seven have no shim yet. This page records, from the file alone, how the executable calls them: how many call sites each 4This page records, from the file alone, how the executable calls them: how many call sites each has and the constant
5has and the constant arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and 5arguments those sites pass. Nothing was run: `tools/import_call_sites.py` finds the call sites, and the instructions
6the instructions that load the argument registers before each call were read by hand. No code or data of the executable 6that load the argument registers before each call were read by hand. No code or data of the executable is quoted, only
7is quoted, only the constants a call passes and the counts. Measured at `main` `1cc6e3c1`, SHA-256 7the constants a call passes and the counts. The call sites were measured at `main` `1cc6e3c1`, SHA-256
8`e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993`. 8`e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993`; the shim column below is the current state, and
9it has moved since then: `042c5f378` (#6919) gave every one of the 12 imports a shim (seven had none at `1cc6e3c1`).
9 10
10```powershell 11```powershell
11python -I tools/import_call_sites.py game_scarlett_master.exe --dll xmem.dll --dll d3d12_xs.dll --dll xg_xs.dll 12python -I tools/import_call_sites.py game_scarlett_master.exe --dll xmem.dll --dll d3d12_xs.dll --dll xg_xs.dll
@@ -15,19 +16,19 @@ The tool finds each import's thunk (`jmp [rip+disp32]` through its address-table
15instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are 16instructions that reach it. Its counts cover direct calls only, and a stray `E8`/`E9` byte could add one, so they are
16bounds, not a proof that every site is reached. 17bounds, not a proof that every site is reached.
17 18
18| Import | Call sites | Shim at `main` `1cc6e3c1` | 19| Import | Call sites | Shim at `main` (since #6919) |
19|---|---:|---| 20|---|---:|---|
20| `XMemVirtualAlloc` | 23 | yes, refuses every one of these 23 (below) | 21| `XMemVirtualAlloc` | 23 | yes, all 23 types served (below) |
21| `XMemMapPhysicalPages` | 12 | no | 22| `XMemMapPhysicalPages` | 12 | yes (pagefile-backed 64 KiB pool) |
22| `XMemAllocatePhysicalPages` | 4 | no | 23| `XMemAllocatePhysicalPages` | 4 | yes |
23| `XMemFreePhysicalPages` | 3 | no | 24| `XMemFreePhysicalPages` | 3 | yes |
24| `XMemMapPhysicalPagesScatter` | 2 | no | 25| `XMemMapPhysicalPagesScatter` | 2 | yes |
25| `XMemAlloc` | 3 | yes | 26| `XMemAlloc` | 3 | yes |
26| `XMemFree` | 3 (2 calls, 1 tail jump) | yes | 27| `XMemFree` | 3 (2 calls, 1 tail jump) | yes |
27| `XMemGetWorkingSetStatistics` | 3 | yes | 28| `XMemGetWorkingSetStatistics` | 3 | yes |
28| `XMemTransferMemory` | 1 | yes | 29| `XMemTransferMemory` | 1 | yes |
29| `XMemIsToolsMemAvailable` | 1 | no | 30| `XMemIsToolsMemAvailable` | 1 | yes (returns `FALSE`) |
30| `XMemAllocDefault`, `XMemFreeDefault` | 1 tail jump each, no call | no | 31| `XMemAllocDefault`, `XMemFreeDefault` | 1 tail jump each, no call | yes |
31 32
32The executable also exports one symbol, `__XMemAllocationHooks__`. 33The executable also exports one symbol, `__XMemAllocationHooks__`.
33 34
@@ -50,10 +51,16 @@ The 23 sites pass these constants (`allocation_type`, `attributes`, `protect`; t
50| `0x20406000` | `0x27` | `0x1004`, `0x1404`, `0x8404`, `0x2404`, `0x2004` | 5 (one each) | 51| `0x20406000` | `0x27` | `0x1004`, `0x1404`, `0x8404`, `0x2404`, `0x2004` | 5 (one each) |
51| `0x42000` | `0x7` | `0x1` | 1 | 52| `0x42000` | `0x7` | `0x1` | 1 |
52 53
53Every `attributes` value is nonzero, and `runtime/shims/xmem.cpp` returns `ERROR_NOT_SUPPORTED` for a nonzero value 54Every `attributes` value is nonzero. Since #6919 `runtime/shims/xmem.cpp` does not decode them: `XMemVirtualAlloc`
54("until their host mapping is known"), so none of the 23 calls succeeds there. Past that check the shim would also 55records the word (`xmem_attributes` in the startup trace) and accepts it. All 23 allocation types are served as well.
55refuse the calls with `allocation_type` `0x20003000` (5 sites: the 2 MiB page mode) and those with bits it does not 56The page-mode mask is `kXmem64kPages` `0x20400000`, which *is* `MEM_LARGE_PAGES | MEM_PHYSICAL`, so `0x20406000`
56know: `0x4000` in `0x20406000` (5 sites) and `0x40000` in `0x42000` (1 site). 57(`0x20400000 | MEM_RESERVE | MEM_REPLACE_PLACEHOLDER`) selects the 64 KiB page mode and replaces part of the
58placeholder — `test_placeholders` in `runtime/test/xmem_test.cpp` allocates that exact shape and maps physical pages
59into the carved window. The 23 sites divide as 17 in the 64 KiB mode (3 committed, 8 reserve-only windows, 1 plain
60commit, 5 placeholder replacements), five in the 2 MiB mode `0x20000000` (committed 2 MiB-aligned through
61`VirtualAlloc2`), and one `0x42000` = `MEM_RESERVE | MEM_RESERVE_PLACEHOLDER`, the ~185 MiB reservation the five
62windows are carved out of (`docs/retail_boot_chain.md`, stops 10-11). That agrees with `docs/runtime_imports.md`
63("The retail executable", `xmem.dll` notes), which records the same 2 MiB and placeholder paths.
57 64
58The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections 65The `protect` values are not Win32 protections alone. The Windows SDK's `winnt.h` defines the graphics page protections
59the high bits match: `PAGE_GRAPHICS_NOACCESS` `0x800`, `_READONLY` `0x1000`, `_READWRITE` `0x2000`, `_EXECUTE_READ` 66the high bits match: `PAGE_GRAPHICS_NOACCESS` `0x800`, `_READONLY` `0x1000`, `_READWRITE` `0x2000`, `_EXECUTE_READ`
@@ -81,13 +88,14 @@ those two facts. The meaning of `flags`, and whether the page numbers in `pageAr
81are **unmeasured**. 88are **unmeasured**.
82 89
83The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range 90The sequence in the first function that calls them is: `XMemAllocatePhysicalPages`, then `XMemVirtualAlloc` of a range
84with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. So the physical-page calls depend on the 91with `0x20402000` and attributes `0x23`, then `XMemMapPhysicalPages` of those pages at that range. That path no longer
85attribute check above: until `XMemVirtualAlloc` accepts these attribute words, the map calls are never reached from 92stops at `XMemVirtualAlloc`: since #6919 it accepts that attribute word and the reserve-only 64 KiB window.
86there. 93
87 94The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so the shim emulates
88The host's own AWE functions need `SeLockMemoryPrivilege`, which an ordinary user does not hold, so a shim would 95the pool rather than forwarding (#6919): a pagefile-backed section in 64 KiB pages, committed at once on Wine (and on demand on native Windows) and given
89emulate the pool (a pagefile-backed section of 64 KiB pages, with views placed at the reserved range) instead of 96physical memory as it is touched, with views placed at the reserved range. Pages keep their contents while unmapped or
90forwarding. That is a design note, not a measurement. 97mapped elsewhere, and one page can be mapped at several addresses. The attribute word is recorded, still not decoded,
98and every page is 64 KiB, which all four callers' arithmetic agrees with (`runtime/shims/xmem.cpp`).
91 99
92## The other imports 100## The other imports
93 101