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:
authorNotRexed <therealnothingfn@gmail.com>2026-12-01 07:52:21 -0500
committerNotRexed <therealnothingfn@gmail.com>2026-12-01 07:52:21 -0500
commitdd4829ecfc259eebc0e42e3f72d2d61911ee010e (patch)
tree607dabec0efef7e5fe71297e2c5f0b512b0859eb /docs
parente12f7f9f9a82288ee0424be753d383eb3eb7843f (diff)
parent1723dec94510d0aa3d99e795f0a656970c1f00e9 (diff)
Merge remote-tracking branch 'origin/main' into push/main-1130
# Conflicts: # d3d12/docs/switches.md
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md2
-rw-r--r--docs/agent_collaboration.md33
-rw-r--r--docs/boot.md23
-rw-r--r--docs/cpu_features.md50
-rw-r--r--docs/design.md26
-rw-r--r--docs/dev-tools.md33
-rw-r--r--docs/linux.md7
-rw-r--r--docs/linux_proton.md7
-rw-r--r--docs/shader_validation.md10
-rw-r--r--docs/testing.md23
10 files changed, 193 insertions, 21 deletions
diff --git a/docs/README.md b/docs/README.md
index 1bc9ffcbb..860f7ef8a 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -19,7 +19,7 @@ method, scope and caveats. No game data is included.
19| [modding.md](modding.md) | The mod format: `mods/<folder>/mod.json`, checked and loaded in name order by `gta6rt`; a swap takes effect once the game's archetype lookup is hooked (needs the executable, RT-5). A mod names game models and holds no game data. | 19| [modding.md](modding.md) | The mod format: `mods/<folder>/mod.json`, checked and loaded in name order by `gta6rt`; a swap takes effect once the game's archetype lookup is hooked (needs the executable, RT-5). A mod names game models and holds no game data. |
20| [progress_dashboard.md](progress_dashboard.md) | A local page of what works, what changed since it last passed and what blocks next: unit and runtime tests, the translator contract by confirmation method, measured imports, corpus counts and, with `--github`, CI and the D3D- items (`tools/progress_dashboard.py`). | 20| [progress_dashboard.md](progress_dashboard.md) | A local page of what works, what changed since it last passed and what blocks next: unit and runtime tests, the translator contract by confirmation method, measured imports, corpus counts and, with `--github`, CI and the D3D- items (`tools/progress_dashboard.py`). |
21| [dev-tools.md](dev-tools.md) | The development CLI `scripts/dev.py`: `discover` (text or `--json`, schema version 1) lists the boot-trace analyzer and the guest-scene runner with their help commands and prerequisites, without running them; live attach, pause, step and screenshots are not available through it. | 21| [dev-tools.md](dev-tools.md) | The development CLI `scripts/dev.py`: `discover` (text or `--json`, schema version 1) lists the boot-trace analyzer and the guest-scene runner with their help commands and prerequisites, without running them; live attach, pause, step and screenshots are not available through it. |
22| [agent_collaboration.md](agent_collaboration.md) | How contributors' coding agents work together through GitHub: which machine profile takes which work, the `AGENT-MSG`, `RUN` and `TEST-WANTED` blocks, and the evidence tags. A convention, not a measurement. | 22| [agent_collaboration.md](agent_collaboration.md) | How contributors' coding agents work together through GitHub: which machine profile takes which work, the `AGENT-MSG`, `RUN`, `PICTURE` and `TEST-WANTED` blocks (`PICTURE` from `tools/picture_metrics.py`: a frame's luma, dark regions, lattice and block detectors, an 8x8 diff and a defect class, numbers only), and the evidence tags. A convention, not a measurement. |
23| [history/README.md](history/README.md) | The original repository's surviving history as portable, hashed text: the 251 `old-pr/*` branch tips and the 135 indexed old issues, with the script that regenerates them ([#563](https://github.com/ubiquitarianism/leonida/issues/563)). | 23| [history/README.md](history/README.md) | The original repository's surviving history as portable, hashed text: the 251 `old-pr/*` branch tips and the 135 indexed old issues, with the script that regenerates them ([#563](https://github.com/ubiquitarianism/leonida/issues/563)). |
24| [port_status.md](port_status.md) | Where the port stands: Leonida's runtime and shader pipeline as the base, what was patched in from VIctory, and what is still open. | 24| [port_status.md](port_status.md) | Where the port stands: Leonida's runtime and shader pipeline as the base, what was patched in from VIctory, and what is still open. |
25| [port_plan.md](port_plan.md) | What the title needs that Leonida's runtime does not do yet, taken from VIctory, in the order the title hits it and where each fix lands. | 25| [port_plan.md](port_plan.md) | What the title needs that Leonida's runtime does not do yet, taken from VIctory, in the order the title hits it and where each fix lands. |
diff --git a/docs/agent_collaboration.md b/docs/agent_collaboration.md
index 23f43323f..67f7325e5 100644
--- a/docs/agent_collaboration.md
+++ b/docs/agent_collaboration.md
@@ -1,7 +1,7 @@
1# Agents working together 1# Agents working together
2 2
3Many contributors work through a coding agent, each on its own machine. This page is how those agents share work 3Many contributors work through a coding agent, each on its own machine. This page is how those agents share work
4without their humans briefing them: where they read and write, which machine takes which kind of work, three blocks 4without their humans briefing them: where they read and write, which machine takes which kind of work, four blocks
5with fixed fields, and how sure a claim is. It adds to [CONTRIBUTING.md](../CONTRIBUTING.md) and 5with fixed fields, and how sure a claim is. It adds to [CONTRIBUTING.md](../CONTRIBUTING.md) and
6[AGENTS.md](../AGENTS.md) and replaces nothing in them. No game data is included. 6[AGENTS.md](../AGENTS.md) and replaces nothing in them. No game data is included.
7 7
@@ -35,10 +35,10 @@ with fixed fields, and how sure a claim is. It adds to [CONTRIBUTING.md](../CONT
35- M is wide: say the video memory and whether it is a laptop, since an 8 GB laptop and a 16 GB desktop card behave 35- M is wide: say the video memory and whether it is a laptop, since an 8 GB laptop and a 16 GB desktop card behave
36 differently. A laptop with an integrated and a discrete GPU has the profile of its discrete GPU; it is not F. 36 differently. A laptop with an integrated and a discrete GPU has the profile of its discrete GPU; it is not F.
37 37
38## Three blocks 38## Four blocks
39 39
40Each block starts with its prefix (`AGENT-MSG`, `RUN`, `TEST-WANTED`) so a search finds it, and says it is 40Each block starts with its prefix (`AGENT-MSG`, `RUN`, `PICTURE`, `TEST-WANTED`) so a search finds it, and says it
41AI-assisted. Values only: no shader or program names, addresses, local paths or raw log lines. 41is AI-assisted. Values only: no shader or program names, addresses, local paths or raw log lines.
42 42
43A message from one agent to another: 43A message from one agent to another:
44 44
@@ -77,6 +77,31 @@ VERDICT: prediction <held | missed by ...>
77Two runs compare only when `BASE`, `RECIPE`, `CACHES` and `INSTRUMENTS` match, apart from the variable under study: 77Two runs compare only when `BASE`, `RECIPE`, `CACHES` and `INSTRUMENTS` match, apart from the variable under study:
78a diagnostic run and a progress run do not compare even when the recipe reads the same. 78a diagnostic run and a progress run do not compare even when the recipe reads the same.
79 79
80What a frame shows, in numbers: `python -I tools/picture_metrics.py <frame> [<reference>]` prints the block from a
81PNG or PPM on your disk, `--json` the same numbers as JSON. The frame stays local: the block has no pixels, no image
82and no path. Fill in the first line; the values below are from a synthetic frame:
83
84```
85PICTURE | 2026-11-27 14:05 UTC | <GitHub handle> | AI-assisted: <tool>
86FRAME: 1280x720 | reference 1280x720
87LUMA: mean 126.75 | min 0 | max 128 | sd 12.59 | dark 0.0098
88DARK 4x4: 0.01 0.01 0.01 0.01 / 0.01 0.01 0.01 0.01 / 0.01 0.01 0.01 0.01 / 0.01 0.01 0.01 0.01
89LATTICE: tile 8 | period 16 | phase 9 | diagonal + | corner TL | tiles 900 | cover 1.0
90BLOCKS: none
91DIFF: changed 0 of 14400 8x8 tiles | share 0.0 | reference luma mean 126.75
92CLASS: LATTICE (measured) | given: none
93EVIDENCE: MEASURED (tools/picture_metrics.py, 2 frames)
94```
95
96`CLASS` is one of `LATTICE`, `BLACK-NEAR`, `BLOCKS`, `FLASH`, `CHAR-BLACK`, `CHAR-MISSING`, `2D-MISSING`,
97`STRAY-GEO`, `SMEAR` or `OK`. The tool measures the first four and `OK`; the other five need to know what the scene
98should show, so only a human gives them (`--class`, with `--region X,Y,W,H` for the numbers of the part concerned),
99and they print as `given`, never as `measured`. A measured class is a hint: a human confirms it before it is
100called a defect. Several sharp rectangles (HUD panels, window frames) can read as `BLOCKS`, and blocks off the
101frame's origin are given at the divisor of their edges (16-pixel blocks shifted by 4 read as 4x4). A lattice that
102repeats fewer than three times in the frame is not reported. A 1280x720 frame takes a few seconds. Put the block
103next to the `RUN` block of the run that made the frame.
104
80A request for a test on a machine you do not have, as a comment on the pull request to test. With no pull request, it 105A request for a test on a machine you do not have, as a comment on the pull request to test. With no pull request, it
81is its own issue titled `TEST-WANTED [<profile>] <one line>`, closed by its author when done, so that 106is its own issue titled `TEST-WANTED [<profile>] <one line>`, closed by its author when done, so that
82`gh issue list --search "TEST-WANTED in:title"` lists what is waiting; labels would do better if maintainers add them: 107`gh issue list --search "TEST-WANTED in:title"` lists what is waiting; labels would do better if maintainers add them:
diff --git a/docs/boot.md b/docs/boot.md
index e6fbea587..7dc1691c2 100644
--- a/docs/boot.md
+++ b/docs/boot.md
@@ -262,6 +262,29 @@ If startup stops before the first D3D12 call, the combined command still prints
262or invalid requested trace is reported on stderr and sets exit code 2. In a partial JSON report that section 262or invalid requested trace is reported on stderr and sets exit code 2. In a partial JSON report that section
263is `null`; if neither input yields a report, stdout is empty. 263is `null`; if neither input yields a report, stdout is empty.
264 264
265### Past the first frame: which of these three stops is it
266
267A run that stops without a frame looks the same in the present count; the `[rt]` lines say which of these three
268stops it was. The rule behind the held value is in [`d3d12_xs_console_abi.md`](d3d12_xs_console_abi.md) §5.5. A
269device loss and the title's watchdog have their own lines (`[rt] aftermath: device lost` and `[rt] hang watchdog:`),
270and a `list values so far` line with a nonzero `at device loss` reason is a device loss even when `released unmet`
271is 0.
272
273| Stop | Lines to read | The measured shape |
274|---|---|---|
275| **Pipelines still compiling** | `[rt] mem-probe t=` `pipelines live ... (made N / M, X s / Y s in vkCreate*Pipelines)`; `[rt] submit frame` | the `made` pair and the `vkCreate*Pipelines` seconds keep rising: one run made 763 graphics and 619 compute pipelines (2,296 modules, 732 MiB of SPIR-V) with 45 minutes of `vkCreate*Pipeline` CPU time, and its scene's first frame came as the builds ended. |
276| **A held console value** | `[rt] d3d12_xs: list values so far`: `released unmet` by reason, then `oldest held gate ...`; `[rt] submit frame` | `0 released unmet` in every reason while the oldest gate's age grows, and the `submit frame` lines stop: one console value wait stayed unmet for 101 minutes; of 209 gates, 192 were met and 0 released unmet. |
277| **Host memory** | `[rt] mem-probe breakdown t=` (what the runtime holds) and the cgroup's peak | the runtime's `allocated` is large and the cgroup peak is at its cap: 22.3 GB of 24 GB killed one run 21 minutes in, before a world frame, and 22.2 GB killed another after it had drawn one; a later run of the same scene peaked at 23.6 GB. |
278
279The `mem-probe` rows need `LEONIDA_MEM_PROBE=30` at the start; without it there is no `mem-probe` line. `submit frame`
280is every `LEONIDA_SUBMIT_FRAME_SECONDS` (default 10; `0` turns it off), and `LEONIDA_LIST_VALUES=0` drops the gate
281counters. The `[rt]` lines are the Vulkan layer's stderr, not a launcher log.
282
283Check the cgroup first when the process is gone without an `exit` event: a peak at `MemoryMax` plus the kernel's OOM
284line is host memory. Otherwise the `made` count decides: while it rises the run is compiling; once it is flat, a
285growing `oldest held gate` names the held value. The cgroup's peak is its `memory.peak`, or
286`systemctl show -p MemoryPeak <scope>` and the scope's journal.
287
265## 4. The open questions, and the trace signal for each 288## 4. The open questions, and the trace signal for each
266 289
267The questions are in [`d3d12_vulkan.md`](d3d12_vulkan.md) §8.2; this table takes the same 1–22 in 290The questions are in [`d3d12_vulkan.md`](d3d12_vulkan.md) §8.2; this table takes the same 1–22 in
diff --git a/docs/cpu_features.md b/docs/cpu_features.md
index 47ffd81dc..9c4e97ea3 100644
--- a/docs/cpu_features.md
+++ b/docs/cpu_features.md
@@ -43,10 +43,27 @@ Each flagged site was read by hand in a private copy (not quoted here):
43- The 8 privileged and 1 `int n` hits are data: tables of 32-bit offsets placed in `.text` (some inside a `.pdata` 43- The 8 privileged and 1 `int n` hits are data: tables of 32-bit offsets placed in `.text` (some inside a `.pdata`
44 range) that the linear sweep decodes as instructions. They are listed for completeness, not as code to replace. 44 range) that the linear sweep decodes as instructions. They are listed for completeness, not as code to replace.
45 45
46No AVX-512, VAES, VPCLMULQDQ, SHA, RDPID, RDPRU, XOP, FMA4, TBM, SYSCALL or SYSENTER instruction was found. The 46No AVX-512, VAES, VPCLMULQDQ, SHA, RDPID, RDPRU, XOP, FMA4, TBM, SYSCALL or SYSENTER instruction was found. No RDTSC,
47256-bit integer, FMA3, F16C, BMI1/2, ADX, MOVBE, AES-NI and PCLMULQDQ instructions it uses are on every Intel CPU 47RDTSCP, RDRAND, RDSEED, FSGSBASE or CLFLUSHOPT instruction is in the image either. The remaining features counted by
48since Haswell/Broadwell and every AMD CPU since Zen, so they are counted but not flagged. No RDTSC or RDTSCP is 48`tools/cpu_feature_scan.py` (at `0b11d86b`) are in its `baseline` class — present on every Intel CPU since
49in the image. 49Haswell/Broadwell and every AMD CPU since Zen:
50
51| Feature | Sites | Inside `.pdata` | Outside `.pdata` | Notes |
52|---|---:|---:|---:|---|
53| `AVX` | 2,981,637 | 2,871,070 | 110,567 | Includes 31,970 `vbroadcastss` and 131 `vbroadcastsd` sites in `.pdata` with an `xmm` register source (`mod == 3`), which are AVX2 rather than AVX1 |
54| `FMA` (FMA3) | 204,279 | 200,924 | 3,355 | 45 mnemonics (`132`/`213`/`231`, `ps`/`pd`/`ss`/`sd`, including 3 `vfmaddsub*`/`vfmsubadd*` sites) |
55| `AVX2` | 86,018 | 81,500 | 4,518 | Zero `vgather*` or `vpgather*` sites; 284 of the `.pdata` hits are AVX1 mnemonics that share the `vp` prefix (`234` `vptest`, `42` `vperm2f128`, `8` `vpermilps`) |
56| `BMI1` | 60,850 | 58,398 | 2,452 | `bextr` (21,546), `andn` (17,585), `tzcnt` (11,827), `blsr` (7,301), `blsi` (139); zero `blsmsk` |
57| `BMI2` | 14,959 | 12,403 | 2,556 | `shlx` (7,581), `mulx` (1,612), `shrx` (1,309), `rorx` (1,064), `bzhi` (808), `sarx` (29); zero `pdep` or `pext` in `.pdata` |
58| `AES` | 3,390 | 13 | 3,377 | `vaesimc` in `.pdata`; the hits outside `.pdata` are data |
59| `F16C` | 3,303 | 2,966 | 337 | `vcvtph2ps` (1,526) and `vcvtps2ph` (1,440) |
60| `ADX` | 2,678 | 0 | 2,678 | Data outside `.pdata`; zero sites inside `.pdata` |
61| `PCLMULQDQ` | 1,128 | 0 | 1,128 | Data outside `.pdata`; zero sites inside `.pdata` |
62| `POPCNT` | 458 | 442 | 16 | — |
63| `MOVBE` | 422 | 195 | 227 | — |
64| `LZCNT` | 321 | 294 | 27 | 149 4-byte and 145 5-to-9-byte encodings in `.pdata` |
65| `CX16` | 56 | 56 | 0 | `cmpxchg16b` |
66| `PREFETCHW` | 5 | 5 | 0 | `0F 0D /1`: architectural NOP on Intel 64 CPUs without `PREFETCHW` |
50 67
51## What it means for the runtime 68## What it means for the runtime
52 69
@@ -70,6 +87,31 @@ in the image.
70 87
71Not measured: which of these sites a boot reaches, and in which order. 88Not measured: which of these sites a boot reaches, and in which order.
72 89
90### Hosts with AVX1 and SSE4.2 (Sandy Bridge and Ivy Bridge)
91
92An Intel Sandy Bridge or Ivy Bridge host (for example an Intel Core i7-2600, `CPUID.1:ECX = 0x1FBAE3FF`, `XCR0 = 0x7`)
93has 256-bit `YMM0`–`YMM15`, `XSAVE`/`OSXSAVE`, `AVX`, `SSE4.2`, `POPCNT`, `CX16`, `AES-NI` and `PCLMULQDQ`, so it
94passes the `host_cpu` AVX preflight, executes the 2,839,253 genuine AVX1 `.pdata` sites (`2,871,070` minus the 32,101
95register-source `vbroadcastss`/`vbroadcastsd` sites, plus the 284 `vp`-prefixed AVX1 sites) natively, and treats the 5
96`PREFETCHW` sites (`0F 0D /1`) as hint NOPs (Intel SDM Vol. 2B). What it lacks inside `.pdata` is the Haswell/ABM
97delta: `FMA` (200,924), `AVX2` (81,216 plus 32,101 register-source `vbroadcastss`/`vbroadcastsd`), `BMI1` (58,398),
98`BMI2` (12,403), `F16C` (2,966 on Sandy Bridge; native on Ivy Bridge), `LZCNT` (294) and `MOVBE` (195).
99
100Those instructions split into two execution classes on a pre-Haswell CPU:
101
102- **Fault with `#UD` (`STATUS_ILLEGAL_INSTRUCTION`):** every VEX `0F38`/`0F3A` instruction in that set (`FMA3`, `F16C`,
103 `bextr`/`andn`/`blsr`/`blsi`, `BMI2`, `AVX2` broadcasts/permutes/blends/variable shifts, and register-source
104 `vbroadcastss`/`vbroadcastsd`), 256-bit `0F`-map integer `vp* ymm` operations, and `MOVBE`.
105- **Do not fault (`LZCNT` and `TZCNT`):** legacy `LZCNT` (`F3 0F BD`) and `TZCNT` (`F3 0F BC`) have no VEX form in
106 x86-64, and a CPU without `LZCNT`/`BMI1` ignores the `F3` prefix and executes `BSR` or `BSF` instead (Intel SDM
107 Vol. 2A/2B). `BSR` returns the bit index (`width - 1 - lzcnt`) rather than the leading-zero count and leaves the
108 destination undefined when the source is zero. `BSF` writes the same bit index as `TZCNT` for non-zero inputs, but
109 leaves `CF` undefined and leaves the destination unmodified when the source is zero, whereas 988 of the 11,827
110 `.pdata` `tzcnt` sites are immediately followed by a `CF`-reading instruction (`793` `cmovb`, `174` `cmovae`, `20`
111 `jae`, `1` `jb`). Supporting an `AVX1` host therefore requires rewriting `LZCNT` and `TZCNT` sites before code runs
112 (149 of the 294 `.pdata` `lzcnt` sites are 4-byte `F3 0F BD /r` encodings without REX, shorter than a 5-byte
113 `jmp rel32`) rather than relying on `#UD`.
114
73### Hosts without AVX 115### Hosts without AVX
74 116
75Measured on one host: Intel Xeon X5675 (Westmere, SSE4.2; no AVX, AVX2, FMA, BMI2 or XSAVE), Fedora 44, 117Measured on one host: Intel Xeon X5675 (Westmere, SSE4.2; no AVX, AVX2, FMA, BMI2 or XSAVE), Fedora 44,
diff --git a/docs/design.md b/docs/design.md
index 2a3126b20..79385b39d 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -383,7 +383,7 @@ How the generated SPIR-V expects the runtime to work:
383| Push-constant tail as a uniform block (`--pc-tail-ubo`) | For devices whose `maxPushConstantsSize` is 128, Vulkan's minimum, which can't take the 144-byte block (152 with `--mesh-compute`): AMD's older Windows drivers on RDNA2 iGPUs (Radeon 680M on 22.40.84.06, 610M on 24.10.16.14, the Ryzen 5 7600's iGPU on 24.10.24; a 610M on 26.11.2 reports 256) and some Intel Arc drivers (D3D-14, `push_constants_need_fallback` in `d3d12_vulkan_device.cpp`). The push-constant block keeps dwords 0–31 (s0–s31, 128 bytes). The tail that follows them by default, the heap base and code base and, with `--mesh-compute`, the output address, becomes `%pc_tail`: a uniform block at **set 1, binding 0** with the same members in the same order at offsets 0, 4, … (16 bytes, 24 with `--mesh-compute`). Set 1 is otherwise unused, so set 0's update-after-bind table doesn't change. The block is declared, and listed in the entry point's interface, only when the shader reads the tail (a memory access through the heap base, `s_getpc_b64`, or the `--mesh-compute` epilogue); the index then records `"pc_tail": {"set": 1, "binding": 0, "bytes": 16}`, and `"push_constant_bytes"` is 128 for every module. `"bindings"` still lists set 0 only. Without the flag nothing changes. **Checked:** `tests/test_pc_tail_ubo.py` (on `cs_store` and `ps_m15`: the block, its interface entry, `spirv-val`, the metadata, no block without a tail read, and the `--mesh-compute` address). The whole hand-written GPU test set in `runtime/test/shaders` is translated with the flag by `build.py` or `scripts/run_gpu_tests.py` under `LEONIDA_PC_TAIL_UBO=1`, and the index's `pc_tail` entries say which modules read the tail; how many do changes as shaders are added, so no count is kept here. The GPU test programs bind the block (`runtime/test/vk_pc_tail.h`; the list is in docs/testing.md), except with `--mesh-compute`, whose tests skip. The D3D12 layer does not yet: it refuses pipelines on a device with fewer than 144 push-constant bytes (`push_constants_fit` in `d3d12_vulkan_device.cpp`). | 383| Push-constant tail as a uniform block (`--pc-tail-ubo`) | For devices whose `maxPushConstantsSize` is 128, Vulkan's minimum, which can't take the 144-byte block (152 with `--mesh-compute`): AMD's older Windows drivers on RDNA2 iGPUs (Radeon 680M on 22.40.84.06, 610M on 24.10.16.14, the Ryzen 5 7600's iGPU on 24.10.24; a 610M on 26.11.2 reports 256) and some Intel Arc drivers (D3D-14, `push_constants_need_fallback` in `d3d12_vulkan_device.cpp`). The push-constant block keeps dwords 0–31 (s0–s31, 128 bytes). The tail that follows them by default, the heap base and code base and, with `--mesh-compute`, the output address, becomes `%pc_tail`: a uniform block at **set 1, binding 0** with the same members in the same order at offsets 0, 4, … (16 bytes, 24 with `--mesh-compute`). Set 1 is otherwise unused, so set 0's update-after-bind table doesn't change. The block is declared, and listed in the entry point's interface, only when the shader reads the tail (a memory access through the heap base, `s_getpc_b64`, or the `--mesh-compute` epilogue); the index then records `"pc_tail": {"set": 1, "binding": 0, "bytes": 16}`, and `"push_constant_bytes"` is 128 for every module. `"bindings"` still lists set 0 only. Without the flag nothing changes. **Checked:** `tests/test_pc_tail_ubo.py` (on `cs_store` and `ps_m15`: the block, its interface entry, `spirv-val`, the metadata, no block without a tail read, and the `--mesh-compute` address). The whole hand-written GPU test set in `runtime/test/shaders` is translated with the flag by `build.py` or `scripts/run_gpu_tests.py` under `LEONIDA_PC_TAIL_UBO=1`, and the index's `pc_tail` entries say which modules read the tail; how many do changes as shaders are added, so no count is kept here. The GPU test programs bind the block (`runtime/test/vk_pc_tail.h`; the list is in docs/testing.md), except with `--mesh-compute`, whose tests skip. The D3D12 layer does not yet: it refuses pipelines on a device with fewer than 144 push-constant bytes (`push_constants_fit` in `d3d12_vulkan_device.cpp`). |
384| Address guard (`--address-guard`) | **Prototype, off by default.** Every `Gen.host_addr` access (buffer, `global_`, scalar and BVH loads, stores and atomics) calls `%guard_fn` with the access's sign-extended 48-bit heap offset, its kind and its span. An access whose first and last byte are below the arena's size passes after one compare. Any other access looks up the 4 KiB pages of its first and last byte in the runtime's two-level page table (level 1 by offset bits 47..32, level 2 one bit per page). A refused load reads the zero area at `heap_base + 0x71000`. A refused store or atomic goes to the dump area at `+ 0x78000`, and an atomic returns 0. Each refusal is counted in the header at `+ 0x70000`. The entry block reads that header once. Without its magic (runtime `LEONIDA_ADDRESS_GUARD` unset) every access passes, and without the flag the module is unchanged byte for byte. The index records `"address_guard": true`. Format: `runtime/src/address_guard.h`, `tools/address_guard.py`; design and costs: `docs/d3d12_vulkan.md` 3.3, "Address guard". **Checked:** `tests/semantic/test_address_guard.py` (fixture `cs_address_guard` through `spirv_mini_interp` with the guard on, off at run time and without the flag; kinds and spans per instruction family; the table model), `runtime/test/address_guard_test.cpp`, and `scripts/run_address_guard_gpu_test.py` (lavapipe, Mesa 26.3.1: the refused loads read 0 over real memory, and the store and the atomic land in the dump area). | 384| Address guard (`--address-guard`) | **Prototype, off by default.** Every `Gen.host_addr` access (buffer, `global_`, scalar and BVH loads, stores and atomics) calls `%guard_fn` with the access's sign-extended 48-bit heap offset, its kind and its span. An access whose first and last byte are below the arena's size passes after one compare. Any other access looks up the 4 KiB pages of its first and last byte in the runtime's two-level page table (level 1 by offset bits 47..32, level 2 one bit per page). A refused load reads the zero area at `heap_base + 0x71000`. A refused store or atomic goes to the dump area at `+ 0x78000`, and an atomic returns 0. Each refusal is counted in the header at `+ 0x70000`. The entry block reads that header once. Without its magic (runtime `LEONIDA_ADDRESS_GUARD` unset) every access passes, and without the flag the module is unchanged byte for byte. The index records `"address_guard": true`. Format: `runtime/src/address_guard.h`, `tools/address_guard.py`; design and costs: `docs/d3d12_vulkan.md` 3.3, "Address guard". **Checked:** `tests/semantic/test_address_guard.py` (fixture `cs_address_guard` through `spirv_mini_interp` with the guard on, off at run time and without the flag; kinds and spans per instruction family; the table model), `runtime/test/address_guard_test.cpp`, and `scripts/run_address_guard_gpu_test.py` (lavapipe, Mesa 26.3.1: the refused loads read 0 over real memory, and the store and the atomic land in the dump area). |
385| `v_mad_u32_u16` / `v_mad_i32_i16` op_sel on S2 and D, and clamp | D = S0.half · S1.half + S2, the halves zero- (u16) or sign-extended (i16), op_sel bit 0 / 1 reading the high half of S0 / S1. The other bits and `clamp` were refused (`Unsupported: op_sel/clamp`) until their results were measured on RDNA2 (AMD Radeon iGPU, gfx1036, Windows driver 26.10.1, raw kernels through `tools/hw_oracle`, wave32 and wave64 alike; EGEN-HW-MAD-U32-U16, 44 words): **op_sel bit 2 adds S2[31:16] zero-extended, in the i16 op too** (`v_mad_i32_i16 d, 3, 3, 0xffff8000 op_sel:[0,0,1,0]` gives `0x00010008`, not 8); an inline float constant there is its f32 pattern (`1.0` adds `0x3f80`); **op_sel bit 3 writes the result shifted left by 16** (low half 0, the old D not kept); **`clamp` saturates the 32-bit sum** to [0, 0xffffffff] (u16) or [0x80000000, 0x7fffffff] (i16), before that shift (the 16-bit product itself never overflows). GPU-checked with `runtime/test/shaders/ps_valu16_mad_sel.asm` (4096/4096 on NVIDIA GeForce RTX 5080, driver 616.92, and the gfx1036 iGPU); CPU-checked by `tests/semantic/test_alu_mad_32_16.py` (40 seeded cases against a Python reference) and `tests/semantic/test_value_semantics.py`. | 385| `v_mad_u32_u16` / `v_mad_i32_i16` op_sel on S2 and D, and clamp | D = S0.half · S1.half + S2, the halves zero- (u16) or sign-extended (i16), op_sel bit 0 / 1 reading the high half of S0 / S1. The other bits and `clamp` were refused (`Unsupported: op_sel/clamp`) until their results were measured on RDNA2 (AMD Radeon iGPU, gfx1036, Windows driver 26.10.1, raw kernels through `tools/hw_oracle`, wave32 and wave64 alike; EGEN-HW-MAD-U32-U16, 44 words): **op_sel bit 2 adds S2[31:16] zero-extended, in the i16 op too** (`v_mad_i32_i16 d, 3, 3, 0xffff8000 op_sel:[0,0,1,0]` gives `0x00010008`, not 8); an inline float constant there is its f32 pattern (`1.0` adds `0x3f80`); **op_sel bit 3 writes the result shifted left by 16** (low half 0, the old D not kept); **`clamp` saturates the 32-bit sum** to [0, 0xffffffff] (u16) or [0x80000000, 0x7fffffff] (i16), before that shift (the 16-bit product itself never overflows). GPU-checked with `runtime/test/shaders/ps_valu16_mad_sel.asm` (4096/4096 on NVIDIA GeForce RTX 5080, driver 616.92, and the gfx1036 iGPU); CPU-checked by `tests/semantic/test_alu_mad_32_16.py` (40 seeded cases against a Python reference) and `tests/semantic/test_value_semantics.py`. |
386| `v_add_nc_i16`, `v_sub_nc_i16` | GFX10 VOP3-only signed 16-bit add and subtract. Without `clamp` they are bit-identical to `v_add_nc_u16`/`v_sub_nc_u16` (the low 16 bits wrap) and take the same path: `op_sel:[s0,s1,dst]` picks each source's half and the destination half, and the other half of D is kept. With `clamp`, the exact sum or difference of the sign-extended halves saturates to [-32768, 32767] (`SClamp`), where the u16 forms saturate to [0, 0xFFFF]. RDNA2 (GFX10.3) dropped reversed 16-bit integer subtraction (`v_subrev_nc_u16` / `v_subrev_nc_i16` do not exist on hardware; `v_subrev_f16` is the only 16-bit reverse subtract opcode). Checked by `tests/semantic/test_valu_add_sub_nc_i16.py` (a value grid with and without `clamp`, `op_sel`, literals, SGPR sources, and untouched half preservation) and **Hardware-verified on AMD RDNA2** (`gfx1036`, wave32 and wave64 via `tools/int_hw_probe.py`, `valu_add_nc_clamp/v_add_sub_nc_i16_clamp`): signed saturation to [-32768, 32767], `op_sel` source selection, and untouched destination half preservation match hardware bit-for-bit. Until 2026-11-22 both raised `Unsupported`. CPU-checked by `tests/semantic/test_valu_add_sub_nc_i16.py` (a value grid with and without `clamp`, `op_sel` including the destination half, and equality with the u16 forms without `clamp`). **GPU-verified** on native RDNA2 (gfx1036, the Radeon iGPU of a Ryzen 7 9800X3D, Windows driver 32.0.21042.62) through `tools/hw_oracle`, one-thread raw kernels: 112 of 112 directed cases (both ops; 0x7FFF+1, 0x8000+1, 0x8000+0xFFFF, 0x7FFF+0x7FFF, 0x8000+0x8000 and others, each with and without `clamp` and with `op_sel` `[0,0,0]`, `[1,0,1]`, `[0,1,0]` and `[1,1,1]`, the destination preset to 0xA5A5A5A5). For example `v_add_nc_i16(0x7FFF, 1)` gives 0x8000 wrapped and 0x7FFF with `clamp`, `v_sub_nc_i16(0x8000, 1) clamp` gives 0x8000, and the destination half `op_sel` doesn't pick keeps its 0xA5A5. `tools/pk16_diff.py --oracle translator,hw --ops v_add_nc_i16,v_sub_nc_i16 --programs 3000 --seed 1`: 3000 of 3000 programs agree with the hardware and the translator. **Not GPU-verified.** Measured on native gfx1100: `clamp` saturates the exact sign-extended sum to [-32768, 32767] and the other half of D is kept. | 386| `v_add_nc_i16`, `v_sub_nc_i16` | GFX10 VOP3-only signed 16-bit add and subtract. Without `clamp` they are bit-identical to `v_add_nc_u16`/`v_sub_nc_u16` (the low 16 bits wrap) and take the same path: `op_sel:[s0,s1,dst]` picks each source's half and the destination half, and the other half of D is kept. With `clamp`, the exact sum or difference of the sign-extended halves saturates to [-32768, 32767] (`SClamp`), where the u16 forms saturate to [0, 0xFFFF]. RDNA2 (GFX10.3) dropped reversed 16-bit integer subtraction (`v_subrev_nc_u16` / `v_subrev_nc_i16` do not exist on hardware; `v_subrev_f16` is the only 16-bit reverse subtract opcode). Checked by `tests/semantic/test_valu_add_sub_nc_i16.py` (a value grid with and without `clamp`, `op_sel`, literals, SGPR sources, and untouched half preservation) and **Hardware-verified on AMD RDNA2** (`gfx1036`, wave32 and wave64 via `tools/int_hw_probe.py`, `valu_add_nc_clamp/v_add_sub_nc_i16_clamp`): signed saturation to [-32768, 32767], `op_sel` source selection, and untouched destination half preservation match hardware bit-for-bit. Until 2026-11-22 both raised `Unsupported`. CPU-checked by `tests/semantic/test_valu_add_sub_nc_i16.py` (a value grid with and without `clamp`, `op_sel` including the destination half, and equality with the u16 forms without `clamp`). **GPU-verified** on native RDNA2 (gfx1036, the Radeon iGPU of a Ryzen 7 9800X3D, Windows driver 32.0.21042.62) through `tools/hw_oracle`, one-thread raw kernels: 112 of 112 directed cases (both ops; 0x7FFF+1, 0x8000+1, 0x8000+0xFFFF, 0x7FFF+0x7FFF, 0x8000+0x8000 and others, each with and without `clamp` and with `op_sel` `[0,0,0]`, `[1,0,1]`, `[0,1,0]` and `[1,1,1]`, the destination preset to 0xA5A5A5A5). For example `v_add_nc_i16(0x7FFF, 1)` gives 0x8000 wrapped and 0x7FFF with `clamp`, `v_sub_nc_i16(0x8000, 1) clamp` gives 0x8000, and the destination half `op_sel` doesn't pick keeps its 0xA5A5. `tools/pk16_diff.py --oracle translator,hw --ops v_add_nc_i16,v_sub_nc_i16 --programs 3000 --seed 1`: 3000 of 3000 programs agree with the hardware and the translator. **Not GPU-verified.** Measured on native gfx1100: `clamp` saturates the exact sign-extended sum to [-32768, 32767] and the other half of D is kept. **NVIDIA driver workaround (2026-11-25):** the low-16 mask on every int-derived value that merges into a preserved 16-bit half is emitted as `OpBitFieldUExtract` (base 0, count 16), not `OpBitwiseAnd & 0xFFFF`. The sites: the VOP3 16-bit integer results (`v_add/sub_{nc_,}{i16,u16}`, the shifts, `v_mad_{u16,i16}` and `v_{min,max,med}3_{u16,i16}`), the signed `v_cvt_i16_f16`/`v_cvt_norm_i16_f16` conversions (a Bitcast of an `%int` convert), and the signed `saturate_int16` feeding d16 image/buffer stores. NVIDIA's shader compiler (RTX 4070 SUPER, wave32) miscompiles the `And` when its operand passed through `%int` ops and the result merges with the preserved high half — `v_add_nc_i16 v14, v3, v12 op_sel:[1,1,0] clamp` wrote `0x1113AAA8` for `0x0002AAA8` (low half fine, kept half corrupted); the same `And`-free extract gives the right word, `SClamp` on `%int` or select-based clamps do not dodge it, and the `op_sel` destination-high merge (`(old & 0xFFFF) \| (lo << 16)`) is unaffected. GPU-checked on the RTX 4070 SUPER (the repro and 160 randomized `op_sel`/`clamp` cases, 0 mismatches against a Python reference) and on the Radeon iGPU (gfx1036, `--pc-tail-ubo`); semantics unchanged (`spirv-val` clean, the CPU interpreter agrees). |
387| Gather sampler LOD | Before choosing the mip for the four fetches in `image_gather4_l(_o)`, clamp the requested LOD to S# word 1's MIN_LOD [11:0] and MAX_LOD [23:12] (unsigned 4.8). `ps_gather_sampler_lod.asm` reads the S# from the heap. On RTX 5080 and Radeon Graphics, a maximum of 0.25 selects the base quadrants and a minimum of 0.75 selects the cyan mip across the 64×64 draw. Without these bounds half of each frame reads the wrong level. Radeon also agreed with native `OpImageGather Lod` (`VK_AMD_texture_gather_bias_lod`) for those bounds. At exactly 0.5, with bounds [0,1], that native draw selected mip 1; the emulation now computes the mip as `Floor(LOD + 0.5)`, ties up, and also selects mip 1 (before SHADER-152 it used `RoundEven`, which selected mip 0). It computes `floor(LOD) + (LOD - floor(LOD) >= 0.5)`, which is exact in binary32, not `Floor(LOD + 0.5)`: that sum rounds `0x3effffff` up to 1.0, and on an RTX 5070 (621.24) the gather then read mip 1 where native `image_sample_l` at the same LOD reads mip 0. | 387| Gather sampler LOD | Before choosing the mip for the four fetches in `image_gather4_l(_o)`, clamp the requested LOD to S# word 1's MIN_LOD [11:0] and MAX_LOD [23:12] (unsigned 4.8). `ps_gather_sampler_lod.asm` reads the S# from the heap. On RTX 5080 and Radeon Graphics, a maximum of 0.25 selects the base quadrants and a minimum of 0.75 selects the cyan mip across the 64×64 draw. Without these bounds half of each frame reads the wrong level. Radeon also agreed with native `OpImageGather Lod` (`VK_AMD_texture_gather_bias_lod`) for those bounds. At exactly 0.5, with bounds [0,1], that native draw selected mip 1; the emulation now computes the mip as `Floor(LOD + 0.5)`, ties up, and also selects mip 1 (before SHADER-152 it used `RoundEven`, which selected mip 0). It computes `floor(LOD) + (LOD - floor(LOD) >= 0.5)`, which is exact in binary32, not `Floor(LOD + 0.5)`: that sum rounds `0x3effffff` up to 1.0, and on an RTX 5070 (621.24) the gather then read mip 1 where native `image_sample_l` at the same LOD reads mip 0. |
388| `s_absdiff_i32`, `s_mul_hi_i32` | `s_absdiff_i32`: D = \|S0 − S1\| with the 32-bit difference wrapped first (0x7FFFFFFF − 0x80000000 → 1; a difference of −2³¹ stays 0x80000000), SCC = D ≠ 0. `s_mul_hi_i32`: high word of the signed 64-bit product, SCC kept. From the RDNA2 ISA pseudocode; checked on the CPU by `tests/semantic/test_salu_absdiff_mul_hi.py`. **Hardware-verified** on an AMD Radeon RX 7900 XTX (gfx1100, Windows 11, driver 26.10.1) as raw wave32 kernels through `tools/hw_oracle`: `s_absdiff_i32(0x7FFFFFFF, 0x80000000)` = 1 and `s_absdiff_i32(0x80000000, 0)` = 0x80000000, both with SCC = 1, and equal operands give 0 with SCC = 0; `s_mul_hi_i32(0x7FFFFFFF, 0x7FFFFFFF)` = 0x3FFFFFFF and `s_mul_hi_i32(-1, 1)` = 0xFFFFFFFF, with SCC left as it was. Also verified on native RDNA2 (gfx1036, AMD Radeon Graphics): 500 programs in `tools/salu_diff.py` (`--oracle translator,hw`) matched bit-for-bit with 0 mismatches, and the high product word and SCC retention confirmed across edge values. | 388| `s_absdiff_i32`, `s_mul_hi_i32` | `s_absdiff_i32`: D = \|S0 − S1\| with the 32-bit difference wrapped first (0x7FFFFFFF − 0x80000000 → 1; a difference of −2³¹ stays 0x80000000), SCC = D ≠ 0. `s_mul_hi_i32`: high word of the signed 64-bit product, SCC kept. From the RDNA2 ISA pseudocode; checked on the CPU by `tests/semantic/test_salu_absdiff_mul_hi.py`. **Hardware-verified** on an AMD Radeon RX 7900 XTX (gfx1100, Windows 11, driver 26.10.1) as raw wave32 kernels through `tools/hw_oracle`: `s_absdiff_i32(0x7FFFFFFF, 0x80000000)` = 1 and `s_absdiff_i32(0x80000000, 0)` = 0x80000000, both with SCC = 1, and equal operands give 0 with SCC = 0; `s_mul_hi_i32(0x7FFFFFFF, 0x7FFFFFFF)` = 0x3FFFFFFF and `s_mul_hi_i32(-1, 1)` = 0xFFFFFFFF, with SCC left as it was. Also verified on native RDNA2 (gfx1036, AMD Radeon Graphics): 500 programs in `tools/salu_diff.py` (`--oracle translator,hw`) matched bit-for-bit with 0 mismatches, and the high product word and SCC retention confirmed across edge values. |
389| SCC from scalar ALU | `s_and/or/xor/andn2/orn2/nand/nor/xnor_b32` and `s_lshl/lshr_b32` set SCC = result ≠ 0, `s_add/sub_i32` and `s_addk_i32` set it to signed overflow, `s_min_u32`/`s_max_u32` to S0 < S1 / S0 > S1, and `s_min_i32`/`s_max_i32` to the same compared signed: SCC is 1 when S0 is the one chosen, and a tie chooses S1 (RDNA2 ISA, S_MIN_I32: D = S0 < S1 ? S0 : S1, SCC = 1 if S0 is chosen). **Before this fix these ops left SCC unchanged**, so a following `s_cbranch_scc*` read a stale flag, and until 2026-11-21 `s_min_i32`/`s_max_i32` set SCC on a tie. 32-bit scalar shifts now mask the amount to 5 bits. GPU-checked with `runtime/test/shaders/ps_scc.asm` and `ps_scc_minmax.asm` (NVIDIA GeForce RTX 2060 SUPER, Linux, driver 620.70.06: 4096/4096 pixels exact, and all 4096 differ with the old translator). **On lane masks in a wave32 program** (a source is EXEC, VCC or a mask SGPR, or the result goes to EXEC) the 32-bit bitwise ops' result is the whole wave's mask, so SCC is a subgroup vote (`OpGroupNonUniformAny`), as for the `_b64` forms. Until 2026-11-22 each lane took its own bit: `s_and_b32 s0, vcc_lo, exec_lo; s_cbranch_scc0` skipped the block in lanes whose bit was 0, and a loop closed by `s_andn2_b32 exec_lo, ...; s_cbranch_scc1` let each lane leave early. Found and checked by `tools/cf_diff.py` (FUZZ-8, CPU differential against the ISA model); GPU test `runtime/test/shaders/ps_scc_mask32.asm` passes (s5 == 8 on 2,048 pixels, 192 of them with bit 0, and s5 == 7 on 2,048) on an NVIDIA RTX 4050 Laptop (Linux, driver 620.73.04, natively and under `LEONIDA_W64_EMULATE=1`) and an AMD Radeon 740M (RADV, Mesa 26.3.1), and on an RTX 2060 SUPER per #634. A 32-bit op on one half of a wave64 mask still takes the lane's bit (its SCC would be a vote of that half). | 389| SCC from scalar ALU | `s_and/or/xor/andn2/orn2/nand/nor/xnor_b32` and `s_lshl/lshr_b32` set SCC = result ≠ 0, `s_add/sub_i32` and `s_addk_i32` set it to signed overflow, `s_min_u32`/`s_max_u32` to S0 < S1 / S0 > S1, and `s_min_i32`/`s_max_i32` to the same compared signed: SCC is 1 when S0 is the one chosen, and a tie chooses S1 (RDNA2 ISA, S_MIN_I32: D = S0 < S1 ? S0 : S1, SCC = 1 if S0 is chosen). **Before this fix these ops left SCC unchanged**, so a following `s_cbranch_scc*` read a stale flag, and until 2026-11-21 `s_min_i32`/`s_max_i32` set SCC on a tie. 32-bit scalar shifts now mask the amount to 5 bits. GPU-checked with `runtime/test/shaders/ps_scc.asm` and `ps_scc_minmax.asm` (NVIDIA GeForce RTX 2060 SUPER, Linux, driver 620.70.06: 4096/4096 pixels exact, and all 4096 differ with the old translator). **On lane masks in a wave32 program** (a source is EXEC, VCC or a mask SGPR, or the result goes to EXEC) the 32-bit bitwise ops' result is the whole wave's mask, so SCC is a subgroup vote (`OpGroupNonUniformAny`), as for the `_b64` forms. Until 2026-11-22 each lane took its own bit: `s_and_b32 s0, vcc_lo, exec_lo; s_cbranch_scc0` skipped the block in lanes whose bit was 0, and a loop closed by `s_andn2_b32 exec_lo, ...; s_cbranch_scc1` let each lane leave early. Found and checked by `tools/cf_diff.py` (FUZZ-8, CPU differential against the ISA model); GPU test `runtime/test/shaders/ps_scc_mask32.asm` passes (s5 == 8 on 2,048 pixels, 192 of them with bit 0, and s5 == 7 on 2,048) on an NVIDIA RTX 4050 Laptop (Linux, driver 620.73.04, natively and under `LEONIDA_W64_EMULATE=1`) and an AMD Radeon 740M (RADV, Mesa 26.3.1), and on an RTX 2060 SUPER per #634. A 32-bit op on one half of a wave64 mask still takes the lane's bit (its SCC would be a vote of that half). |
@@ -412,7 +412,7 @@ How the generated SPIR-V expects the runtime to work:
412| PS `v_interp` read methods (SHADER-181, translator side) | Bits 0–1 of the FSSM input record's flags byte (byte 7; `fssm_header.read_methods`) give the **read method** of each table position: bit 0 (0x01) = read through `v_interp_mov_f32`, bit 1 (0x02) = read through `v_interp_p1/p2` or the f16 forms. They do not give the D3D interpolation mode, which is PSV0's (row "PS interpolation modes", `tools/ps_interp_modes.py`, #1256). Exactly one bit is set in every corpus record (bit 1 in 51,191, bit 0 in 4,600). In all 12,101 PS every bit-0 position the code reads is read only by `v_interp_mov_f32` (4,295 read positions), every bit-1 position only by `p1/p2` or the f16 forms (49,594), and no position is read both ways (1,902 positions are unread, and 88 reads fall past the table). The translator follows the read method, which is what the code does: `v_interp_mov` → `Flat`, `p1/p2` → a plain input (perspective, pixel center; `BaryCoordKHR` for raw i/j). That this one pair is perspective-center holds because PSV0 lists no centroid, sample or noperspective generic input, and the code reads one barycentric pair (#1256). Table positions don't pair one-to-one with PSV0 rows, since the table keeps only the inputs the compiled code uses, so a PSV0 row's mode and the record's read method can differ at a paired position; #1256 counts those cases. `rdna2spirv.check_read_methods` refuses a PS whose read position disagrees with its record's read method (`v_interp_mov` of a bit-1 position, `p1/p2`/f16 of a bit-0 one), or whose record has neither or both bits, instead of reading it as perspective-center. It refuses 0 of 12,101 PS, and shard 0/12 translates byte-identically to before the check. `index.json` records `ps_flat_interpolants`, the bit-0 positions. Tests: `tests/test_rdna2spirv_pixelinput.py` and `tests/test_fssm_header.py` (synthetic). GPU-checked by @Vonsek on #1246 (RTX 5080 and Radeon integrated graphics, stock `ps_flat` with a hand-built table of read methods 2 and 1): the smooth channels match a per-center perspective reference, the flat channel keeps the provoking value, and flipping either record's read method makes the translator refuse the shader. Bit 3 (0x08, 11,619 records) is a Float16-typed parameter per #1256. | 412| PS `v_interp` read methods (SHADER-181, translator side) | Bits 0–1 of the FSSM input record's flags byte (byte 7; `fssm_header.read_methods`) give the **read method** of each table position: bit 0 (0x01) = read through `v_interp_mov_f32`, bit 1 (0x02) = read through `v_interp_p1/p2` or the f16 forms. They do not give the D3D interpolation mode, which is PSV0's (row "PS interpolation modes", `tools/ps_interp_modes.py`, #1256). Exactly one bit is set in every corpus record (bit 1 in 51,191, bit 0 in 4,600). In all 12,101 PS every bit-0 position the code reads is read only by `v_interp_mov_f32` (4,295 read positions), every bit-1 position only by `p1/p2` or the f16 forms (49,594), and no position is read both ways (1,902 positions are unread, and 88 reads fall past the table). The translator follows the read method, which is what the code does: `v_interp_mov` → `Flat`, `p1/p2` → a plain input (perspective, pixel center; `BaryCoordKHR` for raw i/j). That this one pair is perspective-center holds because PSV0 lists no centroid, sample or noperspective generic input, and the code reads one barycentric pair (#1256). Table positions don't pair one-to-one with PSV0 rows, since the table keeps only the inputs the compiled code uses, so a PSV0 row's mode and the record's read method can differ at a paired position; #1256 counts those cases. `rdna2spirv.check_read_methods` refuses a PS whose read position disagrees with its record's read method (`v_interp_mov` of a bit-1 position, `p1/p2`/f16 of a bit-0 one), or whose record has neither or both bits, instead of reading it as perspective-center. It refuses 0 of 12,101 PS, and shard 0/12 translates byte-identically to before the check. `index.json` records `ps_flat_interpolants`, the bit-0 positions. Tests: `tests/test_rdna2spirv_pixelinput.py` and `tests/test_fssm_header.py` (synthetic). GPU-checked by @Vonsek on #1246 (RTX 5080 and Radeon integrated graphics, stock `ps_flat` with a hand-built table of read methods 2 and 1): the smooth channels match a per-center perspective reference, the flat channel keeps the provoking value, and flipping either record's read method makes the translator refuse the shader. Bit 3 (0x08, 11,619 records) is a Float16-typed parameter per #1256. |
413| Mixed flat and smooth f32 reads | A pixel shader may use `v_interp_mov_f32 p0` and `v_interp_p1/p2_f32` on the same input location. The translator declares it `PerVertexKHR`, takes vertex 0 for the MOV, and interpolates the smooth read with the triangle weights. The fallback modes without per-vertex inputs reject this combination. The synthetic `mixed_f32_varying.asm` fixture and CPU interpreter check both reads at two points of one triangle. [AMD RDNA 2 ISA, VINTRP instructions](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) | 413| Mixed flat and smooth f32 reads | A pixel shader may use `v_interp_mov_f32 p0` and `v_interp_p1/p2_f32` on the same input location. The translator declares it `PerVertexKHR`, takes vertex 0 for the MOV, and interpolates the smooth read with the triangle weights. The fallback modes without per-vertex inputs reject this combination. The synthetic `mixed_f32_varying.asm` fixture and CPU interpreter check both reads at two points of one triangle. [AMD RDNA 2 ISA, VINTRP instructions](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) |
414| Computed I/J barycentrics (SHADER-177) | `v_interp_p1/p2` weight the interpolation with the values their operand VGPRs hold at the two ops, not with the hardware's own pair. Vonsek's image evidence on a synthetic triangle (#1224): zeroed sources render P0 = (0,0) on all 4,096 pixels, and copies of the pair read in swapped order render (v,u) — both follow the two VINTRP equations in the RDNA2 ISA guide; the centre interpolation the single-lane model used to emit is wrong for both. When a write of the operand register reaches an interp site (earlier in its own basic block, or in any block a path runs through first — loops included; a write at the site itself, an interp whose destination is its own I/J register, happens after the operand is read), the attribute is read `PerVertexKHR` and both ops interpolate with the operand values loaded from `%vgpr`, which holds whatever the program computed: constants (snapped coordinates, 577 straight-line sites), copies and copy chains (575), arithmetic (8), multi-writer sequences (1,135). The p1 loads its I and keeps it for the p2, which loads its J fresh — the program often sets J up between the two ops (574 sites) — so the final value uses the I of the p1 with the J of the p2; the p1's own full-sum value is dead because nothing may read the partial between the ops. Pipodi's straight-line scan puts the upper bound at 213 PS (#1218 comment 7076614458; 2,290 v0/v1 sites plus one PS reading J through a copy, all branchy); the reaching-write analysis finds 207 with a write that can reach an interp, and 6 whose overwrites sit on paths that cannot (left pristine, `.spv` unchanged). The other 11,888 PS keep the interpolated-input read and a byte-identical `.spv`. Composes with the operand guards (row above, #1224): a pristine plain `v_mov` copy of the pair stays the guards' to model (centre interpolation, bit-identical `.spv`, including the corpus's one copy PS), an operand that is neither v0/v1 nor written stays the guards' role-naming refusal, and a computed site is exempt from `interp_pair_src` and modelled here — which relaxes exactly the guards' copy-based refusals whose operand a program write reaches: a twice-written register (`v_mov` then arithmetic — the load reads the value the later write left; value-proven by `test_copy_written_again_is_computed`), a copy of an already-overwritten v0/v1 (Vonsek's zero-before-copy row: hardware renders P0, which is exactly the loaded zeros), and a modified `v_mov_b32_dpp` source (any write of the operand is a `%vgpr` value; translation-only test). A pristine copy in the wrong role still refuses (no computed value to model). Over the corpus the relaxation is empty — every one of the 213 PS names v0/v1 (or the one qualified copy), so on main and on this branch alike the set translates 213/213 and passes `spirv-val` 213/213, and no shader changes class; the guards' refusals that relax are the synthetic ones the tests cover. Refused (naming the pattern): a computed pair whose p1 partial is rewritten or read between the ops (its hardware value P10·I would be observable), one whose ops are not in one basic block (the captured I would not dominate the p2), a dangling op without its partner, any computed pair under `--bary-fallback` or `--f16-interp-fallback` (neither has PerVertexKHR inputs; the latter's decoded-half read would otherwise drop the computed weights), and a computed 32-bit read of a 16-bit-flagged interpolant — every one empty over the corpus. Confirmed by `tests/semantic/test_interp_computed_ij.py` and `tests/semantic/test_interp_guards.py` (Vonsek's rows, the between-ops J, f16 pairs, the refusals, the relaxed classes) and the `ps_ij_computed` GPU test (RTX 5060 Ti: snapped quarter pair = 0.5, zeroed pair = P0 = 0, (i, j/2) halving the second weight with 0.0 max error over 4,096 pixels; the same fixture built on main is wrong on 4,096 of 4,096). | 414| Computed I/J barycentrics (SHADER-177) | `v_interp_p1/p2` weight the interpolation with the values their operand VGPRs hold at the two ops, not with the hardware's own pair. Vonsek's image evidence on a synthetic triangle (#1224): zeroed sources render P0 = (0,0) on all 4,096 pixels, and copies of the pair read in swapped order render (v,u) — both follow the two VINTRP equations in the RDNA2 ISA guide; the centre interpolation the single-lane model used to emit is wrong for both. When a write of the operand register reaches an interp site (earlier in its own basic block, or in any block a path runs through first — loops included; a write at the site itself, an interp whose destination is its own I/J register, happens after the operand is read), the attribute is read `PerVertexKHR` and both ops interpolate with the operand values loaded from `%vgpr`, which holds whatever the program computed: constants (snapped coordinates, 577 straight-line sites), copies and copy chains (575), arithmetic (8), multi-writer sequences (1,135). The p1 loads its I and keeps it for the p2, which loads its J fresh — the program often sets J up between the two ops (574 sites) — so the final value uses the I of the p1 with the J of the p2; the p1's own full-sum value is dead because nothing may read the partial between the ops. Pipodi's straight-line scan puts the upper bound at 213 PS (#1218 comment 7076614458; 2,290 v0/v1 sites plus one PS reading J through a copy, all branchy); the reaching-write analysis finds 207 with a write that can reach an interp, and 6 whose overwrites sit on paths that cannot (left pristine, `.spv` unchanged). The other 11,888 PS keep the interpolated-input read and a byte-identical `.spv`. Composes with the operand guards (row above, #1224): a pristine plain `v_mov` copy of the pair stays the guards' to model (centre interpolation, bit-identical `.spv`, including the corpus's one copy PS), an operand that is neither v0/v1 nor written stays the guards' role-naming refusal, and a computed site is exempt from `interp_pair_src` and modelled here — which relaxes exactly the guards' copy-based refusals whose operand a program write reaches: a twice-written register (`v_mov` then arithmetic — the load reads the value the later write left; value-proven by `test_copy_written_again_is_computed`), a copy of an already-overwritten v0/v1 (Vonsek's zero-before-copy row: hardware renders P0, which is exactly the loaded zeros), and a modified `v_mov_b32_dpp` source (any write of the operand is a `%vgpr` value; translation-only test). A pristine copy in the wrong role still refuses (no computed value to model). Over the corpus the relaxation is empty — every one of the 213 PS names v0/v1 (or the one qualified copy), so on main and on this branch alike the set translates 213/213 and passes `spirv-val` 213/213, and no shader changes class; the guards' refusals that relax are the synthetic ones the tests cover. Refused (naming the pattern): a computed pair whose p1 partial is rewritten or read between the ops (its hardware value P10·I would be observable), one whose ops are not in one basic block (the captured I would not dominate the p2), a dangling op without its partner, any computed pair under `--bary-fallback` or `--f16-interp-fallback` (neither has PerVertexKHR inputs; the latter's decoded-half read would otherwise drop the computed weights), and a computed 32-bit read of a 16-bit-flagged interpolant — every one empty over the corpus. Confirmed by `tests/semantic/test_interp_computed_ij.py` and `tests/semantic/test_interp_guards.py` (Vonsek's rows, the between-ops J, f16 pairs, the refusals, the relaxed classes) and the `ps_ij_computed` GPU test (RTX 5060 Ti: snapped quarter pair = 0.5, zeroed pair = P0 = 0, (i, j/2) halving the second weight with 0.0 max error over 4,096 pixels; the same fixture built on main is wrong on 4,096 of 4,096). |
415| Whole-wave masks | `tools/lane_masks.py` tracks per-lane mask bits through scalar registers, vector operations and saved EXEC spills. Whole-mask counts, first-set-lane queries, the leading-bit scans `s_flbit_i32_b32` / `s_flbit_i32` of `vcc_lo`/`exec_lo` (and `_hi`) and equality use subgroup operations (`tests/semantic/test_salu_flbit_lane_mask.py`; until then the flbit scans saw this lane's 0 / ~0). Whole-mask counts, first-set-lane queries and equality use subgroup operations. `cs_wavemask` checks all 64 lanes with a partially active EXEC mask. A physical 32-lane subgroup cannot directly exchange mask bits with the other half of a wave64, so `cs_wavemask` and the `cs_wave64_ballot` / `cs_wm_*` tests are exact only on 64-wide subgroups (AMD): on an RTX 4090 (subgroup 32) `s_bcnt1_i32_b64` of lanes 16–47 counts 16, one half (#101). `check.py` skips them where the GPU has no 64-wide compute subgroup. A mask copied into a VGPR with `v_mov_b32` goes through the normal EXEC-gated store, so inactive lanes keep the old VGPR (SHADER-21 part 2, #210); per-lane mask computations still store in all lanes, because whole-wave readers (`wave_mask`, `v_readfirstlane`) read every lane's bit. `cs_mask_vgpr_exec` checks it. The gathered mask is stored to a variable of its own before a reader uses it (`Gen.eager`, as DPP's ballot and shuffle are since SHADER-529): `v_mbcnt` writes a VGPR, so its result is selected on the lane's EXEC, and MoltenVK's SPIRV-Cross inlined the single-use gather into the taken arm of that ternary (`active ? popcount(simd_or(...) & below) + acc : old`), where a lane that is off never ran it and its bit was missing from every other lane's count. Confirmed on an Apple M5 (MoltenVK 1.4.2) with `tools/crosslane_fuzz.py --wave 32 --modes native --no-maskdata`: 4 of 100 programs of the default seed mismatched before, none after (SHADER-WAVEMASK-EAGER, `tests/semantic/test_wave_mask_eager.py`). Vector bitwise mask tracking (`VECTOR_BITWISE`) also includes `v_and_or_b32`, `v_xnor_b32` and `v_bfi_b32` when every source is a lane mask or `0`/`-1` (CPU-checked by `tests/test_lane_masks.py` and `tests/semantic/test_lane_masks_vector_bitwise.py`). | 415| Whole-wave masks | `tools/lane_masks.py` tracks per-lane mask bits through scalar registers, vector operations and saved EXEC spills. Whole-mask counts, first-set-lane queries, the leading-bit scans `s_flbit_i32_b32` / `s_flbit_i32` of `vcc_lo`/`exec_lo` (and `_hi`) and equality use subgroup operations (`tests/semantic/test_salu_flbit_lane_mask.py`; until then the flbit scans saw this lane's 0 / ~0). Whole-mask counts, first-set-lane queries and equality use subgroup operations. `cs_wavemask` checks all 64 lanes with a partially active EXEC mask. A physical 32-lane subgroup cannot directly exchange mask bits with the other half of a wave64, so `cs_wavemask` and the `cs_wave64_ballot` / `cs_wm_*` tests are exact only on 64-wide subgroups (AMD): on an RTX 4090 (subgroup 32) `s_bcnt1_i32_b64` of lanes 16–47 counts 16, one half (#101). `check.py` skips them where the GPU has no 64-wide compute subgroup. A mask copied into a VGPR with `v_mov_b32` goes through the normal EXEC-gated store, so inactive lanes keep the old VGPR (SHADER-21 part 2, #210); per-lane mask computations still store in all lanes, because whole-wave readers (`wave_mask`, `v_readfirstlane`) read every lane's bit. `cs_mask_vgpr_exec` checks it. A lane mask (EXEC/VCC or a mask-tracked SGPR) that a VALU op reads as a 32-bit value — `v_mov_b32` of it into a plain VGPR, or any VALU source where the mask is data rather than a mask operand — yields the whole wave's mask word, the same in every lane, not this lane's 0 / ~0 bit; until the fix it gave each lane its own bit (found by `tools/crosslane_fuzz.py`, #293). A mask that stays in or passes through a VGPR holds that word. `v_readfirstlane_b32` of one broadcasts the first active lane's copy — the only lane guaranteed fresh after an EXEC-gated `v_mov_b32` — as the word itself into a VGPR destination (VGPR writes are never mask-tracked, so no extraction); a mask-tracked SGPR or special destination gets this lane's bit of it, half-aware in wave64 (a stale word in a lane an EXEC-gated `v_mov_b32` skipped would otherwise leak the other half's bits, `cs_wavemask` lanes 48–63). The gathered mask is stored to a variable of its own before a reader uses it (`Gen.eager`, as DPP's ballot and shuffle are since SHADER-529): `v_mbcnt` writes a VGPR, so its result is selected on the lane's EXEC, and MoltenVK's SPIRV-Cross inlined the single-use gather into the taken arm of that ternary (`active ? popcount(simd_or(...) & below) + acc : old`), where a lane that is off never ran it and its bit was missing from every other lane's count. Confirmed on an Apple M5 (MoltenVK 1.4.2) with `tools/crosslane_fuzz.py --wave 32 --modes native --no-maskdata`: 4 of 100 programs of the default seed mismatched before, none after (SHADER-WAVEMASK-EAGER, `tests/semantic/test_wave_mask_eager.py`). Vector bitwise mask tracking (`VECTOR_BITWISE`) also includes `v_and_or_b32`, `v_xnor_b32` and `v_bfi_b32` when every source is a lane mask or `0`/`-1` (CPU-checked by `tests/test_lane_masks.py` and `tests/semantic/test_lane_masks_vector_bitwise.py`). The mask-word gather is emitted for every such data read. EXEC narrowing is a per-lane value in the translator's model, not SPIR-V control flow, and mask-data readers are kept out of lane-local `if (active)` runs, so lanes EXEC has off still execute the gather and contribute the mask bits they hold. The eager store above keeps compiler lowering from moving that subgroup op into an EXEC-selected arm (the MoltenVK failure mode). Narrowed-EXEC SGPR/VCC reads, an independent all-ones SGPR restore, and the composed vector-bitwise masks are covered in `tests/semantic/test_lane_masks_vector_bitwise.py`; `tests/semantic/test_wave_mask_eager.py` checks that no gather is conditional. Scalar number ops (`s_add_u32 s20, s10, K` after `v_cmp` wrote `s10`) read a mask operand as data the same way (#1043's `NUMBER_READERS`). |
416| Floating-point operations | Separate floating-point instructions carry `NoContraction` so the driver preserves their individual rounding. The instructions that fuse multiply-add (`v_fma_f32`, `v_fmac_f32`, `v_fmaak_f32`, `v_fmamk_f32`, `v_fma_mix*`) round **once** on RDNA2 (measured on gfx1150 by `tools/f32_fuzz.py --oracle hw`: 72 of 72 cancellation probes fused). SPIR-V has two ways to say that. `GLSL.std.450 Fma` is the default (`--fma glsl`), but the Vulkan SPIR-V environment gives it the precision "inherited from `OpFMul` followed by `OpFAdd`", so a driver may legally round twice; `tools/f32_fuzz.py` and `runtime/test/shaders/cs_fma_fused.asm` are the tests that notice — on Mesa RADV/ACO (Linux), `--fma glsl` splits a subset of the 7 f32 FMAs in `cs_fma_fused` depending on GPU, Mesa version, and shader execution modes (measured: 4 of 7 on RX 6800 / Mesa 26.2.6-arch3.1 and RX 7600 / Mesa 27.0.0-devel with `SignedZeroInfNanPreserve 32`, 5 of 7 on RX 6800 before float controls, and 7 of 7 on Radeon Pro V540 RDNA1 / Mesa 25.2.8), while `--fma khr` emits single-rounded `v_fma_f32` (8/8 exact). `tools/f32_fuzz.py` and `runtime/test/shaders/cs_fma_fused.asm` are the tests that notice. `tools/f32_fuzz.py` and `runtime/test/shaders/cs_fma_fused.asm` are the tests that notice — on an AMD Radeon RX 6800 (Mesa RADV 26.2.6-arch3.1, Linux), RADV/ACO actually splits 5 of the 7 f32 FMAs in `cs_fma_fused` under `--fma glsl` (folding/splitting against the live `v_mul_f32` product `a*a`) and emits single-rounded `v_fma_f32` (8/8 exact) under `--fma khr`. `--fma khr` emits `OpFmaKHR` (`SPV_KHR_fma`, capability `FMAKHR`; "correctly rounded"), which needs `VK_KHR_shader_fma` with `shaderFmaFloat32` on the device. The index then lists capability `FMAKHR`, extension `SPV_KHR_fma` and feature `shaderFmaFloat32` for exactly the shaders that use it, and the output of every shader without a fused multiply-add is byte-identical under both options. `khr` is not the default because a device without the extension would fail pipeline creation; a runtime that knows its device has `shaderFmaFloat32` should translate with `--fma khr`. A device that has neither can split `Fma`: the Intel UHD Graphics driver (Xe-LP, Windows 101.7088) does, `cs_fma_fused` words 0, 2, 3 and 5 coming out split, with no `VK_KHR_shader_fma` (SHADER-497). RADV (Mesa 26.3.1, RX 6700 XT) splits the same four words, measured in #3004's review, but it has `VK_KHR_shader_fma` since Mesa 26.2, so `--fma khr` covers it. For it, `--fma exact` (`Gen.fma_exact`, no extension; per multiply-add about 110 instructions more than `glsl`, plus 31 `NoContraction` decorations and 13 constants) builds the single rounding from `NoContraction` f32 operations, after Boldo and Melquiond (IEEE Transactions on Computers 57(4), 2008): Dekker's exact product with the factors split by masking their low 12 mantissa bits, a TwoSum of the addend and the product, the two error terms summed with round-to-odd, and one final rounding. Power-of-two scaling keeps every intermediate in the normal range: by 2^-64 when the product or the addend is at least 2^126, by 2^96 when both are tiny, and 2^64 traded between a factor below 2^-100 and one above 2^-20. Infinite or NaN operands, and a product beyond even the scaled range (the result is ±inf), take the plain `Fma`. Confirmed: `tests/semantic/test_fma_exact.py` runs the emitted instructions in the interpreter with its `Fma` split as on that driver and compares 700 random and 96 edge cases with an exact rational reference; a model of the same steps matched 399,989 of 399,989 cases with a normal or zero result, with f32 denormals kept and flushed; on the GPU, `cs_fma_fused` (and #2211's `cs_w32_fma_mix`) pass with `--fma exact` on that Intel UHD and on an RTX 3050 Laptop (617.42). Not exact: a result in the denormal range (scaled back with a second rounding) and denormal operands, which follow the driver's denormal mode as every f32 operation does here. The f16 forms (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) never use either: they are exact round-to-odd arithmetic built from `OpFMul`/`OpFAdd` with `NoContraction` (`Gen.fma_f16_odd`), so a fused f32 `Fma` would not change them (`v_fma_mixlo_f16`/`v_fma_mixhi_f16` under the toward-zero MODE are the exception: `fma_mix_odd` needs the exact product error `Fma(x, y, -p)`, which is only guaranteed with `OpFmaKHR`), and an f16 `OpFmaKHR` (`shaderFmaFloat16`) is not used. The f64 multiply-adds of `v_div_fmas_f64` (the plain `fma`, the pre-scaled one and the exact product error) are `GLSL.std.450 Fma` on doubles by default, and the Vulkan environment lets a driver round that twice too: NVIDIA's does on some GPUs when it folds an all-constant `Fma` while compiling the pipeline: `runtime/test/shaders/cs_div_fmas_f64.asm`, whose operands are literals, gives the split 0 instead of 2^-60 for `fma(a, a, c)` with a = 1 + 2^-30 and c = -(1 + 2^-29) on the RTX 4090 (621.24, Windows), RTX 3070 (621.01, Windows) and Quadro RTX 4000 (Turing, 615.71.09, Linux), and the fused result on an RTX 5060 Laptop (Blackwell, 621.24). `cs_div_fmas_f64_rt.asm` reads the same operands at run time from s4..s7 and is fused on the 4090, 3070 and 5060 (and on an RTX 4070, #4536); the f32 `cs_fma_fused` fuses 8/8 on the 4090. `--fma khr` emits them as `OpFmaKHR` on doubles, which needs `shaderFmaFloat64` (the index lists that feature, and `shaderFmaFloat32` only for a module with an f32 FMA; `vk_pipeline_check` checks each); on the RTX 4090 it gives the fused 2^-60. `--fma exact` has no f64 form and keeps `Fma`. Checked by `tests/semantic/test_fma_khr_f64.py` (emission, index features, `spirv-val`). | 416| Floating-point operations | Separate floating-point instructions carry `NoContraction` so the driver preserves their individual rounding. The instructions that fuse multiply-add (`v_fma_f32`, `v_fmac_f32`, `v_fmaak_f32`, `v_fmamk_f32`, `v_fma_mix*`) round **once** on RDNA2 (measured on gfx1150 by `tools/f32_fuzz.py --oracle hw`: 72 of 72 cancellation probes fused). SPIR-V has two ways to say that. `GLSL.std.450 Fma` is the default (`--fma glsl`), but the Vulkan SPIR-V environment gives it the precision "inherited from `OpFMul` followed by `OpFAdd`", so a driver may legally round twice; `tools/f32_fuzz.py` and `runtime/test/shaders/cs_fma_fused.asm` are the tests that notice — on Mesa RADV/ACO (Linux), `--fma glsl` splits a subset of the 7 f32 FMAs in `cs_fma_fused` depending on GPU, Mesa version, and shader execution modes (measured: 4 of 7 on RX 6800 / Mesa 26.2.6-arch3.1 and RX 7600 / Mesa 27.0.0-devel with `SignedZeroInfNanPreserve 32`, 5 of 7 on RX 6800 before float controls, and 7 of 7 on Radeon Pro V540 RDNA1 / Mesa 25.2.8), while `--fma khr` emits single-rounded `v_fma_f32` (8/8 exact). `tools/f32_fuzz.py` and `runtime/test/shaders/cs_fma_fused.asm` are the tests that notice. `tools/f32_fuzz.py` and `runtime/test/shaders/cs_fma_fused.asm` are the tests that notice — on an AMD Radeon RX 6800 (Mesa RADV 26.2.6-arch3.1, Linux), RADV/ACO actually splits 5 of the 7 f32 FMAs in `cs_fma_fused` under `--fma glsl` (folding/splitting against the live `v_mul_f32` product `a*a`) and emits single-rounded `v_fma_f32` (8/8 exact) under `--fma khr`. `--fma khr` emits `OpFmaKHR` (`SPV_KHR_fma`, capability `FMAKHR`; "correctly rounded"), which needs `VK_KHR_shader_fma` with `shaderFmaFloat32` on the device. The index then lists capability `FMAKHR`, extension `SPV_KHR_fma` and feature `shaderFmaFloat32` for exactly the shaders that use it, and the output of every shader without a fused multiply-add is byte-identical under both options. `khr` is not the default because a device without the extension would fail pipeline creation; a runtime that knows its device has `shaderFmaFloat32` should translate with `--fma khr`. A device that has neither can split `Fma`: the Intel UHD Graphics driver (Xe-LP, Windows 101.7088) does, `cs_fma_fused` words 0, 2, 3 and 5 coming out split, with no `VK_KHR_shader_fma` (SHADER-497). RADV (Mesa 26.3.1, RX 6700 XT) splits the same four words, measured in #3004's review, but it has `VK_KHR_shader_fma` since Mesa 26.2, so `--fma khr` covers it. For it, `--fma exact` (`Gen.fma_exact`, no extension; per multiply-add about 110 instructions more than `glsl`, plus 31 `NoContraction` decorations and 13 constants) builds the single rounding from `NoContraction` f32 operations, after Boldo and Melquiond (IEEE Transactions on Computers 57(4), 2008): Dekker's exact product with the factors split by masking their low 12 mantissa bits, a TwoSum of the addend and the product, the two error terms summed with round-to-odd, and one final rounding. Power-of-two scaling keeps every intermediate in the normal range: by 2^-64 when the product or the addend is at least 2^126, by 2^96 when both are tiny, and 2^64 traded between a factor below 2^-100 and one above 2^-20. Infinite or NaN operands, and a product beyond even the scaled range (the result is ±inf), take the plain `Fma`. Confirmed: `tests/semantic/test_fma_exact.py` runs the emitted instructions in the interpreter with its `Fma` split as on that driver and compares 700 random and 96 edge cases with an exact rational reference; a model of the same steps matched 399,989 of 399,989 cases with a normal or zero result, with f32 denormals kept and flushed; on the GPU, `cs_fma_fused` (and #2211's `cs_w32_fma_mix`) pass with `--fma exact` on that Intel UHD and on an RTX 3050 Laptop (617.42). Not exact: a result in the denormal range (scaled back with a second rounding) and denormal operands, which follow the driver's denormal mode as every f32 operation does here. The f16 forms (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) never use either: they are exact round-to-odd arithmetic built from `OpFMul`/`OpFAdd` with `NoContraction` (`Gen.fma_f16_odd`), so a fused f32 `Fma` would not change them (`v_fma_mixlo_f16`/`v_fma_mixhi_f16` under the toward-zero MODE are the exception: `fma_mix_odd` needs the exact product error `Fma(x, y, -p)`, which is only guaranteed with `OpFmaKHR`), and an f16 `OpFmaKHR` (`shaderFmaFloat16`) is not used. The f64 multiply-adds of `v_div_fmas_f64` (the plain `fma`, the pre-scaled one and the exact product error) are `GLSL.std.450 Fma` on doubles by default, and the Vulkan environment lets a driver round that twice too: NVIDIA's does on some GPUs when it folds an all-constant `Fma` while compiling the pipeline: `runtime/test/shaders/cs_div_fmas_f64.asm`, whose operands are literals, gives the split 0 instead of 2^-60 for `fma(a, a, c)` with a = 1 + 2^-30 and c = -(1 + 2^-29) on the RTX 4090 (621.24, Windows), RTX 3070 (621.01, Windows) and Quadro RTX 4000 (Turing, 615.71.09, Linux), and the fused result on an RTX 5060 Laptop (Blackwell, 621.24). `cs_div_fmas_f64_rt.asm` reads the same operands at run time from s4..s7 and is fused on the 4090, 3070 and 5060 (and on an RTX 4070, #4536); the f32 `cs_fma_fused` fuses 8/8 on the 4090. `--fma khr` emits them as `OpFmaKHR` on doubles, which needs `shaderFmaFloat64` (the index lists that feature, and `shaderFmaFloat32` only for a module with an f32 FMA; `vk_pipeline_check` checks each); on the RTX 4090 it gives the fused 2^-60. `--fma exact` has no f64 form and keeps `Fma`. Checked by `tests/semantic/test_fma_khr_f64.py` (emission, index features, `spirv-val`). |
417| `NoContraction` cost on MoltenVK (SHADER-234) | MoltenVK's SPIRV-Cross turns each `NoContraction` `OpFAdd`, `OpFSub` and `OpFMul` into a call to a `[[clang::optnone]]` helper (`spvFAdd`, `spvFSub`, `spvFMul`), and Metal does not inline it. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected. SPIRV-Cross `98cbb7c0` inlines the helpers from MSL 3.2 with bit-identical output, and MoltenVK on macOS 26 or newer compiles MSL 4.0. On an Apple M3 Max, a translated compute shader of `v_mul_f32`, `v_add_f32` and `v_sub_f32` in a loop took 7.6 to 15.7 times as long on the GPU with the optnone helpers as with `98cbb7c0`. With independent operations and no `NoContraction`, it took two thirds of the `98cbb7c0` time, which is the cost of the decoration itself ([measurement](https://github.com/ItsNotRexed/Leonida/issues/1380#issuecomment-7078722086)). The same `spvFMul` helper drops the sign of a -0 product (SHADER-182, #1376). | 417| `NoContraction` cost on MoltenVK (SHADER-234) | MoltenVK's SPIRV-Cross turns each `NoContraction` `OpFAdd`, `OpFSub` and `OpFMul` into a call to a `[[clang::optnone]]` helper (`spvFAdd`, `spvFSub`, `spvFMul`), and Metal does not inline it. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected. SPIRV-Cross `98cbb7c0` inlines the helpers from MSL 3.2 with bit-identical output, and MoltenVK on macOS 26 or newer compiles MSL 4.0. On an Apple M3 Max, a translated compute shader of `v_mul_f32`, `v_add_f32` and `v_sub_f32` in a loop took 7.6 to 15.7 times as long on the GPU with the optnone helpers as with `98cbb7c0`. With independent operations and no `NoContraction`, it took two thirds of the `98cbb7c0` time, which is the cost of the decoration itself ([measurement](https://github.com/ItsNotRexed/Leonida/issues/1380#issuecomment-7078722086)). The same `spvFMul` helper drops the sign of a -0 product (SHADER-182, #1376). |
418| `NoContraction` multiply on MoltenVK (SHADER-182) | On MoltenVK, a multiply whose exact product is a negative zero (`+0 × -1.5`, `-0 × 1.0`) returns +0 in f32, f16 and packed f16 (#1203). MoltenVK's SPIRV-Cross turns every `NoContraction` `OpFMul` into its `spvFMul` helper, which returns `fma(l, r, T(0))`. A -0 product plus +0 is +0. The f16 multiplies are `OpFMul` on `float` or `v2float`, so they take the same path. So does the product inside `fma_f16_odd`: `v_fma_f16`, `v_fmac_f16` and `v_pk_fma_f16` return +0 for a -0 product plus a -0 addend. SPIRV-Cross [300681bb](https://github.com/KhronosGroup/SPIRV-Cross/commit/300681bbcb8365a8d1eacdacdbdd0249bbf1d6b1) changes the addend to `T(-0.0)`. MoltenVK 1.4.2 has the old helper, and so does MoltenVK `main` at `5189f8de` (2026-10-13), which pins the parent commit `aa217aeb`. The translator does not change for this. `MVK_CONFIG_FAST_MATH_ENABLED=0` does not help, because the helper itself adds +0, and per #1203 neither does `SignedZeroInfNanPreserve` (#664). Measured on an Apple M3 Max (macOS 27.3): Metal keeps the sign for `a * b` and for `fma(a, b, -0.0)` with `MTLMathModeFast` and with `MTLMathModeSafe`, and loses it only with the +0 addend. With `valu_fuzz.py --family f16`, MoltenVK `5189f8de` as pinned matches 49/50 programs with `--seed 1 --wave 32`, 98/100 with `--seed 1 --emulate` and 98/100 with `--seed 4 --emulate`, and Homebrew MoltenVK 1.4.2 gives the same counts. Each mismatch is a -0 product read as +0. The same build with SPIRV-Cross `300681bb` matches 50/50, 100/100 and 100/100, as does KosmicKrisp (Mesa 26.3.1). For the FMA path, `--seed 330 --wave 32` with `--skip-op v_mul_f16 --skip-op v_pk_mul_f16` matches 49/50 with `aa217aeb` (a `v_fmac_f16` result) and 50/50 with `300681bb` and on KosmicKrisp. | 418| `NoContraction` multiply on MoltenVK (SHADER-182) | On MoltenVK, a multiply whose exact product is a negative zero (`+0 × -1.5`, `-0 × 1.0`) returns +0 in f32, f16 and packed f16 (#1203). MoltenVK's SPIRV-Cross turns every `NoContraction` `OpFMul` into its `spvFMul` helper, which returns `fma(l, r, T(0))`. A -0 product plus +0 is +0. The f16 multiplies are `OpFMul` on `float` or `v2float`, so they take the same path. So does the product inside `fma_f16_odd`: `v_fma_f16`, `v_fmac_f16` and `v_pk_fma_f16` return +0 for a -0 product plus a -0 addend. SPIRV-Cross [300681bb](https://github.com/KhronosGroup/SPIRV-Cross/commit/300681bbcb8365a8d1eacdacdbdd0249bbf1d6b1) changes the addend to `T(-0.0)`. MoltenVK 1.4.2 has the old helper, and so does MoltenVK `main` at `5189f8de` (2026-10-13), which pins the parent commit `aa217aeb`. The translator does not change for this. `MVK_CONFIG_FAST_MATH_ENABLED=0` does not help, because the helper itself adds +0, and per #1203 neither does `SignedZeroInfNanPreserve` (#664). Measured on an Apple M3 Max (macOS 27.3): Metal keeps the sign for `a * b` and for `fma(a, b, -0.0)` with `MTLMathModeFast` and with `MTLMathModeSafe`, and loses it only with the +0 addend. With `valu_fuzz.py --family f16`, MoltenVK `5189f8de` as pinned matches 49/50 programs with `--seed 1 --wave 32`, 98/100 with `--seed 1 --emulate` and 98/100 with `--seed 4 --emulate`, and Homebrew MoltenVK 1.4.2 gives the same counts. Each mismatch is a -0 product read as +0. The same build with SPIRV-Cross `300681bb` matches 50/50, 100/100 and 100/100, as does KosmicKrisp (Mesa 26.3.1). For the FMA path, `--seed 330 --wave 32` with `--skip-op v_mul_f16 --skip-op v_pk_mul_f16` matches 49/50 with `aa217aeb` (a `v_fmac_f16` result) and 50/50 with `300681bb` and on KosmicKrisp. |
@@ -536,6 +536,7 @@ How the generated SPIR-V expects the runtime to work:
536| `v_interp_p2_f16` clamp | The VOP3 `clamp` bit on `v_interp_p2_f16` clamps its f16 result to [0, 1], applied before the narrowing like the other f16 results (Mesa ACO `aco_opcodes.py` declares the op `dst(F16)`, which takes output modifiers; llvm-mc encodes `clamp` on it but no omod). Until 2026-11-22 the translator dropped it. Checked by `tests/semantic/test_interp_f16.py`: attributes 1.5 and -0.25 read with clamp give 1.0 and +0.0, and without it 1.5 and -0.25. No GPU test: `vs_ids` gives attributes in [0, 1) only. | 536| `v_interp_p2_f16` clamp | The VOP3 `clamp` bit on `v_interp_p2_f16` clamps its f16 result to [0, 1], applied before the narrowing like the other f16 results (Mesa ACO `aco_opcodes.py` declares the op `dst(F16)`, which takes output modifiers; llvm-mc encodes `clamp` on it but no omod). Until 2026-11-22 the translator dropped it. Checked by `tests/semantic/test_interp_f16.py`: attributes 1.5 and -0.25 read with clamp give 1.0 and +0.0, and without it 1.5 and -0.25. No GPU test: `vs_ids` gives attributes in [0, 1) only. |
537| 16-bit interpolation (`v_interp_p1ll_f16` / `v_interp_p2_f16`, `high`) | A 16-bit varying shares its 32-bit param channel with another: the producer packs them as low half, high half (Mesa `ac_nir_prerast_utils.c`: `nir_pack_32_2x16_split` by `io_sem.high_16bits`), the PS sets `FP16_INTERP_MODE` (plus `ATTR1_VALID` when the high half is used, RADV `radv_ps_input_type_bits`), and the `high` bit picks the half on both ops of the pair (ACO `emit_interp_instr`, `aco_isel_helpers.cpp`; llvm-mc gfx1013 sets the same bit, byte 5 bit 0, on both: p1ll `v2, v0, attr0.x high` 0x00 → 0x01, p2 `v2, v1, attr0.x, v3 high` 0x02 → 0x03). The translated VS exports the channel's raw bits, so interpolating them as one f32 gives neither half. A location any `*_f16` interp reads is therefore declared `PerVertexKHR` (`vec4[3]`, no `Flat`; it still matches a producer's vec4 output at that location); this needs `VK_KHR_fragment_shader_barycentric` (`fragmentShaderBarycentric`) for every such PS, not just the raw-barycentric ones; the index records it like any capability (`features: ["fragmentShaderBarycentric"]`), so `vk_pipeline_check` and `vk_harness` skip such a PS on a device without it. Nothing picks `--bary-fallback` from the device: it is a translation-time flag. Each f16 read decodes its half of each vertex's word (`UnpackHalf2x16` component 0 or 1) and weights them as the hardware does: the delta P1 − P0 (and P2 − P0) is rounded to f16 first — the SPI's P10/P20 words for a 16-bit channel are per-half f16 differences, measured below — and P0 + i·P10 + j·P20 is summed in f32 with i, j = `BaryCoordKHR`.y/.z (f32, not f16) before p2 clamps and narrows toward zero. f32 reads of such a location (`p1/p2_f32`) interpolate the raw word the same way, and `v_interp_mov_f32` takes vertex 0's. Until 2026-11-22 `high` was ignored and both halves read the smooth-f32 interpolation of the whole word; abilliontokens counted `high` in 4,776 of 12,101 PS (39.5%, 51,684 instructions, always p1ll/p2 pairs, no `p1lv`), and Pipodi found 4,731 of those 4,776 read both halves of the same channel, with p1ll and p2 always agreeing on attribute, channel and `high`. Like the f32 path, the pair's I/J operands are not read: the weights come from `BaryCoordKHR` (213 PS that compute their own barycentrics into v0/v1 first are a separate gap). Confirmed by `tests/semantic/test_interp_f16_high.py` (per-vertex halves 0.5/1.5/2.5 and −4/8/16 at weights (0.25, 0.25, 0.5) give 1.75 and 9.0; fails on the old translation) and the GPU fixture `ps_interp_f16_high` drawn with `vs_f16_pack` (u and v packed in one channel both ways, f32 control) and, through `scripts/run_gpu_tests.py`, with the mesh producer `ms_f16_pack` (mesh `exp paramN` stores the same raw words, `Gen.ms_export`): both pass on an RTX 5070 and fail on the old translation (off by 0.984). spirv-val and `vk_pipeline_check` (real pipelines against the vec4 VS stubs, RTX 5070) also accept PS mixing high, low, f32 and flat reads of one location and of several. **Measured natively on RDNA2** (AMD Radeon 680M, `gfx1035`, wave32 and wave64 via `tools/vinterp_hw_probe.py --oracle both`, SHADER-430): the VINTRP unit reads `P0`, `P10` and `P20` from LDS at `M0 + 48·attr + {8·c, 8·c + 4, 32 + 4·c}`; `v_interp_p1ll_f16` (and `v_interp_p1lv_f16`, taking `P0.half` from `vsrc2`) widens the selected f16 half (`[15:0]` or `[31:16]` with `high`) to binary32 and writes the fused binary32 `fma(i, f32(P10.half), f32(P0.half))`, while `v_interp_p2_f16` rounds the exact `partial_f32 + j · f32(P20.half)` once to f16 following `MODE.FP_ROUND.16_64` (like `v_fma_mixlo_f16`, whereas the translator sums P0 + i·P10 + j·P20 in f32 and narrows toward zero — SHADER-468: the driver's ISA runs the pair inside `s_round_mode 0x000c`, so the narrow is toward zero whatever the shader's own MODE writes are) and writes `vdst[15:0]` while hardware keeps `vdst[31:16]`; f16 subnormal halves are preserved with `denorm_mode_16_64 = 3` (`0x0001 + 0.5·0x0200 + 0.5·0x0200 → 0x0201`, flushed to `±0` when `0`), and f16 NaN halves quiet with payload preserved (`0x7e05 → 0x7e05`, `0x7c01 → 0x7e01`). **ALU half measured on AMD hardware** (SHADER-430, `tools/interp_hw_probe.py`, gfx1036, every case matched; `docs/shader_validation.md`): `p1ll_f16` widens the chosen f16 halves exactly and computes fma(h10, I, h0) with one rounding to f32. `p2_f16` computes fma(h20, J, p1ll) and rounds it once, straight to f16: 30 hand-built ties gave that result and never f32-then-f16. It keeps vdst's high 16 bits. The translator used to zero them and now keeps them (`write_lo16`; `test_p2_f16_keeps_the_high_half_of_vdst`). **Measured on AMD hardware (SHADER-468, `tools/f16_interp_probe.py`; native 64×64 draws of a hand-written `f16vec2` varying through `vk_harness` on the Ryzen 5 7600 iGPU, gfx1036, AMD Windows driver 24.10.24, Vulkan 1.3.280; 12 draws, six value sets × orthographic and perspective, 98,304 samples):** the SPI writes P10/P20 as f16 differences of the two halves (round to nearest even) — a pair whose difference is 66,504, past the largest f16, interpolates to inf where the f32 difference stays finite — the sum is f32 (an f16 sum misses 11,385 of the 98,304 samples) and `v_interp_p2_f16` narrows **toward zero** (nearest even misses 36,078). The f16-delta model explains 98,274 of 98,304 samples, against 89,993 for the same model without the f16 delta, 86,919 for an f16 sum and 62,226 for nearest-even narrowing; until 2026-11-22 the translation used the f32 difference and nearest even, which is what the last number measures. The narrow follows MODE.FP16_ROUND, which every AMD compiler sets toward zero around this pair (LLVM `SIModeRegister`: "f16 interpolation instructions need double precision round to zero"; the Windows driver's ISA runs both ops inside `s_round_mode 0x000c`), so the translated p2 rounds toward zero whatever the shader's own MODE writes are. The weights are the SPI's f32 values, not f16: a perspective triangle (w = 1, 2, 4) quantized to f16 misses most samples, f32 matches. Confirmed by `tests/semantic/test_interp_f16_round.py` (both cases fail on the old translation). **Still unverified:** the 30 misses (26 where the exact value is a few 2^-24 — the hardware gives the smallest f16 subnormal where a plain toward-zero narrow gives zero — and 4 at an exact f16 grid boundary, where the vertex-0 weight is the SPI's own f32 value rather than 1 − i − j), f16 inf/NaN halves and `p1lv_f16`, and what a 32-bit `p1/p2_f32` read of a 16-bit-mode channel returns: with the LDS words holding f16 lanes that read cannot be the f16-rounded smooth value the "Pixel-shader interpolants" row assumes, but no Vulkan or D3D12 shader can ask for 16-bit mode and a 32-bit read of the same attribute, so it stays unmeasured. **`--bary-fallback`** has no per-vertex inputs, so it keeps the old smooth-f32 read and cannot honour `high`; `check.py` skips the fixture there. MoltenVK can't compile `PerVertexKHR`: see the next row. | 537| 16-bit interpolation (`v_interp_p1ll_f16` / `v_interp_p2_f16`, `high`) | A 16-bit varying shares its 32-bit param channel with another: the producer packs them as low half, high half (Mesa `ac_nir_prerast_utils.c`: `nir_pack_32_2x16_split` by `io_sem.high_16bits`), the PS sets `FP16_INTERP_MODE` (plus `ATTR1_VALID` when the high half is used, RADV `radv_ps_input_type_bits`), and the `high` bit picks the half on both ops of the pair (ACO `emit_interp_instr`, `aco_isel_helpers.cpp`; llvm-mc gfx1013 sets the same bit, byte 5 bit 0, on both: p1ll `v2, v0, attr0.x high` 0x00 → 0x01, p2 `v2, v1, attr0.x, v3 high` 0x02 → 0x03). The translated VS exports the channel's raw bits, so interpolating them as one f32 gives neither half. A location any `*_f16` interp reads is therefore declared `PerVertexKHR` (`vec4[3]`, no `Flat`; it still matches a producer's vec4 output at that location); this needs `VK_KHR_fragment_shader_barycentric` (`fragmentShaderBarycentric`) for every such PS, not just the raw-barycentric ones; the index records it like any capability (`features: ["fragmentShaderBarycentric"]`), so `vk_pipeline_check` and `vk_harness` skip such a PS on a device without it. Nothing picks `--bary-fallback` from the device: it is a translation-time flag. Each f16 read decodes its half of each vertex's word (`UnpackHalf2x16` component 0 or 1) and weights them as the hardware does: the delta P1 − P0 (and P2 − P0) is rounded to f16 first — the SPI's P10/P20 words for a 16-bit channel are per-half f16 differences, measured below — and P0 + i·P10 + j·P20 is summed in f32 with i, j = `BaryCoordKHR`.y/.z (f32, not f16) before p2 clamps and narrows toward zero. f32 reads of such a location (`p1/p2_f32`) interpolate the raw word the same way, and `v_interp_mov_f32` takes vertex 0's. Until 2026-11-22 `high` was ignored and both halves read the smooth-f32 interpolation of the whole word; abilliontokens counted `high` in 4,776 of 12,101 PS (39.5%, 51,684 instructions, always p1ll/p2 pairs, no `p1lv`), and Pipodi found 4,731 of those 4,776 read both halves of the same channel, with p1ll and p2 always agreeing on attribute, channel and `high`. Like the f32 path, the pair's I/J operands are not read: the weights come from `BaryCoordKHR` (213 PS that compute their own barycentrics into v0/v1 first are a separate gap). Confirmed by `tests/semantic/test_interp_f16_high.py` (per-vertex halves 0.5/1.5/2.5 and −4/8/16 at weights (0.25, 0.25, 0.5) give 1.75 and 9.0; fails on the old translation) and the GPU fixture `ps_interp_f16_high` drawn with `vs_f16_pack` (u and v packed in one channel both ways, f32 control) and, through `scripts/run_gpu_tests.py`, with the mesh producer `ms_f16_pack` (mesh `exp paramN` stores the same raw words, `Gen.ms_export`): both pass on an RTX 5070 and fail on the old translation (off by 0.984). spirv-val and `vk_pipeline_check` (real pipelines against the vec4 VS stubs, RTX 5070) also accept PS mixing high, low, f32 and flat reads of one location and of several. **Measured natively on RDNA2** (AMD Radeon 680M, `gfx1035`, wave32 and wave64 via `tools/vinterp_hw_probe.py --oracle both`, SHADER-430): the VINTRP unit reads `P0`, `P10` and `P20` from LDS at `M0 + 48·attr + {8·c, 8·c + 4, 32 + 4·c}`; `v_interp_p1ll_f16` (and `v_interp_p1lv_f16`, taking `P0.half` from `vsrc2`) widens the selected f16 half (`[15:0]` or `[31:16]` with `high`) to binary32 and writes the fused binary32 `fma(i, f32(P10.half), f32(P0.half))`, while `v_interp_p2_f16` rounds the exact `partial_f32 + j · f32(P20.half)` once to f16 following `MODE.FP_ROUND.16_64` (like `v_fma_mixlo_f16`, whereas the translator sums P0 + i·P10 + j·P20 in f32 and narrows toward zero — SHADER-468: the driver's ISA runs the pair inside `s_round_mode 0x000c`, so the narrow is toward zero whatever the shader's own MODE writes are) and writes `vdst[15:0]` while hardware keeps `vdst[31:16]`; f16 subnormal halves are preserved with `denorm_mode_16_64 = 3` (`0x0001 + 0.5·0x0200 + 0.5·0x0200 → 0x0201`, flushed to `±0` when `0`), and f16 NaN halves quiet with payload preserved (`0x7e05 → 0x7e05`, `0x7c01 → 0x7e01`). **ALU half measured on AMD hardware** (SHADER-430, `tools/interp_hw_probe.py`, gfx1036, every case matched; `docs/shader_validation.md`): `p1ll_f16` widens the chosen f16 halves exactly and computes fma(h10, I, h0) with one rounding to f32. `p2_f16` computes fma(h20, J, p1ll) and rounds it once, straight to f16: 30 hand-built ties gave that result and never f32-then-f16. It keeps vdst's high 16 bits. The translator used to zero them and now keeps them (`write_lo16`; `test_p2_f16_keeps_the_high_half_of_vdst`). **Measured on AMD hardware (SHADER-468, `tools/f16_interp_probe.py`; native 64×64 draws of a hand-written `f16vec2` varying through `vk_harness` on the Ryzen 5 7600 iGPU, gfx1036, AMD Windows driver 24.10.24, Vulkan 1.3.280; 12 draws, six value sets × orthographic and perspective, 98,304 samples):** the SPI writes P10/P20 as f16 differences of the two halves (round to nearest even) — a pair whose difference is 66,504, past the largest f16, interpolates to inf where the f32 difference stays finite — the sum is f32 (an f16 sum misses 11,385 of the 98,304 samples) and `v_interp_p2_f16` narrows **toward zero** (nearest even misses 36,078). The f16-delta model explains 98,274 of 98,304 samples, against 89,993 for the same model without the f16 delta, 86,919 for an f16 sum and 62,226 for nearest-even narrowing; until 2026-11-22 the translation used the f32 difference and nearest even, which is what the last number measures. The narrow follows MODE.FP16_ROUND, which every AMD compiler sets toward zero around this pair (LLVM `SIModeRegister`: "f16 interpolation instructions need double precision round to zero"; the Windows driver's ISA runs both ops inside `s_round_mode 0x000c`), so the translated p2 rounds toward zero whatever the shader's own MODE writes are. The weights are the SPI's f32 values, not f16: a perspective triangle (w = 1, 2, 4) quantized to f16 misses most samples, f32 matches. Confirmed by `tests/semantic/test_interp_f16_round.py` (both cases fail on the old translation). **Still unverified:** the 30 misses (26 where the exact value is a few 2^-24 — the hardware gives the smallest f16 subnormal where a plain toward-zero narrow gives zero — and 4 at an exact f16 grid boundary, where the vertex-0 weight is the SPI's own f32 value rather than 1 − i − j), f16 inf/NaN halves and `p1lv_f16`, and what a 32-bit `p1/p2_f32` read of a 16-bit-mode channel returns: with the LDS words holding f16 lanes that read cannot be the f16-rounded smooth value the "Pixel-shader interpolants" row assumes, but no Vulkan or D3D12 shader can ask for 16-bit mode and a 32-bit read of the same attribute, so it stays unmeasured. **`--bary-fallback`** has no per-vertex inputs, so it keeps the old smooth-f32 read and cannot honour `high`; `check.py` skips the fixture there. MoltenVK can't compile `PerVertexKHR`: see the next row. |
538| 16-bit interpolation without `PerVertexKHR` (`--f16-interp-fallback`) | MoltenVK reports `fragmentShaderBarycentric` but can't create a pipeline with the row above's inputs: its SPIR-V to MSL conversion stops with "PerVertexKHR decoration is not supported in MSL" (MoltenVK 1.4.2 on an Apple A18 Pro and, reported by @DomasUrbonas in #166, an M4 Pro), so `ps_interp_f16_high` failed on every Mac. With the flag no `PerVertexKHR` (and, for these reads, no `BaryCoordKHR`) is used: every VS `exp paramN`, mesh param and `--mesh-compute` vertex (`tools/mesh_compute_vs.py`) also exports the channel's two f16 halves decoded to f32 (`UnpackHalf2x16`), low halves at location 28 − 2N and high halves at 29 − 2N, so nothing goes above location 29: MoltenVK's `maxVertexOutputComponents` is 124 because Metal counts `gl_Position` in its 128 vertex-output scalars, and the Khronos validation layer counts it too, so a VS output at location 30 failed VUID-RuntimeSpirv-Location-06272 on `vs_ids` (SHADER-291); a PS `*_f16` read of attrN.c takes component c of that ordinary smooth input, then p2 clamps and narrows as before. Interpolation is linear, so the device interpolating the decoded halves gives the same P0 + i(P1 − P0) + j(P2 − P0) as the per-vertex path, with the interpolator's rounding instead of explicit f32 arithmetic. f32 and `v_interp_mov_f32` reads of such a location are the raw word as on any location (flat = the provoking vertex's word, exact). A producer leaves out the halves of a param whose locations would land on one of its own params (params 0..P−1 leave room for the halves of params 0..(28 − P) / 2), and when a PS's canonical decoded-half locations collide with an attribute it reads, its halves are packed into free locations instead (dynamic packing, below). The index records `f16_halves` ({param: [low, high location]}) on both sides; a pipeline links when the PS's entries are among its producer's. Chosen like the wave64 mode: `tools/vk_subgroup_info.py` reports `per_vertex_inputs` (false without `fragmentShaderBarycentric` or on driver ID MoltenVK), and `make_game.py` and `run_gpu_tests.py` turn the flag on where it is false (`LEONIDA_F16_INTERP_FALLBACK=1`/`0` overrides the runner; `build.py` takes only the variable, since it may run in WSL). Without the flag the translation is unchanged: all 139 GPU-test modules are byte-identical to main's, with and without `--bary-fallback` and with `--mesh-compute --wave64-emulate`, so NVIDIA and AMD keep the exact per-vertex path. Confirmed on an Apple A18 Pro (macOS 26.6.2, MoltenVK 1.4.2): `ps_interp_f16_high` drawn with `vs_f16_pack` passes natively and with wave64 emulation, every one of its 4,096 pixels bit-exact to f16 of the exact u and v in both halves (it failed before at pipeline creation), and `ms_f16_pack` through `--mesh-compute` (`LEONIDA_MESH_COMPUTE=1`) passes too; `tests/semantic/test_f16_interp_fallback.py` checks the PS reads (1.75 and 9.0 from the decoded halves), the VS exports (one-lane interpreter), the overlap rules and the default being unchanged. CPU check (TEST-398, `FallbackStagePair`): with ordinary VS exports at 28 and 29, the PS reads those values (5 and 7 in the test) in place of attr0's decoded halves (2 and 3). Only the PS lists attr0 in `f16_halves`. With param28 as the last export, location 28 carries its ordinary value and location 29 has no VS output. When the last ordinary export is at 27, both stages list the pair and the PS reads 2 and 3. The move from 30 to 29 (SHADER-291) was checked on an Apple M5 (macOS 27.2.1, MoltenVK 1.4.2, Khronos validation layer 1.4.363): over the 170 GPU-test modules `vk_pipeline_check` reported VUID-RuntimeSpirv-Location-06272 on 6 vertex shaders at location 30 and on none at 29; the same 15 modules list `f16_halves` for the same params, `run_gpu_tests.py` gives the same result per test, and `ps_interp_f16_high` reads back byte-identical pixels. **Dynamic packing and per-pipeline PSO linking (SHADER-378):** when a PS's canonical `28 − 2N`/`29 − 2N` slots collide with its raw attributes (266 corpus PS where f16-read attrs reach `n >= 7` and raw attrs reach 12–14, all with `2·\|F\| <= 29 − max`) or fall below 0, `assign_f16_half_locations` in `tools/rdna2spirv.py` packs all `f16_halves` pairs downward from location 29 into locations disjoint from its raw attributes (keeping the canonical slots byte-identical whenever collision-free, and refusing only genuine `> 30` location budget overflows); `tools/mesh_compute_vs.py` adds `pair_f16_halves` and an optional `f16_halves` override to `vs_spvasm`; and at graphics PSO creation `runtime/src/shader_library.h` loads `f16_halves` while `runtime/src/spirv_f16_halves.h` (called from `runtime/shims/d3d12_vulkan_device.cpp`) fast-paths exact matches, relocates PS/VS `Location` decorations when needed, demotes unneeded VS static half outputs to `Private`, and synthesizes `UnpackHalf2x16` half exports before `OpReturn` for params a high-param producer (`param0..15`) could not emit statically. Checked by `tests/semantic/test_f16_interp_fallback.py`, `tests/semantic/test_interp_p1lv_f16.py`, `tests/test_mesh_compute_vs.py`, `runtime/test/shader_library_test.cpp`, `runtime/test/spirv_f16_halves_test.cpp`, and `runtime/test/d3d12_f16_halves_test.cpp` (real Vulkan 1.3 draw on NVIDIA GeForce RTX 4060 Ti, driver 32.0.16.1088, Windows 11: 16-param VS + colliding PS both synthesized and relocated render exact RGBA `(64, 191, 127, 255)`). **Unverified:** a PS whose producer exports more params than leave room for the halves it reads (it reads that producer's param, not halves: the `f16_halves` entries then don't match); devices with fewer than 31 output locations; native MoltenVK validation run on macOS and full-corpus recount under `--f16-interp-fallback` (needs game copy); native `MeshEXT` runtime PSO specialization (mesh PSOs are not on `main` yet); devices with fewer than 124 vertex output components. Combined with `--bary-fallback`'s geometry shader (`tools/rdna2spirv.py` allocates `%bary` outside all occupied read and reserved f16-half slots; covered by `tests/semantic/test_bary_fallback.py`, and all `3/3` whole-corpus shaders combining both draw `11/11` targets bit-exact on an RX 6650 XT). | 538| 16-bit interpolation without `PerVertexKHR` (`--f16-interp-fallback`) | MoltenVK reports `fragmentShaderBarycentric` but can't create a pipeline with the row above's inputs: its SPIR-V to MSL conversion stops with "PerVertexKHR decoration is not supported in MSL" (MoltenVK 1.4.2 on an Apple A18 Pro and, reported by @DomasUrbonas in #166, an M4 Pro), so `ps_interp_f16_high` failed on every Mac. With the flag no `PerVertexKHR` (and, for these reads, no `BaryCoordKHR`) is used: every VS `exp paramN`, mesh param and `--mesh-compute` vertex (`tools/mesh_compute_vs.py`) also exports the channel's two f16 halves decoded to f32 (`UnpackHalf2x16`), low halves at location 28 − 2N and high halves at 29 − 2N, so nothing goes above location 29: MoltenVK's `maxVertexOutputComponents` is 124 because Metal counts `gl_Position` in its 128 vertex-output scalars, and the Khronos validation layer counts it too, so a VS output at location 30 failed VUID-RuntimeSpirv-Location-06272 on `vs_ids` (SHADER-291); a PS `*_f16` read of attrN.c takes component c of that ordinary smooth input, then p2 clamps and narrows as before. Interpolation is linear, so the device interpolating the decoded halves gives the same P0 + i(P1 − P0) + j(P2 − P0) as the per-vertex path, with the interpolator's rounding instead of explicit f32 arithmetic. f32 and `v_interp_mov_f32` reads of such a location are the raw word as on any location (flat = the provoking vertex's word, exact). A producer leaves out the halves of a param whose locations would land on one of its own params (params 0..P−1 leave room for the halves of params 0..(28 − P) / 2), and when a PS's canonical decoded-half locations collide with an attribute it reads, its halves are packed into free locations instead (dynamic packing, below). The index records `f16_halves` ({param: [low, high location]}) on both sides; a pipeline links when the PS's entries are among its producer's. Chosen like the wave64 mode: `tools/vk_subgroup_info.py` reports `per_vertex_inputs` (false without `fragmentShaderBarycentric` or on driver ID MoltenVK), and `make_game.py` and `run_gpu_tests.py` turn the flag on where it is false (`LEONIDA_F16_INTERP_FALLBACK=1`/`0` overrides the runner; `build.py` takes only the variable, since it may run in WSL). Without the flag the translation is unchanged: all 139 GPU-test modules are byte-identical to main's, with and without `--bary-fallback` and with `--mesh-compute --wave64-emulate`, so NVIDIA and AMD keep the exact per-vertex path. Confirmed on an Apple A18 Pro (macOS 26.6.2, MoltenVK 1.4.2): `ps_interp_f16_high` drawn with `vs_f16_pack` passes natively and with wave64 emulation, every one of its 4,096 pixels bit-exact to f16 of the exact u and v in both halves (it failed before at pipeline creation), and `ms_f16_pack` through `--mesh-compute` (`LEONIDA_MESH_COMPUTE=1`) passes too; `tests/semantic/test_f16_interp_fallback.py` checks the PS reads (1.75 and 9.0 from the decoded halves), the VS exports (one-lane interpreter), the overlap rules and the default being unchanged. CPU check (TEST-398, `FallbackStagePair`): with ordinary VS exports at 28 and 29, the PS reads those values (5 and 7 in the test) in place of attr0's decoded halves (2 and 3). Only the PS lists attr0 in `f16_halves`. With param28 as the last export, location 28 carries its ordinary value and location 29 has no VS output. When the last ordinary export is at 27, both stages list the pair and the PS reads 2 and 3. The move from 30 to 29 (SHADER-291) was checked on an Apple M5 (macOS 27.2.1, MoltenVK 1.4.2, Khronos validation layer 1.4.363): over the 170 GPU-test modules `vk_pipeline_check` reported VUID-RuntimeSpirv-Location-06272 on 6 vertex shaders at location 30 and on none at 29; the same 15 modules list `f16_halves` for the same params, `run_gpu_tests.py` gives the same result per test, and `ps_interp_f16_high` reads back byte-identical pixels. **Dynamic packing and per-pipeline PSO linking (SHADER-378):** when a PS's canonical `28 − 2N`/`29 − 2N` slots collide with its raw attributes (266 corpus PS where f16-read attrs reach `n >= 7` and raw attrs reach 12–14, all with `2·\|F\| <= 29 − max`) or fall below 0, `assign_f16_half_locations` in `tools/rdna2spirv.py` packs all `f16_halves` pairs downward from location 29 into locations disjoint from its raw attributes (keeping the canonical slots byte-identical whenever collision-free, and refusing only genuine `> 30` location budget overflows); `tools/mesh_compute_vs.py` adds `pair_f16_halves` and an optional `f16_halves` override to `vs_spvasm`; and at graphics PSO creation `runtime/src/shader_library.h` loads `f16_halves` while `runtime/src/spirv_f16_halves.h` (called from `runtime/shims/d3d12_vulkan_device.cpp`) fast-paths exact matches, relocates PS/VS `Location` decorations when needed, demotes unneeded VS static half outputs to `Private`, and synthesizes `UnpackHalf2x16` half exports before `OpReturn` for params a high-param producer (`param0..15`) could not emit statically. Checked by `tests/semantic/test_f16_interp_fallback.py`, `tests/semantic/test_interp_p1lv_f16.py`, `tests/test_mesh_compute_vs.py`, `runtime/test/shader_library_test.cpp`, `runtime/test/spirv_f16_halves_test.cpp`, and `runtime/test/d3d12_f16_halves_test.cpp` (real Vulkan 1.3 draw on NVIDIA GeForce RTX 4060 Ti, driver 32.0.16.1088, Windows 11: 16-param VS + colliding PS both synthesized and relocated render exact RGBA `(64, 191, 127, 255)`). **Unverified:** a PS whose producer exports more params than leave room for the halves it reads (it reads that producer's param, not halves: the `f16_halves` entries then don't match); devices with fewer than 31 output locations; native MoltenVK validation run on macOS and full-corpus recount under `--f16-interp-fallback` (needs game copy); native `MeshEXT` runtime PSO specialization (mesh PSOs are not on `main` yet); devices with fewer than 124 vertex output components. Combined with `--bary-fallback`'s geometry shader (`tools/rdna2spirv.py` allocates `%bary` outside all occupied read and reserved f16-half slots; covered by `tests/semantic/test_bary_fallback.py`, and all `3/3` whole-corpus shaders combining both draw `11/11` targets bit-exact on an RX 6650 XT). |
539| S# LOD bias without the sampler's `mipLodBias` (`--explicit-lod-bias`) | The S#'s `LOD_BIAS` (word 2 [13:0], signed 5.8) is the Vulkan sampler's `mipLodBias` (`vulkan_sampler()` in `runtime/src/gfx10_descriptors.h`), and Vulkan adds it to every sample's LOD, explicit or derivative. MoltenVK 1.4.2 on an Apple M3 drops it from both: `ps_ssharp` reads level 0 for `image_sample_lz` with a +0.6 or +1 bias and level 1 for the derivative-LOD `image_sample` with -0.6 or -1, where KosmicKrisp and llvmpipe (Mesa 26.3.1) on the same machine move both; the same MoltenVK on an Apple M5 Pro (macOS 26.7.3) applies it (#1774). With the flag the shader applies the bias itself, read from the S# SGPRs (a literal S# folds to a constant): added to the `Lod` of `_lz`, `_l`, `_c_lz`, `_c_l` and of the implicit forms outside the PS (before their `_cl` clamp: Vulkan clamps the biased LOD, `max(bias, minlod)`, as for `_b_cl`), added to the bias of `_b` / `_c_b`, a `Bias` operand on implicit samples in the PS, and a 2^bias scale of `Grad` derivatives (the typed 2D implicit read, `_d`, and the `--texel-offset-fallback` gradients). The sampler still clamps to `MIN_LOD`..`MAX_LOD`. Confirmed on the Apple M3 with MoltenVK 1.4.2: `ps_ssharp`'s ten S# cases exact, including +-0.26, which tell a bias counted once from twice. On KosmicKrisp and llvmpipe the flag makes +-0.26 fail (the bias counts twice), so it is measured per device, not looked up by driver ID: `tools/vk_subgroup_info.py --lod-bias` (`tools/vk_lod_bias.py`) clears a two-level R32_SFLOAT image to 0.0 and 1.0 and samples it in one compute dispatch at explicit LOD 0 through samplers with `mipLodBias` 0 and +1, plus a control read at explicit LOD 1 that must return 1.0 (a level 1 that was never cleared would also read 0.0); it answers true when +1 still reads level 0, false when it reads level 1, null otherwise (the control included), and needs no built test programs, llvm-mc or SPIR-V tools. `tools/lod_bias_probe.py` returns that answer, and only when there is none and `--build` names the test programs does it draw `ps_ssharp` without the flag at LOD_BIAS 0, +1 and -1 instead. `scripts/run_gpu_tests.py`, `runtime/test/shaders/build.py` and `make_game.py` take the answer; `LEONIDA_EXPLICIT_LOD_BIAS=1`/`0` forces it in the test runners. Confirmed with this compute measurement on two Apple M3s, macOS 26.5.1 and 27.0 (MoltenVK 1.4.2), where it answers true, and on KosmicKrisp and llvmpipe (Mesa 26.3.1) on both, where it answers false; on the 27.0 M3 `ps_ssharp` and its five variants pass in auto mode on all three drivers, and on an Apple M5 (macOS 26.6.2, MoltenVK) the probe answers false ("the sampler applies mipLodBias") and they pass without the flag (#1774). GPU-checked forms, each with the same `SAMPLER_CASES` through `check.py`'s `SAMPLER_FIXTURES` and `vk_sampler_test`: `image_sample_lz` and the derivative `image_sample` (`ps_ssharp`), `image_sample_l` and `image_sample_d`, whose `Grad` scale this checks (`ps_ssharp_ld`), `image_sample_b` (`ps_ssharp_b`), the same pair on a cube (`ps_ssharp_cube`, `vk_sampler_test --cube`, images_arr) and on a volume (`ps_ssharp_3d`, `--3d`, images_3d), `image_sample_c_lz` and `image_sample_c` on a D32 texture with a LESS_EQUAL S# (`ps_ssharp_c`, `--dref`), and `image_sample_lz_o` and `image_sample_o` under `LEONIDA_TEXOFF_FALLBACK=1`, whose folded `Grad` derivatives this scales (`ps_ssharp_o`, a SKIP without the fallback). |
539| Computed I/J barycentrics without `PerVertexKHR` (`--f16-interp-fallback`) | Under `--f16-interp-fallback` (without `--bary-fallback`), pixel shaders have no `PerVertexKHR` `[3 x vec4]` attribute arrays (neither Metal/MoltenVK nor devices without `VK_KHR_fragment_shader_barycentric` support them; `tools/vk_subgroup_info.py` sets `per_vertex_inputs: false` there, causing `make_game.py` to pass `--f16-interp-fallback`). Previously, `interp_ij_analysis` in `tools/rdna2spirv.py` raised `Unsupported` on any computed `v_interp_p1/p2` `(I, J)` pair under `--f16-interp-fallback`, refusing all 207 computed-barycentric pixel shaders in the corpus (`26,296 / 26,503`). Neither `InterpolateAtOffset` (`OpCapability InterpolationFunction` requires `sampleRateShading`, which the runtime does not enable, and SPIRV-Cross MSL rejects `interpolate_at_offset` on `BuiltIn BaryCoordKHR`) nor a geometry shader is required: in real arithmetic, because `%bary` (`BuiltIn BaryCoordKHR`) carries perspective-correct barycentrics `(1 − I_c − J_c, I_c, J_c)`, every smooth attribute or decoded f16 half (`%in_attrN` / `%in_f16hN_{lo,hi}`) is affine in `(I, J)` across a 2x2 fragment quad (`P^(q) = P_0 + I^(q) P_10 + J^(q) P_20`) even under perspective foreshortening. `tools/rdna2spirv.py` (`Gen.ij_quad_eval` and `assemble`) declares `OpCapability FragmentBarycentricKHR` + `SPV_KHR_fragment_shader_barycentric` for `%bary` (recording `features: ["fragmentShaderBarycentric"]` in `index.json`, so the device must support `VK_KHR_fragment_shader_barycentric` for `BaryCoordKHR`, though not `PerVertexKHR` compilation: MoltenVK runs it natively, while drivers without `VK_KHR_fragment_shader_barycentric` such as KosmicKrisp skip it) alongside core Vulkan 1.0 `OpCapability DerivativeControl` (which adds no extra `VkPhysicalDeviceFeatures` bit and consumes zero extra `Location` slots), and hoists all `OpDPdxFine` / `OpDPdyFine` evaluations into the uniform `%entry` block (satisfying SPIR-V uniform control flow when `v_interp_p1/p2` sits inside divergent `EXEC` branches): `%entry` computes `(dI_x, dI_y)` and `(dJ_x, dJ_y)` of `%bc.y` / `%bc.z`, the 2x2 screen-quad Jacobian determinant `det = dI_x · dJ_y − dI_y · dJ_x`, and `(P_c, dP_x, dP_y)` for each computed `(input, component)`, while each computed site solves pixel steps `alpha = ((I − I_c) · dJ_y − (J − J_c) · dI_y) / det`, `beta = (dI_x · (J − J_c) − dJ_x · (I − I_c)) / det` and evaluates `P_c + alpha · dP_x + beta · dP_y`. **Shortcut (finite-difference amplification and `det == 0` fallback):** smooth fragment inputs and `BaryCoordKHR` arrive from the rasterizer quantized to binary32 (per-lane residual `\|e_q\| <= 0.5·ulp(P_q) + \|P_10\|·0.5·ulp(I_q) + \|P_20\|·0.5·ulp(J_q)`), and 1-pixel quad differences amplify that rounding by `1 + 2\|alpha\| + 2\|beta\|` (`alpha ~ (I − I_c) / (dI/dx)`, proportional to pixel step up to the primitive's pixel span): sub-pixel barycentric offsets (`\|alpha\|, \|beta\| <= 1` px) stay near input precision (`~2e-6` on `1920x1080` `W = (1, 2.5, 4)`), ~1,000-pixel constant jumps on `[-2.75, 10]` reach `1.09e-3` in IEEE binary32 (`2.04e-3` / `1` f16 ulp at `1.5 → 1.4990234375` on an RTX 4090, `@ecox982745`, NVIDIA `616.64`, #2239), and >1,100-pixel jumps to `(0, 0)` across a `2048`-pixel perspective triangle with `P in [1.5, 4096]` reach `0.358` (`>300` f16 ulps at `1.5`, bounded by `(1 + 2\|alpha\| + 2\|beta\|)·m_ulp`). To guard degenerate zero-area, subnormal, infinite, or NaN determinants without `OpFDiv`-by-zero, `1 / det` overflow, or MoltenVK's `OpFOrdNotEqual` NaN bug (`!=` in SPIRV-Cross MSL), `%entry` checks `0x00800000 <= (OpBitcast_u32(det) & 0x7FFFFFFF) < 0x7F800000` in integer ops (`OpUGreaterThanEqual` / `OpULessThan`), clamping the divisor to `1.0` and returning `P_c` when outside the IEEE-754 normal f32 range (including 1D/line primitives where `J` is constant across the quad, `det == 0`, so computed `I` is ignored in favour of `P_c`). Like the non-computed path, `v_interp_p1lv_f16` takes `P_0` from the interpolated attribute (`vsrc2` is unread; the corpus has `0` computed `*_f16` ops), while `--bary-fallback`, `mixed_f32` (flat + smooth f32 on one location), `v_interp_mov_f32` `p10`/`p20`, and computed 32-bit reads of 16-bit-flagged interpolants remain `Unsupported`. Source: AMD [RDNA 2 ISA reference](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) (VINTRP) and Khronos SPIR-V 1.3 (`OpDPdxFine`, `OpDPdyFine`, `DerivativeControl`). Confirmed across the full shader corpus: all `207 / 207` previously refused pixel shaders (`1,139` `v_interp_p1_f32` / `v_interp_p2_f32` computed pairs; `0` computed `*_f16` ops, `2` shaders also reading non-computed `*_f16` inputs) translate and pass `spirv-val --target-env vulkan1.2 --allow-offset-texture-operand` under `--f16-interp-fallback`, bringing `--f16-interp-fallback` corpus translation from `26,296 / 26,503` (`99.22%`) to `26,503 / 26,503` (`100%`), while default-flag outputs stay byte-identical across all 207 shaders. Checked on the CPU (`spirv_mini_interp` 2x2 quad evaluation across dyadic weights, `64x64`, `1920x1080`, and `2048`-pixel perspective `w` foreshortening with tight binary64 Jacobian and `(1 + 2\|alpha\| + 2\|beta\|)·m_ulp` error bounds, non-uniform `EXEC`-masked branches, non-`v0`/`v1` operand registers, between-ops `J` writes, `v_interp_p1lv_f16` `vsrc2` invariance, line-primitive `det == 0` / subnormal / `±inf` / `NaN` determinants, and `f16_halves` metadata) and with `spirv-val` by `tests/semantic/test_interp_computed_ij_fallback.py` (`tests/semantic/fixtures/ps_ij_computed_deriv_fallback.asm`) and `tests/semantic/test_interp_computed_ij.py`. **GPU-verified through Vulkan** on `Apple M3` (`@EvgHaze`, MoltenVK `1.4.2`, #2239), `Apple M3 Pro` (`@wavehs`, MoltenVK `1.4.0`, #2239), `NVIDIA GeForce RTX 3090` (Windows driver `610.88`, Vulkan `1.4.341`, `VK_LAYER_KHRONOS_validation` `1.4.363`, `LEONIDA_F16_INTERP_FALLBACK=1`, `LEONIDA_BARY_FALLBACK=0`), and `NVIDIA GeForce RTX 5070` (`@lixonik`, Windows driver `610.88`, #2239): `runtime/test/shaders/ps_ij_computed.asm` drawn with `vs_ids` passes `vk_pipeline_check`, `runtime/test/shaders/check.py`, and `scripts/run_gpu_tests.py` (`4,096 / 4,096` pixels exact on RTX 3090/5070 and within `1e-6` natively on MoltenVK, `0` validation errors). | 540| Computed I/J barycentrics without `PerVertexKHR` (`--f16-interp-fallback`) | Under `--f16-interp-fallback` (without `--bary-fallback`), pixel shaders have no `PerVertexKHR` `[3 x vec4]` attribute arrays (neither Metal/MoltenVK nor devices without `VK_KHR_fragment_shader_barycentric` support them; `tools/vk_subgroup_info.py` sets `per_vertex_inputs: false` there, causing `make_game.py` to pass `--f16-interp-fallback`). Previously, `interp_ij_analysis` in `tools/rdna2spirv.py` raised `Unsupported` on any computed `v_interp_p1/p2` `(I, J)` pair under `--f16-interp-fallback`, refusing all 207 computed-barycentric pixel shaders in the corpus (`26,296 / 26,503`). Neither `InterpolateAtOffset` (`OpCapability InterpolationFunction` requires `sampleRateShading`, which the runtime does not enable, and SPIRV-Cross MSL rejects `interpolate_at_offset` on `BuiltIn BaryCoordKHR`) nor a geometry shader is required: in real arithmetic, because `%bary` (`BuiltIn BaryCoordKHR`) carries perspective-correct barycentrics `(1 − I_c − J_c, I_c, J_c)`, every smooth attribute or decoded f16 half (`%in_attrN` / `%in_f16hN_{lo,hi}`) is affine in `(I, J)` across a 2x2 fragment quad (`P^(q) = P_0 + I^(q) P_10 + J^(q) P_20`) even under perspective foreshortening. `tools/rdna2spirv.py` (`Gen.ij_quad_eval` and `assemble`) declares `OpCapability FragmentBarycentricKHR` + `SPV_KHR_fragment_shader_barycentric` for `%bary` (recording `features: ["fragmentShaderBarycentric"]` in `index.json`, so the device must support `VK_KHR_fragment_shader_barycentric` for `BaryCoordKHR`, though not `PerVertexKHR` compilation: MoltenVK runs it natively, while drivers without `VK_KHR_fragment_shader_barycentric` such as KosmicKrisp skip it) alongside core Vulkan 1.0 `OpCapability DerivativeControl` (which adds no extra `VkPhysicalDeviceFeatures` bit and consumes zero extra `Location` slots), and hoists all `OpDPdxFine` / `OpDPdyFine` evaluations into the uniform `%entry` block (satisfying SPIR-V uniform control flow when `v_interp_p1/p2` sits inside divergent `EXEC` branches): `%entry` computes `(dI_x, dI_y)` and `(dJ_x, dJ_y)` of `%bc.y` / `%bc.z`, the 2x2 screen-quad Jacobian determinant `det = dI_x · dJ_y − dI_y · dJ_x`, and `(P_c, dP_x, dP_y)` for each computed `(input, component)`, while each computed site solves pixel steps `alpha = ((I − I_c) · dJ_y − (J − J_c) · dI_y) / det`, `beta = (dI_x · (J − J_c) − dJ_x · (I − I_c)) / det` and evaluates `P_c + alpha · dP_x + beta · dP_y`. **Shortcut (finite-difference amplification and `det == 0` fallback):** smooth fragment inputs and `BaryCoordKHR` arrive from the rasterizer quantized to binary32 (per-lane residual `\|e_q\| <= 0.5·ulp(P_q) + \|P_10\|·0.5·ulp(I_q) + \|P_20\|·0.5·ulp(J_q)`), and 1-pixel quad differences amplify that rounding by `1 + 2\|alpha\| + 2\|beta\|` (`alpha ~ (I − I_c) / (dI/dx)`, proportional to pixel step up to the primitive's pixel span): sub-pixel barycentric offsets (`\|alpha\|, \|beta\| <= 1` px) stay near input precision (`~2e-6` on `1920x1080` `W = (1, 2.5, 4)`), ~1,000-pixel constant jumps on `[-2.75, 10]` reach `1.09e-3` in IEEE binary32 (`2.04e-3` / `1` f16 ulp at `1.5 → 1.4990234375` on an RTX 4090, `@ecox982745`, NVIDIA `616.64`, #2239), and >1,100-pixel jumps to `(0, 0)` across a `2048`-pixel perspective triangle with `P in [1.5, 4096]` reach `0.358` (`>300` f16 ulps at `1.5`, bounded by `(1 + 2\|alpha\| + 2\|beta\|)·m_ulp`). To guard degenerate zero-area, subnormal, infinite, or NaN determinants without `OpFDiv`-by-zero, `1 / det` overflow, or MoltenVK's `OpFOrdNotEqual` NaN bug (`!=` in SPIRV-Cross MSL), `%entry` checks `0x00800000 <= (OpBitcast_u32(det) & 0x7FFFFFFF) < 0x7F800000` in integer ops (`OpUGreaterThanEqual` / `OpULessThan`), clamping the divisor to `1.0` and returning `P_c` when outside the IEEE-754 normal f32 range (including 1D/line primitives where `J` is constant across the quad, `det == 0`, so computed `I` is ignored in favour of `P_c`). Like the non-computed path, `v_interp_p1lv_f16` takes `P_0` from the interpolated attribute (`vsrc2` is unread; the corpus has `0` computed `*_f16` ops), while `--bary-fallback`, `mixed_f32` (flat + smooth f32 on one location), `v_interp_mov_f32` `p10`/`p20`, and computed 32-bit reads of 16-bit-flagged interpolants remain `Unsupported`. Source: AMD [RDNA 2 ISA reference](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) (VINTRP) and Khronos SPIR-V 1.3 (`OpDPdxFine`, `OpDPdyFine`, `DerivativeControl`). Confirmed across the full shader corpus: all `207 / 207` previously refused pixel shaders (`1,139` `v_interp_p1_f32` / `v_interp_p2_f32` computed pairs; `0` computed `*_f16` ops, `2` shaders also reading non-computed `*_f16` inputs) translate and pass `spirv-val --target-env vulkan1.2 --allow-offset-texture-operand` under `--f16-interp-fallback`, bringing `--f16-interp-fallback` corpus translation from `26,296 / 26,503` (`99.22%`) to `26,503 / 26,503` (`100%`), while default-flag outputs stay byte-identical across all 207 shaders. Checked on the CPU (`spirv_mini_interp` 2x2 quad evaluation across dyadic weights, `64x64`, `1920x1080`, and `2048`-pixel perspective `w` foreshortening with tight binary64 Jacobian and `(1 + 2\|alpha\| + 2\|beta\|)·m_ulp` error bounds, non-uniform `EXEC`-masked branches, non-`v0`/`v1` operand registers, between-ops `J` writes, `v_interp_p1lv_f16` `vsrc2` invariance, line-primitive `det == 0` / subnormal / `±inf` / `NaN` determinants, and `f16_halves` metadata) and with `spirv-val` by `tests/semantic/test_interp_computed_ij_fallback.py` (`tests/semantic/fixtures/ps_ij_computed_deriv_fallback.asm`) and `tests/semantic/test_interp_computed_ij.py`. **GPU-verified through Vulkan** on `Apple M3` (`@EvgHaze`, MoltenVK `1.4.2`, #2239), `Apple M3 Pro` (`@wavehs`, MoltenVK `1.4.0`, #2239), `NVIDIA GeForce RTX 3090` (Windows driver `610.88`, Vulkan `1.4.341`, `VK_LAYER_KHRONOS_validation` `1.4.363`, `LEONIDA_F16_INTERP_FALLBACK=1`, `LEONIDA_BARY_FALLBACK=0`), and `NVIDIA GeForce RTX 5070` (`@lixonik`, Windows driver `610.88`, #2239): `runtime/test/shaders/ps_ij_computed.asm` drawn with `vs_ids` passes `vk_pipeline_check`, `runtime/test/shaders/check.py`, and `scripts/run_gpu_tests.py` (`4,096 / 4,096` pixels exact on RTX 3090/5070 and within `1e-6` natively on MoltenVK, `0` validation errors). |
540| `v_fmac_f16`, `v_interp_p2/mov_f32` output modifiers | VOP3 `mul:2`/`mul:4`/`div:2` (applied first) and `clamp` to [0, 1] apply to `v_fmac_f16_e64` (before narrowing to f16, matching `v_fma_f16`, high half preserved) and to `v_interp_p2_f32_e64` / `v_interp_mov_f32_e64` (no-op when no modifier is present). Until 2026-11-22 all three dropped output modifiers. Source: LLVM `llvm/test/MC/AMDGPU/gfx10_asm_vop2.s` (`v_fmac_f16_e64`) and `gfx10_asm_vop3.s` (`v_interp_p2_f32_e64`, `v_interp_mov_f32_e64`). Checked on the CPU by `tests/semantic/test_f16_fma_rounding.py` (`test_fmac_output_modifiers`) and `tests/semantic/test_interp_f32_mods.py`, and on a GPU by `ps_fmac_f16_mods.asm`, `ps_interp_f32_mods.asm` and `ps_interp_mov_mods.asm` (the last two drawn with `vs_interp_consts.asm`, whose params are constant over the triangle; each modifier and the omod-before-clamp order change a word; Tesla V100 (NVIDIA 580.95.05, Linux)). **The hardware ignores the f16 omod in the MODE the translator assumes:** on an RDNA2 iGPU (gfx1036) `mul:2`/`mul:4`/`div:2` change an f16 result (`v_fmac_f16`, `v_add/mul/fma_f16`, `v_cvt_f16_f32`, `v_exp/rcp_f16`) only with IEEE 0 and `denorm_mode_16_64 = 0`, and do nothing with f16 denormals kept; omod comes before clamp, and clamp gives +0 for -0 and, with DX10_CLAMP 1, for a NaN (SHADER-135, docs/shader_validation.md). The translator is not changed yet: which of omod and the kept f16 denormals is wrong for the game is a corpus question. | 541| `v_fmac_f16`, `v_interp_p2/mov_f32` output modifiers | VOP3 `mul:2`/`mul:4`/`div:2` (applied first) and `clamp` to [0, 1] apply to `v_fmac_f16_e64` (before narrowing to f16, matching `v_fma_f16`, high half preserved) and to `v_interp_p2_f32_e64` / `v_interp_mov_f32_e64` (no-op when no modifier is present). Until 2026-11-22 all three dropped output modifiers. Source: LLVM `llvm/test/MC/AMDGPU/gfx10_asm_vop2.s` (`v_fmac_f16_e64`) and `gfx10_asm_vop3.s` (`v_interp_p2_f32_e64`, `v_interp_mov_f32_e64`). Checked on the CPU by `tests/semantic/test_f16_fma_rounding.py` (`test_fmac_output_modifiers`) and `tests/semantic/test_interp_f32_mods.py`, and on a GPU by `ps_fmac_f16_mods.asm`, `ps_interp_f32_mods.asm` and `ps_interp_mov_mods.asm` (the last two drawn with `vs_interp_consts.asm`, whose params are constant over the triangle; each modifier and the omod-before-clamp order change a word; Tesla V100 (NVIDIA 580.95.05, Linux)). **The hardware ignores the f16 omod in the MODE the translator assumes:** on an RDNA2 iGPU (gfx1036) `mul:2`/`mul:4`/`div:2` change an f16 result (`v_fmac_f16`, `v_add/mul/fma_f16`, `v_cvt_f16_f32`, `v_exp/rcp_f16`) only with IEEE 0 and `denorm_mode_16_64 = 0`, and do nothing with f16 denormals kept; omod comes before clamp, and clamp gives +0 for -0 and, with DX10_CLAMP 1, for a NaN (SHADER-135, docs/shader_validation.md). The translator is not changed yet: which of omod and the kept f16 denormals is wrong for the game is a corpus question. |
541| `v_fmac_f16`, `v_interp_p2/mov_f32`, and f16 output modifiers | VOP3 `omod` (`[60:59]`) scales the floating-point result by `2`, `4`, or `0.5` before `clamp` (`[0.0, 1.0]`), gated by RDNA2 silicon on **both** `MODE.ieee == 0` and output denorms for the **destination precision** being flushed (`fp32_denorm` for `f32` destinations; `fp16_fp64_denorm` for `f16`/`f64` destinations). Under Leonida's default shader `MODE` (`IEEE=0`, FP32 denorms flushed, FP16/FP64 denorms kept `denorm16_64=3`), `Gen.clamp_mods(..., allow_omod=True)` applies `omod` then `clamp` on `f32` destinations (including `v_interp_p2_f32_e64`, `v_interp_mov_f32_e64`, and `v_cvt_f32_f16`), whereas `Gen.clamp_f16` (`allow_omod=False`) drops `omod` and keeps `clamp` on all `f16`-destination instructions (`v_add/sub/subrev/mul/min/max_f16`, `v_fma/fmac/min3/max3/med3_f16`, unary/transcendental/exponent `*_f16`, `v_cvt_f16_*`, `v_interp_p2_f16`, `v_fma_mixlo/hi_f16`). Hardware-verified on native RDNA2 (`gfx1036`, Windows 11, driver `32.0.21045.29003`, AMD clang `23.0.0git`, wave32 & wave64 parity, ELF binary disassembly confirming non-zero VOP3 `[60:59]` bits emitted, in-wave `v_add_f32_e64 mul:2` witness proving `IEEE=0` active -> `6.0` vs `IEEE=1` -> `3.0`): across all 4 `f16`-destination classes (binary ALU, 3-op ALU, unary/transcendental, and `v_cvt_f16_{f32,u16,i16}`), `mul:2`/`mul:4`/`div:2` are completely ignored under `IEEE=0, denorm16_64=3` while `clamp` still saturates `[0.0, 1.0]`, whereas the `f32`-destination control `v_cvt_f32_f16` scales (`2.0 -> 4.0 / 8.0 / 1.0`); flipping `MODE` to `IEEE=0, denorm16_64=0` (flushed FP16 denorms) re-enables `f16` `omod` scaling (`v_fma_f16 mul:2 -> 6.0`, `v_rcp_f16 mul:2 -> 1.0`, `v_cvt_f16_f32 mul:2 -> 4.0`), confirming the exact hardware gating condition. CPU-checked by `tests/semantic/test_f16_omod_rdna2.py`. **The gate is RDNA2 behaviour, not a general RDNA rule.** `tools/f64_omod_probe.py` (added by this PR) measures the same gate by destination precision on a gfx1036 iGPU (driver `31.0.24002.92`, raw ISA, 175 cases, `mismatches=0`, `wave_diffs=0`): `v_cvt_f64_i32`, `v_cvt_f64_u32`, `v_frexp_mant_f64`, `v_div_fixup_f64` and `v_div_fixup_f16` are f16/binary64 destinations and ignore `mul:2`/`mul:4`/`div:2` under `denorm16_64=3`, while `v_cvt_f32_f64` has binary64 sources and an f32 destination and scales under `denorm16_64=3` whenever `denorm32=0`. And @bunbeans2-arch reported in #4371 that RDNA4 `gfx1201` (RX 9070 XT, Windows driver 26.10.1, where IEEE is fixed on) applies the scaling for all 8 binary64 ops with `denorm16_64=3` kept, `v_add_f64 1.5+1.5 mul:2 = 0x4018000000000000`; that run is quoted from the thread and is not reproduced here. The two readings together are why the translator follows the console's RDNA2 MODEs rather than a hardware-agnostic rule, and why no row here should be read as describing RDNA3 or RDNA4. | 542| `v_fmac_f16`, `v_interp_p2/mov_f32`, and f16 output modifiers | VOP3 `omod` (`[60:59]`) scales the floating-point result by `2`, `4`, or `0.5` before `clamp` (`[0.0, 1.0]`), gated by RDNA2 silicon on **both** `MODE.ieee == 0` and output denorms for the **destination precision** being flushed (`fp32_denorm` for `f32` destinations; `fp16_fp64_denorm` for `f16`/`f64` destinations). Under Leonida's default shader `MODE` (`IEEE=0`, FP32 denorms flushed, FP16/FP64 denorms kept `denorm16_64=3`), `Gen.clamp_mods(..., allow_omod=True)` applies `omod` then `clamp` on `f32` destinations (including `v_interp_p2_f32_e64`, `v_interp_mov_f32_e64`, and `v_cvt_f32_f16`), whereas `Gen.clamp_f16` (`allow_omod=False`) drops `omod` and keeps `clamp` on all `f16`-destination instructions (`v_add/sub/subrev/mul/min/max_f16`, `v_fma/fmac/min3/max3/med3_f16`, unary/transcendental/exponent `*_f16`, `v_cvt_f16_*`, `v_interp_p2_f16`, `v_fma_mixlo/hi_f16`). Hardware-verified on native RDNA2 (`gfx1036`, Windows 11, driver `32.0.21045.29003`, AMD clang `23.0.0git`, wave32 & wave64 parity, ELF binary disassembly confirming non-zero VOP3 `[60:59]` bits emitted, in-wave `v_add_f32_e64 mul:2` witness proving `IEEE=0` active -> `6.0` vs `IEEE=1` -> `3.0`): across all 4 `f16`-destination classes (binary ALU, 3-op ALU, unary/transcendental, and `v_cvt_f16_{f32,u16,i16}`), `mul:2`/`mul:4`/`div:2` are completely ignored under `IEEE=0, denorm16_64=3` while `clamp` still saturates `[0.0, 1.0]`, whereas the `f32`-destination control `v_cvt_f32_f16` scales (`2.0 -> 4.0 / 8.0 / 1.0`); flipping `MODE` to `IEEE=0, denorm16_64=0` (flushed FP16 denorms) re-enables `f16` `omod` scaling (`v_fma_f16 mul:2 -> 6.0`, `v_rcp_f16 mul:2 -> 1.0`, `v_cvt_f16_f32 mul:2 -> 4.0`), confirming the exact hardware gating condition. CPU-checked by `tests/semantic/test_f16_omod_rdna2.py`. **The gate is RDNA2 behaviour, not a general RDNA rule.** `tools/f64_omod_probe.py` (added by this PR) measures the same gate by destination precision on a gfx1036 iGPU (driver `31.0.24002.92`, raw ISA, 175 cases, `mismatches=0`, `wave_diffs=0`): `v_cvt_f64_i32`, `v_cvt_f64_u32`, `v_frexp_mant_f64`, `v_div_fixup_f64` and `v_div_fixup_f16` are f16/binary64 destinations and ignore `mul:2`/`mul:4`/`div:2` under `denorm16_64=3`, while `v_cvt_f32_f64` has binary64 sources and an f32 destination and scales under `denorm16_64=3` whenever `denorm32=0`. And @bunbeans2-arch reported in #4371 that RDNA4 `gfx1201` (RX 9070 XT, Windows driver 26.10.1, where IEEE is fixed on) applies the scaling for all 8 binary64 ops with `denorm16_64=3` kept, `v_add_f64 1.5+1.5 mul:2 = 0x4018000000000000`; that run is quoted from the thread and is not reproduced here. The two readings together are why the translator follows the console's RDNA2 MODEs rather than a hardware-agnostic rule, and why no row here should be read as describing RDNA3 or RDNA4. |
@@ -621,10 +622,21 @@ cross-half code on 32-wide subgroups.
621 622
622## Disassembling shaders 623## Disassembling shaders
623 624
624The AMDGPU disassembler needs LLVM 21+ built with the AMDGPU target (`llvm-mc`; on Linux the `llvm-21` package 625The AMDGPU disassembler needs LLVM 23+ built with the AMDGPU target (`llvm-mc`; on Linux the `llvm-23` package
625installs it at `/usr/lib/llvm-21/bin/llvm-mc`). The official Windows LLVM build has no AMDGPU target and ships no 626installs it at `/usr/lib/llvm-23/bin/llvm-mc`). The official Windows LLVM build has no AMDGPU target and ships no
626`llvm-mc.exe`. On Windows, either build a native one or run it from WSL. 627`llvm-mc.exe`. On Windows, either build a native one or run it from WSL.
627 628
62923+ is the requirement because of the pipeline library: LLVM 21.1.8 decodes all 26,503 shaders of `shaders.rpf`, but
630840 of the 2,684 compute programs there come out of its listings with 79,490 undecodable words and 8,310
631`exp invalid_target_N` words, so the translator refuses them as `fall-through into undecodable words` and the stage
632ends at 1,844 of 2,684.
633Under LLVM 23.1.5 those 840 have no undecodable word, and the stage translates 2,683 of the 2,684 and passes
634`spirv-val`; the 2,684th is refused for `s_sethalt`, which the translator does not implement, under either version.
6351,674 of the 1,844 that already translated print differently under 23.1.5, because LLVM prints some operands
636differently; re-translated from those listings all 1,674 pass, and the other 170 listings are byte-identical
637(`-mcpu=gfx1013`, `--stages cs`, 1.0.2.1). `scripts/build_llvm_mc.ps1` builds 23.1.5 by default for this reason; keep
638`LLVM_MC` on 23+ for the `shaders` stage.
639
628Native: `scripts\build_llvm_mc.ps1` fetches the LLVM sources the tool needs (sparse, shallow), builds `llvm-mc` alone 640Native: `scripts\build_llvm_mc.ps1` fetches the LLVM sources the tool needs (sparse, shallow), builds `llvm-mc` alone
629with `LLVM_TARGETS_TO_BUILD=AMDGPU`, static CRT and the DIA SDK off (its headers need ATL, which the C++ build tools 641with `LLVM_TARGETS_TO_BUILD=AMDGPU`, static CRT and the DIA SDK off (its headers need ATL, which the C++ build tools
630don't always include), checks it disassembles an `s_endpgm` for `gfx1013`, keeps only `llvm-mc.exe` (by default in 642don't always include), checks it disassembles an `s_endpgm` for `gfx1013`, keeps only `llvm-mc.exe` (by default in
@@ -640,10 +652,10 @@ powershell -ExecutionPolicy Bypass -File scripts\build_llvm_mc.ps1
640python -I make_game.py --game "D:\path\to\your\package" --stages shaders 652python -I make_game.py --game "D:\path\to\your\package" --stages shaders
641``` 653```
642 654
643WSL: install `llvm-21` and give `LLVM_MC` the whole command: 655WSL: install `llvm-23` and give `LLVM_MC` the whole command:
644 656
645``` 657```
646set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc 658set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-23/bin/llvm-mc
647python -I make_game.py --game "D:\path\to\your\package" --stages shaders 659python -I make_game.py --game "D:\path\to\your\package" --stages shaders
648``` 660```
649 661
@@ -655,7 +667,7 @@ on stdin, so a WSL command never receives a Windows file path.
655with that reason instead of writing empty `.s` files. To disassemble by hand inside WSL: 667with that reason instead of writing empty `.s` files. To disassemble by hand inside WSL:
656 668
657``` 669```
658LLVM_MC=/usr/lib/llvm-21/bin/llvm-mc python3 -I <repo>/tools/shader_disasm.py <work>/shaders/fssm 670LLVM_MC=/usr/lib/llvm-23/bin/llvm-mc python3 -I <repo>/tools/shader_disasm.py <work>/shaders/fssm
659``` 671```
660 672
661Code starts at the u32 at FSSM offset 0xC0 (the code-section offset) plus 0x28 bytes into that section, and ends at the 673Code starts at the u32 at FSSM offset 0xC0 (the code-section offset) plus 0x28 bytes into that section, and ends at the
diff --git a/docs/dev-tools.md b/docs/dev-tools.md
index d36091ec3..ed7fa4355 100644
--- a/docs/dev-tools.md
+++ b/docs/dev-tools.md
@@ -59,6 +59,39 @@ recorded events, and the exit status reports the analysis result.
59 59
60You can also run `python -I tools/boot_trace.py` with the same arguments. 60You can also run `python -I tools/boot_trace.py` with the same arguments.
61 61
62## Check the shader chain of a work folder
63
64`tools/chain_check.py` prints one page of counts for each link between the game files and the GPU. It reads the
65work folder that `make_game.py` built and, if you pass one, the log of one run:
66
67```powershell
68python -I tools/chain_check.py <work>
69python -I tools/chain_check.py <work> --log <OutDir>\<Name>.log --json
70```
71
72The page has one block per link, and each block gets a verdict (OK, WARN or FAIL) and its most likely cause:
73
74- tools: the llvm-mc each family was disassembled with and its AMDGPU target, spirv-val, and whether the
75 translator sources recorded in the folder still match this checkout's;
76- one block per family (game programs, pipeline library, FSPX, BVH, executable): programs unpacked, listings,
77 listings with rejected words, programs translated, and up to 5 refusal reasons from `logs/shaders.log`;
78- contract: tagged and plain modules, and the runtime folders that are present or absent (`fspx_compute` and the
79 others);
80- runtime, from `--log` (`scripts/windows-boot/boot.ps1`'s `<Name>.log`): modules loaded, failed device slot calls,
81 failed D3D12 calls, compute pipeline builds, waits at the compile gate, device faults and the exit code.
82
83The last line names the weakest link: the first block, in chain order, with the worst verdict.
84
85A family is FAIL when more than 1% of its programs have no module. An llvm-mc older than 23 is a WARN (#1923). The
86`--help` text lists every threshold. The report prints counts and fixed words only: no program names, no log lines
87and no paths. A refusal reason is printed only when it matches a message from `tools/rdna2spirv.py`; any other
88reason is counted as `other`. A D3D12 method name is printed only when the runtime's sources contain it, and the
89end of a boot digest only in the forms boot.ps1 writes. Add `--show-paths` to name the folder and the log, but not
90in a report you publish.
91
92The exit code is `0` whatever the verdicts. With `--strict` it is `1` when a block is FAIL, and bad arguments exit
93`2`. Probing asks llvm-mc, spirv-val and git for their versions; `--no-probe` runs nothing.
94
62## Run a synthetic guest scene 95## Run a synthetic guest scene
63 96
64Use the existing headless runner with a loader and guest built on Windows 97Use the existing headless runner with a loader and guest built on Windows
diff --git a/docs/linux.md b/docs/linux.md
index b6be52568..d1cdb8d92 100644
--- a/docs/linux.md
+++ b/docs/linux.md
@@ -53,9 +53,12 @@ default stages leave `runtime` out (`check,shaders,assets,pipelines`).
53 53
54Notes: 54Notes:
55 55
56- **llvm-mc**: Debian and Ubuntu's `llvm-21` installs it only as `llvm-mc-21` and `/usr/lib/llvm-21/bin/llvm-mc`. 56- **llvm-mc**: the `shaders` stage needs LLVM 23 or newer, so install `llvm-23` where the distribution has it. Debian and Ubuntu's `llvm-21` installs `llvm-mc` only as `llvm-mc-21` and `/usr/lib/llvm-21/bin/llvm-mc`.
57 With `LLVM_MC` unset the tools use the plain `llvm-mc` when it is on `PATH` and otherwise the newest of those 57 With `LLVM_MC` unset the tools use the plain `llvm-mc` when it is on `PATH` and otherwise the newest of those
58 versioned names (`tools/mc_command.py`). Set `LLVM_MC` to choose another one. 58 versioned names (`tools/mc_command.py`). Set `LLVM_MC` to choose another one. The `shaders` stage needs LLVM 23+
59 for its pipeline library: 21.1.8's listings of 840 of its 2,684 compute programs carry 79,490 undecodable words and
60 the translator refuses them, while 23.1.5 leaves none in those 840 and the stage translates 2,683 of 2,684
61 ([design.md](design.md#disassembling-shaders)).
59- **File names are case-sensitive.** The build opens the package's files by their exact names 62- **File names are case-sensitive.** The build opens the package's files by their exact names
60 (`MicrosoftGame.Config`, `Catalog000.bin`, ...). A copy whose names changed case on the way is reported with the 63 (`MicrosoftGame.Config`, `Catalog000.bin`, ...). A copy whose names changed case on the way is reported with the
61 name it found and the one it needs; nothing is renamed for you. 64 name it found and the one it needs; nothing is renamed for you.
diff --git a/docs/linux_proton.md b/docs/linux_proton.md
index 61627b69a..8117a01f5 100644
--- a/docs/linux_proton.md
+++ b/docs/linux_proton.md
@@ -97,6 +97,13 @@ What it does:
97- **Limits:** a hard time limit (`--seconds`, then SIGTERM and SIGKILL 10 s later), a lock so one run happens at a 97- **Limits:** a hard time limit (`--seconds`, then SIGTERM and SIGKILL 10 s later), a lock so one run happens at a
98 time (`--lock`, by default in `XDG_RUNTIME_DIR`), and teardown of Wine and the whole session on exit, time-out or 98 time (`--lock`, by default in `XDG_RUNTIME_DIR`), and teardown of Wine and the whole session on exit, time-out or
99 signal. 99 signal.
100- **Shader cache:** the session's `XDG_CACHE_HOME`, where NVIDIA's `GLCache` and Mesa's shader cache go, is the
101 caller's when it is set, or the folder `--cache DIR` names; both are kept from run to run, so a later launch does
102 not compile every pipeline in the driver again. Without either, or with `--cache fresh`, it is a new folder in the
103 run folder, for a cold-cache run. The summary's first line says which (`shader cache: kept in DIR` or `fresh`).
104 The flag picks the XDG cache root; a driver's own variable (`MESA_SHADER_CACHE_DIR`, the older
105 `MESA_GLSL_CACHE_DIR`, NVIDIA's `__GL_SHADER_DISK_CACHE_PATH`) wins over it. A fresh run unsets them and empties
106 the run folder's `session/cache`, so it is cold; with a kept cache the caller's variables stay.
100- **Traces:** `gta6rt --run` with `--trace` and `--trace-d3d12`, a fresh `--overlay` and save folder in the run 107- **Traces:** `gta6rt --run` with `--trace` and `--trace-d3d12`, a fresh `--overlay` and save folder in the run
101 folder. Every other `LEONIDA_*` variable reaches the runtime unchanged, so `LEONIDA_INPUT_SCRIPT=a@210,a@240` 108 folder. Every other `LEONIDA_*` variable reaches the runtime unchanged, so `LEONIDA_INPUT_SCRIPT=a@210,a@240`
102 presses A as above. Arguments after `--` go to `gta6rt`. 109 presses A as above. Arguments after `--` go to `gta6rt`.
diff --git a/docs/shader_validation.md b/docs/shader_validation.md
index 4215afb6a..294648249 100644
--- a/docs/shader_validation.md
+++ b/docs/shader_validation.md
@@ -1343,8 +1343,14 @@ mask or VCC) and `v_cmp_class_f32` e64, each read back with `v_cndmask_b32_e64`.
1343`mul:2`/`mul:4`/`div:2` and `clamp`, with VGPR, SGPR, inline-constant and literal sources within the constant-bus 1343`mul:2`/`mul:4`/`div:2` and `clamp`, with VGPR, SGPR, inline-constant and literal sources within the constant-bus
1344limits. It runs one lane through `tests/semantic/spirv_mini_interp.py` against its own exact-rational ISA model, with 1344limits. It runs one lane through `tests/semantic/spirv_mini_interp.py` against its own exact-rational ISA model, with
1345the shrinking, skips and exit codes of `salu_diff.py`. Any NaN matches any NaN. It does not judge denormal operands 1345the shrinking, skips and exit codes of `salu_diff.py`. Any NaN matches any NaN. It does not judge denormal operands
1346or results, a computed NaN read as an integer, the clamp of a NaN or an output modifier that gives a zero: those 1346or results, a computed NaN read as an integer, the clamp of a NaN, an output modifier that gives a zero, and the
1347programs are counted as skips with the reason. 1347class bits of a NaN whose quiet bit the model does not know (a `v_fmamk_f32` NaN, or a pass-through of one): those
1348programs are counted as skips with the reason. The model knows a computed NaN's payload only for a quiet NaN;
1349for `v_fmamk_f32` it assumes the quiet bit the arithmetic gives, while on gfx1036 under the game's MODE the
1350hardware mostly returns the NaN source's word but sometimes quiets a signalling one (`f32_hw_s5.log`: signalling
1351NaN passes unchanged 3 of 4, quieted 1 of 4), and a driver that quiets where the model does not changes the class
1352bit a `v_cmp_class_f32` reads. That is why the fuzzed `sNaN -> v_fmamk_f32 -> v_cmp_class_f32` divergence was a
1353model gap, not a translator bug: on both GPUs the translated bit matched what the hardware itself produces.
1348 1354
1349`--oracle hw` runs the kernels under the MODE inferred for the game's shaders (IEEE off, f32 denormals flushed). With 1355`--oracle hw` runs the kernels under the MODE inferred for the game's shaders (IEEE off, f32 denormals flushed). With
1350the assembler's compute default (IEEE on) the hardware ignores `omod`: `v_fract_f32_e64 v4, -v16 mul:2` with v16 = 0.5 1356the assembler's compute default (IEEE on) the hardware ignores `omod`: `v_fract_f32_e64 v4, -v16 mul:2` with v16 = 0.5
diff --git a/docs/testing.md b/docs/testing.md
index 635c700a6..ba91fb2af 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -163,7 +163,7 @@ C++ `runtime/` tests are not run by it; use the fork's CI as above.
163 163
164- **Python 3.12+**, which `make_game.py` requires (it stops with "Python 3.12 or newer is needed" on an older one, so 164- **Python 3.12+**, which `make_game.py` requires (it stops with "Python 3.12 or newer is needed" on an older one, so
165 its tests fail there too). `scripts/run_gpu_tests.py` on its own runs on 3.10 or newer. 165 its tests fail there too). `scripts/run_gpu_tests.py` on its own runs on 3.10 or newer.
166- **`llvm-mc` with the AMDGPU target** (LLVM 21+). The official LLVM Windows release has no AMDGPU target. On 166- **`llvm-mc` with the AMDGPU target** (LLVM 21+ to assemble the test fixtures, 23+ for the `shaders` stage; see below). The official LLVM Windows release has no AMDGPU target. On
167 Windows, use one of: 167 Windows, use one of:
168 - `scripts\build_llvm_mc.ps1`, which builds a native `llvm-mc.exe` (needs git and the Visual Studio C++ tools); 168 - `scripts\build_llvm_mc.ps1`, which builds a native `llvm-mc.exe` (needs git and the Visual Studio C++ tools);
169 - conda-forge's `llvm-tools` package, whose Windows build includes the AMDGPU target; 169 - conda-forge's `llvm-tools` package, whose Windows build includes the AMDGPU target;
@@ -193,6 +193,13 @@ C++ `runtime/` tests are not run by it; use the fork's CI as above.
193 193
194 If it reports `not a valid operand`, point `LLVM_MC` at a build that accepts this instruction. The Windows 194 If it reports `not a valid operand`, point `LLVM_MC` at a build that accepts this instruction. The Windows
195 conda-forge `llvm-tools` 23.1.6 package assembled the same f16 programs. 195 conda-forge `llvm-tools` 23.1.6 package assembled the same f16 programs.
196
197 The `shaders` stage needs LLVM 23+ as well, for reasons that have nothing to do with the tests above: 840 of the
198 2,684 compute programs in the pipeline library come out of LLVM 21.1.8's listings with 79,490 undecodable words, so
199 the translator refuses them (`fall-through into undecodable words`) and 1,844 of 2,684 reach the output. 23.1.5
200 decodes those 840 with no rejected word and the stage translates 2,683 of 2,684 (the last is refused for
201 `s_sethalt`, which the translator does not implement); `scripts\build_llvm_mc.ps1` builds 23.1.5 by default
202 ([design.md](design.md), "Disassembling shaders").
196- **SPIRV-Tools** (`spirv-as`, `spirv-val`): part of the Vulkan SDK, or a distribution package. 203- **SPIRV-Tools** (`spirv-as`, `spirv-val`): part of the Vulkan SDK, or a distribution package.
197- **A C++20 compiler, CMake and the Vulkan headers** to build the test programs: 204- **A C++20 compiler, CMake and the Vulkan headers** to build the test programs:
198 - Windows: the full runtime needs Visual Studio 2022 with "Desktop development with C++" and Windows SDK 205 - Windows: the full runtime needs Visual Studio 2022 with "Desktop development with C++" and Windows SDK
@@ -400,6 +407,18 @@ WINEPREFIX="$HOME/.local/share/leonida-wine" ctest --test-dir runtime/build/wind
400Use a recent xwin: 0.10.0 lays out SDK 10.0.26100 with the command above, while 0.6.5 stops with "unable to find 407Use a recent xwin: 0.10.0 lays out SDK 10.0.26100 with the command above, while 0.6.5 stops with "unable to find
401x86_64 headers for Win11SDK_10.0.26100". 408x86_64 headers for Win11SDK_10.0.26100".
402 409
410On a Mac (Apple Silicon) the same steps work with Homebrew's LLVM and lld (`brew install llvm lld xwin`; the cross
411tools are `clang-cl`, `lld-link`, `llvm-lib`, `llvm-rc` and `llvm-mt` under `$(brew --prefix)/opt/llvm/bin` and
412`$(brew --prefix)/opt/lld/bin`) and the WineHQ macOS build, an x86-64 Wine that runs under Rosetta. Homebrew's
413`wine-stable` cask is disabled (it does not pass Gatekeeper), so take the archive the cask names from its
414`url` and check it against the cask's `sha256`. Configure with `-DCMAKE_CROSSCOMPILING_EMULATOR=<path to its wine>`
415when `wine` is not on `PATH`; a path with spaces (`Wine Stable.app`) is easiest behind a small wrapper script. Run
416`ctest` with `ROSETTA_ADVERTISE_AVX=1`: without it Rosetta hides AVX from Wine, and the `run_tiny_*` loader tests stop
417with "the game's code needs AVX, and this CPU or OS lacks AVX, OSXSAVE". Measured on an Apple M3 (macOS 26.5.1,
418Wine 11.0, its bundled MoltenVK 1.4.1) at `main` `fbf100b1b`: 1084 targets build, and `ctest -j 6 --timeout 120`
419gives 461 of 482 passed (440 without `ROSETTA_ADVERTISE_AVX`). The display is the Mac's own, so no virtual X server
420is needed.
421
403On a machine without a display (a server, a container, WSL without WSLg), Wine has no graphics driver to create a 422On a machine without a display (a server, a container, WSL without WSLg), Wine has no graphics driver to create a
404Vulkan instance with, so every Vulkan test fails with `vkCreateInstance failed (VkResult -3)` and, with 423Vulkan instance with, so every Vulkan test fails with `vkCreateInstance failed (VkResult -3)` and, with
405`WINEDEBUG=+vulkan`, "Failed to load Wine graphics driver supporting Vulkan". Run the tests under a virtual X server, 424`WINEDEBUG=+vulkan`, "Failed to load Wine graphics driver supporting Vulkan". Run the tests under a virtual X server,
@@ -985,6 +1004,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin
985| `cs_w32_salu64` gives eight wrong words on RDNA1 under RADV Mesa 25.2.8 (`0x1E6A2C48 0x1234 0 0x100 47 48 0xFFFF8000 0xFFFFFFFE`, where word 2 should be `0xFFFFFFFF`) | Only the high word of the `s_bfe_i64` result is wrong. The same words appear on four pinned V540s (Navi 12, PCI `1002:7360`) and on a clean upstream/main worktree, and three different valid SPIR-V sign-extension formulations give the same result while the CPU interpreter matches, so this is the driver version rather than the translator (SHADER-276) | Expected with Mesa 25.2.8; the fixture passes on NVIDIA and on AMD's Windows driver. Try a newer Mesa before treating it as a translator bug; do not weaken the fixture's expectation | 1004| `cs_w32_salu64` gives eight wrong words on RDNA1 under RADV Mesa 25.2.8 (`0x1E6A2C48 0x1234 0 0x100 47 48 0xFFFF8000 0xFFFFFFFE`, where word 2 should be `0xFFFFFFFF`) | Only the high word of the `s_bfe_i64` result is wrong. The same words appear on four pinned V540s (Navi 12, PCI `1002:7360`) and on a clean upstream/main worktree, and three different valid SPIR-V sign-extension formulations give the same result while the CPU interpreter matches, so this is the driver version rather than the translator (SHADER-276) | Expected with Mesa 25.2.8; the fixture passes on NVIDIA and on AMD's Windows driver. Try a newer Mesa before treating it as a translator bug; do not weaken the fixture's expectation |
986| `d3d12_typeless_rtv` fails its WARP comparison on an AMD desktop iGPU (TEST-591) | [Reported on the Ryzen 5 7600X iGPU with Windows 10 build 19045 and AMD 23.40.02](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7083403389). The exact cause is still open. | Retest on a newer Windows and AMD driver combination. Passing results were reported on the [Ryzen 9 7900 iGPU with AMD 25.10.30.02](https://github.com/ItsNotRexed/Leonida/issues/3232#issuecomment-7085263408), a [gfx1036 iGPU with AMD 26.5.2](https://github.com/ItsNotRexed/Leonida/issues/2891#issuecomment-7084023801), and the [Ryzen 7 9800X3D iGPU with driver 32.0.21045.29003](https://github.com/ItsNotRexed/Leonida/pull/3440). | 1005| `d3d12_typeless_rtv` fails its WARP comparison on an AMD desktop iGPU (TEST-591) | [Reported on the Ryzen 5 7600X iGPU with Windows 10 build 19045 and AMD 23.40.02](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7083403389). The exact cause is still open. | Retest on a newer Windows and AMD driver combination. Passing results were reported on the [Ryzen 9 7900 iGPU with AMD 25.10.30.02](https://github.com/ItsNotRexed/Leonida/issues/3232#issuecomment-7085263408), a [gfx1036 iGPU with AMD 26.5.2](https://github.com/ItsNotRexed/Leonida/issues/2891#issuecomment-7084023801), and the [Ryzen 7 9800X3D iGPU with driver 32.0.21045.29003](https://github.com/ItsNotRexed/Leonida/pull/3440). |
987| `ps_interp_f16_high` fails on a Mac: `PerVertexKHR decoration is not supported in MSL`, then `vkCreateGraphicsPipelines` -3 | MoltenVK can't convert `PerVertexKHR` inputs to Metal | Current `main` translates it with `--f16-interp-fallback` on MoltenVK (see "Macs: 16-bit interpolation") | 1006| `ps_interp_f16_high` fails on a Mac: `PerVertexKHR decoration is not supported in MSL`, then `vkCreateGraphicsPipelines` -3 | MoltenVK can't convert `PerVertexKHR` inputs to Metal | Current `main` translates it with `--f16-interp-fallback` on MoltenVK (see "Macs: 16-bit interpolation") |
1007| `ps_ssharp` fails on some Macs with MoltenVK 1.4.2 (an Apple M3, not an M5 Pro): `point bias +1: (0,0): (1.0, 0.0, 0.502, 0.502) != (0.502, 0.502, 0.502, 0.502)` | MoltenVK drops the sampler's `mipLodBias`, so the S#'s `LOD_BIAS` moves neither the explicit nor the derivative LOD | Current `main` translates with `--explicit-lod-bias` where `tools/vk_subgroup_info.py --lod-bias` measures that the sampler drops the bias (see "S# LOD bias without the sampler's `mipLodBias`" in [design.md](design.md)). Forcing it on another driver (`LEONIDA_EXPLICIT_LOD_BIAS=1`) counts the bias twice and fails the +-0.26 cases |
988| `ps_vcmpx_forms` fails on a Mac: word 1 reads `0xf05e8e16`, want `0xf05e8a12` | MoltenVK's fast-math makes a compare of a NaN with itself true (SHADER-234) | Current `main`'s test programs turn it off (`MVK_CONFIG_FAST_MATH_ENABLED=0`, unless you set the variable yourself); rebuild them | 1008| `ps_vcmpx_forms` fails on a Mac: word 1 reads `0xf05e8e16`, want `0xf05e8a12` | MoltenVK's fast-math makes a compare of a NaN with itself true (SHADER-234) | Current `main`'s test programs turn it off (`MVK_CONFIG_FAST_MATH_ENABLED=0`, unless you set the variable yourself); rebuild them |
989| On a Mac, a translated shader's GPU time is 1.5 to 16 times what it would be without the precise-arithmetic overhead | MoltenVK's SPIRV-Cross turns every `NoContraction` float add, subtract and multiply into a call to an `[[clang::optnone]]` helper that Metal does not inline. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-234, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions, and the output is still exact. Before you time shaders on a Mac, build MoltenVK with SPIRV-Cross `98cbb7c0` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision` (KhronosGroup/MoltenVK#2917 moves it to `57e4efcc`), and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` | 1009| On a Mac, a translated shader's GPU time is 1.5 to 16 times what it would be without the precise-arithmetic overhead | MoltenVK's SPIRV-Cross turns every `NoContraction` float add, subtract and multiply into a call to an `[[clang::optnone]]` helper that Metal does not inline. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-234, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions, and the output is still exact. Before you time shaders on a Mac, build MoltenVK with SPIRV-Cross `98cbb7c0` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision` (KhronosGroup/MoltenVK#2917 moves it to `57e4efcc`), and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` |
990| `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 | 1010| `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 |
@@ -998,6 +1018,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin
998| `cs_bvh` and `cs_bvh32` fail on a Mac with KosmicKrisp: `out[3]` reads `0x7fc00000`, want `0xffffffff` | KosmicKrisp's `nir_to_msl` compiler (Mesa 26.3.1, measured on Apple M2 Ultra, macOS 27.3), not the translator or the buffer format. The triangle branch writes bitcast `float` words and the box branch writes `OpSelect %uint` with `0xffffffff` (`-1`) into the same VGPRs; NIR erases `OpBitcast`, type inference marks the shared register and `bcsel` as `float`, and `nir_to_msl` prints any `float`-typed 32-bit constant in the IEEE-754 NaN range (`0x7f800001..0x7fffffff`, `0xff800001..0xffffffff`) as `(NAN)` (`0x7fc00000`) | Expected with KosmicKrisp in Mesa 26.3.1; MoltenVK 1.4.2 and llvmpipe (Mesa 26.3.1) return `0xffffffff` on the same machine. Do not weaken `vk_compute_test`'s expected BVH words | 1018| `cs_bvh` and `cs_bvh32` fail on a Mac with KosmicKrisp: `out[3]` reads `0x7fc00000`, want `0xffffffff` | KosmicKrisp's `nir_to_msl` compiler (Mesa 26.3.1, measured on Apple M2 Ultra, macOS 27.3), not the translator or the buffer format. The triangle branch writes bitcast `float` words and the box branch writes `OpSelect %uint` with `0xffffffff` (`-1`) into the same VGPRs; NIR erases `OpBitcast`, type inference marks the shared register and `bcsel` as `float`, and `nir_to_msl` prints any `float`-typed 32-bit constant in the IEEE-754 NaN range (`0x7f800001..0x7fffffff`, `0xff800001..0xffffffff`) as `(NAN)` (`0x7fc00000`) | Expected with KosmicKrisp in Mesa 26.3.1; MoltenVK 1.4.2 and llvmpipe (Mesa 26.3.1) return `0xffffffff` on the same machine. Do not weaken `vk_compute_test`'s expected BVH words |
999| `ps_cndmask_sign_mods` fails on a Mac with KosmicKrisp: all 4096 pixels differ, `(0,0)` reads `0x7fc00000, 0x7fc00000, 0x80000001, 0x7fc00000`, want `0xff800001, 0x7f800001, 0x80000001, 0x7f800001` | The same `nir_to_msl` NaN-constant path as `cs_bvh` above: the shader selects between `float` NaNs with sign and payload (`-NaN`, `+NaN`), and KosmicKrisp prints each such constant as `(NAN)` (`0x7fc00000`). Measured on an Apple M3, macOS 27.0, Mesa 26.3.1 | Expected with KosmicKrisp; the same test passes 4096/4096 on llvmpipe (Mesa 26.3.1) and on MoltenVK 1.4.2 on the same machine | 1019| `ps_cndmask_sign_mods` fails on a Mac with KosmicKrisp: all 4096 pixels differ, `(0,0)` reads `0x7fc00000, 0x7fc00000, 0x80000001, 0x7fc00000`, want `0xff800001, 0x7f800001, 0x80000001, 0x7f800001` | The same `nir_to_msl` NaN-constant path as `cs_bvh` above: the shader selects between `float` NaNs with sign and payload (`-NaN`, `+NaN`), and KosmicKrisp prints each such constant as `(NAN)` (`0x7fc00000`). Measured on an Apple M3, macOS 27.0, Mesa 26.3.1 | Expected with KosmicKrisp; the same test passes 4096/4096 on llvmpipe (Mesa 26.3.1) and on MoltenVK 1.4.2 on the same machine |
1000| `ps_valu16_mad_sel` fails on a Mac with KosmicKrisp: all 4096 pixels differ, `(0,0)` reads `0x8003, 0xdb880000, 0x7fc00000, 0x80000000`, want `0x8003, 0xdb880000, 0xffffffff, 0x80000000` | Same cause: a value the shader writes as `0xffffffff` (`-1`) reaches the render target as `0x7fc00000` because `nir_to_msl` types the shared register as `float` and prints the NaN-range constant as `(NAN)`. Measured on an Apple M3, macOS 27.0, Mesa 26.3.1 | Expected with KosmicKrisp; passes 4096/4096 on llvmpipe (Mesa 26.3.1) and on MoltenVK 1.4.2 on the same machine | 1020| `ps_valu16_mad_sel` fails on a Mac with KosmicKrisp: all 4096 pixels differ, `(0,0)` reads `0x8003, 0xdb880000, 0x7fc00000, 0x80000000`, want `0x8003, 0xdb880000, 0xffffffff, 0x80000000` | Same cause: a value the shader writes as `0xffffffff` (`-1`) reaches the render target as `0x7fc00000` because `nir_to_msl` types the shared register as `float` and prints the NaN-range constant as `(NAN)`. Measured on an Apple M3, macOS 27.0, Mesa 26.3.1 | Expected with KosmicKrisp; passes 4096/4096 on llvmpipe (Mesa 26.3.1) and on MoltenVK 1.4.2 on the same machine |
1021| `cs_fmt_all` fails on a Mac with KosmicKrisp: word 293 reads `0x80007e00`, want `0x80007c01` | The same `(NAN)` printing as the rows above, still in Mesa `main`: `emit_src_component` in `src/kosmickrisp/compiler/msl_type_inference.c` prints every `float`-typed NaN constant as `(NAN)`, dropping its payload and sign. Here the input `0x7f800001` of a 16-bit float store becomes `0x7fc00000`, which narrows to `0x7e00` instead of `0x7c01`. Measured on an Apple M3 (macOS 26.5.1) with Mesa 26.3.1 at `main` `a73a57e13` | Expected with KosmicKrisp; MoltenVK 1.4.2 and llvmpipe (Mesa 26.3.1) pass on the same machine. Do not weaken the expected words |
1001| `cs_fma_fused` fails on a Mac with KosmicKrisp: word 7 reads `0x7352`, want `0x7351` | The f16 multiply-add (round to odd), computed at run time, comes out as if the product were rounded first: the exact product, 14988, is halfway between the f16 values 14984 (`0x7351`) and 14992 (`0x7352`), the addend is -2^-22, and one rounding gives `0x7351`. Measured on an Apple M3 with Mesa 26.3.1, 20 of 20 runs (the review of #1724). While the fixture's f16 operands were literals the constant was folded exactly, so the test passed there | Expected with KosmicKrisp in Mesa 26.3.1; MoltenVK 1.4.2 and llvmpipe (Mesa 26.3.1) give `0x7351` on the same machine. The f32 words KosmicKrisp splits are accepted under `--fma glsl`; the f16 word is not, since it does not use `Fma` | 1022| `cs_fma_fused` fails on a Mac with KosmicKrisp: word 7 reads `0x7352`, want `0x7351` | The f16 multiply-add (round to odd), computed at run time, comes out as if the product were rounded first: the exact product, 14988, is halfway between the f16 values 14984 (`0x7351`) and 14992 (`0x7352`), the addend is -2^-22, and one rounding gives `0x7351`. Measured on an Apple M3 with Mesa 26.3.1, 20 of 20 runs (the review of #1724). While the fixture's f16 operands were literals the constant was folded exactly, so the test passed there | Expected with KosmicKrisp in Mesa 26.3.1; MoltenVK 1.4.2 and llvmpipe (Mesa 26.3.1) give `0x7351` on the same machine. The f32 words KosmicKrisp splits are accepted under `--fma glsl`; the f16 word is not, since it does not use `Fma` |
1002| CMake stops with "needs the Windows SDK 10.0.26100 or newer", or MSVC reports `'Desc_1_2': is not a member of 'D3D12_VERSIONED_ROOT_SIGNATURE_DESC'` | A Windows SDK older than 10.0.26100 (10.0.22621 is the common one), which has no version 1.2 root signatures | `winget install Microsoft.WindowsSDK.10.0.26100`, or add it in the Visual Studio Installer, then delete `runtime/build` and configure again | 1023| CMake stops with "needs the Windows SDK 10.0.26100 or newer", or MSVC reports `'Desc_1_2': is not a member of 'D3D12_VERSIONED_ROOT_SIGNATURE_DESC'` | A Windows SDK older than 10.0.26100 (10.0.22621 is the common one), which has no version 1.2 root signatures | `winget install Microsoft.WindowsSDK.10.0.26100`, or add it in the Visual Studio Installer, then delete `runtime/build` and configure again |
1003| `scripts/build_runtime.ps1` stops at once: "The checkout path ... contains '%'" (`build_llvm_mc.ps1`: "-Temp ... contains '%'") | A `%` in the checkout's path (or in `-Temp`). cmd.exe expands `%...%` in the generated `_build.cmd` (twice on a `CALL` line), and even with that escaped, `cl` rejects a `%` in the path-valued `/D` definitions of the test targets (`D8038: invalid argument`) however it is quoted. Older scripts failed in configure or a few hundred steps into Ninja instead | Move or clone the checkout (or choose a `-Temp`) in a folder without `%` in its path | 1024| `scripts/build_runtime.ps1` stops at once: "The checkout path ... contains '%'" (`build_llvm_mc.ps1`: "-Temp ... contains '%'") | A `%` in the checkout's path (or in `-Temp`). cmd.exe expands `%...%` in the generated `_build.cmd` (twice on a `CALL` line), and even with that escaped, `cl` rejects a `%` in the path-valued `/D` definitions of the test targets (`D8038: invalid argument`) however it is quoted. Older scripts failed in configure or a few hundred steps into Ninja instead | Move or clone the checkout (or choose a `-Temp`) in a folder without `%` in its path |