diff options
| author | Claude <noreply@anthropic.com> | 2026-11-29 19:18:03 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-11-29 19:18:03 +0000 |
| commit | f61e5e89333aa18a1ca894e54da38d5460f7cee2 (patch) | |
| tree | ba590eaad8b20cefbfd0a6ebdc782cdba2ba5bf3 /docs | |
| parent | ee27e871966c01d59c0cbc36468fa7f7cf51f33f (diff) | |
| parent | dd87aa405a0d48cbce4269c9d20e50c3ec8b5dbc (diff) | |
Merge ProjectLeonida/mandy main into port/nv-vram-target-reserve-settle
# Conflicts:
# d3d12/README.md
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/README.md | 1 | ||||
| -rw-r--r-- | docs/audio_hal_exe_calls.md | 12 | ||||
| -rw-r--r-- | docs/boot.md | 13 | ||||
| -rw-r--r-- | docs/change_gate.md | 313 | ||||
| -rw-r--r-- | docs/d3d12_command_objects.md | 79 | ||||
| -rw-r--r-- | docs/d3d12_vulkan.md | 173 | ||||
| -rw-r--r-- | docs/descriptor_lookup_ampere.md | 68 | ||||
| -rw-r--r-- | docs/design.md | 2 | ||||
| -rw-r--r-- | docs/directstorage.md | 22 | ||||
| -rw-r--r-- | docs/gameinput.md | 12 | ||||
| -rw-r--r-- | docs/i18n/ar/quickstart.md | 4 | ||||
| -rw-r--r-- | docs/running.md | 12 | ||||
| -rw-r--r-- | docs/test_inventory.md | 41 | ||||
| -rw-r--r-- | docs/testing.md | 3 |
14 files changed, 710 insertions, 45 deletions
diff --git a/docs/README.md b/docs/README.md index a0eeee400..1bb2ea02e 100644 --- a/docs/README.md +++ b/docs/README.md | |||
| @@ -77,6 +77,7 @@ method, scope and caveats. No game data is included. | |||
| 77 | | [modding.md](modding.md) | The mod format: a `mods/<folder>/mod.json` next to `gta6rt.exe` or under `--mods DIR`, swapping a named (or `joaat`) archetype for another; the `tools/leonida_mods.py` manager (`Mods.bat` on Windows, `Mods.sh` on Linux and macOS); load order, the start-up log, and the fact that a swap waits for the executable's archetype lookup address (RT-5). | | 77 | | [modding.md](modding.md) | The mod format: a `mods/<folder>/mod.json` next to `gta6rt.exe` or under `--mods DIR`, swapping a named (or `joaat`) archetype for another; the `tools/leonida_mods.py` manager (`Mods.bat` on Windows, `Mods.sh` on Linux and macOS); load order, the start-up log, and the fact that a swap waits for the executable's archetype lookup address (RT-5). | |
| 78 | | [descriptor_lookup_apple.md](descriptor_lookup_apple.md) | M3 Max GPU timings for texture and sampler descriptor lookups at 1k, 10k and 100k live entries. | | 78 | | [descriptor_lookup_apple.md](descriptor_lookup_apple.md) | M3 Max GPU timings for texture and sampler descriptor lookups at 1k, 10k and 100k live entries. | |
| 79 | | [descriptor_lookup_ada.md](descriptor_lookup_ada.md) | RTX 4070 SUPER (Ada, Windows) timings for the same lookups in VRAM, host-visible and ReBAR memory. | | 79 | | [descriptor_lookup_ada.md](descriptor_lookup_ada.md) | RTX 4070 SUPER (Ada, Windows) timings for the same lookups in VRAM, host-visible and ReBAR memory. | |
| 80 | | [descriptor_lookup_ampere.md](descriptor_lookup_ampere.md) | RTX 3070 (Ampere, Windows, PCIe 3.0 x16, ReBAR off) timings for the same lookups in VRAM, host-visible and 214 MiB BAR1 memory. | | ||
| 80 | | [descriptor_lookup_intel.md](descriptor_lookup_intel.md) | Intel UHD Graphics 770 (Xe-LP, Windows, driver 101.6129) timings for the same lookups at 1k–100k live entries; both memory placements within 0.6% of each other. | | 81 | | [descriptor_lookup_intel.md](descriptor_lookup_intel.md) | Intel UHD Graphics 770 (Xe-LP, Windows, driver 101.6129) timings for the same lookups at 1k–100k live entries; both memory placements within 0.6% of each other. | |
| 81 | | [d3d12_xs_surface.md](d3d12_xs_surface.md) | The 116-slot `d3d12_xs.dll` export surface; 83/83 standard GUIDs match the PC SDK. | | 82 | | [d3d12_xs_surface.md](d3d12_xs_surface.md) | The 116-slot `d3d12_xs.dll` export surface; 83/83 standard GUIDs match the PC SDK. | |
| 82 | | [xdxr.md](xdxr.md) | `BATCHED_DESC2` (`0x50`) and `XDXR_STREAM_DESC` (`0x10`) from `XboxBvhBuilder.dll`'s reads; stream records' offsets and defaults; offline statistics not in the package. | | 83 | | [xdxr.md](xdxr.md) | `BATCHED_DESC2` (`0x50`) and `XDXR_STREAM_DESC` (`0x10`) from `XboxBvhBuilder.dll`'s reads; stream records' offsets and defaults; offline statistics not in the package. | |
diff --git a/docs/audio_hal_exe_calls.md b/docs/audio_hal_exe_calls.md index a500e16fc..42ec9fd78 100644 --- a/docs/audio_hal_exe_calls.md +++ b/docs/audio_hal_exe_calls.md | |||
| @@ -26,7 +26,7 @@ Every one of the 22 has at least one site, so none is dead code the linker kept. | |||
| 26 | | `AcpHalReleaseShapeContexts` | 1 | called with a handle read from the first global; result not used | | 26 | | `AcpHalReleaseShapeContexts` | 1 | called with a handle read from the first global; result not used | |
| 27 | | `ApuCreateHeap` | 1 | second argument `0x226e00`; the result is tested for a negative value | | 27 | | `ApuCreateHeap` | 1 | second argument `0x226e00`; the result is tested for a negative value | |
| 28 | | `ApuAlloc` | 1 | second argument `0`, third a computed value, fourth `0x800`; the result is not used at the site | | 28 | | `ApuAlloc` | 1 | second argument `0`, third a computed value, fourth `0x800`; the result is not used at the site | |
| 29 | | `ApuFree` | 1 tail jump | no call, only a tail jump from a wrapper | | 29 | | `ApuFree` | 1 tail jump | the `site` is a whole function that is one `jmp` to the thunk (`0x1443aea10`), so it forwards its arguments unchanged and adds no arity of its own | |
| 30 | | `ApuIsVirtualAddressValid` | 4 | second argument `0x40`, `0x80`, `0x800`, `0x800`; the result byte is tested | | 30 | | `ApuIsVirtualAddressValid` | 4 | second argument `0x40`, `0x80`, `0x800`, `0x800`; the result byte is tested | |
| 31 | | `ApuMapVirtualAddress` | 4 | the same pointer and the same four constants as `ApuIsVirtualAddressValid`, one after the other; the 32-bit result is stored in a per-entry record | | 31 | | `ApuMapVirtualAddress` | 4 | the same pointer and the same four constants as `ApuIsVirtualAddressValid`, one after the other; the 32-bit result is stored in a per-entry record | |
| 32 | | `ApuMapApuAddress` | 2 | the argument is a 32-bit value read from those records; the result is tested for null, so it is a pointer | | 32 | | `ApuMapApuAddress` | 2 | the argument is a 32-bit value read from those records; the result is tested for null, so it is a pointer | |
| @@ -39,14 +39,14 @@ turns such an address back into a pointer. That is an inference from the shapes; | |||
| 39 | 39 | ||
| 40 | | Import | Sites | What the sites show | | 40 | | Import | Sites | What the sites show | |
| 41 | |---|---:|---| | 41 | |---|---:|---| |
| 42 | | `XApuConnect` | 1 | no argument loaded in the lines before the call was read | | 42 | | `XApuConnect` | 1 | three arguments, the addresses of three `.data` globals (`0x149B69890`, `0x149B698A8`, `0x149B68960`), in `rcx`/`rdx`/`r8`; the result is tested as non-negative (`setns`) | |
| 43 | | `XApuDisconnect` | 1 | first argument a handle read from a global, second `0x20`; the global is set to 0 right after | | 43 | | `XApuDisconnect` | 1 | first argument a handle read from a global, second `0x20`; the global is set to 0 right after | |
| 44 | | `XApuEnqueueCommand` | 4 | the same global handle, a pointer to a stack-built command, and 0 | | 44 | | `XApuEnqueueCommand` | 4 | the same global handle, a pointer to a stack-built command, and 0 | |
| 45 | | `XApuDequeueResult` | 1 | the same global handle and a second argument; the result is tested for a negative value | | 45 | | `XApuDequeueResult` | 1 | the same handle global, and a 16-byte stack buffer as the second argument; a negative result jumps out, otherwise the record is read from buffer `+0x20`/`+0x24` | |
| 46 | | `XApuGetResultCount` | 1 | no argument read | | 46 | | `XApuGetResultCount` | 1 | the queue handle global and a second argument `0`; the result count is tested for zero and both branches are taken on it | |
| 47 | | `XDspConnectWithMaximumStreamLimit` | 1 | fourth argument `0x80`; the result is compared with 0 and turned into a boolean that is true for 0 | | 47 | | `XDspConnectWithMaximumStreamLimit` | 1 | fourth argument `0x80`; the result is compared with 0 and turned into a boolean that is true for 0 | |
| 48 | | `XDspActivate` | 1 | the result is tested | | 48 | | `XDspActivate` | 1 | a wrapper that swaps the incoming `r8`/`r9` before calling; the result is tested | |
| 49 | | `XDspSubmitCommand` | 1 | two arguments, both taken from registers; not read further | | 49 | | `XDspSubmitCommand` | 1 | a two-argument wrapper that swaps the incoming registers (`rcx` <- `rdx`, `rdx` <- old `rcx`) before calling, so the published order is the reverse of the wrapper's | |
| 50 | | `XDspDeactivate`, `XDspDisconnect` | 1 tail jump each | no call | | 50 | | `XDspDeactivate`, `XDspDisconnect` | 1 tail jump each | no call | |
| 51 | 51 | ||
| 52 | `XApuEnqueueCommand` and `XApuDequeueResult` share one handle global, which `XApuDisconnect` clears: a command queue | 52 | `XApuEnqueueCommand` and `XApuDequeueResult` share one handle global, which `XApuDisconnect` clears: a command queue |
diff --git a/docs/boot.md b/docs/boot.md index 06b34a11d..688d91dd1 100644 --- a/docs/boot.md +++ b/docs/boot.md | |||
| @@ -109,6 +109,10 @@ Useful switches: | |||
| 109 | read when the trace opens. | 109 | read when the trace opens. |
| 110 | Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file | 110 | Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file |
| 111 | open is always traced as `file_open_failed` (path, error, caller) when `--trace` is on. | 111 | open is always traced as `file_open_failed` (path, error, caller) when `--trace` is on. |
| 112 | * `LEONIDA_SKIP_ASSERTS=N` steps over up to N int3 in guest code, with or without `--trace`, and prints each one | ||
| 113 | as `[rt] LEONIDA_SKIP_ASSERTS: int3 at <module>+0x... stepped over (k of N)`; the next one after N ends the run as | ||
| 114 | before. An int3 in a host module is never stepped over. The same caveat: each skipped address is a finding | ||
| 115 | ([runtime/README.md](../runtime/README.md), "Guest asserts"). | ||
| 112 | * `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry | 116 | * `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry |
| 113 | for its program) as a stub instead of failing `CreateGraphicsPipelineState` / `CreateComputePipelineState`. | 117 | for its program) as a stub instead of failing `CreateGraphicsPipelineState` / `CreateComputePipelineState`. |
| 114 | A graphics pipeline with a vertex stage (MVP-GPU-04) is a real Vulkan pipeline built from the built-in stages in | 118 | A graphics pipeline with a vertex stage (MVP-GPU-04) is a real Vulkan pipeline built from the built-in stages in |
| @@ -133,6 +137,13 @@ Useful switches: | |||
| 133 | diagnostic). | 137 | diagnostic). |
| 134 | * `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first | 138 | * `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first |
| 135 | observed loss prints a `[rt] device-fault:` report to stderr. | 139 | observed loss prints a `[rt] device-fault:` report to stderr. |
| 140 | * `LEONIDA_IO_TRACE=<file>` writes one line for every read the title asks for (`runtime/shims/io_trace.h`): | ||
| 141 | - `ds`: a DirectStorage request, with its file, file offset, source and destination sizes, zlib and BCPack, and the | ||
| 142 | request's name; | ||
| 143 | - `rf`: a ReadFile, ReadFileEx or ReadFileScatter on a disk file, with its path, offset and size. | ||
| 144 | |||
| 145 | Each line starts with the local time, as the `mem-probe` lines do. Each line is flushed at once and the file can be | ||
| 146 | read while the game runs, so the last reads before a crash or a device loss name what the title was loading. | ||
| 136 | * `LEONIDA_TITLE_HUD=1` shows live counters in the title bar of the window the title presents in | 147 | * `LEONIDA_TITLE_HUD=1` shows live counters in the title bar of the window the title presents in |
| 137 | (`runtime/shims/title_hud.h`). It updates twice a second with: | 148 | (`runtime/shims/title_hud.h`). It updates twice a second with: |
| 138 | - the frame rate and the average and worst frame time from PresentX, or, when no frame came in that half | 149 | - the frame rate and the average and worst frame time from PresentX, or, when no frame came in that half |
| @@ -258,7 +269,7 @@ order. It maps each question to the event to look for; it does not answer them. | |||
| 258 | 269 | ||
| 259 | | # | Question | Signal in the first trace | | 270 | | # | Question | Signal in the first trace | |
| 260 | |---|---|---| | 271 | |---|---|---| |
| 261 | | 1 | `D3D12XboxCreateDevice` 24-word params and flags | first `D3D12XboxCreateDevice` in the D3D12 trace; the shim prints the 24 words as an `[rt]` line in the same log, with or without `--trace-d3d12` (grep `^\[rt\]`); accept unknown flags | | 272 | | 1 | `D3D12XboxCreateDevice` 0x50-byte params and flags | first `D3D12XboxCreateDevice` in the D3D12 trace; the shim prints the twenty dwords as an `[rt]` line in the same log, with or without `--trace-d3d12` (grep `^\[rt\]`); accept unknown flags. The struct is 0x50 bytes (20 dwords), not 24 words: at the single retail call site it is a stack local of a `0x228` frame whose saved `xmm6` begins at `+0x200`, and three 32-byte stores zero it up to `+0x4F`. Only `+0x00 = 0x00020004`, `+0x08 = 0x00100000`, `+0x28 = 1` and `+0x3C = 0x20` are fixed; `+0x20` and `+0x24` carry two bytes of launch state and `+0x30`-`+0x4F` stay zero. Adapter is null, the IID is `{5405C344-D457-444E-B4DD-2366E45AEE39}` | |
| 262 | | 2 | Xbox device/heap/queue/command-list slots | queue, fence and allocator method names in the D3D12 trace; device slots past the PC vtable print an `[rt] d3d12_xs: device slot …` line instead and record nothing; compare with the SDK vtable | | 273 | | 2 | Xbox device/heap/queue/command-list slots | queue, fence and allocator method names in the D3D12 trace; device slots past the PC vtable print an `[rt] d3d12_xs: device slot …` line instead and record nothing; compare with the SDK vtable | |
| 263 | | 3 | Root signature → `s0..s31` | `CreateRootSignature`, `SetGraphicsRootSignature`, then the shader's user-SGPR reads; mask `0x03000000` on a copy | | 274 | | 3 | Root signature → `s0..s31` | `CreateRootSignature`, `SetGraphicsRootSignature`, then the shader's user-SGPR reads; mask `0x03000000` on a copy | |
| 264 | | 4 | Descriptor bytes and heap increments | first `CreateShaderResourceView`/`CreateSampler` and the first draw; dump the heap bytes and compare with the T#/S# parser | | 275 | | 4 | Descriptor bytes and heap increments | first `CreateShaderResourceView`/`CreateSampler` and the first draw; dump the heap bytes and compare with the T#/S# parser | |
diff --git a/docs/change_gate.md b/docs/change_gate.md new file mode 100644 index 000000000..5b4dcb355 --- /dev/null +++ b/docs/change_gate.md | |||
| @@ -0,0 +1,313 @@ | |||
| 1 | # Proposal: a change gate for module boundaries, function complexity and doubled text | ||
| 2 | |||
| 3 | **Status: a proposal for the maintainer's decision; nothing on this page is implemented, and the pull request that | ||
| 4 | adds it changes no other file. The numbers were measured at `dde82f2` on the tree and on the 300 squash merges | ||
| 5 | that end with it (one merge round on 2026-11-23 in the original repository, whose history this one carries), with a standard-library prototype that is | ||
| 6 | not part of this pull request.** | ||
| 7 | |||
| 8 | GitHub's search counts 3,680 pull requests merged in the original repository from 2026-11-21 to 2026-11-23. [AGENTS.md](../AGENTS.md) is | ||
| 9 | written for the coding agents that many contributors use, and the template asks about them. Review and CI catch | ||
| 10 | what a diff shows and what a test exercises. Three things a diff does not show: a new dependency on another part of | ||
| 11 | the tree, hidden behind a `sys.path` insert; a function that has grown past the point where a person or an agent can | ||
| 12 | change it without breaking a case it did not look at; and text that a merge doubled. This page proposes one | ||
| 13 | deterministic check for those three. It compares a pull request with its base, blocks only what the pull request | ||
| 14 | adds, tolerates what is already on `main`, and tells the author why a finding matters and how to fix it. Because CI | ||
| 15 | had finished on few pull requests when they were merged (section 1.4), it runs where the code is written and in the | ||
| 16 | merge round as well as in CI. | ||
| 17 | |||
| 18 | Claims are marked: | ||
| 19 | |||
| 20 | - **Measured** — counted on the tree or the history at `dde82f2`; section 6 says how. | ||
| 21 | - **Proposed** — what this page asks the maintainer to accept. | ||
| 22 | - **Open** — a question for the maintainer, collected in section 5. | ||
| 23 | |||
| 24 | ## 1. What was measured | ||
| 25 | |||
| 26 | ### 1.1 Dependencies between parts of the tree | ||
| 27 | |||
| 28 | **Measured.** Python files reach each other through 1,262 `sys.path.insert` calls, which is why 1,527 imports carry | ||
| 29 | `# noqa: E402`. Resolving those paths gives 2,182 import edges between repository files. | ||
| 30 | These boundaries hold today with no exception: | ||
| 31 | |||
| 32 | - `make_game.py` imports only `tools/`. | ||
| 33 | - `viewer/` imports nothing from the repository. | ||
| 34 | - `tools/` never imports `scripts/`, `make_game.py` or `viewer/`; `scripts/` never imports `tests/`. | ||
| 35 | - No import cycle crosses two areas; inside `tools/` there are two, each of two files | ||
| 36 | (`tools/calibrated_texture.py` with `tools/ttpf_mips.py`, `tools/hw_oracle/drm.py` with `tools/hw_oracle/runner.py`). | ||
| 37 | - No production C++ file (`runtime/src`, `runtime/shims`, `runtime/xma_decoder`) includes a `runtime/test` file, and | ||
| 38 | no file-level `#include` cycle exists. | ||
| 39 | |||
| 40 | One boundary is crossed: production code imports test code through 39 edges from 32 files. 26 edges go from | ||
| 41 | `tools/` to `tests/`, 22 of them to `tests/semantic/spirv_mini_interp.py`, which is in effect a shared reference | ||
| 42 | interpreter kept in a test folder; 8 go from `tools/` and 5 from `scripts/` to the GPU fixture helpers in | ||
| 43 | `runtime/test/shaders`. The `scripts/` ones are test runners (`scripts/run_gpu_tests.py`, | ||
| 44 | `scripts/bench_wave64.py`) using the fixture helpers they run, and the rules below allow them. Two of the 300 merges | ||
| 45 | added another edge from `tools/`, both new tools that copied the pattern (`tools/wave_diff.py:53` in `db77244`, | ||
| 46 | `tools/div_fixup_diff.py:104` in `5e54bda`). | ||
| 47 | |||
| 48 | To be fair to the current setup: 31 of the 32 importing files are themselves imported by a test, so an edit to | ||
| 49 | `spirv_mini_interp.py` that breaks a tool makes a test fail once CI runs (section 1.4 shows how often it has not | ||
| 50 | run by the merge). What the edge costs even then is legibility. The file looks like test code, and nothing beside it says that 22 tools depend on | ||
| 51 | it; an author, human or agent, edits it with that context missing. | ||
| 52 | |||
| 53 | The C++ runtime has one directory-level cycle: `runtime/shims` includes `runtime/src` 27 times, and `runtime/src` | ||
| 54 | includes `runtime/shims` 7 times, all from `runtime/src/main.cpp` and `runtime/src/pe_loader.cpp`. Whether that is the | ||
| 55 | intended layering is question 5 in section 5. | ||
| 56 | |||
| 57 | ### 1.2 Function complexity | ||
| 58 | |||
| 59 | **Measured**, cyclomatic complexity (McCabe for Python, lizard's CCN for C++; section 6): | ||
| 60 | |||
| 61 | | Area | Functions | Complexity 11-20 | 21-50 | Above 50 | Largest | | ||
| 62 | |---|---|---|---|---|---| | ||
| 63 | | `tools/` (Python) | 5,579 | 774 | 399 | 95 | 1,261 | | ||
| 64 | | `make_game.py` and `scripts/` | 291 | 37 | 15 | 3 | 280 | | ||
| 65 | | `runtime/src` and `runtime/shims` (C++) | 2,514 | 165 | 88 | 27 | 370 | | ||
| 66 | |||
| 67 | The largest is `Gen._insn` in `tools/rdna2spirv.py` (line 6722): 4,889 lines and a complexity of 1,261 in an | ||
| 68 | 18,229-line file. One `if`/`elif` chain of 182 arms holds nearly all of that; section 2.3 judges such a function arm | ||
| 69 | by arm. | ||
| 70 | |||
| 71 | What the 300 merges did to production functions, checked with the rule proposed in section 2.3: | ||
| 72 | 89 findings in 48 pull requests. Each was labelled after reading its diff | ||
| 73 | (section 6 says by whom): 66 made a function measurably harder to change (new nested logic, a 9 -> 20 or 10 -> 27 | ||
| 74 | jump, an optional feature threaded through an existing function), 21 are correct measurements whose value is | ||
| 75 | arguable, and 2 are artefacts of the tool (section 2.3 lists them). Examples of the first kind: | ||
| 76 | |||
| 77 | | Commit | Function | Complexity before -> after | | ||
| 78 | |---|---|---| | ||
| 79 | | `0a8a552` | `export_bank` in `tools/awc_opus.py` | 19 -> 30 | | ||
| 80 | | `9a9ca1e` | `ExecuteIndirect` in `runtime/shims/d3d12_com.cpp` | 10 -> 27 | | ||
| 81 | | `21e72aa` | `scan_offsets` in `tools/smh_groom.py` | 9 -> 20 | | ||
| 82 | | `86d1c86` | `verify_manifest` in `tools/manifest_verifier.py` | 23 -> 33 | | ||
| 83 | | `c1aa89e` | `verify` in `tools/world_drawable_verify.py` (new) | 34 | | ||
| 84 | |||
| 85 | ### 1.3 Text doubled by a merge | ||
| 86 | |||
| 87 | **Measured.** Eight blocks of six or more lines repeat within the same file on `main`, the trace of a pull request | ||
| 88 | merged twice or a conflict resolved by keeping both sides (line numbers of the first and last non-blank line of each | ||
| 89 | copy; the last row is the first nine lines of the row four above it, which appear a third time): | ||
| 90 | |||
| 91 | | File | First copy | Second copy | | ||
| 92 | |---|---|---| | ||
| 93 | | `docs/models.md` | 568-651 | 653-736 | | ||
| 94 | | `docs/animation.md` | 971-1023 | 1052-1104 | | ||
| 95 | | `docs/animation.md` | 1025-1050 | 1106-1131 | | ||
| 96 | | `docs/shader_validation.md` | 1998-2040 | 2061-2103 | | ||
| 97 | | `docs/gbuffer.md` | 13-49 | 52-88 | | ||
| 98 | | `docs/testing.md` | 337-353 | 355-371 | | ||
| 99 | | `docs/design.md` | 576-590 | 592-606 | | ||
| 100 | | `docs/shader_validation.md` | 2061-2069 | 2174-2182 | | ||
| 101 | |||
| 102 | The existing guards pass on all of them: `tests/test_docs_repeated_lines.py` compares prose lines at most three lines | ||
| 103 | apart and `tests/test_docs_list_items.py` list items at most eight apart, which a doubled section of 84 lines never | ||
| 104 | is. `scripts/merge_check.py` finds the doubling when it is run before a merge round; nothing finds it after. No new | ||
| 105 | doubled block appeared in the 300 merges, so this part of the check guards a failure that is rare now, not frequent. | ||
| 106 | |||
| 107 | ### 1.4 Whether a check runs before the merge | ||
| 108 | |||
| 109 | **Measured** in the original repository. GitHub's search returned 1,000 of the 1,252 pull requests merged there on 2026-11-23 (it stops at 1,000); | ||
| 110 | all of them came from forks. The CI workflow on the head commit each was merged with had: | ||
| 111 | |||
| 112 | | CI workflow at merge | Pull requests | | ||
| 113 | |---|---| | ||
| 114 | | passed | 55 | | ||
| 115 | | failed | 282 | | ||
| 116 | | queued, pending or still running | 661 | | ||
| 117 | | cancelled, or no run | 2 | | ||
| 118 | |||
| 119 | After a merge the push run does not finish either: 164 of the last 165 CI runs for pushes to `main` were cancelled | ||
| 120 | by the next push, and the last one was still pending when read (2026-11-23, about 20:00 UTC). At `867d922` three | ||
| 121 | documentation tests fail on `main`. `tests/test_docs_cli_flags.py` and `tests/test_docs_links.py` have failed since `cc67780`, and later | ||
| 122 | merges changed the items they report; `tests/test_docs_design_rows.py` has failed since `0980bea` (both found with | ||
| 123 | `git bisect`). Neither pull request had a finished CI run when it was merged. | ||
| 124 | |||
| 125 | So a check that lives only in a CI job would have run before the merge for about one pull request in eighteen. This repository merges the same way: of | ||
| 126 | its 40 most recently merged pull requests (read on 2026-11-24 at about 03:20 UTC), 19 had no CI run at merge, 18 had | ||
| 127 | at least one failing CI job, 2 had jobs still pending and 1 had only passing or skipped jobs. | ||
| 128 | Section 2.1 therefore puts it where the code is written and where merges are decided, not only in CI. | ||
| 129 | |||
| 130 | ## 2. The proposed check | ||
| 131 | |||
| 132 | ### 2.1 How it runs | ||
| 133 | |||
| 134 | **Proposed.** One standard-library script under `scripts/`, run with `python -I` like the other tools. The same | ||
| 135 | command gives the same verdict in three places: | ||
| 136 | |||
| 137 | - **By the author, before opening or updating the pull request.** It compares the working tree with the merge base | ||
| 138 | of `origin/main`. [AGENTS.md](../AGENTS.md) gives an agent the command, and the pull request's `Tested` section | ||
| 139 | names the result, the way it names the tests that were run. | ||
| 140 | - **In the merge round, before the push.** One command takes the round's pull requests in merge order and checks each | ||
| 141 | against `main` plus the ones before it, the way `scripts/merge_check.py` checks a round for repeated merges. It | ||
| 142 | needs no runner, so it does not wait for CI approval or a free runner slot. | ||
| 143 | - **In CI, when the pull request's run is approved.** It compares the test merge with its first parent, as the | ||
| 144 | `change-scope` job of `ci.yml` already does. | ||
| 145 | - It looks only at what the pull request changed: the files it touched are parsed again, the import and include | ||
| 146 | graphs are re-linked, and the functions whose lines changed are measured on both sides. On the 300 merges the | ||
| 147 | prototype took 80 ms per pull request (90th percentile 170 ms, slowest 1.9 s); building the state | ||
| 148 | of a whole tree from cold takes 8.2 s, so a CI job without a cache costs about ten seconds. | ||
| 149 | - What is on the base is tolerated by construction, so there is no baseline list for every pull request to edit and | ||
| 150 | conflict on. The one shared file is the exception list (section 2.5), which changes only when a reviewer approves an | ||
| 151 | exception. | ||
| 152 | - No model, no network, no service: the verdict is the same on every machine. C++ complexity uses lizard, pinned in | ||
| 153 | the CI job; everything else is the standard library. | ||
| 154 | |||
| 155 | ### 2.2 The rules | ||
| 156 | |||
| 157 | **Proposed.** "Blocks" means the CI job fails; "reports" means the finding is listed and the job passes. | ||
| 158 | |||
| 159 | | ID | Rule | Kind | On `main` today | Findings in the 300 merges | | ||
| 160 | |---|---|---|---|---| | ||
| 161 | | P1 | `make_game.py` imports only `tools/` | blocks | 0 | 0 | | ||
| 162 | | P2 | `viewer/` imports nothing from the repository | blocks | 0 | 0 | | ||
| 163 | | P3 | `tools/` does not import `scripts/`, `make_game.py` or `viewer/` | blocks | 0 | 0 | | ||
| 164 | | P4 | `tools/` does not import `tests/` or `runtime/` | blocks | 34 edges, tolerated | 2 | | ||
| 165 | | P5 | `scripts/` does not import `tests/`, `make_game.py` or `viewer/` | blocks | 0 | 0 | | ||
| 166 | | P6 | no new or larger Python import cycle | blocks | 2 cycles, tolerated | 0 | | ||
| 167 | | C1 | production C++ does not include `runtime/test` | blocks | 0 | 0 | | ||
| 168 | | C2 | no new or larger `#include` cycle | blocks | 0 | 0 | | ||
| 169 | | D1 | no new block of six lines repeated within one Markdown file | blocks | 8 blocks, tolerated | 0 | | ||
| 170 | | X1 | a new production function has complexity 10 or lower | blocks | — | 44 in 23 pull requests | | ||
| 171 | | X2 | a changed production function at 10 or lower stays at 12 or lower (`main`: 15) | blocks | — | 4 in 4 pull requests | | ||
| 172 | | X3 | a changed production function above 10 grows by at most 2 (`main`: 5) | blocks | — | 41 in 31 pull requests | | ||
| 173 | | R1 | a block of six or more code lines that duplicates code elsewhere | reports | — | 138 | | ||
| 174 | | R2 | an added skip or suppression (`unittest.skip`, `# noqa` other than E402, `# type: ignore`, ...) | reports | — | 24 | | ||
| 175 | |||
| 176 | An edge counts as new when it exists in the pull request and not in its base; a cycle counts as new when it is not | ||
| 177 | contained in one cycle of the base. Existing edges and cycles are never reported again. | ||
| 178 | |||
| 179 | ### 2.3 The complexity rules in detail | ||
| 180 | |||
| 181 | **Proposed.** | ||
| 182 | |||
| 183 | - Production code only: `tools/`, `scripts/`, `make_game.py`, `viewer/`, `runtime/src`, `runtime/shims` and | ||
| 184 | `runtime/xma_decoder`. Tests are left out; a test that checks forty cases in a row is long, not tangled. | ||
| 185 | - Python complexity is McCabe's: one plus each `if`/`elif`, conditional expression, `for`, `while`, `except`, each | ||
| 186 | extra operand of `and`/`or`, each `for` and `if` of a comprehension, and each `case`. Nested functions are measured | ||
| 187 | on their own. C++ uses lizard's CCN. | ||
| 188 | - A function counts as changed when any of its lines changed; it is compared with the function of the same qualified | ||
| 189 | name in the base. | ||
| 190 | - Dispatch functions are judged one arm at a time. A function is a dispatch function when one `if`/`elif` chain | ||
| 191 | testing a single subject against constants (`op == "..."`, `name in (...)`, `isinstance(x, ...)`) has at least | ||
| 192 | eight arms and holds at least half of its decision points. A new arm then needs a complexity of 10 or lower, a | ||
| 193 | changed arm keeps the +2 allowance, and code outside the arms may grow by 2. Adding a translator rule as one more | ||
| 194 | arm of `Gen._insn` passes; adding a 14-branch arm does not. | ||
| 195 | - `main` and `wmain` may grow by 5 instead of 2, because argument and input checks land there. In the 300 merges | ||
| 196 | this let 18 additions through, all labelled arguable: argument and input checks, and one +3 of other logic in | ||
| 197 | `tools/hashdict.py`. `make_game.py` `main` going from 53 to 59 in one pull request still fails. | ||
| 198 | - Known artefacts, both from the 300 merges: `slot_name` in `runtime/shims/d3d12_xs_device.cpp` grew by five `case` | ||
| 199 | labels of a name table (a C++ function is judged whole, since lizard reports no arms); the `VulkanPresenter` | ||
| 200 | constructor in `runtime/src/vulkan_present.h` gained a parameter, so its name changed and it was judged as a new | ||
| 201 | function. A renamed or moved function is judged as new in the same way. | ||
| 202 | |||
| 203 | ### 2.4 What the author sees | ||
| 204 | |||
| 205 | **Proposed.** Every finding carries four parts: why the rule exists, exactly what triggered it, a fix chosen from the | ||
| 206 | shape of the change, and how to ask for an exception. The same findings are written three ways: a GitHub annotation on | ||
| 207 | the line in the pull request's diff, a job summary with the full text, and plain text for a local run. The prototype's | ||
| 208 | output for `0a8a552`, which grew `export_bank` from 19 to 30: | ||
| 209 | |||
| 210 | ```text | ||
| 211 | ERROR X3 tools/awc_opus.py:381 export_bank went from complexity 19 to 30; a changed function may end at 21 | ||
| 212 | why: A function this branchy is too large to change safely: neither a person nor a coding agent keeps all its cases in view, so an edit breaks a case it did not look at. | ||
| 213 | what: export_bank at tools/awc_opus.py:381-439: complexity 19 -> 30 (limit 10) | ||
| 214 | what: added lines that carry decision points (11 on 8 lines): 383, 385, 397, 403, 432-433, 435, 437 | ||
| 215 | what: tools/awc_opus.py:383 (+1): if cue_sheet: | ||
| 216 | what: tools/awc_opus.py:385 (+1): if os.path.exists(sheet): | ||
| 217 | what: tools/awc_opus.py:397 (+1): if cue_sheet: | ||
| 218 | what: tools/awc_opus.py:403 (+3): if cue_sheet and rate == 48000 and samples > 0: | ||
| 219 | what: tools/awc_opus.py:435 (+2): verified = {cid: limit for cid, limit in frame_limits.items() if channel_counts[cid] == 1} | ||
| 220 | fix: 4 of the added branches test `cue_sheet` (lines 383, 397, 403, 432): that is one optional feature threaded through export_bank. Put its steps into a function of their own and call it where the feature applies. | ||
| 221 | fix: It passes at complexity 21 or lower (now 30): moving 9 decision points out is enough. | ||
| 222 | else: If the rule is wrong for this case, add {"rule": "X3", "path": "tools/awc_opus.py", "key": "export_bank", "reason": "..."} to gate_rules.json in this pull request; it counts once a reviewer approves it. | ||
| 223 | |||
| 224 | ``` | ||
| 225 | |||
| 226 | and for `5e54bda`, the second of the two new imports of test code: | ||
| 227 | |||
| 228 | ```text | ||
| 229 | ERROR P4 tools/div_fixup_diff.py:104 new import tools/div_fixup_diff.py -> tests/semantic/spirv_mini_interp.py: tools/ must not import tests/ or runtime/ files (existing edges are tolerated, new ones are not) | ||
| 230 | why: Hidden cross-module coupling: the imported file is changed as if nothing on this side depended on it, so an edit there can break this file without the author or reviewer expecting it. | ||
| 231 | what: tools/div_fixup_diff.py:104 imports tests/semantic/spirv_mini_interp.py (import spirv_mini_interp) | ||
| 232 | fix: `spirv_mini_interp` is shared code kept in a test folder: 21 other tools/ files already import it (tools/buffer_swizzle_probe.py, tools/bvh_tri_probe.py, tools/f32_fuzz.py, ...). Move tests/semantic/spirv_mini_interp.py to tools/ in its own pull request (the tests then import it from tools/), and import it from there. | ||
| 233 | fix: Do not add tests/semantic to sys.path from tools/div_fixup_diff.py: that is the hidden edge this rule stops. | ||
| 234 | else: If the rule is wrong for this case, add {"rule": "P4", "path": "tools/div_fixup_diff.py", "key": "tests/semantic/spirv_mini_interp.py", "reason": "..."} to gate_rules.json in this pull request; it counts once a reviewer approves it. | ||
| 235 | |||
| 236 | ``` | ||
| 237 | |||
| 238 | ### 2.5 Exceptions | ||
| 239 | |||
| 240 | **Proposed.** A finding that is wrong for a case is not fixed by working around the check. The author adds an entry | ||
| 241 | with the rule, the path, the edge or function and a reason to one exception file at the repository root, in the same | ||
| 242 | pull request; the finding then turns into a note, and the entry is visible in the diff for the reviewer to approve or | ||
| 243 | refuse. An entry that no longer matches anything is reported so the file does not grow stale. | ||
| 244 | |||
| 245 | ## 3. What it does not do | ||
| 246 | |||
| 247 | - It changes no existing code and asks nobody to fix what is already on `main`. The 34 imports of test code from | ||
| 248 | `tools/`, the two import cycles and the eight doubled blocks stay until someone chooses to fix them (section 4). | ||
| 249 | - It does not judge whether code is correct; the tests and the reviewer still do that. | ||
| 250 | - It blocks nothing on code duplication or on skips: the tests copy their templates on purpose, and nearly every skip | ||
| 251 | added in the 300 merges was a missing tool, platform or numpy, which is legitimate. | ||
| 252 | - It needs no model and no service. The author adapted it from a gate they use in their own projects; there, a local | ||
| 253 | model chose which documents an agent should read before a change. That part is left out here: the rules file and | ||
| 254 | the messages say what applies to a change, and the same verdict comes out on every machine. | ||
| 255 | |||
| 256 | ## 4. Rollout | ||
| 257 | |||
| 258 | **Proposed**, each step its own pull request: | ||
| 259 | |||
| 260 | 1. This page, for the decision. | ||
| 261 | 2. The implementation: the script with its merge-round mode, the rules and exception files, a standard-library test | ||
| 262 | file under `tests/` (the CI loop picks it up, as `tests/test_ci_registration.py` requires), a job on | ||
| 263 | `ubuntu-24.04`, a few lines in [AGENTS.md](../AGENTS.md) that give an agent the local command and the map of which | ||
| 264 | area may import which, and one line in the pull request template for the result. | ||
| 265 | 3. Follow-up items for the coordination issue, for anyone to claim: move `tests/semantic/spirv_mini_interp.py`, | ||
| 266 | `tests/semantic/spirv_wave_interp.py` and `tests/spirv_interp.py` under `tools/` (removes 25 of the 34 imports | ||
| 267 | of test code from `tools/` at once); delete the second copy of each doubled block in section 1.3; split the largest production | ||
| 268 | functions, starting with those changed most often. | ||
| 269 | |||
| 270 | ## 5. Decisions for the maintainer | ||
| 271 | |||
| 272 | **Open.** | ||
| 273 | |||
| 274 | 1. Are the boundaries in section 2.2 the intended ones? In particular P4: should the reference interpreters move | ||
| 275 | under `tools/` (proposed), or should `tests/semantic` be declared a library that tools may import? | ||
| 276 | 2. Complexity: production code only, limit 10 for a new function, +2 for a changed one (+5 for `main`), dispatch | ||
| 277 | arms judged one by one — accept, or which number to change? | ||
| 278 | 3. Should the job block from the first day (proposed), given the 48 of 300 pull requests it would have | ||
| 279 | stopped and the share of those that were real? | ||
| 280 | 4. Should the merge round run it before each push (proposed, since CI has not finished for most merges; section 1.4), | ||
| 281 | and should a pull request whose author reports no result be sent back? Where should the CI job live, in `ci.yml` | ||
| 282 | or a workflow of its own, and who approves an entry in the exception file? | ||
| 283 | 5. `runtime/src` includes `runtime/shims` from `main.cpp` and `pe_loader.cpp`, and the shims include `runtime/src`: | ||
| 284 | is the loader the composition root that may include both, or should one direction be forbidden? | ||
| 285 | |||
| 286 | ## 6. How the numbers were measured | ||
| 287 | |||
| 288 | - Tree: `dde82f2`. History: the 300 single-parent squash merges that end with it (`dde82f2` and the 299 before it), | ||
| 289 | each compared with its parent; the commit below them is the root of the shallow clone and only served as a base. | ||
| 290 | - Python imports: resolved from the AST, through each file's own directory and every `sys.path` set-up it performs | ||
| 291 | (`insert`, `append`, slice assignment, `extend`, paths from `conftest.py` and from an imported helper). | ||
| 292 | `importlib` loads with a constant path count as edges. The resolver is a heuristic; it left no import of a | ||
| 293 | repository module unresolved in the measured areas. | ||
| 294 | - C++ includes: quoted includes only, resolved against the including file's directory and then the union of the | ||
| 295 | include directories in `runtime/CMakeLists.txt`. | ||
| 296 | - Complexity: Python on the AST with the definition in section 2.3; C++ with lizard 1.24.1. | ||
| 297 | - Duplication: windows of six significant lines (whitespace normalised; blank lines, comments and lines with fewer | ||
| 298 | than four non-space characters skipped). | ||
| 299 | - Every blocking finding was labelled by reading its diff, by one reader: the coding agent that ran the backtest. | ||
| 300 | Each label has a one-line reason (most generated from the label's class and the measured change, five written by | ||
| 301 | hand), and the list can be posted here on request. "Genuine" and "arguable" are a | ||
| 302 | judgement about value; every finding except the 2 artefacts is a correct measurement under the rule as written. | ||
| 303 | - Not measured: how often the rules with no finding in the window (P1 to P3, P5, P6, C1, C2, D1) would be wrong. | ||
| 304 | The prototype's own test builds a small repository in which every rule fires once. | ||
| 305 | - The 300 merges are one merge round of the original repository (committed between 09:35 and 11:23 UTC-6 on 2026-11-23) of pull requests opened | ||
| 306 | over a longer time; rates per pull request may differ in other rounds. | ||
| 307 | - The merge counts in the introduction come from GitHub's search (`is:pr is:merged merged:<date>`), read on | ||
| 308 | 2026-11-23 at about 20:00 UTC. | ||
| 309 | - Section 1.4: the GraphQL search for pull requests merged on 2026-11-23, with the check suites of each one's last | ||
| 310 | commit, taking the suite of the workflow named CI; the push runs from the Actions list for `main`; the first failing | ||
| 311 | commit of each documentation test by `git bisect` between the oldest commit of the window and `867d922`, and each | ||
| 312 | pull request's checks from its page. All read on 2026-11-23 at about 20:00 UTC, before that repository went private. The | ||
| 313 | figures for this repository come from the checks of its 40 most recently merged pull requests. | ||
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md index 2b4c2d873..f5ce49d64 100644 --- a/docs/d3d12_command_objects.md +++ b/docs/d3d12_command_objects.md | |||
| @@ -120,7 +120,7 @@ these four slots. Measured on 1.0.2.1 (counts only): | |||
| 120 | | Image | `ID3D12*` IIDs it contains | Imports from `d3d12_xs.dll` | Calls at `0x40`/`0x48`/`0x60`/`0x120` on the device | | 120 | | Image | `ID3D12*` IIDs it contains | Imports from `d3d12_xs.dll` | Calls at `0x40`/`0x48`/`0x60`/`0x120` on the device | |
| 121 | |---|---|---|---| | 121 | |---|---|---|---| |
| 122 | | `XboxBvhBuilder.dll` | `PipelineState`, `RootSignature` | `D3D12SerializeVersionedRootSignature` | none: no indirect call at any of the four offsets | | 122 | | `XboxBvhBuilder.dll` | `PipelineState`, `RootSignature` | `D3D12SerializeVersionedRootSignature` | none: no indirect call at any of the four offsets | |
| 123 | | `amd_fidelityfx_upscaler_xbox.dll` | `CommandSignature`, `DescriptorHeap`, `Device`, `Heap`, `PipelineState`, `Resource`, `RootSignature`, `RootSignatureDeserializer` | `D3D12CreateRootSignatureDeserializer` | none: the 3 calls at `0x40` are `ID3D12Resource::Map` on a resource it has just created, the 29 at `0x48` are `Close`/`Unmap`-shaped calls with no `(type, &IID, &out)` arguments, the 4 at `0x60` are a function-pointer field in a plain struct (no vtable load), and there are none at `0x120` | | 123 | | `amd_fidelityfx_upscaler_xbox.dll` | `CommandSignature`, `DescriptorHeap`, `Device`, `Heap`, `PipelineState`, `Resource`, `RootSignature`, `RootSignatureDeserializer` | `D3D12CreateRootSignatureDeserializer` | none: the 3 calls at `0x40` are `ID3D12Resource::Map` on a resource it has just created, the 29 at `0x48` are `Close`/`Unmap`-shaped calls with no `(type, &IID, &out)` arguments (§2.1a explains why that shape rules out `CreateCommandAllocator`), the 4 at `0x60` are a function-pointer field in a plain struct (no vtable load), and there are none at `0x120` | |
| 124 | | `amd_fidelityfx_loader_xbox.dll`, `Bink2Scarlett.dll` | none | none | — | | 124 | | `amd_fidelityfx_loader_xbox.dll`, `Bink2Scarlett.dll` | none | none | — | |
| 125 | 125 | ||
| 126 | Neither image contains the IID of `ID3D12CommandQueue`, `ID3D12CommandAllocator`, | 126 | Neither image contains the IID of `ID3D12CommandQueue`, `ID3D12CommandAllocator`, |
| @@ -172,6 +172,83 @@ at `0x142478B56` → `0x142478B71` ([retail_boot_chain.md](retail_boot_chain.md) | |||
| 172 | `IID_ID3D12GraphicsCommandList` (`0x1461ECFA0`) is passed to slot 73 at a separate site | 172 | `IID_ID3D12GraphicsCommandList` (`0x1461ECFA0`) is passed to slot 73 at a separate site |
| 173 | (`0x1417F6D1D` → `0x1417F6D34`). | 173 | (`0x1417F6D1D` → `0x1417F6D34`). |
| 174 | 174 | ||
| 175 | ### 2.1a A byte offset is not a method: `0x48` and `0x50` | ||
| 176 | |||
| 177 | `0x48` and `0x50` are the worst pair in the whole surface because the same two numbers name a | ||
| 178 | *device factory* in one receiver and two *descriptor-heap getters* in another. The offset alone | ||
| 179 | therefore decides nothing; a call site has to be resolved to its receiver's interface first. On | ||
| 180 | the device (this page's subject) `0x48` is `CreateCommandAllocator` and `0x50` is not used at | ||
| 181 | all. On an `ID3D12DescriptorHeap` the same two offsets are `GetCPUDescriptorHandleForHeapStart` | ||
| 182 | and `GetGPUDescriptorHandleForHeapStart`, because `ID3D12DescriptorHeap` inherits | ||
| 183 | `IUnknown` + `ID3D12Object` + `ID3D12DeviceChild` (eight slots) and puts `GetDesc` at `0x40`, | ||
| 184 | the CPU getter at `0x48` and the GPU getter at `0x50` (`d3d12.h:5768`, `:5775`, `:5782`). | ||
| 185 | |||
| 186 | | Receiver | `0x48` | `0x50` | | ||
| 187 | |---|---|---| | ||
| 188 | | `ID3D12Device` | `CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE, REFIID, void**)`, `HRESULT` | — (no call site in the image) | | ||
| 189 | | `ID3D12CommandQueue` (§2.2) | `CopyTileMappings(...)`, `HRESULT` | `ExecuteCommandLists(...)`, no return | | ||
| 190 | | `ID3D12DescriptorHeap` | `GetCPUDescriptorHandleForHeapStart()`, 8-byte handle in `RAX` | `GetGPUDescriptorHandleForHeapStart()`, 8-byte handle in `RAX` | | ||
| 191 | |||
| 192 | Three interfaces, three meanings at each offset, and the shapes do not overlap, which is what | ||
| 193 | makes the resolution possible: a device factory call is `(rcx = device, edx = type, rdx = &IID, | ||
| 194 | r8 = &out)` and tests `eax`; a heap getter is `(rcx = heap)` alone and consumes `rax`; a queue | ||
| 195 | call passes list arrays or does not return a value. | ||
| 196 | |||
| 197 | **Measured, device side.** The device object lives in the global `0x148759D00` and is set up in | ||
| 198 | `0x142478440`. That function has six sites at `+0x48`: two are the device | ||
| 199 | (`0x142478B2D` with `xor edx, edx` and `0x142478C3B` with `mov edx, 2`), each passing | ||
| 200 | `&IID_ID3D12CommandAllocator` at `0x1461E0658` | ||
| 201 | (`6102dee4-af59-4b09-b999-b44d73f09b24`, `d3d12.h:5192`) and a distinct out slot; two are | ||
| 202 | `ID3D12GraphicsCommandList::Close` on the list it just created, and two are no-argument calls on | ||
| 203 | the globals `0x1475E7390`/`0x1475E7420` (the getter shape). Across the whole image, scanning the rip-relative | ||
| 204 | device load in front of every `+0x48` and `+0x50` call site finds **2 device sites at `0x48` and | ||
| 205 | none at `0x50`**: the game never calls anything at device `0x50`, so a replacement runtime | ||
| 206 | should leave that slot inert rather than guess a meaning for it. | ||
| 207 | |||
| 208 | **Measured, heap side.** `0x141CF3280` is the clearest anchor. It calls device `0x70` | ||
| 209 | (`CreateDescriptorHeap`, see §4.2 for that slot) with a `D3D12_DESCRIPTOR_HEAP_DESC` and | ||
| 210 | `&IID_ID3D12DescriptorHeap` (`0x1461E0628`, `8efb471d-616c-4f49-90f7-127bb763fa51`, | ||
| 211 | `d3d12.h:5763`), then calls the returned object at `0x48` and `0x50` with only `this`: it caches | ||
| 212 | the CPU handle, asserts it equals the expected base address, and subtracts it from the GPU | ||
| 213 | handle to store the GPU−CPU base delta. `0x141C744F0` does the same `0x70`/`0x48` pair and | ||
| 214 | strides the returned CPU handle by the `GetDescriptorHandleIncrementSize` value from device | ||
| 215 | `0x78` while filling a descriptor array. Both are `create → get handle → arithmetic`, which is | ||
| 216 | what the two getters are for. | ||
| 217 | |||
| 218 | | Shape | Site | Receiver | | ||
| 219 | |---|---|---| | ||
| 220 | | CPU getter, base for a descriptor array | `0x141C74559` | heap returned by device `0x70` | | ||
| 221 | | CPU getter, asserted against the expected base | `0x141CF3358` | heap returned by device `0x70` | | ||
| 222 | | GPU getter, minus the CPU handle = base delta | `0x141CF3392` | heap returned by device `0x70` | | ||
| 223 | |||
| 224 | **How often the shapes collide.** Of the 33 functions that contain a `+0x70` call and a `+0x48` | ||
| 225 | call, and the 81 that contain `+0x70` and `+0x50`, 19 trace a `+0x48`/`+0x50` receiver back to | ||
| 226 | the `CreateDescriptorHeap` return: 47 sites, 14 of them passing only `this`. In a heap-creating | ||
| 227 | function, a bare `(this)` call at `0x48`/`0x50` whose result comes back in `RAX` is therefore a | ||
| 228 | getter, and the `(type, &IID, &out)` form at the same offset is the device factory. | ||
| 229 | |||
| 230 | **Where one hop is not enough.** Four shapes in the same function population are *not* heap | ||
| 231 | getters and would be misfiled by offset alone: | ||
| 232 | |||
| 233 | - `0x14080C3E0` passes `plVar1[1]`, an inner object, at `0x48`/`0x50` and tests the returned | ||
| 234 | `char`: a boolean pair, not handles; | ||
| 235 | - `0x14049E200` passes an out buffer in `rdx` at `0x50`, the C `RetVal` variant from | ||
| 236 | `d3d12.h:5784`; | ||
| 237 | - `0x140087040` is a dispatch thunk that forwards `rdx`/`r8` to whichever slot matches a tag | ||
| 238 | byte, so both offsets show two extra argument registers there; | ||
| 239 | - `0x141993B30` reloads `rcx` from a factory global before its `0x50` call, so a trace that only | ||
| 240 | remembers "this register once held the heap" mislabels it. | ||
| 241 | |||
| 242 | Confidence: the device/handle distinction is **Measured**; the getter *names* come from the SDK | ||
| 243 | declarations and are matched to the measured `create → handle → arithmetic` shape, not read from | ||
| 244 | the runtime, which the package does not ship (§1.1). | ||
| 245 | |||
| 246 | Reproduce: the receiver scan disassembles each function holding a `+0x70` call, tracks the | ||
| 247 | `RAX` return into the registers and stack slots it is stored to, and prints the argument | ||
| 248 | registers in front of every `+0x48`/`+0x50` call that resolves to that object; the device side | ||
| 249 | resolves rip-relative globals to `0x148759D00` the same way. Ghidra's decompiler of | ||
| 250 | `0x141CF3280`, `0x141C744F0` and `0x142478440` shows the same three shapes in one screen. | ||
| 251 | |||
| 175 | ### 2.2 Queue, allocator and fence | 252 | ### 2.2 Queue, allocator and fence |
| 176 | 253 | ||
| 177 | `ID3D12CommandQueue` is declared at `d3d12.h:8701`. It has 19 slots (0–18); its own methods start | 254 | `ID3D12CommandQueue` is declared at `d3d12.h:8701`. It has 19 slots (0–18); its own methods start |
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index c5c4c4922..2098e348b 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -164,7 +164,7 @@ The design is therefore an **IR per command list**: | |||
| 164 | here, while the host hands out a video list (`E_NOINTERFACE` for `ID3D12GraphicsCommandList`), so they are not | 164 | here, while the host hands out a video list (`E_NOINTERFACE` for `ID3D12GraphicsCommandList`), so they are not |
| 165 | compared. | 165 | compared. |
| 166 | - `Close` freezes the IR. `ExecuteBundle` is accepted only on a direct list, with an already-closed bundle as its callee; the bundle's recorded commands and calls are replayed at the call site, so the source can be reused or reset without changing the parent. Command-list creation and reset require an allocator of the same type. A bundle cannot be submitted directly to a command queue. | 166 | - `Close` freezes the IR. `ExecuteBundle` is accepted only on a direct list, with an already-closed bundle as its callee; the bundle's recorded commands and calls are replayed at the call site, so the source can be reused or reset without changing the parent. Command-list creation and reset require an allocator of the same type. A bundle cannot be submitted directly to a command queue. |
| 167 | - Bundle restrictions are checked while recording for the IR operations currently implemented here (barriers, clears, copies, resolves, `SetPredication`, `DiscardResource`, the atomic copies, `RSSetViewports`, `RSSetScissorRects`, `OMSetRenderTargets` and `ClearState`; `WriteBufferImmediate` is allowed in a bundle); those calls are not legal inside a D3D12 bundle and make `Close` return `E_INVALIDARG`. `d3d12_bundle_forbidden_test` measured the last four on the PC runtime without the debug layer: the bundle's `Close` fails (`E_FAIL`, where this layer gives `E_INVALIDARG`) on the default adapter and on WARP, and executing a bundle whose `Close` failed crashes the runtime, so the layer refuses it in `ExecuteBundle` instead. A bundle has no render targets, viewport or root signature of its own, so its state calls (pipeline state, root signature and arguments, vertex and index buffers, topology, blend factor, stencil references) and its draws and dispatches are kept as they were called, and `ExecuteBundle` plays them on the parent through the same members the application would have called. A draw then snapshots the parent's state plus what the bundle set, and what the bundle set stays on the parent afterwards. Commands that need no state (markers, immediate writes) are copied between them in order. `d3d12_bundle_test` measured the rule on the PC runtime, where the default adapter (an RTX 4060 Ti) and WARP drew the same picture in every case it ran. A bundle's draws see the parent's render targets, viewport and scissor, root signature and arguments (also when the bundle sets the same root signature first, so those arguments stay), and vertex and index buffers. A bundle starts with the pipeline state it was created or reset with, not the parent's. After `ExecuteBundle` the parent has that pipeline state and whatever else the bundle set: topology, root arguments, vertex and index buffers, and a different root signature with the bundle's arguments in place of the parent's. Topology: the default adapter takes the parent's when the bundle sets none. That is more lenient than Microsoft's stated rule (topology is undefined when a bundle begins), and WARP follows the rule by removing the device when a bundle draws or hands back without one, so a bundle should set it; the layer follows the default adapter. A bundle that sets a root argument before any root signature crashes the NVIDIA driver (the layer applies it to the parent's signature). The deferred calls are checked when they play, against the parent's root signature, so a bad one makes the parent's `Close` fail, not the bundle's. A per-list state setter must go through the deferred path (`defer()` in `d3d12_com.cpp`, replaying through a private member that does not trace) to work in a bundle. Not deferred yet: `ExecuteIndirect` in a bundle, and bundle `Dispatch` has no GPU test. | 167 | - Bundle restrictions are checked while recording for the IR operations currently implemented here (barriers, clears, copies, resolves, `SetPredication`, `DiscardResource`, the atomic copies, `RSSetViewports`, `RSSetScissorRects`, `OMSetRenderTargets` and `ClearState`; `WriteBufferImmediate` is allowed in a bundle); those calls are not legal inside a D3D12 bundle and make `Close` return `E_INVALIDARG`. `d3d12_bundle_forbidden_test` measured the last four on the PC runtime without the debug layer: the bundle's `Close` fails (`E_FAIL`, where this layer gives `E_INVALIDARG`) on the default adapter and on WARP, and executing a bundle whose `Close` failed crashes the runtime, so the layer refuses it in `ExecuteBundle` instead. A bundle has no render targets, viewport or root signature of its own, so its state calls (pipeline state, root signature and arguments, vertex and index buffers, topology, blend factor, stencil references) and its draws and dispatches are kept as they were called, and `ExecuteBundle` plays them on the parent through the same members the application would have called. A draw then snapshots the parent's state plus what the bundle set, and what the bundle set stays on the parent afterwards. Commands that need no state (markers, immediate writes) are copied between them in order. `d3d12_bundle_test` measured the rule on the PC runtime, where the default adapter (an RTX 4060 Ti) and WARP drew the same picture in every case it ran. A bundle's draws see the parent's render targets, viewport and scissor, root signature and arguments (also when the bundle sets the same root signature first, so those arguments stay), and vertex and index buffers. A bundle starts with the pipeline state it was created or reset with, not the parent's. After `ExecuteBundle` the parent has that pipeline state and whatever else the bundle set: topology, root arguments, vertex and index buffers, and a different root signature with the bundle's arguments in place of the parent's. Topology: the default adapter takes the parent's when the bundle sets none. That is more lenient than Microsoft's stated rule (topology is undefined when a bundle begins), and WARP follows the rule by removing the device when a bundle draws or hands back without one, so a bundle should set it; the layer follows the default adapter. A bundle that sets a root argument before any root signature crashes the NVIDIA driver (the layer applies it to the parent's signature). The deferred calls are checked when they play, against the parent's root signature, so a bad one makes the parent's `Close` fail, not the bundle's. A per-list state setter must go through the deferred path (`defer()` in `d3d12_com.cpp`, replaying through a private member that does not trace) to work in a bundle. `ExecuteIndirect` in a bundle is deferred the same way (see `CreateCommandSignature` and `ExecuteIndirect` below): a single DRAW, DRAW_INDEXED, DISPATCH or DISPATCH_MESH operation with no count buffer plays at each `ExecuteBundle` with the parent's state at that call, and a count buffer or a signature with root or IA arguments makes the bundle's `Close` fail. `d3d12_bundle_indirect_dispatch` measured the DISPATCH case on the PC runtime (an RTX 4060, driver 610.88, and WARP, Windows 11 10.0.26300.9974): a bundle created with a compute pipeline and no root signature, executed twice with a different root UAV bound on the parent each time, wrote each run's counters through the parent's root UAV of that call, also when the bundle set the parent's root signature first, and a direct `Dispatch` right after the second `ExecuteBundle` (behind a UAV barrier, with no rebind) still wrote through the parent's root UAV, so the parent keeps its root signature and arguments. Both host adapters return `E_INVALIDARG` from the bundle's `Close` for a count buffer and for a root-constant signature, the code this layer gives. Bundle `Dispatch` itself has no GPU test. |
| 168 | - What `Close` returns after one recorded call is compared with the PC runtime over WARP (no debug layer) by | 168 | - What `Close` returns after one recorded call is compared with the PC runtime over WARP (no debug layer) by |
| 169 | `d3d12_close_parity_test`, 116 cases on fresh lists, nothing executed. 85 agree (three of them enhanced texture | 169 | `d3d12_close_parity_test`, 116 cases on fresh lists, nothing executed. 85 agree (three of them enhanced texture |
| 170 | barriers, two into `LAYOUT_UNDEFINED`: section 4.3); the other 31 are listed in the | 170 | barriers, two into `LAYOUT_UNDEFINED`: section 4.3); the other 31 are listed in the |
| @@ -400,9 +400,10 @@ What is implemented (all of it testable without the game): | |||
| 400 | - **Device** (`runtime/shims/d3d12_vulkan_device.cpp`): an `ID3D12Device11` (PC ABI, 80 slots) that the Xbox-ABI | 400 | - **Device** (`runtime/shims/d3d12_vulkan_device.cpp`): an `ID3D12Device11` (PC ABI, 80 slots) that the Xbox-ABI |
| 401 | proxy (`d3d12_xs_device.cpp`) forwards to, so slot 14's heap-handle conversion and slot 76's resource creation | 401 | proxy (`d3d12_xs_device.cpp`) forwards to, so slot 14's heap-handle conversion and slot 76's resource creation |
| 402 | work unchanged. It creates the objects above, plus: | 402 | work unchanged. It creates the objects above, plus: |
| 403 | - descriptor heaps whose slots are 32 bytes (`GetDescriptorHandleIncrementSize`; the console's increments are | 403 | - descriptor heaps whose slots are 32 bytes (`GetDescriptorHandleIncrementSize`). The game asks the device for the |
| 404 | question 4). RTV/DSV slots hold a `TargetView`; shader-visible heaps return a GPU handle, but nothing reads it | 404 | increment and derives heap sizes and handle strides from the answer (measured, section 3.4), so the shim returns |
| 405 | yet; | 405 | its own host slot size. RTV/DSV slots hold a `TargetView`; shader-visible heaps return a GPU handle, but nothing |
| 406 | reads it yet; | ||
| 406 | - `CreateRenderTargetView` / `CreateDepthStencilView` for whole resources, `TEXTURE1D`, `TEXTURE1DARRAY` (D3D-63), | 407 | - `CreateRenderTargetView` / `CreateDepthStencilView` for whole resources, `TEXTURE1D`, `TEXTURE1DARRAY` (D3D-63), |
| 407 | `TEXTURE2D`, `TEXTURE2DMS`, `TEXTURE2DARRAY` and `TEXTURE2DMSARRAY` (a slice range; `ArraySize` -1 is every | 408 | `TEXTURE2D`, `TEXTURE2DMS`, `TEXTURE2DARRAY` and `TEXTURE2DMSARRAY` (a slice range; `ArraySize` -1 is every |
| 408 | slice from the first on, as on the host, `d3d12_view_slices_test`); | 409 | slice from the first on, as on the host, `d3d12_view_slices_test`); |
| @@ -523,6 +524,8 @@ What is implemented (all of it testable without the game): | |||
| 523 | direct parent's state at that call. Count buffers and compound signatures remain invalid in bundles. | 524 | direct parent's state at that call. Count buffers and compound signatures remain invalid in bundles. |
| 524 | `d3d12_bundle_indirect_warp` and `d3d12_bundle_indirect_layer` compare DRAW and DRAW_INDEXED against direct | 525 | `d3d12_bundle_indirect_warp` and `d3d12_bundle_indirect_layer` compare DRAW and DRAW_INDEXED against direct |
| 525 | pixels with two different parent bindings; the layer fixture also checks marker order and captured views. | 526 | pixels with two different parent bindings; the layer fixture also checks marker order and captured views. |
| 527 | `d3d12_bundle_indirect_dispatch` checks DISPATCH the same way against the counters WARP and the default | ||
| 528 | adapter write (bundle section above). | ||
| 526 | Compound graphics signatures, non-unit instance divisors | 529 | Compound graphics signatures, non-unit instance divisors |
| 527 | and unsupported capabilities stay guarded. A GPU-counted draw currently requires | 530 | and unsupported capabilities stay guarded. A GPU-counted draw currently requires |
| 528 | `maxDrawIndirectCount == UINT32_MAX`: Vulkan also limits the raw counter value, not just the caller's maximum. | 531 | `maxDrawIndirectCount == UINT32_MAX`: Vulkan also limits the raw counter value, not just the caller's maximum. |
| @@ -2213,10 +2216,34 @@ The layer's descriptor model: | |||
| 2213 | the bound heap, and cache parsed descriptors by key so unchanged slots cost nothing. **Open:** whether the game | 2216 | the bound heap, and cache parsed descriptors by key so unchanged slots cost nothing. **Open:** whether the game |
| 2214 | uses unbounded tables; the trace will show the root-signature ranges. | 2217 | uses unbounded tables; the trace will show the root-signature ranges. |
| 2215 | - The heap stride is the value the layer returns from `GetDescriptorHandleIncrementSize`. Prior art forwards device | 2218 | - The heap stride is the value the layer returns from `GetDescriptorHandleIncrementSize`. Prior art forwards device |
| 2216 | slot 15 (`GetDescriptorHandleIncrementSize`) unchanged, but the actual increment values are still **Open**. Choose | 2219 | slot 15 (`GetDescriptorHandleIncrementSize`) unchanged. **Measured** in the executable: every one of the 943 |
| 2217 | 32 bytes for CBV/SRV/UAV (the T# size) and 32 bytes for samplers (16 bytes of S# plus padding) pending the console | 2220 | indirect calls through `[device vtable + 0x78]` was resolved by tracing `rcx` from its function's start; ten reach |
| 2218 | value. The game may hardcode the console increments or infer them from shader address arithmetic; the shader's | 2221 | the device itself: `rcx` is loaded rip-relative from the BSS device global `0x148759D00` or from one of its aliases |
| 2219 | shift amount gives the stride it expects, and the layer must match it. | 2222 | `0x1475DF000`-`0x1475DF048`, the same global the measured device calls in section 7.1 use (the load is |
| 2223 | `mov rcx, qword ptr [rip + displacement]`, so the literal address does not appear in the instruction). | ||
| 2224 | The other 933 call the same slot on another object (queue, factory, wrapper) and are counted but not attributed. | ||
| 2225 | |||
| 2226 | | site | descriptor heap type (`edx`) | what the return does | | ||
| 2227 | | --- | --- | --- | | ||
| 2228 | | `0x141C7456B` | 0 (`CBV_SRV_UAV`) | `add rdi, rax` in the slot loop: the increment advances the GPU handle stored in each entry | | ||
| 2229 | | `0x141F75FDD` | 0 (`CBV_SRV_UAV`) | the same handle-stride loop | | ||
| 2230 | | `0x142478E42` | 0 (`CBV_SRV_UAV`) | stored for later: `mov dword ptr [rip + 0x516E1AE], eax` | | ||
| 2231 | | `0x142478E5F` | 1 (`SAMPLER`) | discarded | | ||
| 2232 | | `0x142478E71` | 2 (`RTV`) | discarded | | ||
| 2233 | | `0x142478E83` | 3 (`DSV`) | discarded | | ||
| 2234 | | `0x142478E9A` | 4 (`NUM_DESCRIPTOR_HEAP_TYPES`) | discarded | | ||
| 2235 | | `0x145C5FF2F` | 0 (`CBV_SRV_UAV`) | `imul rsi, rax` and `imul rdi, rax`: two buffer sizes, each then rounded up to 64 KiB | | ||
| 2236 | | `0x145CABB18` | 0 (`CBV_SRV_UAV`) | `mov ecx, eax; div rcx`: slot count from a byte count, handed to the heap-size path (`0x141CF3280`) that multiplies it back | | ||
| 2237 | | `0x141CF32BE` | `edx` argument of its wrapper | `imul rdi, r12`: size = count x increment; the callers pass type 0 (`0x145CABB00`) or forward their own argument `0x145A54700`, itself called with types 1, 2 and 3 | | ||
| 2238 | |||
| 2239 | So the game queries the increment and derives sizes, divisions and handles from the answer: it does not hardcode a | ||
| 2240 | stride, and it is the getter, not the shader's shift, that decides it here. The layer must therefore return the | ||
| 2241 | host heap's own increment per type, never a console constant, or every size and handle walk above is wrong. In the | ||
| 2242 | two table builders the CPU-side record stride is `0x40` while the handle advances by the returned value, so the | ||
| 2243 | increment is a slot stride and a record can be wider than one slot. The bootstrap queried all five enum values but | ||
| 2244 | cached only type 0; types 1-4 reach the getter only through `0x141CF3280`. **Open:** the numeric console values | ||
| 2245 | themselves, and the console slot sizes behind them (32 bytes for CBV/SRV/UAV and for samplers stays this layer's | ||
| 2246 | choice); the shader's shift amount still has to match whatever stride the layer hands out. | ||
| 2220 | - `CopyDescriptors` copies raw bytes. If the descriptor was produced by our `Create*View`, the copy is a valid | 2247 | - `CopyDescriptors` copies raw bytes. If the descriptor was produced by our `Create*View`, the copy is a valid |
| 2221 | T#/S#; if it came from game memory, it is still valid raw data. No re-encoding is needed. | 2248 | T#/S#; if it came from game memory, it is still valid raw data. No re-encoding is needed. |
| 2222 | - Handle validation: a GPU descriptor handle is an arena VA; the heap registry maps the containing range to a | 2249 | - Handle validation: a GPU descriptor handle is an arena VA; the heap registry maps the containing range to a |
| @@ -3264,13 +3291,13 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 3264 | 3291 | ||
| 3265 | | D3D12 / Xbox object | Vulkan / layer object | Notes | | 3292 | | D3D12 / Xbox object | Vulkan / layer object | Notes | |
| 3266 | |---|---|---| | 3293 | |---|---|---| |
| 3267 | | `ID3D12Device` … `ID3D12Device11` | one `Device` object with the public chain plus measured Xbox overrides | The shipped BVH builder names Device11; slots 1/15/18/19/27/38 matched desktop in prior art, slot 48 is called as `(desc, riid, out)` with `IID_ID3D12CommandQueue` (PC slot 48 is `OpenExistingHeapFromAddress`; the 32-byte desc is a PC `D3D12_COMMAND_QUEUE_DESC` plus four Xbox words, logged once, and the proxy takes the slot 8 path with the PC prefix and only `DISABLE_GPU_TIMEOUT` kept), slot 62 is called as `CreateComputePipelineState`, slot 76 is Xbox texture creation, and heap slots 9/10 return in RAX. Unknown Xbox IIDs/slots are logged and refused. | | 3294 | | `ID3D12Device` … `ID3D12Device11` | one `Device` object with the public chain plus measured Xbox overrides | The shipped BVH builder names Device11; slots 1/15/18/19/27/38 matched desktop in prior art, slot 48 is called as `(desc, riid, out)` with `IID_ID3D12CommandQueue` (PC slot 48 is `OpenExistingHeapFromAddress`; the 32-byte desc is a PC `D3D12_COMMAND_QUEUE_DESC` plus four Xbox words, logged once, and the proxy takes the slot 8 path with the PC prefix and only `DISABLE_GPU_TIMEOUT` kept), slot 62 is called at `0x14247FE66` as a create with `(desc, 0, 0, &riid, &out)` — five parameters with an explicit IID/out pair, where the PC method it forwards to, `CreateComputePipelineState`, takes three — and static Capstone disassembly over the executable's `.text` (following the device globals `0x148759D00` and `0x1475DF000`–`0x1475DF048` from renderer init `0x142478440`) finds no device call site for slot 76 (`+0x260`; none of the 57 indirect `call [reg+0x260]` sites in `.text` loads a device global); its only measured caller is the shipped FidelityFX upscaler, with the seven `CreateCommittedResource` arguments ([d3d12_command_objects.md](d3d12_command_objects.md) §3.5a), and heap slots 9/10 return in RAX. Unknown Xbox IIDs/slots are logged and refused. | |
| 3268 | | `ID3D12CommandQueue` | one leased `VkQueue` per live queue: direct queues on the graphics family, compute queues on an async-compute family and copy queues on a transfer-only (DMA) family when the GPU has them (`src/queue_families.h`), else graphics-family leases | Distinct Vulkan queues allow cross-queue waits and signals to make progress. With more than one family in use, buffers, images, the arena and staging are created `VK_SHARING_MODE_CONCURRENT` over those families, so no ownership transfers are needed. Barriers on copy and compute queues are narrowed to the stages their family has; render-target and depth clears are refused there (as in D3D12), and the D24/RGB96 copy conversions and bindless flushes stay off a transfer-only queue. Tested by `vk_queue_test`. `PresentX`, `SuspendX`, `ResumeX` are Xbox queue methods, not in the public vtable; public GDKX samples present only through them (§4.5). Call shapes known, slots **Open**. | | 3295 | | `ID3D12CommandQueue` | one leased `VkQueue` per live queue: direct queues on the graphics family, compute queues on an async-compute family and copy queues on a transfer-only (DMA) family when the GPU has them (`src/queue_families.h`), else graphics-family leases | Distinct Vulkan queues allow cross-queue waits and signals to make progress. With more than one family in use, buffers, images, the arena and staging are created `VK_SHARING_MODE_CONCURRENT` over those families, so no ownership transfers are needed. Barriers on copy and compute queues are narrowed to the stages their family has; render-target and depth clears are refused there (as in D3D12), and the D24/RGB96 copy conversions and bindless flushes stay off a transfer-only queue. Tested by `vk_queue_test`. `PresentX`, `SuspendX`, `ResumeX` are Xbox queue methods, not in the public vtable; public GDKX samples present only through them (§4.5). Call shapes known, slots **Open**. | |
| 3269 | | `ID3D12CommandAllocator` | IR arena + `VkCommandPool` | Reset only when the previous submission's fence is complete. | | 3296 | | `ID3D12CommandAllocator` | IR arena + `VkCommandPool` | Reset only when the previous submission's fence is complete. | |
| 3270 | | `ID3D12GraphicsCommandList` … `8` | `CommandList` with IR | Replay at `ExecuteCommandLists`; bundles inlined. Supports render passes, mesh dispatch, enhanced barriers; records the GCL8 front/back stencil references (applied only once a pipeline path consumes them). `Draw` views are inlined and moved into the command stream (D3D-289), eliminating per-draw heap allocations. | | 3297 | | `ID3D12GraphicsCommandList` … `8` | `CommandList` with IR | Replay at `ExecuteCommandLists`; bundles inlined. Supports render passes, mesh dispatch, enhanced barriers; records the GCL8 front/back stencil references (applied only once a pipeline path consumes them). `Draw` views are inlined and moved into the command stream (D3D-289), eliminating per-draw heap allocations. | |
| 3271 | | `ID3D12RootSignature` | `RootSignature` + `VkPipelineLayout` | Deserialize the blob with the host `D3D12CreateVersionedRootSignatureDeserializer` when possible; clear the measured `0x03000000` flag byte on a copy first; fall back to a local parser. Build the user-SGPR map and static samplers. | | 3298 | | `ID3D12RootSignature` | `RootSignature` + `VkPipelineLayout` | Deserialize the blob with the host `D3D12CreateVersionedRootSignatureDeserializer` when possible; clear the measured `0x03000000` flag byte on a copy first; fall back to a local parser. Build the user-SGPR map and static samplers. | |
| 3272 | | `ID3D12PipelineState` | `VkPipeline` + a `PipelineInfo` | Shader hash → SPIR-V + index entry; PSO state → Vulkan state; dynamic state where possible. The BVH builder's compute PSOs arrive at device slot 62 with a plain `D3D12_COMPUTE_PIPELINE_STATE_DESC`. | | 3299 | | `ID3D12PipelineState` | `VkPipeline` + a `PipelineInfo` | Shader hash → SPIR-V + index entry; PSO state → Vulkan state; dynamic state where possible. The BVH builder's compute PSOs arrive at device slot 62 with a plain `D3D12_COMPUTE_PIPELINE_STATE_DESC`. | |
| 3273 | | `ID3D12DescriptorHeap` | `DescriptorHeap` (shadow + optional arena range) | CBV/SRV/UAV and sampler heaps can be shader-visible; RTV/DSV are host-only. Start handles use the measured RAX return at heap slots 9/10. Increments are layer-chosen (32/32) pending the console value. | | 3300 | | `ID3D12DescriptorHeap` | `DescriptorHeap` (shadow + optional arena range) | CBV/SRV/UAV and sampler heaps can be shader-visible; RTV/DSV are host-only. Start handles use the measured RAX return at heap slots 9/10. The game derives heap sizes and handle strides from `GetDescriptorHandleIncrementSize` (measured call sites, section 3.4), so the layer returns its own slot size (32/32) rather than a console value. | |
| 3274 | | `ID3D12Resource` | `Resource` (a range in the arena buffer; a separate `VkImage` for textures) | Committed, placed and reserved. Reserved buffers use sparse memory where supported (section 4.2). Xbox textures may arrive through device slot 76. `GetGPUVirtualAddress` returns a console VA (a buffer offset or an image key). | | 3301 | | `ID3D12Resource` | `Resource` (a range in the arena buffer; a separate `VkImage` for textures) | Committed, placed and reserved. Reserved buffers use sparse memory where supported (section 4.2). Xbox textures may arrive through device slot 76. `GetGPUVirtualAddress` returns a console VA (a buffer offset or an image key). | |
| 3275 | | `ID3D12Heap` | `Heap` (a reserved VA range) | Buffer ranges are backed by the arena; images get ranges of shared blocks or their own `VkDeviceMemory` (section 3.3). Residency calls are no-ops. True buffer/image aliasing inside a heap is **Open**. | | 3302 | | `ID3D12Heap` | `Heap` (a reserved VA range) | Buffer ranges are backed by the arena; images get ranges of shared blocks or their own `VkDeviceMemory` (section 3.3). Residency calls are no-ops. True buffer/image aliasing inside a heap is **Open**. | |
| 3276 | | `ID3D12Fence` / `ID3D12Fence1` | `Fence` over a timeline `VkSemaphore` | `GetCompletedValue` = counter value; `SetEventOnCompletion` = wait thread + Win32 event; CPU `Signal` = host signal. | | 3303 | | `ID3D12Fence` / `ID3D12Fence1` | `Fence` over a timeline `VkSemaphore` | `GetCompletedValue` = counter value; `SetEventOnCompletion` = wait thread + Win32 event; CPU `Signal` = host signal. | |
| @@ -3652,11 +3679,15 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 3652 | - Sampled title images can use device-local memory even when Vulkan host image copies require a | 3679 | - Sampled title images can use device-local memory even when Vulkan host image copies require a |
| 3653 | host-visible memory type. The runtime queries the same image with and without host-transfer usage. | 3680 | host-visible memory type. The runtime queries the same image with and without host-transfer usage. |
| 3654 | When only the latter permits plain device-local backing, it detiles the complete image into a reusable | 3681 | When only the latter permits plain device-local backing, it detiles the complete image into a reusable |
| 3655 | staging buffer and transfers all its mips and layers together. Linear slot-133 placements retain host | 3682 | staging buffer and transfers all its mips and layers together. Linear slot-133 placements use host |
| 3656 | copies. On a device without `VK_EXT_host_image_copy` every colour title image, linear placements too, takes the | 3683 | copies when the image supports them. |
| 3657 | staged upload: the refresh before a submission has no other way to fill one, and without it the title's textures | 3684 | A CPU-visible, single-sampled colour title image that needs no format conversion uses the staged upload |
| 3658 | stayed zero (a flat green intro movie). An allocation failure retries the original host-copyable image. | 3685 | if the device, format or image usage lacks host-transfer support, or if the host-transfer image has no |
| 3659 | `LEONIDA_TITLE_IMAGE_STAGING=0` | 3686 | compatible memory type. The runtime logs that last case once per Vulkan format. A GTX 1050 Ti on |
| 3687 | NVIDIA 582.66 reported it for R8_UNORM, R8G8B8A8_UNORM and BC1_RGBA_UNORM_BLOCK. | ||
| 3688 | [GTX 1050 Ti test results](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7174515492) | ||
| 3689 | When both placements are available, an allocation failure on the staged path retries the original | ||
| 3690 | host-copyable image. `LEONIDA_TITLE_IMAGE_STAGING=0` | ||
| 3660 | restores the original placement policy. With `LEONIDA_MEM_PROBE`, each title image class logs its | 3691 | restores the original placement policy. With `LEONIDA_MEM_PROBE`, each title image class logs its |
| 3661 | Vulkan memory type mask, mask without host transfer, and selected type. | 3692 | Vulkan memory type mask, mask without host transfer, and selected type. |
| 3662 | - `WriteToSubresource`/`ReadFromSubresource` (implemented in `d3d12_vulkan_device.cpp`) complete before they | 3693 | - `WriteToSubresource`/`ReadFromSubresource` (implemented in `d3d12_vulkan_device.cpp`) complete before they |
| @@ -3678,7 +3709,8 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 3678 | the host refuses and the layer copies on purpose. | 3709 | the host refuses and the layer copies on purpose. |
| 3679 | - A driver can report `VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT` for a format, create the image with | 3710 | - A driver can report `VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT` for a format, create the image with |
| 3680 | host-transfer usage, and then give it no memory type (`memoryTypeBits = 0`). This was measured on a GTX 1050 Ti | 3711 | host-transfer usage, and then give it no memory type (`memoryTypeBits = 0`). This was measured on a GTX 1050 Ti |
| 3681 | with NVIDIA 582.78, and the validation layer of Vulkan SDK 1.4.363 reports nothing. Such a texture is made again | 3712 | with NVIDIA 582.78 and again with 582.66 on Windows 10 (#1364), where the same image without host-transfer usage |
| 3713 | takes device-local memory; the validation layer of Vulkan SDK 1.4.363 reports nothing. Such a texture is made again | ||
| 3682 | without host-transfer usage before it is bound, and takes the staging path. `d3d12_vulkan_device_test` and | 3714 | without host-transfer usage before it is bound, and takes the staging path. `d3d12_vulkan_device_test` and |
| 3683 | `d3d12_subresource_copy_test` force this branch on any GPU with `VulkanDeviceInfo::force_host_transfer_retry` | 3715 | `d3d12_subresource_copy_test` force this branch on any GPU with `VulkanDeviceInfo::force_host_transfer_retry` |
| 3684 | (their third CPU-copy path; the second compares it with the host runtime). | 3716 | (their third CPU-copy path; the second compares it with the host runtime). |
| @@ -3879,13 +3911,52 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 3879 | and 2^32 in alpha match WARP). `d3d12_clear_test` compares full and rectangular D3D12 readbacks with WARP across | 3911 | and 2^32 in alpha match WARP). `d3d12_clear_test` compares full and rectangular D3D12 readbacks with WARP across |
| 3880 | UNORM, SNORM, FLOAT, all 15 exposed UINT/SINT render targets (11 value vectors, including 8-/16-/10-/2-bit range | 3912 | UNORM, SNORM, FLOAT, all 15 exposed UINT/SINT render targets (11 value vectors, including 8-/16-/10-/2-bit range |
| 3881 | boundaries) and depth/stencil; `clear_color_test` checks both replay paths for 19 integer formats without a GPU, | 3913 | boundaries) and depth/stencil; `clear_color_test` checks both replay paths for 19 integer formats without a GPU, |
| 3882 | including unchanged float values. SRGB clears are omitted from the comparison: the | 3914 | including unchanged float values. SRGB clears are omitted from that comparison; `d3d12_clear_formats_test` |
| 3883 | linear→sRGB encoding rounds differently at the `.5` boundary on WARP vs Vulkan (a 1-ulp driver difference). | 3915 | compares them (next item). |
| 3884 | **Open:** on NVIDIA RTX 5080 (driver 616.56) clears that land exactly on a `.5` UNORM/SNORM step round down where | 3916 | **Open:** on NVIDIA RTX 5080 (driver 616.56) clears that land exactly on a `.5` UNORM/SNORM step round down where |
| 3885 | WARP rounds up: `R8G8B8A8_UNORM`/`SNORM` 0.5 store `7f`/`3f` vs WARP `80`/`40`, and a `D16_UNORM` 0.5 depth clear | 3917 | WARP rounds up: `R8G8B8A8_UNORM`/`SNORM` 0.5 store `7f`/`3f` vs WARP `80`/`40`, and a `D16_UNORM` 0.5 depth clear |
| 3886 | stores `0x7fff` vs WARP `0x8000` (all on `main` before this change; same 1-ulp class as SRGB, not addressed here). | 3918 | stores `0x7fff` vs WARP `0x8000` (all on `main` before this change; same 1-ulp class as SRGB, not addressed here). |
| 3887 | `D32_FLOAT` and `D32_FLOAT_S8X24_UINT` match WARP. | 3919 | `D32_FLOAT` and `D32_FLOAT_S8X24_UINT` match WARP. |
| 3888 | This does not add typed-view reinterpretation of typeless resources. | 3920 | This does not add typed-view reinterpretation of typeless resources. |
| 3921 | - **sRGB RTV clears (D3D-CLEAR-SRGB-ENCODE):** `ClearRenderTargetView` through an `R8G8B8A8_UNORM_SRGB` or | ||
| 3922 | `B8G8R8A8_UNORM_SRGB` view encodes the colour channels in the layer and hands Vulkan the linear value of the | ||
| 3923 | resulting code (`srgb8_from_linear` and `srgb8_linear` in `vulkan_replay.h`); alpha is linear and rounds like | ||
| 3924 | UNORM. Before, the linear float went to `vkCmdClearColorImage` or `vkCmdClearAttachments` as it was and the GPU | ||
| 3925 | encoded it, so the stored byte depended on the GPU: 0.5 was `bb` on an Intel Iris Xe and `bc` on WARP and an | ||
| 3926 | NVIDIA RTX 4060. **Measured** (Windows 11 build 26100, WARP 10.0.26100.5074, Iris Xe with Intel 32.0.101.7092, RTX | ||
| 3927 | 4060 Laptop with NVIDIA 616.92; a scratch program cleared 256-slice sRGB targets through the layer and through | ||
| 3928 | WARP, a whole view and a rectangle each, and bisected over float bit patterns): | ||
| 3929 | - No driver is wrong. D3D permits FLOAT → SRGB a tolerance of 0.6 of a step (Direct3D 11.3 functional | ||
| 3930 | specification, 3.2.3.8), and each implementation puts the 255 steps between two codes somewhere else: measured | ||
| 3931 | against the halfway point of the ideal curve, the Iris Xe's sit between 0.18 of a code below and 0.33 above, the | ||
| 3932 | RTX 4060's within 0.10 and WARP's between 0.29 below and 0.34 above. On each GPU both Vulkan commands have the | ||
| 3933 | same 255 steps. Of 60 000 random values (half uniform in 0..1, half log-uniform from 1e-6) the Iris Xe stored | ||
| 3934 | another byte than WARP for 6 649 and the RTX 4060 for 3 648, never more than one code away. | ||
| 3935 | - WARP takes the value to 12 bits first and encodes that: `j = floor(x * 4095 + 0.5)` with the product rounded to | ||
| 3936 | single precision, then the nearest code of the IEC 61966-2-1 curve at `j / 4095`. The 255 floats at which WARP's | ||
| 3937 | byte changes are the 255 this rule gives (with the product in exact arithmetic only 188 are: `0x3f018018` times | ||
| 3938 | 4095 is 2071.4999986, which a float rounds to 2071.5), and WARP agrees with it on 84 582 further values: every | ||
| 3939 | 12-bit value, five floats around each of the 4 095 places between two of them, the 60 000 random ones, 0, 1, | ||
| 3940 | values outside 0..1, NaN and both infinities. It is not the nearest code of the ideal curve for 2 852 of the | ||
| 3941 | 60 000 (0.0004 is 2, the curve gives 1.32). | ||
| 3942 | - WARP and both GPUs store the linear value of a code as that code, for all 256 codes and with both commands. That | ||
| 3943 | value is the one farthest from any implementation's steps, so it is what the layer hands over; a GPU whose | ||
| 3944 | encoding is more than half a code off at one of these values would still differ. | ||
| 3945 | - Each GPU's own D3D12 driver stores what its Vulkan driver stores (the same byte for 84 582 of 84 582 values, on | ||
| 3946 | both GPUs): the encoding is the hardware's. So the layer used to store the bytes of the D3D12 driver of the GPU it | ||
| 3947 | ran on, and now stores WARP's on every GPU, which differ from the Intel driver's for those 6 649 of 60 000 values | ||
| 3948 | and from the NVIDIA driver's for 3 648. That is the choice made before for the ties of UNORM clears and for D24: | ||
| 3949 | the layer converts, WARP is the reference, and a host driver that does otherwise is a host quirk. | ||
| 3950 | |||
| 3951 | `clear_color_test` (no GPU) pins 38 values to the bytes WARP stored, checks that every code encodes to itself and | ||
| 3952 | that the result is the same under each floating-point rounding mode. `d3d12_clear_formats_test` clears both formats | ||
| 3953 | to the UNORM colours, the value of every code and the value halfway between every two codes (176 colours each, as | ||
| 3954 | a whole view and as a rectangle): against WARP, 178 of the 352 cases differed on the Iris Xe and 170 on the RTX | ||
| 3955 | 4060 before, none after (the five UNORM colours alone differed in 10 of 10 cases on the Iris Xe and in none on the | ||
| 3956 | RTX 4060). `d3d12_state_sweep_test` compares with the D3D12 driver of the same adapter and cleared its sRGB targets | ||
| 3957 | to 0.2, 0.4 and 0.6, of which the first two are codes 124 and 170 on WARP and 123 and 169 on the Iris Xe; it now | ||
| 3958 | clears them to the values of codes 124, 170 and 203, so its eight sRGB cases compare the blending whichever way | ||
| 3959 | the host encodes. A draw into an sRGB target is still encoded by the GPU. | ||
| 3889 | - **Depth clears.** Microsoft documents a `[0, 1]` clamp. On Windows 11 build 26100, both WARP and native D3D12 on | 3960 | - **Depth clears.** Microsoft documents a `[0, 1]` clamp. On Windows 11 build 26100, both WARP and native D3D12 on |
| 3890 | an RTX 5070 Ti (610.74) preserved finite out-of-range `D32_FLOAT` values and quiet NaN in full and rectangle | 3961 | an RTX 5070 Ti (610.74) preserved finite out-of-range `D32_FLOAT` values and quiet NaN in full and rectangle |
| 3891 | clears. Replay preserves those values when the Vulkan device has enabled `VK_EXT_depth_range_unrestricted`. | 3962 | clears. Replay preserves those values when the Vulkan device has enabled `VK_EXT_depth_range_unrestricted`. |
| @@ -3901,6 +3972,49 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 3901 | and the specular sparkles. Create them with the format the game asks for (`R8G8B8A8_UNORM` and the like) and don't | 3972 | and the specular sparkles. Create them with the format the game asks for (`R8G8B8A8_UNORM` and the like) and don't |
| 3902 | substitute a wider or float format for them. | 3973 | substitute a wider or float format for them. |
| 3903 | 3974 | ||
| 3975 | <a id="xg-swizzle-linear-path"></a> | ||
| 3976 | #### The title already supports the linear tile path (`XG-SWIZZLE-LINEAR-PATH`) | ||
| 3977 | |||
| 3978 | Read statically in 1.0.2.1; nothing was executed. Both `xg_xs.dll` imports are adjacent IAT thunks: | ||
| 3979 | `XGCreateTextureComputer` at `0x145F3FF40` (`JMP [0x146793F60]`) and `XGSuggestSwizzleMode` at | ||
| 3980 | `0x145F3FF50` (`JMP [0x146793F68]`). | ||
| 3981 | |||
| 3982 | `XGSuggestSwizzleMode` has one shape at both call sites, `0x140C4B3CE` (in `0x140C4B030`) and | ||
| 3983 | `0x144ECCCA2` (in `0x144ECC940`). The helper loads the description's tile-class byte `[desc+8]`, | ||
| 3984 | compares it with `0xFF` (`0x140C4B3B5`, `0x144ECCB00`/`0x144ECCB28`) and calls only on equality, so | ||
| 3985 | the class is unknown. The arguments are `RCX` = the description block being filled, `RDX` = 0 | ||
| 3986 | (`XOR EDX,EDX`) and `R8` = `RCX+0x2C` (`LEA R8,[RCX+0x2C]`), the block's 32-bit tile-mode field — | ||
| 3987 | i.e. `XGSuggestSwizzleMode(desc, NULL, &desc->tileMode)`. Both helpers zero the block at `+0x28` | ||
| 3988 | first, so that field is 0 unless a class is known; a known class writes `0x100 | class` (with | ||
| 3989 | `0x102` and `0x10A` as special cases) and never 0. The result the callee writes is therefore the | ||
| 3990 | mode, and 0 is already the value the title uses for "linear" everywhere. | ||
| 3991 | |||
| 3992 | The consumers test that mode word as tiled with `CMP x,0x100` plus `BT x,9` (bits 8 and 9) and | ||
| 3993 | run the linear arithmetic on the `0` result: | ||
| 3994 | |||
| 3995 | - `0x14555E9E0`, test at `0x14555EA2C`: 0 stores 0 at `[out+8]` and returns | ||
| 3996 | `pitch*(row+…) + x` at `0x14555EA45`. | ||
| 3997 | - `0x14193DE10`, test at `0x14193DE73`: 0 goes to `0x14193DE9E` (which builds a layout through | ||
| 3998 | `0x140C4B030` at `0x14193E06B` and then calls `0x1416F7100` from `0x14193DF4B`), not to the | ||
| 3999 | tiled branch at `0x14193E314`. | ||
| 4000 | - `0x1404F4210`, test at `0x1404F448A`: 0 takes `0x1404F44E4`. | ||
| 4001 | - `0x145121690` takes its non-`0x980` path and calls the computer's `+0x40` with offset 0 and a | ||
| 4002 | `pitch*height` span. | ||
| 4003 | |||
| 4004 | What a shim can do with that: `XGSuggestSwizzleMode` writes `0` and returns `S_OK`, and | ||
| 4005 | `XGCreateTextureComputer` can hand back an object whose slots used at these sites (2, 8, 10 and | ||
| 4006 | `+0x40`) pass the byte offset through and report the full linear row span. The linear paths above | ||
| 4007 | compute `pitch*row + x` themselves and ask the object only for an offset, so nothing has to model | ||
| 4008 | a tile. `FUN_145121980` (`0x145121980`) is not the mode test but a cache: `0x144DB9180` keys it on | ||
| 4009 | the description bytes, `0xE` and `(flags&0xFF)<<16 | mode`, and it builds a tiled layout only on a | ||
| 4010 | miss, so an identity computer still has to answer whatever that branch asks. | ||
| 4011 | |||
| 4012 | What is not established: `0x102` and `0x10A` are written by the two helpers, but the four | ||
| 4013 | consumers above only special-case `0x100` and bit 9, so whether the variants are meant to be tiled | ||
| 4014 | was not measured. The physical layout of a non-zero mode is not new here either | ||
| 4015 | ([textures.md](textures.md), `runtime/src/gfx10_tiling.h`); 0 is the choice of the linear layout, | ||
| 4016 | not a description of one. | ||
| 4017 | |||
| 3904 | ### 4.3 Barriers and layouts | 4018 | ### 4.3 Barriers and layouts |
| 3905 | 4019 | ||
| 3906 | Plain buffer copies order earlier transfer writes on the same queue before reading or writing the next range. | 4020 | Plain buffer copies order earlier transfer writes on the same queue before reading or writing the next range. |
| @@ -4930,6 +5044,27 @@ when it cannot sample the submission lock for that long. A progress warning leav | |||
| 4930 | device state intact. The driver checkpoint and fault-info queries run after Vulkan reports device loss. This mode | 5044 | device state intact. The driver checkpoint and fault-info queries run after Vulkan reports device loss. This mode |
| 4931 | is off by default. | 5045 | is off by default. |
| 4932 | 5046 | ||
| 5047 | Each fault address is also looked up in this process (RT-FAULT-ADDRESS-OWNER). On Windows, `VirtualQuery` of the | ||
| 5048 | same number gives the region's base, allocation base, state, protection and type. A GPU address isn't a CPU one, | ||
| 5049 | but a host import, a range of the title's memory and a raw CPU pointer that reached a shader all share the | ||
| 5050 | number. With `LEONIDA_ADDRESS_BINDINGS=1` as well, the device enables `VK_EXT_device_address_binding_report`, and | ||
| 5051 | a debug messenger records the GPU virtual address range of every buffer, image and allocation the driver binds | ||
| 5052 | and unbinds (`runtime/src/address_binding.h`). The fault report then lists, for each address: | ||
| 5053 | - the live objects that contain the address ("containing"), and those that only share its reported page, whose | ||
| 5054 | size is the fault's `addressPrecision` ("on the page"); | ||
| 5055 | - the live objects that end nearest below it and start nearest above it; | ||
| 5056 | - up to 16 recently unbound objects that held it, with their type, range, handle and the times they were bound | ||
| 5057 | and unbound. | ||
| 5058 | |||
| 5059 | "Nothing live or recently unbound there" means that no object of this device had that GPU address. On an | ||
| 5060 | RTX 5070 Ti the world-start loss of 1.0.2.1 reported write addresses far above every bound range, at about 50,000 | ||
| 5061 | binds. The record keeps the last 16,384 unbinds and costs one map entry per live binding. | ||
| 5062 | |||
| 5063 | There is one record per process. A second Vulkan instance in the same process (a second device) is refused a | ||
| 5064 | messenger, and its device doesn't enable the extension, so the two devices' GPU addresses aren't mixed. If | ||
| 5065 | `LEONIDA_ADDRESS_BINDINGS=1` is set but no messenger records the device, the fault report says that the bindings | ||
| 5066 | were not recorded, so this can't be mistaken for "nothing live or recently unbound there". | ||
| 5067 | |||
| 4933 | Each dispatch line carries a `seq`: a number every recorded dispatch gets, across queues and submissions, in the | 5068 | Each dispatch line carries a `seq`: a number every recorded dispatch gets, across queues and submissions, in the |
| 4934 | order the submissions were recorded. The list keeps the last 64, so its numbers can have gaps where a submission | 5069 | order the submissions were recorded. The list keeps the last 64, so its numbers can have gaps where a submission |
| 4935 | recorded more than that. | 5070 | recorded more than that. |
| @@ -5358,7 +5493,7 @@ nothing is copied from their trees. | |||
| 5358 | | 1 | The device entry point is now named `D3D12XboxCreateDevice(adapter, params, riid, out)`. What do its 24-word params and flag bits mean? | Public documentation and the executable's call sites. Log the words and accept any flag bits; do not treat a wrong params layout as fatal until the fields are understood. | | 5493 | | 1 | The device entry point is now named `D3D12XboxCreateDevice(adapter, params, riid, out)`. What do its 24-word params and flag bits mean? | Public documentation and the executable's call sites. Log the words and accept any flag bits; do not treat a wrong params layout as fatal until the fields are understood. | |
| 5359 | | 2 | Which Xbox device/heap/queue/command-list slots differ? Prior art measured device slots 62 and 76 and descriptor-heap slots 9/10; slot 14 is the public `CreateDescriptorHeap`, with only the returned heap's start-handle return wrapped. **Partly measured** with the FSR DLL ([d3d12_command_objects.md §3.5a](d3d12_command_objects.md)): device slots 14, 15, 16, 18, 19, 27, 38, 62 and 76 at their expected shapes (24 in the code, not called), slot 67 a console-only pipeline call; command-list slots 14, 15, 25 and 26 at their PC positions, then shifted (+4 from `SetDescriptorHeaps` at 32, +2 at `ExecuteIndirect` at 61), with console-only methods at 85 and 141. The BVH builder's call sites add the rest of the +4 root group (37, 39, 43, 45) and console slots 71, 73, 80, 146 (the GCL7 `Barrier`) and 148 (an upload allocator whose pointer is also the GPU address) ([d3d12_command_objects.md §3.3, §3.3a](d3d12_command_objects.md)). A second, retail-title measurement adds console slots 83 (`CopyTextureRegion`), 84 (`CopyResource`), 26 (barriers), 127 (direct mesh dispatch — not the PC position, GCL6 slot 79), 59 (a second indirect/mesh dispatch path) and 96 (an async-compute budget call) (section 7). Presentation, queue and fence slots remain unknown. | Trace every `QueryInterface` and every method slot with per-slot hit counters. A wrong slot shows as an immediate crash or wrong argument; compare against the SDK vtable. | | 5494 | | 2 | Which Xbox device/heap/queue/command-list slots differ? Prior art measured device slots 62 and 76 and descriptor-heap slots 9/10; slot 14 is the public `CreateDescriptorHeap`, with only the returned heap's start-handle return wrapped. **Partly measured** with the FSR DLL ([d3d12_command_objects.md §3.5a](d3d12_command_objects.md)): device slots 14, 15, 16, 18, 19, 27, 38, 62 and 76 at their expected shapes (24 in the code, not called), slot 67 a console-only pipeline call; command-list slots 14, 15, 25 and 26 at their PC positions, then shifted (+4 from `SetDescriptorHeaps` at 32, +2 at `ExecuteIndirect` at 61), with console-only methods at 85 and 141. The BVH builder's call sites add the rest of the +4 root group (37, 39, 43, 45) and console slots 71, 73, 80, 146 (the GCL7 `Barrier`) and 148 (an upload allocator whose pointer is also the GPU address) ([d3d12_command_objects.md §3.3, §3.3a](d3d12_command_objects.md)). A second, retail-title measurement adds console slots 83 (`CopyTextureRegion`), 84 (`CopyResource`), 26 (barriers), 127 (direct mesh dispatch — not the PC position, GCL6 slot 79), 59 (a second indirect/mesh dispatch path) and 96 (an async-compute budget call) (section 7). Presentation, queue and fence slots remain unknown. | Trace every `QueryInterface` and every method slot with per-slot hit counters. A wrong slot shows as an immediate crash or wrong argument; compare against the SDK vtable. | |
| 5360 | | 3 | How does the console map a root signature to `s0..s31` (order, per-stage visibility, spills above 32 dwords, static samplers, direct-heap base)? | **Compute partly measured** by a sibling project's console-compiler output (section 7): parameters inline in user SGPRs from `s4` in root order while each fits whole; the first that does not fit, and all after it, go into a packed array addressed by a 40-bit pointer at `s[0:1]`; thread-group ids follow the user SGPRs. That matches this repo's CS census (lowest CS pointer SGPR `s4`). VS/PS/MS bases remain open. Static samplers: no sampling instruction was found reading one from a driver table (SHADER-735, section 3.5; 0.66% undetermined); which S# is a static sampler remains open. Dump the game's root-signature blobs with the host deserializer; mask the `0x03000000` flag byte on a copy first; match against the per-shader user-SGPR read sets. If a signature exceeds 32 dwords, reverse the spill pointer from the shader. | | 5495 | | 3 | How does the console map a root signature to `s0..s31` (order, per-stage visibility, spills above 32 dwords, static samplers, direct-heap base)? | **Compute partly measured** by a sibling project's console-compiler output (section 7): parameters inline in user SGPRs from `s4` in root order while each fits whole; the first that does not fit, and all after it, go into a packed array addressed by a 40-bit pointer at `s[0:1]`; thread-group ids follow the user SGPRs. That matches this repo's CS census (lowest CS pointer SGPR `s4`). VS/PS/MS bases remain open. Static samplers: no sampling instruction was found reading one from a driver table (SHADER-735, section 3.5; 0.66% undetermined); which S# is a static sampler remains open. Dump the game's root-signature blobs with the host deserializer; mask the `0x03000000` flag byte on a copy first; match against the per-shader user-SGPR read sets. If a signature exceeds 32 dwords, reverse the spill pointer from the shader. | |
| 5361 | | 4 | Are Xbox descriptor bytes GFX10 T#/S#, and what are the heap increments? Does the game use `Create*View` or build descriptors itself? | Dump a shader-visible heap after the first `CreateShaderResourceView` and after the first draw; compare the bytes the shader loads with the T# parser. The start-handle return ABI is known (RAX); the increment values still need measuring. | | 5496 | | 4 | Are Xbox descriptor bytes GFX10 T#/S#, and what are the heap increments? Does the game use `Create*View` or build descriptors itself? | Dump a shader-visible heap after the first `CreateShaderResourceView` and after the first draw; compare the bytes the shader loads with the T# parser. The start-handle return ABI is known (RAX). The game calls `GetDescriptorHandleIncrementSize` itself (ten device sites, all five heap types, section 3.4) and sizes heaps and handles from the answer; the numeric console values still need measuring, by hooking slot 15 and logging the answer. | |
| 5362 | | 5 | What is the buffer/descriptor/code VA range, and what arena capacity is needed? | Log every `GetGPUVirtualAddress` and every descriptor base; track the high-water mark. Choose a capacity; grow at a frame boundary if needed. | | 5497 | | 5 | What is the buffer/descriptor/code VA range, and what arena capacity is needed? | Log every `GetGPUVirtualAddress` and every descriptor base; track the high-water mark. Choose a capacity; grow at a frame boundary if needed. | |
| 5363 | | 6 | Which swapchain/present path is used: DXGI, `PresentX`, or both? | **Partly answered from public samples (§4.5):** GDKX samples use `PresentX` + frame events and no DXGI swapchain (DXGI only for `IDXGIDevice1`→adapter→output). Hypothesis for the game, not observed: same. Still open: vtable slots, `D3D12XBOX_*` layouts, and whether the game also creates a swapchain. Check imports and the first present call. Implement the `PresentX` + frame-event presenter first; keep DXGI swapchain as fallback. | | 5498 | | 6 | Which swapchain/present path is used: DXGI, `PresentX`, or both? | **Partly answered from public samples (§4.5):** GDKX samples use `PresentX` + frame events and no DXGI swapchain (DXGI only for `IDXGIDevice1`→adapter→output). Hypothesis for the game, not observed: same. Still open: vtable slots, `D3D12XBOX_*` layouts, and whether the game also creates a swapchain. Check imports and the first present call. Implement the `PresentX` + frame-event presenter first; keep DXGI swapchain as fallback. | |
| 5364 | | 7 | Does the game build acceleration structures through the standard D3D12 calls or through `XboxBvhBuilder`'s own compute path? | Log `BuildRaytracingAccelerationStructure`, `CopyRaytracingAccelerationStructure`, `Emit...PostbuildInfo`, and the builder's command-list method calls on the first RT frame. The builder's container carries a DXIL bitcode blob and a console `XBCH` record; the record is `FSSM` and all 52 programs pass `spirv-val` ([embedded_shaders.md](embedded_shaders.md)). If the builder path is used, translate the `XBCH` record rather than the bitcode. | | 5499 | | 7 | Does the game build acceleration structures through the standard D3D12 calls or through `XboxBvhBuilder`'s own compute path? | Log `BuildRaytracingAccelerationStructure`, `CopyRaytracingAccelerationStructure`, `Emit...PostbuildInfo`, and the builder's command-list method calls on the first RT frame. The builder's container carries a DXIL bitcode blob and a console `XBCH` record; the record is `FSSM` and all 52 programs pass `spirv-val` ([embedded_shaders.md](embedded_shaders.md)). If the builder path is used, translate the `XBCH` record rather than the bitcode. | |
diff --git a/docs/descriptor_lookup_ampere.md b/docs/descriptor_lookup_ampere.md new file mode 100644 index 000000000..440d7ec06 --- /dev/null +++ b/docs/descriptor_lookup_ampere.md | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | # Descriptor lookup cost on NVIDIA RTX 3070 (Ampere) | ||
| 2 | |||
| 3 | Divergent lookups in host-visible system RAM showed a steep cliff once the table reached 100,000 entries on this PCIe 3.0 x16 Ampere card with Resizable BAR off. On the GPU-only memory type, one million logical lane lookups took 270.3 µs at 1,000 live descriptors, 773.3 µs at 10,000 and 2,502.6 µs at 100,000 for divergent misses, and 73.0, 94.3 and 231.9 µs for divergent texture hits. The 214 MiB BAR1 memory type (`DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT`, exposed even with Resizable BAR disabled) stayed within 0.5% of GPU-only in every cell across all three sizes. By contrast, host-visible memory outside VRAM stayed within 10% of GPU-only at 1,000 entries and within 16% at 10,000, but at 100,000 entries it was 5.0× slower for uniform texture hits, 14.2× slower for divergent texture hits, 21.9× slower for divergent T#+S# pairs and 22.6× slower for divergent misses. These are synthetic compute results from one GeForce RTX 3070 on an idle Windows 11 desktop with NVIDIA driver 621.24. The benchmark ran unchanged at `5d74c27` (with the current default `--warmup-ms 300`). | ||
| 4 | |||
| 5 | ## Measurements | ||
| 6 | |||
| 7 | Each cell is gross GPU time in **µs per million logical lane lookups**, including key reads and result accumulation. The benchmark also prints a figure with a key-read baseline subtracted (summarised below). The table uses its gross column so it compares directly with the [RTX 4070 SUPER (Ada) run](descriptor_lookup_ada.md). | ||
| 8 | |||
| 9 | | Live descriptors | Memory type | Uniform T# hit | Uniform S# hit | Divergent T# hit | Divergent T#+S# pair | Divergent miss | | ||
| 10 | |---:|:---|---:|---:|---:|---:|---:| | ||
| 11 | | 1,000 | GPU-only | 15.0 | 15.1 | 73.0 | 68.2 | 270.3 | | ||
| 12 | | 1,000 | Host-visible | 16.5 | 16.4 | 71.3 | 69.9 | 267.6 | | ||
| 13 | | 1,000 | BAR1 (`host_device_local`) | 15.0 | 15.1 | 73.0 | 68.2 | 270.3 | | ||
| 14 | | 10,000 | GPU-only | 15.5 | 15.0 | 94.3 | 115.9 | 773.3 | | ||
| 15 | | 10,000 | Host-visible | 16.8 | 17.0 | 104.4 | 134.4 | 880.7* | | ||
| 16 | | 10,000 | BAR1 (`host_device_local`) | 15.5 | 15.0 | 94.4 | 115.4 | 771.7 | | ||
| 17 | | 100,000 | GPU-only | 21.7 | 15.7 | 231.9 | 216.6 | 2,502.6 | | ||
| 18 | | 100,000 | Host-visible | 108.0 | 18.4 | 3,290.5 | 4,734.5 | 56,519.6* | | ||
| 19 | | 100,000 | BAR1 (`host_device_local`) | 21.7 | 15.8 | 231.8 | 216.7 | 2,499.3 | | ||
| 20 | |||
| 21 | \* Shortened by the benchmark's Windows timeout guard in all 12 rounds (see Method). | ||
| 22 | |||
| 23 | Net timings (after subtracting the matching key-read baseline) at 100,000 entries were: GPU-only `14.6`, `8.6`, `207.6`, `204.5`, `2,478.3`; BAR1 `14.6`, `8.6`, `207.5`, `204.6`, `2,475.1`; Host-visible `101.0`, `11.5`, `3,265.5`, `4,722.4`, `56,495.1*` µs per million. | ||
| 24 | |||
| 25 | At 100,000 entries on type 1 (GPU-only), a divergent T# dispatch took 3.89 ms, a T#+S# dispatch took 7.27 ms and a divergent miss dispatch took 41.99 ms. Each paired iteration resolves two descriptors. | ||
| 26 | |||
| 27 | GPU-only is type 1, `DEVICE_LOCAL`, on heap 0 (8,018 MiB). Host-visible is type 3, `HOST_VISIBLE | HOST_COHERENT` without `HOST_CACHED`, on heap 1 (16,345 MiB, not device-local). BAR1 (`host_device_local`, selected by `--memory rebar`) is type 5, `DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT`, on heap 2 (214 MiB). Resizable BAR was **off**: `nvidia-smi` reported a 256 MiB BAR1 aperture (227 MiB used, 29 MiB free at idle), and every allocation on type 5 still succeeded up to the 20.0 MiB table. On this card, keeping the descriptor table out of non-device-local host-visible RAM matters far more at 100,000 entries than on the [Ada PCIe 4.0 + ReBAR card](descriptor_lookup_ada.md) (14.2×–22.6× penalty on divergent traffic here vs 1.45×–2.5× there), while the 214 MiB BAR1 heap remained within 0.5% of GPU-only VRAM in every cell whenever the table fit inside it. | ||
| 28 | |||
| 29 | At 100,000 entries on GPU-only and BAR1, the 12 round medians split deterministically by which table size ran first in the process: the four rounds that started with 1,000 entries (rounds 1, 5, 8 and 12) measured 167.4–167.9 µs per million for divergent T# hits and 1,791.5–1,791.9 for divergent misses; the four that started with 10,000 entries (rounds 3, 6, 7 and 10) measured 231.8–232.1 and 2,498.4–2,505.4; and the four that started with 100,000 entries (rounds 2, 4, 9 and 11) measured 232.2–232.9 and 2,581.9–2,591.8. The table medians follow the eight rounds that did not start at 1,000 entries. The cause was not measured. | ||
| 30 | |||
| 31 | The tables contain 90% T# texture keys and 10% S# sampler keys. Their allocations were 163,844, 2,621,444 and 20,971,524 bytes (0.156, 2.50 and 20.0 MiB). The capacities were 4,096, 65,536 and 524,288 slots, at 24.4%, 15.3% and 19.1% load. At 100,000 entries the ordinary uniform hit runs covered all 90,000 textures or all 10,000 samplers. Each workgroup shared a key for each iteration. The separate hot-key control (`uniform_hot_tsharp`) reused one texture and measured 12.8–13.1 µs per million gross (5.7–6.8 µs net) across all three memory types and sizes. Divergent misses visited 1,024, 16,384 and 131,072 distinct absent keys across the three sizes. Cache residency and memory traffic were unmeasured. | ||
| 32 | |||
| 33 | ## Method and replay | ||
| 34 | |||
| 35 | Each dispatch used 4,096 groups of 64 lanes and 64 iterations. The RTX 3070 reported 32-lane subgroups (`minSubgroupSize = maxSubgroupSize = 32`). The denominator was 16,777,216 logical lookups per single-key dispatch and 33,554,432 per paired dispatch, counting the texture and sampler separately. Vulkan timestamps bracketed one dispatch. The compute queue advertised 64 valid bits and a 1 ns tick period. | ||
| 36 | |||
| 37 | Each cell is the median of 12 process medians, each from 25 timed dispatches after five warmups plus the default `--warmup-ms 300` clock-warmup window (TEST-277). The 11 scenarios ran in the benchmark's fixed order. There were 36 processes: three memory types in each of 12 rounds. Across them there were 29,124 timed dispatches. Every process exited 0, wrote nothing to stderr and reported `timing_status` `ok` on all 1,188 rows. The run used the default Windows Vulkan loader with validation layers off and `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` set to keep overlay layers out of the run; desktop GPU utilization at idle was 2% (993 MiB VRAM used, P5). | ||
| 38 | |||
| 39 | As in the [Ada run](descriptor_lookup_ada.md), this run kept the default `--max-dispatch-ms 120` guard to stay clear of the Windows 2 s GPU timeout (TDR). Only host-visible cells were shortened, all 12 of 12 rounds: at 10,000 entries, `divergent_miss` ran with 13–26 iterations (median dispatch 4.38 ms, range 1.60–6.37 ms); at 100,000 entries, `divergent_miss` ran with 19 iterations in all 12 rounds (median dispatch 281.51 ms, range 276.11–285.21 ms) and `latency_divergent` (outside the summary table; gross median 8,135.0 µs per million) ran with 26 iterations in all 12 rounds (median dispatch 55.45 ms, range 47.57–56.15 ms). | ||
| 40 | |||
| 41 | From a Leonida checkout on Windows, with Visual Studio C++ tools, CMake + Ninja, Windows SDK 10.0.26100+ and Vulkan headers (`VULKAN_SDK` or `-DLEONIDA_VULKAN_HEADERS_FETCH=ON`): | ||
| 42 | |||
| 43 | ```powershell | ||
| 44 | runtime\build\vk_descriptor_bench.exe --list-devices | ||
| 45 | runtime\build\vk_descriptor_bench.exe --self-test | ||
| 46 | $env:DISABLE_RTSS_LAYER = "1" | ||
| 47 | $env:DISABLE_VULKAN_OBS_CAPTURE = "1" | ||
| 48 | foreach ($memory in 'device', 'host', 'rebar') { | ||
| 49 | runtime\build\vk_descriptor_bench.exe --device 0 --memory $memory --sizes 1000,10000,100000 ` | ||
| 50 | --groups 4096 --iters 64 --warmup 5 --reps 25 --warmup-ms 300 --csv | ||
| 51 | } | ||
| 52 | ``` | ||
| 53 | |||
| 54 | Device 0 was the RTX 3070, the only Vulkan device. For the full 12-round series, let A, B and C denote 1k, 10k and 100k. The rounds used the same size orders and starting memory types as the [M3 Max](descriptor_lookup_apple.md) and [Ada](descriptor_lookup_ada.md) runs: the first six size orders were ABC, CBA, BAC, CAB, ACB and BCA, starting with `device`, `host`, `device`, `device`, `host` and `host` respectively; the next six reversed the sequence of rounds and swapped the starting memory type in each, with `rebar` third in every round. | ||
| 55 | |||
| 56 | ## System | ||
| 57 | |||
| 58 | | | | | ||
| 59 | |:---|:---| | ||
| 60 | | GPU | NVIDIA GeForce RTX 3070 (Ampere), 8,192 MiB (discrete) | | ||
| 61 | | PCI id | `0x10de:0x2488`, subsystem `0x404e1458` | | ||
| 62 | | Link | PCIe 3.0 x16 (current and maximum reported by `nvidia-smi`; B450 AORUS M) | | ||
| 63 | | Resizable BAR | Off (BAR1 aperture 256 MiB, `nvidia-smi -q -d MEMORY`; Vulkan heap 2 reports 214 MiB `DEVICE_LOCAL \| HOST_VISIBLE \| HOST_COHERENT`) | | ||
| 64 | | Subgroup size | 32 | | ||
| 65 | | Driver | NVIDIA 621.24 (`nvidia-smi`), Vulkan API 1.4.357 | | ||
| 66 | | OS | Windows 11 Pro 26H2, build 26300.9974 | | ||
| 67 | | Vulkan headers | 1.4.363.0 (`-DLEONIDA_VULKAN_HEADERS_FETCH=ON`) | | ||
| 68 | | Compiler | Visual Studio 18 Professional (MSVC 19.51.36260.0), `RelWithDebInfo` via CMake + Ninja | | ||
diff --git a/docs/design.md b/docs/design.md index fa7e34a4e..d11c33206 100644 --- a/docs/design.md +++ b/docs/design.md | |||
| @@ -300,7 +300,7 @@ How the generated SPIR-V expects the runtime to work: | |||
| 300 | |---|---| | 300 | |---|---| |
| 301 | | Heap-relative buffer device addresses | `Gen.host_addr` sign-extends the low 48 bits of the effective VA after adding any byte offset, then adds `%heap_base`. The runtime stores `device_address - heap_base` in a V#'s 48-bit base field. NVIDIA's Windows driver can place an imported buffer below the heap, so that offset is negative. Zero extension made the resulting device address too high by `2^48`. Console user-mode VAs below `2^47` and full-width root descriptor addresses already within the signed 48-bit range retain their values. A 64-bit base-plus-offset sum gives the correct address for effective VAs in that range, including when the sum crosses zero. Each new shader's `index.json` entry carries `"vsharp_base_sign_extended": true`. Check the field on all loaded entries before enabling below-arena imports for a library, because older modules can share an index with newly translated ones. `tests/semantic/test_vsharp_sext48.py` checks the emitted shifts, both reads against synthetic memory, and the metadata field. | | 301 | | Heap-relative buffer device addresses | `Gen.host_addr` sign-extends the low 48 bits of the effective VA after adding any byte offset, then adds `%heap_base`. The runtime stores `device_address - heap_base` in a V#'s 48-bit base field. NVIDIA's Windows driver can place an imported buffer below the heap, so that offset is negative. Zero extension made the resulting device address too high by `2^48`. Console user-mode VAs below `2^47` and full-width root descriptor addresses already within the signed 48-bit range retain their values. A 64-bit base-plus-offset sum gives the correct address for effective VAs in that range, including when the sum crosses zero. Each new shader's `index.json` entry carries `"vsharp_base_sign_extended": true`. Check the field on all loaded entries before enabling below-arena imports for a library, because older modules can share an index with newly translated ones. `tests/semantic/test_vsharp_sext48.py` checks the emitted shifts, both reads against synthetic memory, and the metadata field. | |
| 302 | | Null sources in 64-bit integer VALU compares | `v_cmp` and `v_cmpx` relations `eq`, `ne`, `lt`, `le`, `gt`, `ge` on `u64` and `i64` read `null` as the 64-bit value 0 in either source, like immediate `0`. Register pairs and immediates retain their existing semantics; `v_cmp` writes the active lane's comparison to VCC/SGPR, while `v_cmpx` narrows EXEC without changing VCC. Source: RDNA2 ISA special operand `null` reads zero; LLVM `llvm-mc -mcpu=gfx1013` accepts the encoding. CPU-checked by `tests/semantic/test_vcmp64_null_src.py` (both sources, signed/unsigned ordering, equality, e32/e64, EXEC and inactive lanes); **not GPU-verified, no corpus count**. | | 302 | | Null sources in 64-bit integer VALU compares | `v_cmp` and `v_cmpx` relations `eq`, `ne`, `lt`, `le`, `gt`, `ge` on `u64` and `i64` read `null` as the 64-bit value 0 in either source, like immediate `0`. Register pairs and immediates retain their existing semantics; `v_cmp` writes the active lane's comparison to VCC/SGPR, while `v_cmpx` narrows EXEC without changing VCC. Source: RDNA2 ISA special operand `null` reads zero; LLVM `llvm-mc -mcpu=gfx1013` accepts the encoding. CPU-checked by `tests/semantic/test_vcmp64_null_src.py` (both sources, signed/unsigned ordering, equality, e32/e64, EXEC and inactive lanes); **not GPU-verified, no corpus count**. | |
| 303 | | `s_load_dword*` with `vcc` 64-bit base pointer | SMEM `s_load_dword*` accepts `vcc` (`{vcc_lo, vcc_hi}`, hardware `s[106:107]`) as its 64-bit base pointer in `Gen.scalar_load`, loading `%vcc` as the low dword and `%vcc_hi` as the high dword; `s_buffer_load*` still requires a 4-dword V# and rejects 2-dword `vcc`. Source: RDNA2 ISA SMEM `SBASE` encoding (`sbase = 53` -> `s[106:107] = vcc`). Confirmed by corpus count over the 2,684-shader pipeline library compute corpus (79 shaders use `vcc` as the `s_load` base: 72 `s_load_dwordx4 sgpr, vcc`, 6 `s_load_dwordx8 sgpr, vcc`, 1 `s_load_dwordx4 slist, vcc`; all 79 translate and pass `spirv-val` under `--wave64-emulate`) and CPU-checked by `tests/semantic/test_sload_vcc_base.py` (`spirv-as` + `spirv-val`) and `tests/semantic/test_scalar_mem_smem.py` (both halves and the resulting addresses); **not GPU-verified**: the synthetic `runtime/test/shaders/cs_smem_vcc_base.asm` reads back eight seeded words through the pair in the standard GPU runner. | | 303 | | `s_load_dword*` with `vcc` 64-bit base pointer | SMEM `s_load_dword*` accepts `vcc` (`{vcc_lo, vcc_hi}`, hardware `s[106:107]`) as its 64-bit base pointer in `Gen.scalar_load`, loading `%vcc` as the low dword and `%vcc_hi` as the high dword; `s_buffer_load*` still requires a 4-dword V# and rejects 2-dword `vcc`. Source: RDNA2 ISA SMEM `SBASE` encoding (`sbase = 53` -> `s[106:107] = vcc`). Confirmed by corpus count over the 2,684-shader pipeline library compute corpus (79 shaders use `vcc` as the `s_load` base: 72 `s_load_dwordx4 sgpr, vcc`, 6 `s_load_dwordx8 sgpr, vcc`, 1 `s_load_dwordx4 slist, vcc`; all 79 translate and pass `spirv-val` under `--wave64-emulate`) and CPU-checked by `tests/semantic/test_sload_vcc_base.py` (`spirv-as` + `spirv-val`) and `tests/semantic/test_scalar_mem_smem.py` (both halves and the resulting addresses); **GPU-checked** with the synthetic `runtime/test/shaders/cs_smem_vcc_base.asm`, which reads back the eight seeded words through the pair in the standard GPU runner (`0x7210..0x7217`): on an AMD Radeon gfx1036 iGPU (Ryzen 7 7800X3D, Windows 11, driver 32.0.21045.29003) and, under `LEONIDA_W64_EMULATE=1`, on an NVIDIA GeForce RTX 4090 (Windows 11, driver 32.0.16.2124); without the emulation the fixture skips on the 4090 (no 64-wide compute subgroup). Still not measured: those eight words of one fixture are the whole hardware check, the 79-program corpus count stays a translation count, and there is no native 32-wide-subgroup run of this form. | |
| 304 | | Execution model | One invocation = one lane. Compute and mesh waves derive lanes from the workgroup-local index; other stages use the subgroup lane. A wave = a subgroup, so cross-lane ops (`ds_swizzle`, `v_permlane*`, `v_readlane`/`v_writelane`, `v_mbcnt`) become subgroup shuffles. Wave32 pixel shaders split a 64-lane physical subgroup into two logical waves: lane IDs are `SubgroupLocalInvocationId & 31`, shuffle sources retain the current half (`& 32`), and ballots/votes use that half's 32-bit word. A value the translator knows is uniform (the bindless descriptor index) is read from the half's first running lane, never from a fixed lane, which need not be running (SHADER-1016). Other stage/wave combinations still require subgroup size == wave size or wave64 emulation. **Requires subgroup size == wave size** (wave32 maps directly onto NVIDIA GPUs; wave64 shaders need a 64-wide subgroup or emulation). `v_readlane_b32`/`v_writelane_b32` mask the lane select with 63 in wave64 (`S1[5:0]`) and 31 in wave32 (`S1[4:0]`); until SHADER-52 both used 63, so a wave32 select ≥ 32 pointed past a 32-wide subgroup. GPU-checked with `cs_w32_lane_wrap.asm` (lane 40 → 8). For the fragment-half rule, `ps_bitmask_perm` produced 4096/4096 exact pixels on an AMD Radeon RX 5700 XT; Vulkan reported a default subgroup size of 64 (range 32..64), but does not permit pinning fragment subgroup size on this device. CPU semantic tests compare a 64-lane wave32 pixel subgroup against two 32-lane subgroups for reads/writes, permutations, ballots, and votes. | | 304 | | Execution model | One invocation = one lane. Compute and mesh waves derive lanes from the workgroup-local index; other stages use the subgroup lane. A wave = a subgroup, so cross-lane ops (`ds_swizzle`, `v_permlane*`, `v_readlane`/`v_writelane`, `v_mbcnt`) become subgroup shuffles. Wave32 pixel shaders split a 64-lane physical subgroup into two logical waves: lane IDs are `SubgroupLocalInvocationId & 31`, shuffle sources retain the current half (`& 32`), and ballots/votes use that half's 32-bit word. A value the translator knows is uniform (the bindless descriptor index) is read from the half's first running lane, never from a fixed lane, which need not be running (SHADER-1016). Other stage/wave combinations still require subgroup size == wave size or wave64 emulation. **Requires subgroup size == wave size** (wave32 maps directly onto NVIDIA GPUs; wave64 shaders need a 64-wide subgroup or emulation). `v_readlane_b32`/`v_writelane_b32` mask the lane select with 63 in wave64 (`S1[5:0]`) and 31 in wave32 (`S1[4:0]`); until SHADER-52 both used 63, so a wave32 select ≥ 32 pointed past a 32-wide subgroup. GPU-checked with `cs_w32_lane_wrap.asm` (lane 40 → 8). For the fragment-half rule, `ps_bitmask_perm` produced 4096/4096 exact pixels on an AMD Radeon RX 5700 XT; Vulkan reported a default subgroup size of 64 (range 32..64), but does not permit pinning fragment subgroup size on this device. CPU semantic tests compare a 64-lane wave32 pixel subgroup against two 32-lane subgroups for reads/writes, permutations, ballots, and votes. | |
| 305 | | DPP | VOP1/VOP2 `_dpp` applies to src0. DPP16 controls (`quad_perm`, `row_shl/shr/ror/share/xmask/mirror/half_mirror`) and DPP8 (`dpp8` + `fi`) select the source lane, then `row_mask` (one bit per 16-lane row) and `bank_mask` (one bit per 4-lane bank) decide which destination lanes update. A lane whose row/bank is off is not written. A source lane outside the row is invalid: `bound_ctrl` 1 uses 0 as src0, otherwise the lane is not written. Hardware applies src0 float modifiers (`neg`/`abs`) after the invalid-lane zero selection, so `-src0` on an invalid lane yields `-0.0f` (`0x80000000`) and `\|src0\|` yields `+0.0f` (HW-DPP-NEG-INVALID-LANE, measured on RDNA3 (gfx1101) RX 7800 XT, RDNA2 not measured; tested by `tests/semantic/test_dpp_bound_ctrl_modifiers.py`). A source lane inactive under EXEC is used when `fi` is 1; otherwise `bound_ctrl` decides. DPP8 always writes an enabled lane: `fi` 1 reads the inactive source, `fi` 0 uses 0. DPP16/8 never leaves its 16/8-lane group, so this is exact on every subgroup at least that wide; under `--wave64-emulate` the exchange goes through the workgroup buffer like the other cross-lane ops. GPU-checked with `runtime/test/shaders/cs_dpp*.asm` on an RTX 3070 and hardware-measured on an RX 6800. On an RX 6700 XT (gfx1031), `tools/crosslane_fuzz.py --dpp-sweep --oracle hw` checks every DPP16 control × `bound_ctrl` × `fi`, every `row_mask`/`bank_mask` pair and the DPP8 selects in wave32 and wave64: 14,412 cases, all matching these rules (BUILD-162, `docs/shader_validation.md` FUZZ-7). The ballot of the source lanes' EXEC bits and the shuffle are each stored to a Function variable of their own (`Gen.eager`): SPIRV-Cross (MoltenVK) inlines a single-use result into the expression that uses it, which put the ballot on the right of a short-circuiting `&&` and the shuffle in a ternary's arm, so lanes out of their row skipped the ballot and row_shr:1's lane 1 found lane 0 inactive (`cs_dpp_ops` on MoltenVK; SHADER-529). A store is a statement every lane runs. For native FI=0, the source-lane ballot bit also selects the shuffle index: an absent or EXEC-off source is redirected to the current subgroup lane before `OpGroupNonUniformShuffle`, because masking an undefined shuffle result afterwards is not sufficient; FI=1 is unchanged. CPU-checked by `tests/semantic/test_dpp_eager_subgroup.py::test_fi0_shuffle_index_is_ballot_safe` with a hand-written `quad_perm` case whose active lane 6 reads absent lane 7 in a seven-invocation wave; **not GPU-verified**. Checked in SPIRV-Cross 1.3.239's MSL for the `cs_dpp*` tests (each op is now its own statement) and by `tests/semantic/test_dpp_eager_subgroup.py`; not yet run on a Mac. Semantics from the RDNA2 ISA, AMD LLVM modifier syntax and the GPUOpen DPP notes. | | 305 | | DPP | VOP1/VOP2 `_dpp` applies to src0. DPP16 controls (`quad_perm`, `row_shl/shr/ror/share/xmask/mirror/half_mirror`) and DPP8 (`dpp8` + `fi`) select the source lane, then `row_mask` (one bit per 16-lane row) and `bank_mask` (one bit per 4-lane bank) decide which destination lanes update. A lane whose row/bank is off is not written. A source lane outside the row is invalid: `bound_ctrl` 1 uses 0 as src0, otherwise the lane is not written. Hardware applies src0 float modifiers (`neg`/`abs`) after the invalid-lane zero selection, so `-src0` on an invalid lane yields `-0.0f` (`0x80000000`) and `\|src0\|` yields `+0.0f` (HW-DPP-NEG-INVALID-LANE, measured on RDNA3 (gfx1101) RX 7800 XT, RDNA2 not measured; tested by `tests/semantic/test_dpp_bound_ctrl_modifiers.py`). A source lane inactive under EXEC is used when `fi` is 1; otherwise `bound_ctrl` decides. DPP8 always writes an enabled lane: `fi` 1 reads the inactive source, `fi` 0 uses 0. DPP16/8 never leaves its 16/8-lane group, so this is exact on every subgroup at least that wide; under `--wave64-emulate` the exchange goes through the workgroup buffer like the other cross-lane ops. GPU-checked with `runtime/test/shaders/cs_dpp*.asm` on an RTX 3070 and hardware-measured on an RX 6800. On an RX 6700 XT (gfx1031), `tools/crosslane_fuzz.py --dpp-sweep --oracle hw` checks every DPP16 control × `bound_ctrl` × `fi`, every `row_mask`/`bank_mask` pair and the DPP8 selects in wave32 and wave64: 14,412 cases, all matching these rules (BUILD-162, `docs/shader_validation.md` FUZZ-7). The ballot of the source lanes' EXEC bits and the shuffle are each stored to a Function variable of their own (`Gen.eager`): SPIRV-Cross (MoltenVK) inlines a single-use result into the expression that uses it, which put the ballot on the right of a short-circuiting `&&` and the shuffle in a ternary's arm, so lanes out of their row skipped the ballot and row_shr:1's lane 1 found lane 0 inactive (`cs_dpp_ops` on MoltenVK; SHADER-529). A store is a statement every lane runs. For native FI=0, the source-lane ballot bit also selects the shuffle index: an absent or EXEC-off source is redirected to the current subgroup lane before `OpGroupNonUniformShuffle`, because masking an undefined shuffle result afterwards is not sufficient; FI=1 is unchanged. CPU-checked by `tests/semantic/test_dpp_eager_subgroup.py::test_fi0_shuffle_index_is_ballot_safe` with a hand-written `quad_perm` case whose active lane 6 reads absent lane 7 in a seven-invocation wave; **not GPU-verified**. Checked in SPIRV-Cross 1.3.239's MSL for the `cs_dpp*` tests (each op is now its own statement) and by `tests/semantic/test_dpp_eager_subgroup.py`; not yet run on a Mac. Semantics from the RDNA2 ISA, AMD LLVM modifier syntax and the GPUOpen DPP notes. | |
| 306 | | DPP on a VOPC compare | A VOPC compare whose src0 field is a DPP marker (250 for DPP16, 233/234 for DPP8) takes src0 through the DPP lane selection of the row above and writes VCC: a lane's bit is `compare(src0 of the selected lane, its own src1)`, with 0 for src0 when the selected lane is out of its row or inactive (`bound_ctrl` 1, or DPP8 with `fi` 0). The second word has the layout of a VOP2's DPP word. `llvm-mc` has no decoding for it on gfx10 (LLVM 21.1.8 rejects the first word for `gfx1013`; LLVM defines the form from GFX11 on), so `tools/shader_disasm.py` prints it: it decodes the pair with the first word turned into `v_max_f32` into `v0`, which takes the same second word, and gives the line the compare's name, a `vcc_lo` destination and the real encoding back (`with_vopc_dpp`); `tools/rdna2_decode.py` decodes it directly. **Only the forms where every lane writes its bit are translated**: `row_mask` and `bank_mask` 0xF and either `bound_ctrl` 1 or DPP8. Any other form is refused (`DPP compare with lanes DPP leaves unwritten`), because what such a lane writes is measured only on RDNA3, not on RDNA2. On RDNA3 (gfx1101, RX 7800 XT, `tools/hw_oracle`, wave32 and wave64; [measurement](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161289307)) a lane DPP leaves unwritten does not keep its bit: `v_cmp` writes 0 to its VCC bit and `v_cmpx` turns it off in EXEC. That holds for an invalid source with `bound_ctrl` 0, and for a lane `row_mask` or `bank_mask` turns off, even with `bound_ctrl` 1. Translating these forms on RDNA2 (gfx1013) would need the same measurement there. `v_cmpx` in DPP form takes the same lane selection and the same forms, and writes EXEC as the plain `v_cmpx` does (a lane that was off stays off); it prints no destination, so its src0 is the first operand (SHADER-VOPCX-DPP). Found in 3 of the 2,684 pipeline-library compute programs of 1.0.2.1: 4 `v_cmp_gt_f32` each, with `quad_perm:[1,0,3,2]`, `quad_perm:[2,3,0,1]`, `row_ror:8` (all `bound_ctrl:1`, masks 0xF) and `dpp8:[4,5,6,7,0,1,2,3]`, beside `v_min/max_f32_dpp` and `v_mov_b32_dpp` on the same lanes. `v_cmpx` in DPP form is in 78 of the 18,837 graphics programs of the pipeline library (all pixel shaders, 113 instructions), all `v_cmpx_gt_f32_dpp vN, -vM quad_perm:[2,3,0,1] row_mask:0xf bank_mask:0xf bound_ctrl:1 fi:1`, a compare against the lane two above or below in its quad. **Not measured on RDNA2 hardware**: the rule follows from the encoding, from LLVM's GFX11 definition of the same form and from the VOP2 DPP rules measured in the row above; the sweep that measured those (`tools/crosslane_fuzz.py --dpp-sweep --oracle hw`) does not cover compares. The RDNA3 measurement above also ran the translated forms (`bound_ctrl` 1, masks 0xF): an invalid source lane gets the compare of a 0 source, as the rule says. Lane values are checked in `tests/semantic/test_dpp_compare.py` (the SPIR-V interpreter) and on a GPU with `runtime/test/shaders/cs_dpp_cmp.asm` and, for `v_cmpx`, `cs_dpp_cmpx.asm` (RTX 4070 Laptop, native wave32 and `--wave64-emulate`). | | 306 | | DPP on a VOPC compare | A VOPC compare whose src0 field is a DPP marker (250 for DPP16, 233/234 for DPP8) takes src0 through the DPP lane selection of the row above and writes VCC: a lane's bit is `compare(src0 of the selected lane, its own src1)`, with 0 for src0 when the selected lane is out of its row or inactive (`bound_ctrl` 1, or DPP8 with `fi` 0). The second word has the layout of a VOP2's DPP word. `llvm-mc` has no decoding for it on gfx10 (LLVM 21.1.8 rejects the first word for `gfx1013`; LLVM defines the form from GFX11 on), so `tools/shader_disasm.py` prints it: it decodes the pair with the first word turned into `v_max_f32` into `v0`, which takes the same second word, and gives the line the compare's name, a `vcc_lo` destination and the real encoding back (`with_vopc_dpp`); `tools/rdna2_decode.py` decodes it directly. **Only the forms where every lane writes its bit are translated**: `row_mask` and `bank_mask` 0xF and either `bound_ctrl` 1 or DPP8. Any other form is refused (`DPP compare with lanes DPP leaves unwritten`), because what such a lane writes is measured only on RDNA3, not on RDNA2. On RDNA3 (gfx1101, RX 7800 XT, `tools/hw_oracle`, wave32 and wave64; [measurement](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161289307)) a lane DPP leaves unwritten does not keep its bit: `v_cmp` writes 0 to its VCC bit and `v_cmpx` turns it off in EXEC. That holds for an invalid source with `bound_ctrl` 0, and for a lane `row_mask` or `bank_mask` turns off, even with `bound_ctrl` 1. Translating these forms on RDNA2 (gfx1013) would need the same measurement there. `v_cmpx` in DPP form takes the same lane selection and the same forms, and writes EXEC as the plain `v_cmpx` does (a lane that was off stays off); it prints no destination, so its src0 is the first operand (SHADER-VOPCX-DPP). Found in 3 of the 2,684 pipeline-library compute programs of 1.0.2.1: 4 `v_cmp_gt_f32` each, with `quad_perm:[1,0,3,2]`, `quad_perm:[2,3,0,1]`, `row_ror:8` (all `bound_ctrl:1`, masks 0xF) and `dpp8:[4,5,6,7,0,1,2,3]`, beside `v_min/max_f32_dpp` and `v_mov_b32_dpp` on the same lanes. `v_cmpx` in DPP form is in 78 of the 18,837 graphics programs of the pipeline library (all pixel shaders, 113 instructions), all `v_cmpx_gt_f32_dpp vN, -vM quad_perm:[2,3,0,1] row_mask:0xf bank_mask:0xf bound_ctrl:1 fi:1`, a compare against the lane two above or below in its quad. **Not measured on RDNA2 hardware**: the rule follows from the encoding, from LLVM's GFX11 definition of the same form and from the VOP2 DPP rules measured in the row above; the sweep that measured those (`tools/crosslane_fuzz.py --dpp-sweep --oracle hw`) does not cover compares. The RDNA3 measurement above also ran the translated forms (`bound_ctrl` 1, masks 0xF): an invalid source lane gets the compare of a 0 source, as the rule says. Lane values are checked in `tests/semantic/test_dpp_compare.py` (the SPIR-V interpreter) and on a GPU with `runtime/test/shaders/cs_dpp_cmp.asm` and, for `v_cmpx`, `cs_dpp_cmpx.asm` (RTX 4070 Laptop, native wave32 and `--wave64-emulate`). | |
diff --git a/docs/directstorage.md b/docs/directstorage.md index d6272e588..10b9390cb 100644 --- a/docs/directstorage.md +++ b/docs/directstorage.md | |||
| @@ -273,16 +273,18 @@ shim beyond the size check it already does. The last one is behaviour the first | |||
| 273 | 256 blocks of a stream. It combines adjacent mips from the same layer with full-stream index anchor | 273 | 256 blocks of a stream. It combines adjacent mips from the same layer with full-stream index anchor |
| 274 | and shared-p-bit constraints. A shared p-bit can relate low red endpoint bits even when its sibling | 274 | and shared-p-bit constraints. A shared p-bit can relate low red endpoint bits even when its sibling |
| 275 | mip supplies only the leading bits. These local fits preserve the recorded precision and exact reference | 275 | mip supplies only the leading bits. These local fits preserve the recorded precision and exact reference |
| 276 | bits. A packed tail whose larger mips are BCPack-coded too has no raw or zlib sibling, so a history field that | 276 | bits. A packed tail whose larger mips are BCPack-coded too has no adjacent raw or zlib sibling, so a history |
| 277 | only such tails use stayed unknown: in the game runs of 2026-11-25 two BC7 tail streams of one pool failed | 277 | field that only such tails use stayed unknown: in the game runs of 2026-11-25 two BC7 tail streams of one pool |
| 278 | with `missing-endpoint` (alpha fields of two history entries). For the streams that still start a chain at a | 278 | failed with `missing-endpoint` (alpha fields of two history entries). For streams that still start a chain at a |
| 279 | missing field, the fitter now decodes the nearest BCPack sibling with the profile so far and fits against it, | 279 | missing field after adjacent-mip fitting, the fitter first pairs their mips with the closest raw or zlib mip on |
| 280 | repeating while a round adds fields. The sibling may sit in the same refused BC7 stream: every block whose | 280 | the same layer across multi-level mip distances, then decodes the nearest BCPack sibling with the profile so far |
| 281 | chains start elsewhere is still determined, and the undetermined ones are left out of the reference. Those | 281 | and fits against it, repeating while a round adds fields. The sibling may sit in the same refused BC7 stream: |
| 282 | fields are fitted, never confirmed, and fill only what the other fits left empty. On the 1.0.2.1 package this | 282 | every block whose chains start elsewhere is still determined, and the undetermined ones are left out of the |
| 283 | raised the BC7 endpoint fields from 4,228 to 4,406 of 6,144; the runtime decoder then refuses 8 of 5,167 BC7 | 283 | reference. Those fields are fitted, never confirmed, and fill only what the earlier fits left empty. On the |
| 284 | streams instead of 60 (both failing requests decode), and the 268 BC6H streams are unchanged (10 refused; a | 284 | 1.0.2.1 package this raised BC6H coverage from 210 to 226 of 256 endpoint rows and 249 to 251 of 256 index rows |
| 285 | refused BC6H sibling is not used as a reference yet). A profile can still lack endpoint values or exceed the reference consistency tolerance. Such a request reports a decompression error before publication. | 285 | (0 of 268 BC6H streams refused instead of 10) and raised BC7 endpoint fields from 4,228 to 4,406 of 6,144 (8 of |
| 286 | 5,167 BC7 streams refused instead of 60; both failing requests decode). A profile can still lack endpoint values | ||
| 287 | or exceed the reference consistency tolerance. Such a request reports a decompression error before publication. | ||
| 286 | - The four swizzle modes interleave stripes from request-wide component planes into 16 KiB (mode 1) or | 288 | - The four swizzle modes interleave stripes from request-wide component planes into 16 KiB (mode 1) or |
| 287 | 32 KiB (modes 2–4) groups. The enum names give the successive stripe widths. The shipped BC4 sample | 289 | 32 KiB (modes 2–4) groups. The enum names give the successive stripe widths. The shipped BC4 sample |
| 288 | separates its endpoint planes from indices across the inflated source. The title's compute shader does | 290 | separates its endpoint planes from indices across the inflated source. The title's compute shader does |
diff --git a/docs/gameinput.md b/docs/gameinput.md index fe1259cc4..1819f0543 100644 --- a/docs/gameinput.md +++ b/docs/gameinput.md | |||
| @@ -643,8 +643,10 @@ holds stays valid after it leaves the history. | |||
| 643 | | nothing newer, or nothing older after the horizon | `GAMEINPUT_E_READING_NOT_FOUND` | | 643 | | nothing newer, or nothing older after the horizon | `GAMEINPUT_E_READING_NOT_FOUND` | |
| 644 | 644 | ||
| 645 | After a pad is plugged back in, its last reading before the unplug leads to the reconnect snapshot, older ones are | 645 | After a pad is plugged back in, its last reading before the unplug leads to the reconnect snapshot, older ones are |
| 646 | `REFERENCE_READING_TOO_OLD`, and sequence numbers carry on. Timestamps are poll times, so a change shorter than one poll | 646 | `REFERENCE_READING_TOO_OLD`, and sequence numbers carry on. Each poll drains SDL's gamepad button and axis events. |
| 647 | (2 ms with the thread) is not seen. | 647 | For each connected pad, events with the same SDL timestamp form one sample. Intermediate samples reach the history |
| 648 | and reading or Guide callbacks, while the final reading uses the current pad snapshot. GameInput timestamps still | ||
| 649 | record when the shim polled. A short press is recoverable when the SDL backend reports its two edges with distinct timestamps. | ||
| 648 | 650 | ||
| 649 | ### Device identity | 651 | ### Device identity |
| 650 | 652 | ||
| @@ -704,8 +706,8 @@ rests on a transcription rather than on a side-by-side compile. | |||
| 704 | - `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through | 706 | - `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through |
| 705 | `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony | 707 | `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony |
| 706 | `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick, | 708 | `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick, |
| 707 | trigger and UI-navigation mapping, reading callbacks and sequence numbers, the reading history (a tap read after | 709 | trigger and UI-navigation mapping, reading callbacks and sequence numbers, the reading history (a button and trigger |
| 708 | the fact, both directions, two pads interleaved and filtered by device, ageing out, held readings, unplug and | 710 | tapped between two shim polls, both directions, two pads interleaved and filtered by device, ageing out, held readings, unplug and |
| 709 | replug), the guide button, motor and trigger | 711 | replug), the guide button, motor and trigger |
| 710 | rumble as SDL receives them, the DualSense effect bytes in each `LEONIDA_DS_TRIGGERS` mode, the lightbar, a | 712 | rumble as SDL receives them, the DualSense effect bytes in each `LEONIDA_DS_TRIGGERS` mode, the lightbar, a |
| 711 | dispatcher and its quota, async and blocking enumeration, unregistering, unplugging and replugging, and three identical pads | 713 | dispatcher and its quota, async and blocking enumeration, unregistering, unplugging and replugging, and three identical pads |
| @@ -755,7 +757,7 @@ These need the game executable or a test on hardware: | |||
| 755 | built against one of those, the vtables need a second set. | 757 | built against one of those, the vtables need a second set. |
| 756 | - **IIDs.** `QueryInterface` answers the v0 IIDs from the public header. | 758 | - **IIDs.** `QueryInterface` answers the v0 IIDs from the public header. |
| 757 | - **Reading history.** Microsoft's [next reading](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getnextreading) | 759 | - **Reading history.** Microsoft's [next reading](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getnextreading) |
| 758 | and [previous reading](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getpreviousreading) pages describe half a second of readings per device and failure when old readings leave the stream. The table above records the shim's HRESULT choices. Changes faster than the poll are not seen. | 760 | and [previous reading](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getpreviousreading) pages describe half a second of readings per device and failure when old readings leave the stream. The table above records the shim's HRESULT choices. |
| 759 | `GetTemporalReading` returns `E_NOTIMPL` with a null reading on purpose: Microsoft's | 761 | `GetTemporalReading` returns `E_NOTIMPL` with a null reading on purpose: Microsoft's |
| 760 | [reference page](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_gettemporalreading) | 762 | [reference page](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_gettemporalreading) |
| 761 | says it "was never implemented in v0" and returns `E_NOTIMPL`, and v1 removed it. The v0 header (NuGet | 763 | says it "was never implemented in v0" and returns `E_NOTIMPL`, and v1 removed it. The v0 header (NuGet |
diff --git a/docs/i18n/ar/quickstart.md b/docs/i18n/ar/quickstart.md index d28d5fc70..970da67c2 100644 --- a/docs/i18n/ar/quickstart.md +++ b/docs/i18n/ar/quickstart.md | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | # دليل البدء السريع لمشروع Leonida | 3 | # دليل البدء السريع لمشروع Leonida |
| 4 | 4 | ||
| 5 | الوثائق الإنجليزية هي المرجع المعتمد. يستند هذا الدليل إلى المراجعة `561b65a` ويغطي خطوات البدء الأساسية. | 5 | الوثائق الإنجليزية هي المرجع المعتمد. يستند هذا الدليل إلى المراجعة `561b65a` ويغطي خطوات البدء الأساسية. |
| 6 | راجع [ملف README بالإنجليزية](../../../README.md#project-status) لمعرفة حالة المشروع الحالية، و[فهرس الوثائق](../../README.md) للمزيد من التفاصيل. | 6 | راجع [ملف README بالإنجليزية](../../../README.md#where-it-stands) لمعرفة حالة المشروع الحالية، و[فهرس الوثائق](../../README.md) للمزيد من التفاصيل. |
| 7 | 7 | ||
| 8 | ## ما هو Leonida؟ | 8 | ## ما هو Leonida؟ |
| 9 | 9 | ||
| @@ -72,7 +72,7 @@ python -I make_game.py --game "D:\path\to\package" --out "D:\Games\Leonida" --wo | |||
| 72 | 72 | ||
| 73 | يعمل `make_game.py` على Linux، ويجد `llvm-mc` تلقائيًا إذا كان ضمن `PATH`. تأكد من أن نسخته تدعم AMDGPU. | 73 | يعمل `make_game.py` على Linux، ويجد `llvm-mc` تلقائيًا إذا كان ضمن `PATH`. تأكد من أن نسخته تدعم AMDGPU. |
| 74 | يعمل محمّل اللعبة، وهو برنامج Windows، عبر Wine أو Proton. إذا كان لديك بناء Windows جاهز للمحمّل، | 74 | يعمل محمّل اللعبة، وهو برنامج Windows، عبر Wine أو Proton. إذا كان لديك بناء Windows جاهز للمحمّل، |
| 75 | فمرّر مجلده باستخدام `--runtime-build`. راجع [تعليمات البناء والتشغيل على Linux](../../../README.md#running-the-loader-on-linux). | 75 | فمرّر مجلده باستخدام `--runtime-build`. راجع [تعليمات البناء والتشغيل على Linux](../../linux.md). |
| 76 | 76 | ||
| 77 | ## حل المشاكل الشائعة | 77 | ## حل المشاكل الشائعة |
| 78 | 78 | ||
diff --git a/docs/running.md b/docs/running.md index 3587cdc49..778c8b83a 100644 --- a/docs/running.md +++ b/docs/running.md | |||
| @@ -37,6 +37,18 @@ Paths are placeholders: `<checkout>` is the repository, `<build>` the folder wit | |||
| 37 | runs used `LEONIDA_SKIP_COMPUTE=<name>,<name>,...` with those programs' names (picked by module size from | 37 | runs used `LEONIDA_SKIP_COMPUTE=<name>,<name>,...` with those programs' names (picked by module size from |
| 38 | `<work>/shaders/spirv/library/index.json`), which drops their dispatches at play, and `LEONIDA_RT_AS=off`, which | 38 | `<work>/shaders/spirv/library/index.json`), which drops their dispatches at play, and `LEONIDA_RT_AS=off`, which |
| 39 | drops acceleration-structure builds. The picture then lacks what they draw. | 39 | drops acceleration-structure builds. The picture then lacks what they draw. |
| 40 | - **The DirectStorage predictor profile.** The runtime decodes the title's BCPack textures with a profile fitted from | ||
| 41 | the local package, `<work>/shaders/bcpack/history.bcph` ([directstorage.md](directstorage.md)). The runtime stage | ||
| 42 | of `make_game.py` regenerates it when the fitter changes; a runtime built without that stage (`cmake` or | ||
| 43 | `scripts/build_runtime.ps1` directly) keeps the old one. Since `2a491668a` the fitter fills the BC7 history fields | ||
| 44 | of packed mip tails, whose missing values made the story load's tail requests fail with `missing-endpoint` | ||
| 45 | (`E_DSTORAGE_DECOMPRESSION_ERROR`; [#2019](https://github.com/ubiquitarianism/leonida/issues/2019), | ||
| 46 | [#2396](https://github.com/ubiquitarianism/leonida/issues/2396)). With an older profile, run | ||
| 47 | `python -I tools/build_dstorage_history.py <package> --out <work>/shaders/bcpack/history.bcph --trainer <build>/bcpack_history_train.exe` | ||
| 48 | once (about 11 minutes here). The runtime's load line then reports 4,406 of 6,144 BC7 endpoint fields (4,228 | ||
| 49 | before). On an RTX 4070 SUPER (Windows 11, NVIDIA 621.01), with the old profile, 7-8 such errors a run and the | ||
| 50 | story load did not finish in 1,800 s (2 runs); with the new one, none, and the run reached the opening sequence | ||
| 51 | (1 run) ([reported by others](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226672676)). | ||
| 40 | 52 | ||
| 41 | ## Recommended variables (all platforms) | 53 | ## Recommended variables (all platforms) |
| 42 | 54 | ||
diff --git a/docs/test_inventory.md b/docs/test_inventory.md new file mode 100644 index 000000000..a4a874912 --- /dev/null +++ b/docs/test_inventory.md | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | # Synthetic Test Inventory & Subsystem Map (DX-10) | ||
| 2 | |||
| 3 | This document provides the authoritative subsystem test map and prerequisite catalog for Leonida, implemented under roadmap task **DX-10**. | ||
| 4 | |||
| 5 | ## Overview | ||
| 6 | |||
| 7 | `tools/test_inventory.py` dynamically discovers source test modules across `tests/` and `runtime/test/` (skipping bytecode caches like `__pycache__` and matching `scripts/run_semantic_tests.py` package discovery rules inside `tests/semantic/`). Over 99% of test files are synthetic and run without retail game packages, executables, or proprietary assets. | ||
| 8 | |||
| 9 | ```bash | ||
| 10 | # Generate the full subsystem breakdown and metrics | ||
| 11 | python -I tools/test_inventory.py --summary | ||
| 12 | |||
| 13 | # Output machine-readable JSON inventory | ||
| 14 | python -I tools/test_inventory.py --json | ||
| 15 | |||
| 16 | # Filter tests by subsystem (runtime, shader, tools, viewer) | ||
| 17 | python -I tools/test_inventory.py --subsystem shader | ||
| 18 | |||
| 19 | # Display tests mentioning retail package environment variables (tagged optional vs required) | ||
| 20 | python -I tools/test_inventory.py --gaps | ||
| 21 | ``` | ||
| 22 | |||
| 23 | ## Subsystems | ||
| 24 | |||
| 25 | - **`shader`**: RDNA2 -> SPIR-V translator, float ALU rounding, vector compares, atomics, mesh/wave64 dispatch (`python_unittest`). | ||
| 26 | - **`tools`**: Asset exporters, PE inspection, manifest checkers, BCPack/texture swizzlers, developer scripts (`python_unittest`, `pytest`). | ||
| 27 | - **`runtime`**: D3D12/Vulkan shims, PE loader, root signature parser, XMA2 audio shims, memory and descriptor heaps (`ctest_cpp`). | ||
| 28 | - **`viewer`**: Map viewer HTTP streaming, LOD residency handoffs, camera positioning, world grid chunking (`python_unittest`, `node_test`). | ||
| 29 | |||
| 30 | ## Runners | ||
| 31 | |||
| 32 | - **`python_unittest`**: Pure standard-library Python test suites runnable with `python -I`. | ||
| 33 | - **`ctest_cpp`**: Native C++20 tests built with CMake/Ninja under `runtime/build/`. | ||
| 34 | - **`pytest`**: Tests requiring the virtual environment dependencies pinned in `tests/requirements.txt`. | ||
| 35 | - **`node_test`**: Viewer streaming protocol tests running under Node.js (`node --test`). | ||
| 36 | |||
| 37 | ## Retail-Gated & Optional Retail Checks (`--gaps`) | ||
| 38 | |||
| 39 | `--gaps` surfaces files mentioning `LEONIDA_GAME_DIR`, `LEONIDA_MOVIE`, or `requires_retail_package`, labelling them with `retail_requirement`: | ||
| 40 | - **`optional`**: Tests whose primary suite runs synthetically and only execute an optional retail leg when `LEONIDA_GAME_DIR`/`LEONIDA_MOVIE` is set (printing `SKIP` otherwise, such as `pe_loader_test.cpp`). These still count toward `synthetic` coverage. | ||
| 41 | - **`required`**: Tests strictly gated on retail package prerequisites. | ||
diff --git a/docs/testing.md b/docs/testing.md index d62a0cf99..ec95d8244 100644 --- a/docs/testing.md +++ b/docs/testing.md | |||
| @@ -899,6 +899,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin | |||
| 899 | | On RADV with Mesa 25.2 (Ubuntu 24.04's default; 25.2.8 measured) or 25.3 (from the source, not run), `cs_w32_salu64` fails with word 2 = `0` (want `0xFFFFFFFF`) and `cs_signed_zero_nan` fails with word 5 = `0` (want `1`). The `cs_signed_zero_nan` failure alone is also measured on RADV 25.0.7 (RX 7800 XT, Debian 13; @mrbean56, #4421) and on ANV 25.2.8 (Intel UHD 630; @theswiss24, #4571); llvmpipe on Mesa 26.0.8 (Ubuntu 26.04) still gives word 5 = `0`, which `check.py` does not judge there (`UNJUDGED_WORDS`) | Two Mesa bugs, not translator bugs (#166). `cs_w32_salu64`: ACO's `combine_add_sub_b2i` reads a temporary without counting the use, so dead-code elimination removes it (`ACO ERROR: ... never defined` with `MESA_SHADER_CACHE_DISABLE=true`); `RADV_DEBUG=llvm` passes. `cs_signed_zero_nan`: NIR's range analysis (`fmul_is_a_number`) calls `0 * x` a number when `x` may be infinite, so the `x != x` check folds to false despite `SignedZeroInfNanPreserve`. The same NIR code is behind llvmpipe's word 5 (#664) and ANV's, since both drivers run NIR; `cs_w32_salu64` is ACO's, so only RADV has it | Expected with these Mesa versions. From the source, the ACO function is gone from Mesa 26.0 and the NIR code was replaced in 26.1 (neither run); RADV from Mesa 26.3.1 passes both on an 8060S (gfx1151) | | 899 | | On RADV with Mesa 25.2 (Ubuntu 24.04's default; 25.2.8 measured) or 25.3 (from the source, not run), `cs_w32_salu64` fails with word 2 = `0` (want `0xFFFFFFFF`) and `cs_signed_zero_nan` fails with word 5 = `0` (want `1`). The `cs_signed_zero_nan` failure alone is also measured on RADV 25.0.7 (RX 7800 XT, Debian 13; @mrbean56, #4421) and on ANV 25.2.8 (Intel UHD 630; @theswiss24, #4571); llvmpipe on Mesa 26.0.8 (Ubuntu 26.04) still gives word 5 = `0`, which `check.py` does not judge there (`UNJUDGED_WORDS`) | Two Mesa bugs, not translator bugs (#166). `cs_w32_salu64`: ACO's `combine_add_sub_b2i` reads a temporary without counting the use, so dead-code elimination removes it (`ACO ERROR: ... never defined` with `MESA_SHADER_CACHE_DISABLE=true`); `RADV_DEBUG=llvm` passes. `cs_signed_zero_nan`: NIR's range analysis (`fmul_is_a_number`) calls `0 * x` a number when `x` may be infinite, so the `x != x` check folds to false despite `SignedZeroInfNanPreserve`. The same NIR code is behind llvmpipe's word 5 (#664) and ANV's, since both drivers run NIR; `cs_w32_salu64` is ACO's, so only RADV has it | Expected with these Mesa versions. From the source, the ACO function is gone from Mesa 26.0 and the NIR code was replaced in 26.1 (neither run); RADV from Mesa 26.3.1 passes both on an 8060S (gfx1151) | |
| 900 | | On an Intel iGPU with ANV from Mesa 25.2 (25.2.8 measured), `cs_fmt_int_narrow` fails with word 34 = `0x00000000` (want `0xFFFFFFFF`); the full dump also has words 49 and 129 = `0x80000000` (want `0x8000FFFF`), natively and under `LEONIDA_W64_EMULATE=1` alike (`check.py`'s comparison stops at the first mismatch, so its line names only word 34). Measured on Gen9 at subgroup sizes 8, 16 and 32 alike (UHD 630, CFL GT2; TEST-1000), and on an Arrow Lake-H Arc 140T (device subgroup 8–32; `Intel(R) Graphics (ARL)`, Xe2; ANV 25.2.8-0ubuntu0.24.04.5, Vulkan 1.4.318) | A Mesa bug, not a translator bug (TEST-1000). The fixture's second source dword `0x8000FFFF` reaches the SSBO as `0x80000000`: the translated module holds it as one `OpConstant %uint` stored by a single dword `OpStore` to PhysicalStorageBuffer, no float operation on the path, yet the raw buffer readback (word 129) shows its low halfword `0xffff` zeroed and its high halfword `0x8000` intact — the bit pattern is a negative f32 denormal and it comes back as `-0`, as if flushed. Words 34 and 49 are a correct `16_16_16_16_SINT` load of the corrupted dword (the neighbouring channels sign-extend correctly). The module requests `DenormPreserve 16` and `SignedZeroInfNanPreserve 32`, not `DenormPreserve 32`, and the same module passes 136/136 on gfx1036 (native `hw_oracle`), llvmpipe, an RTX 2060 SUPER, 5060 Laptop and 5080, an RX 7900 XTX under RADV, Xe-LP (UHD 770, ANV 26.3.1) and Meteor Lake (ANV 26.2.7); adding `OpExecutionMode DenormPreserve 32` by hand fixes all 136 words on both Gen9 and the Arc 140T | Expected with this Mesa. Don't add `DenormPreserve 32` to the translator for it: the game runs f32 denormals flushed (`denorm_mode_32 = 0`, docs/design.md) and the translator leaves denormal handling to the driver. A newer Mesa passes (26.2.7 on Meteor Lake, 26.3.1 on Xe-LP); Gen9 and the Arc 140T with a newer Mesa not run | | 900 | | On an Intel iGPU with ANV from Mesa 25.2 (25.2.8 measured), `cs_fmt_int_narrow` fails with word 34 = `0x00000000` (want `0xFFFFFFFF`); the full dump also has words 49 and 129 = `0x80000000` (want `0x8000FFFF`), natively and under `LEONIDA_W64_EMULATE=1` alike (`check.py`'s comparison stops at the first mismatch, so its line names only word 34). Measured on Gen9 at subgroup sizes 8, 16 and 32 alike (UHD 630, CFL GT2; TEST-1000), and on an Arrow Lake-H Arc 140T (device subgroup 8–32; `Intel(R) Graphics (ARL)`, Xe2; ANV 25.2.8-0ubuntu0.24.04.5, Vulkan 1.4.318) | A Mesa bug, not a translator bug (TEST-1000). The fixture's second source dword `0x8000FFFF` reaches the SSBO as `0x80000000`: the translated module holds it as one `OpConstant %uint` stored by a single dword `OpStore` to PhysicalStorageBuffer, no float operation on the path, yet the raw buffer readback (word 129) shows its low halfword `0xffff` zeroed and its high halfword `0x8000` intact — the bit pattern is a negative f32 denormal and it comes back as `-0`, as if flushed. Words 34 and 49 are a correct `16_16_16_16_SINT` load of the corrupted dword (the neighbouring channels sign-extend correctly). The module requests `DenormPreserve 16` and `SignedZeroInfNanPreserve 32`, not `DenormPreserve 32`, and the same module passes 136/136 on gfx1036 (native `hw_oracle`), llvmpipe, an RTX 2060 SUPER, 5060 Laptop and 5080, an RX 7900 XTX under RADV, Xe-LP (UHD 770, ANV 26.3.1) and Meteor Lake (ANV 26.2.7); adding `OpExecutionMode DenormPreserve 32` by hand fixes all 136 words on both Gen9 and the Arc 140T | Expected with this Mesa. Don't add `DenormPreserve 32` to the translator for it: the game runs f32 denormals flushed (`denorm_mode_32 = 0`, docs/design.md) and the translator leaves denormal handling to the driver. A newer Mesa passes (26.2.7 on Meteor Lake, 26.3.1 on Xe-LP); Gen9 and the Arc 140T with a newer Mesa not run | |
| 901 | | Every test crashes inside `libnvidia-eglcore.so` | NVIDIA's 535 server driver (Ubuntu 24.04's default) | Use driver 615 or newer | | 901 | | Every test crashes inside `libnvidia-eglcore.so` | NVIDIA's 535 server driver (Ubuntu 24.04's default) | Use driver 615 or newer | |
| 902 | | The synthetic `cs_imgstore_cube` test reports 63 bad `r32 sint` texels on a Tesla V100-SXM2-16GB (Volta, NVIDIA 580.178.04, Linux; Vulkan 1.4.312; [#1492](https://github.com/ubiquitarianism/leonida/issues/1492)) | The signed 32-bit cube-storage-write failure is known on that reported host, but its cause has not been isolated. It passes on an RTX 5090 with NVIDIA 621.14 on Windows 11 | No workaround is confirmed. Keep the test's expected values; report the GPU, driver and output if you reproduce it on another setup | | ||
| 902 | | `build.py`: 0 translated, reason `.text` | An old `build.py` with LLVM 19 | Update to current `main` | | 903 | | `build.py`: 0 translated, reason `.text` | An old `build.py` with LLVM 19 | Update to current `main` | |
| 903 | | `vk_harness` doesn't compile: `VK_KHR_maintenance8` names unknown | Vulkan headers older than the SDK the code was written against | Update to current `main` (the code now builds without it), or use current Khronos Vulkan-Headers; conda-forge's package is too old | | 904 | | `vk_harness` doesn't compile: `VK_KHR_maintenance8` names unknown | Vulkan headers older than the SDK the code was written against | Update to current `main` (the code now builds without it), or use current Khronos Vulkan-Headers; conda-forge's package is too old | |
| 904 | | Configure stops with "Vulkan headers too old: ... VK_HEADER_VERSION N" (before: the build stopped at `d3d12_com.h(42): error C3646: 'calibrated': unknown override specifier` and 100+ errors in `d3d12_vulkan_device.cpp`, or at `VkPhysicalDevicePipelineBinaryFeaturesKHR` in `vk_harness.cpp`) | The Windows runtime found Vulkan headers older than v1.3.294 (`runtime/cmake/vulkan_headers_version.cmake`). conda-forge's `vulkan-headers` resolves to 1.3.231 next to `llvm-tools`. Measured on MSVC 14.51: v1.3.294 builds every target, SDK 1.3.280.0 all but `vk_harness` (`VK_KHR_pipeline_binary` is new in v1.3.294), 1.3.231 stops in the D3D12 layer | Point `VULKAN_SDK` at a Vulkan SDK from 1.3.296.0 on or current Khronos Vulkan-Headers, then delete `CMakeCache.txt`; or pass `-DLEONIDA_VULKAN_HEADERS_FETCH=ON` with no other headers installed | | 905 | | Configure stops with "Vulkan headers too old: ... VK_HEADER_VERSION N" (before: the build stopped at `d3d12_com.h(42): error C3646: 'calibrated': unknown override specifier` and 100+ errors in `d3d12_vulkan_device.cpp`, or at `VkPhysicalDevicePipelineBinaryFeaturesKHR` in `vk_harness.cpp`) | The Windows runtime found Vulkan headers older than v1.3.294 (`runtime/cmake/vulkan_headers_version.cmake`). conda-forge's `vulkan-headers` resolves to 1.3.231 next to `llvm-tools`. Measured on MSVC 14.51: v1.3.294 builds every target, SDK 1.3.280.0 all but `vk_harness` (`VK_KHR_pipeline_binary` is new in v1.3.294), 1.3.231 stops in the D3D12 layer | Point `VULKAN_SDK` at a Vulkan SDK from 1.3.296.0 on or current Khronos Vulkan-Headers, then delete `CMakeCache.txt`; or pass `-DLEONIDA_VULKAN_HEADERS_FETCH=ON` with no other headers installed | |
| @@ -918,6 +919,8 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin | |||
| 918 | | On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` | | 919 | | On a Mac, `valu_fuzz.py --family f16` reads `+0` where the model wants `-0`, from a multiply whose exact product is -0 (`v_mul_f16`, `v_pk_mul_f16`) or from an FMA whose product and addend are both -0 (`v_fma_f16`, `v_fmac_f16`, `v_pk_fma_f16`) | MoltenVK computes a `NoContraction` multiply as `fma(l, r, +0)`, which drops the sign. MoltenVK 1.4.2 and `main` up to at least `5189f8de` are affected (SHADER-182, [design notes](design.md#translator-status-and-runtime-contract)) | Expected with these MoltenVK versions. To run the rest of the fuzzer clean, add `--skip-op` for each of the five ops. To see them match, install Homebrew's `mesa` and use its KosmicKrisp driver: `LEONIDA_VULKAN_LOADER=/opt/homebrew/opt/vulkan-loader/lib/libvulkan.1.dylib VK_DRIVER_FILES=/opt/homebrew/share/vulkan/icd.d/kosmickrisp_mesa_icd.aarch64.json python3 -I tools/valu_fuzz.py --family f16 --build runtime/build/linux`. Or build MoltenVK with SPIRV-Cross `300681bb` or newer in `ExternalRevisions/SPIRV-Cross_repo_revision`, and point `LEONIDA_VULKAN_LOADER` at its `libMoltenVK.dylib` | |
| 919 | | A pixel shader exporting non-canonical f32 NaNs reads back `0x7fc00000` from an RGBA32F color attachment | KosmicKrisp (Mesa 26.3.1), reproduced on Apple M3 Max, M2 Ultra and M1 Pro ([#3125](https://github.com/ItsNotRexed/Leonida/issues/3125)): `nir_to_msl` emits `(NAN)` for `float`-typed NaN constants (`MESA_KK_DEBUG=msl`); MoltenVK 1.4.2 preserved both tested payloads on the same hardware | `ps_nan_payload` allows the measured canonical word only for the NaN channels and only when `vk_harness` reports `driver: KosmicKrisp`. Finite channels and other drivers still require exact words. Integer or storage-buffer readback still canonicalizes constants that NIR infers as `float` (see the `cs_bvh` row below). | | 920 | | A pixel shader exporting non-canonical f32 NaNs reads back `0x7fc00000` from an RGBA32F color attachment | KosmicKrisp (Mesa 26.3.1), reproduced on Apple M3 Max, M2 Ultra and M1 Pro ([#3125](https://github.com/ItsNotRexed/Leonida/issues/3125)): `nir_to_msl` emits `(NAN)` for `float`-typed NaN constants (`MESA_KK_DEBUG=msl`); MoltenVK 1.4.2 preserved both tested payloads on the same hardware | `ps_nan_payload` allows the measured canonical word only for the NaN channels and only when `vk_harness` reports `driver: KosmicKrisp`. Finite channels and other drivers still require exact words. Integer or storage-buffer readback still canonicalizes constants that NIR infers as `float` (see the `cs_bvh` row below). | |
| 920 | | `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 | | 921 | | `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 | |
| 922 | | `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 | | ||
| 923 | | `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 | | ||
| 921 | | `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` | | 924 | | `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` | |
| 922 | | 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 | | 925 | | 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 | |
| 923 | | `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 | | 926 | | `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 | |