Skip to content

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

Open
baldyb4242 wants to merge 1 commit into
ProjectLeonida:mainfrom
baldyb4242:bl3/console-slot-drop-check
Open

baldyb4242 wants to merge 1 commit into
ProjectLeonida:mainfrom
baldyb4242:bl3/console-slot-drop-check

Conversation

@baldyb4242

Copy link
Copy Markdown

Claimed in the coordination issue as: BL-3 (#14 (comment))

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

…ls (BL-3)

A console DLL writes a command into the list object while it has room instead
of calling the vtable (docs/d3d12_command_objects.md §3.5a). The list proxy
avoids this today by pinning the cursor at its limit; an inline write the
title makes without checking first would be lost.

console_list_records.h decodes the measured records (the two dispatch headers,
root constants, descriptor table, root CBV/SRV/UAV, pipeline record) into the
fallback calls (slots 14, 80, 37, 39, 35, 41/43/45, 25), using a root-argument
header table this runtime defines. An unknown or truncated record stops
decoding with its offset instead of being skipped.

console_list_records_test models the DLL independently from the doc and runs
1,200 seeded sequences at six cursor limits: the inline path (replayed before
each vtable call and at Close) and the all-vtable path give the same calls.
Eight planted decoder bugs each fail it.

Not yet wired into runtime/shims/d3d12_xs_device.cpp (Windows-only, not
buildable here). No game files, no GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@baldyb4242
baldyb4242 marked this pull request as ready for review November 24, 2026 18:04

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

milk4sale pushed a commit to milk4sale/leonida that referenced this pull request Nov 27, 2026
…16-minmax-neg-zero-test

Shaders: negative-zero ordering test for the f16 min/max forms
@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#1050 | head 675c3fb (merged cleanly with main aa918e5) | 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

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Verified by OreoFR

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

@OreoFR

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants