runtime: replay the console list's inline records as their vtable calls (BL-3) #1050

Merged
baldyb4242 merged 1 commit from upstream-pr/1050 into main 2026-11-30 17:15:06 +00:00
baldyb4242 commented 2026-11-24 17:20:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by baldyb4242 on 2026-11-24T17:20:53Z.


Claimed in the coordination issue as: BL-3 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7138403816)

What and why

A console DLL writes a command into the list object itself while the list has room, instead of calling the vtable (docs/d3d12_command_objects.md §3.5a). The list proxy avoids this today by keeping the cursor at its limit, so every command goes through the vtable. An inline write the title makes without checking the cursor first would be lost.

This adds the decoder half of BL-3:

  • runtime/src/console_list_records.h decodes the measured inline records into the vtable calls they replace:

    Record Fallback slot
    0x4002C400 dispatch 14
    0x4003CC00 dispatch with an extra word 80
    one root constant 37
    several root constants 39
    descriptor table 35
    root CBV / SRV / UAV 41 / 43 / 45
    pipeline record 25
  • The root-argument header is the list's table entry at +0x344, which the runtime fills. The header defines an encoding for it that keeps bits 30–31 clear (the DLL writes inline only then) and leaves room for the DLL's measured + 4*offset and + ((n-1) << 16) adjustments.

  • An unknown or truncated record stops decoding and reports its offset. It is never skipped.

  • docs/boot_leads.md: a status line for BL-3.

Not in this PR (draft for that reason):

  • Wiring the decoder into runtime/shims/d3d12_xs_device.cpp: replay pending records before each vtable call and at Close.
  • The bytes our PSOs expose as the 28-byte pipeline record. The decoder takes a resolver for now.
  • Widening the 32-bit descriptor-table address (BL-4).

Slot 80 → Dispatch on the vtable path is #687's change and is not duplicated here.

Tested

  • console_list_records_test (new) models the DLL independently from §3.5a. It runs 1,200 seeded sequences at six cursor limits (0 to 4,096 bytes), and the inline path and the all-vtable path give the same call stream (13,190 commands written inline and replayed). It also has one case per measured form and 11 refusal cases.
  • Eight planted decoder bugs (slot swap, dropped VA high half, offset and count arithmetic, field masks, skipping unknown records, the combined-adjustment check) each make the test fail.
  • Portable ctest on macOS (AppleClang 21, Apple Silicon): 75/75 passed, 2 skipped (shader_library_corpus and vk_sync_validation need game files). Before the change: 72/72.
  • Builds clean with -Wall -Wextra -Wpedantic -Werror.
  • check_no_game_data.py passes on the changed files.
  • Not built with MSVC or run under Wine: this change touches no Windows-only code.

GPUs tested: n/a (CPU-only test)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5476993195 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1050). Originally posted by [baldyb4242](https://github.com/baldyb4242) on 2026-11-24T17:20:53Z. --- Claimed in the coordination issue as: BL-3 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7138403816) ### What and why A console DLL writes a command into the list object itself while the list has room, instead of calling the vtable (`docs/d3d12_command_objects.md` §3.5a). The list proxy avoids this today by keeping the cursor at its limit, so every command goes through the vtable. An inline write the title makes without checking the cursor first would be lost. This adds the decoder half of BL-3: - `runtime/src/console_list_records.h` decodes the measured inline records into the vtable calls they replace: | Record | Fallback slot | |---|---| | `0x4002C400` dispatch | 14 | | `0x4003CC00` dispatch with an extra word | 80 | | one root constant | 37 | | several root constants | 39 | | descriptor table | 35 | | root CBV / SRV / UAV | 41 / 43 / 45 | | pipeline record | 25 | - The root-argument header is the list's table entry at `+0x344`, which the runtime fills. The header defines an encoding for it that keeps bits 30–31 clear (the DLL writes inline only then) and leaves room for the DLL's measured `+ 4*offset` and `+ ((n-1) << 16)` adjustments. - An unknown or truncated record stops decoding and reports its offset. It is never skipped. - `docs/boot_leads.md`: a status line for BL-3. Not in this PR (draft for that reason): - Wiring the decoder into `runtime/shims/d3d12_xs_device.cpp`: replay pending records before each vtable call and at Close. - The bytes our PSOs expose as the 28-byte pipeline record. The decoder takes a resolver for now. - Widening the 32-bit descriptor-table address (BL-4). Slot 80 → `Dispatch` on the vtable path is #687's change and is not duplicated here. ### Tested - `console_list_records_test` (new) models the DLL independently from §3.5a. It runs 1,200 seeded sequences at six cursor limits (0 to 4,096 bytes), and the inline path and the all-vtable path give the same call stream (13,190 commands written inline and replayed). It also has one case per measured form and 11 refusal cases. - Eight planted decoder bugs (slot swap, dropped VA high half, offset and count arithmetic, field masks, skipping unknown records, the combined-adjustment check) each make the test fail. - Portable `ctest` on macOS (AppleClang 21, Apple Silicon): 75/75 passed, 2 skipped (`shader_library_corpus` and `vk_sync_validation` need game files). Before the change: 72/72. - Builds clean with `-Wall -Wextra -Wpedantic -Werror`. - `check_no_game_data.py` passes on the changed files. - Not built with MSVC or run under Wine: this change touches no Windows-only code. GPUs tested: n/a (CPU-only test) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
abnalstlll-byte commented 2026-11-24 18:49:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:49:56Z.

Review: APPROVED


Clean-Room Audit & Architectural Review — PR #1050 (BL-3 Console Command List Record Decoder)

Strong, clean-room implementation for BL-3!

Technical Verification

  1. Inline Record Decoding (runtime/src/console_list_records.h):
    • Decodes the measured inline forms from docs/d3d12_command_objects.md §3.5a (0x4002C400 -> slot 14 Dispatch, 0x4003CC00 -> slot 80, root constants slots 37/39, root table slot 35, root CBV/SRV/UAV slots 41/43/45, and 28-byte pipeline record -> slot 25 SetPipelineState).
    • Stops cleanly at the exact byte offset on unknown/truncated/misaligned records rather than skipping bytes.
    • Accurately updates docs/boot_leads.md §BL-3 noting the remaining proxy wiring and BL-4 widening items.
  2. Synthetic Verification (runtime/test/console_list_records_test.cpp):
    • Verifies header bitfields don't collide with dispatch headers or overflow across max parameters/constants, tests all 9 record forms and refusal paths, and validates inline-vs-vtable stream equivalence across 1,200 seeded sequences.
  3. Clean-Room Compliance:
    • 0 retail files or keys; C++20 stdlib + synthetic tests only.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045339914 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1050#pullrequestreview-6045339914). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:49:56Z. **Review:** APPROVED --- ### Clean-Room Audit & Architectural Review — PR #1050 (`BL-3` Console Command List Record Decoder) Strong, clean-room implementation for BL-3! #### Technical Verification 1. **Inline Record Decoding (`runtime/src/console_list_records.h`)**: - Decodes the measured inline forms from `docs/d3d12_command_objects.md §3.5a` (`0x4002C400` -> slot 14 `Dispatch`, `0x4003CC00` -> slot 80, root constants slots 37/39, root table slot 35, root CBV/SRV/UAV slots 41/43/45, and 28-byte pipeline record -> slot 25 `SetPipelineState`). - Stops cleanly at the exact byte offset on unknown/truncated/misaligned records rather than skipping bytes. - Accurately updates `docs/boot_leads.md §BL-3` noting the remaining proxy wiring and BL-4 widening items. 2. **Synthetic Verification (`runtime/test/console_list_records_test.cpp`)**: - Verifies header bitfields don't collide with dispatch headers or overflow across max parameters/constants, tests all 9 record forms and refusal paths, and validates inline-vs-vtable stream equivalence across 1,200 seeded sequences. 3. **Clean-Room Compliance**: - 0 retail files or keys; C++20 stdlib + synthetic tests only. **Verdict: APPROVED**
zmasi commented 2026-11-28 21:42:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T21:42:19Z.


#1050 | head 675c3fb1b9 (merged cleanly with main aa918e5d9f) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(console_list_records|command_list)$" --output-on-failure + python -m unittest tests/test_docs_encoding.py tests/test_docs_repo_paths.py | red on main: console_list_records_test.cpp fails to compile (error C1083: Cannot open include file: 'console_list_records.h') | green on PR+main: 2/2 CTests pass on Windows 11 MSVC (console_list_records: 1,200 seeded sequences, 13,190 inline records replayed matching the vtable stream across all 9 forms and 11 refusal cases, plus command_list); test_docs_encoding.py, test_docs_repo_paths.py, and check_no_game_data.py 0 violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246210939 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1050#issuecomment-7246210939). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T21:42:19Z. --- #1050 | head 675c3fb1b9bc5a25627a2de9025fbd1a355dbd2b (merged cleanly with main aa918e5d9f9e2f03e078d8f08854324890b5e176) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(console_list_records|command_list)$" --output-on-failure` + `python -m unittest tests/test_docs_encoding.py tests/test_docs_repo_paths.py` | red on main: `console_list_records_test.cpp` fails to compile (`error C1083: Cannot open include file: 'console_list_records.h'`) | green on PR+main: 2/2 CTests pass on Windows 11 MSVC (`console_list_records`: `1,200` seeded sequences, `13,190` inline records replayed matching the vtable stream across all 9 forms and 11 refusal cases, plus `command_list`); `test_docs_encoding.py`, `test_docs_repo_paths.py`, and `check_no_game_data.py` `0` violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes
OreoFR commented 2026-11-29 00:14:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T00:14:10Z.


Verified by OreoFR

  • Base: main a8465211f + PR head 675c3fb1b (merged with --no-ff, no conflict)
  • Test: ctest -R ^console_list_records$
  • Red on main: the test cannot build on main: it includes src/console_list_records.h, which this PR adds
  • Green with the PR: passes; full ctest on the package: 486 tests, only the known main failure xbox_present plus vk_compile_gate_calibration, which passed on rerun
  • Verdict: READY (new header plus its test; nothing in the runtime includes it yet)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11
  • Note: shares runtime/CMakeLists.txt with the open #2566; a rebase may be needed if #2566 lands first.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247970937 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1050#issuecomment-7247970937). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T00:14:10Z. --- **Verified by OreoFR** - Base: main `a8465211f` + PR head `675c3fb1b` (merged with --no-ff, no conflict) - Test: `ctest -R ^console_list_records$` - Red on main: the test cannot build on main: it includes `src/console_list_records.h`, which this PR adds - Green with the PR: passes; full ctest on the package: 486 tests, only the known main failure `xbox_present` plus `vk_compile_gate_calibration`, which passed on rerun - Verdict: READY (new header plus its test; nothing in the runtime includes it yet) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 - Note: shares `runtime/CMakeLists.txt` with the open #2566; a rebase may be needed if #2566 lands first. AI-assisted (Claude Code, Claude Opus 5.5).
OreoFR commented 2026-11-29 02:15:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T02:15:33Z.


Verified by OreoFR: link check

  • main 59e65849b + this PR (head 675c3fb1b, the head verified earlier) merged with --no-ff, built without the XMA decoder (LEONIDA_CARGO=OFF, no LEONIDA_XMA2_DECODER_LIB: configure reports the XMA2 and Opus decoders not built), RelWithDebInfo, Ninja, MSVC 19.44.35230 (VS 2022 BuildTools), LEONIDA_REQUIRE_VULKAN=ON
  • gta6rt.exe links; imports unchanged vs main built the same way (dumpbin /imports: 25 DLLs, 655 functions, no WS2_32)
  • gta6rt was not launched.

AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249312197 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1050#issuecomment-7249312197). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T02:15:33Z. --- **Verified by OreoFR**: link check - main `59e65849b` + this PR (head `675c3fb1b`, the head verified earlier) merged with --no-ff, built without the XMA decoder (`LEONIDA_CARGO=OFF`, no `LEONIDA_XMA2_DECODER_LIB`: configure reports the XMA2 and Opus decoders not built), RelWithDebInfo, Ninja, MSVC 19.44.35230 (VS 2022 BuildTools), `LEONIDA_REQUIRE_VULKAN=ON` - `gta6rt.exe` links; imports unchanged vs main built the same way (`dumpbin /imports`: 25 DLLs, 655 functions, no WS2_32) - gta6rt was not launched. AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
OreoFR commented 2026-11-29 08:33:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:33:45Z.


@baldyb4242 this PR now conflicts with main (runtime/CMakeLists.txt). Could you merge main into your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/1050#issuecomment-7247970937. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253184791 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1050#issuecomment-7253184791). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T08:33:45Z. --- @baldyb4242 this PR now conflicts with `main` (`runtime/CMakeLists.txt`). Could you merge `main` into your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/1050#issuecomment-7247970937. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)
OreoFR commented 2026-11-30 13:24:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:24:48Z.


Carried as #2716 because of the conflict with main after #2566; @baldyb4242, if you come back, say so and the carry is dropped.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7279808307 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1050#issuecomment-7279808307). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:24:48Z. --- Carried as #2716 because of the conflict with main after #2566; @baldyb4242, if you come back, say so and the carry is dropped.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1050
No description provided.