Skip to content

Decode the vertex input layout used by slot 57 - #8754

Open
hah346 wants to merge 1 commit into
ItsNotRexed:mainfrom
hah346:slot57-input-layout
Open

hah346 wants to merge 1 commit into
ItsNotRexed:mainfrom
hah346:slot57-input-layout

Conversation

@hah346

@hah346 hah346 commented Nov 23, 2026

Copy link
Copy Markdown

Claim: #8504 (comment) (slot 57 input-layout blob).

Adds a checked runtime helper for the vertex input element list in the second slot-57 blob. It owns the semantic strings and returns the six serialized D3D12 input-element fields. A malformed or truncated layout returns no result, while an empty layout succeeds. This is a building block for the slot-57 handler tracked in #8273 and complements the graphics state decoder in #8507. It has no code dependency on either PR.

Tests: Windows x64, Clang 23.1.6, CTest slot57_input_layout passed with synthetic descriptors covering unaligned field starts, per-instance values, and malformed payloads. The compiled parser independently matched a local Python probe for 25,229 library blob references containing 20,638 elements, including 15,935 valid empty lists. check_no_game_data.py and git diff --check passed. No GPU or title runtime used by this test. AI-assisted.

@thehollowedone

Copy link
Copy Markdown

Independent MSVC check of 4a043987 on native Windows x64, MSVC 19.44.35230, Release.

The focused slot57_input_layout CTest passed. I kept the PR parser unchanged and ran the stock valid cases plus four synthetic layouts covering zero through three bytes of alignment padding. Each decoded semantic name stayed intact after I overwrote and released the source buffer. All six numeric fields matched, including an append-aligned offset (0xffffffff), per-instance input class, and step rate 7.

This run covered valid layouts only. No GPU or game files used. AI-assisted.

@hah346

hah346 commented Nov 23, 2026

Copy link
Copy Markdown
Author

Follow-up on connecting the input-layout decoder to graphics PSO creation. I joined the vertex container's ISG1 to the serialized layout by case-folded semantic name and semantic index, restricting the audit to VS-only and VS+PS library records. Of 13,407 records, 9,292 had live non-system inputs and an exact match for every such input in the layout. Another 4,096 had no live non-system inputs and 19 did not have a readable source signature. No live input was missing a corresponding layout element in the covered records.

The consumer still needs to distinguish how the translated shader fetches vertices. The current translator declares Vulkan vertex inputs when it sees the external s_swappc_b64 fetch-call path. None of the 1,342 distinct VS programs in this cohort contain that call, and 932 contain typed buffer loads. The only fetch-call VS found in the full VS corpus belongs to the two records with a third, unidentified stage. The 16 VS modules in my Vulkan smoke test consequently expose no fixed-function vertex inputs. The presence of an ISG1 semantic and layout element is insufficient to reconstruct how a library VS obtains the vertex data at draw time. Analysis of the actual buffer descriptors and draw bindings is still needed. AI-assisted. Aggregate counts only.

@Disliked

Copy link
Copy Markdown

Independent Windows Clang check

Tested 4a043987 on Windows 11 x64 using Zig 0.17.1, Clang 22.1.8 and MinGW. The standalone slot-57 parser test built cleanly with -std=c++20 -Wall -Wextra -Werror -O2 and exited 0, including every truncated prefix plus malformed lengths and invalid padding.

A separate synthetic probe passed all four padding lengths, rejected nonzero trailing padding, and confirmed the decoded semantic string survives changes to the source buffer. This path did not need the game, a GPU, or the Windows SDK. AI-assisted (Codex).

@lohant27-netizen

Copy link
Copy Markdown

Tested 4a043987b on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8777, #8763, #8762, #8754, #8711 and #8695 (no conflicts): pass.

@comtek21516

Copy link
Copy Markdown

Tested 4a043987b on main at 867d922f0 (merged together with #8729 and #8562, which touch other files) on Windows Server 2025, MSVC 14.52 (Visual Studio 18), Ninja RelWithDebInfo: pass. The PR's own run was Clang 23.1.6, so this is the MSVC build.

  • Build: slot57_input_layout_test compiles and links with MSVC without a warning from the header or the test.
  • ctest slot57_input_layout: passed.
  • Code read of parse_slot57_input_layout: I looked for a read past the span and found none. Before each element the remaining size is at least 30, so after the length word at least 26 remain and data.size() - element_fields_bytes cannot wrap; name_bytes is then at most size - 24, so the 24 field bytes after the name are inside the span. The count is bounded by size / 30 before reserve. The test's cut loop (every prefix of a valid two-element blob is refused) exercises those bounds.

Not checked: the 25,229-reference corpus count in the description (no game files used here), and nothing calls the parser yet, so there is no runtime path to test.

AI-assisted (Claude Code).

@Kerwinss

Copy link
Copy Markdown

Tested 4a04398 on Windows 11 Pro 10.0.26300, MSVC 14.51 (VS Build Tools 2026), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4060 / 621.24, Khronos Vulkan headers via -DLEONIDA_VULKAN_HEADERS_FETCH=ON: pass, no regression. This is an MSVC build, as a second compiler next to the Clang 23 run in the description.

Merged onto main 867d922 (clean), full runtime build, ctest -C RelWithDebInfo -j4: 238/240, the two failures are main's own on this GPU (d3d12_depth_resolve, #7985; d3d12_vulkan_device:6574). slot57_input_layout_test.cpp compiles without warnings under MSVC, and slot57_input_layout passes.

Code read of parse_slot57_input_layout: every subtraction is guarded. After the min_element_bytes check, data.size() >= 26, so data.size() - element_fields_bytes can't wrap, and name_bytes <= data.size() - 24 keeps the 24 field bytes in range. Name termination and embedded NULs are refused, and trailing bytes must be at most 3 zero pad bytes. I see no out-of-bounds read on malformed input.

AI-assisted (Claude Code). No game files.

gahitchi added a commit to gahitchi/Leonida that referenced this pull request Nov 23, 2026
@MarcPique

Copy link
Copy Markdown

Independent Windows 11 / RTX 4090 boot check. I wired the parser from 4a043987 into a local integration of #8890, with the same 17 translated native graphics stages as the control. MSVC 19.44.35228, driver 32.0.16.1656.

  • The slot57_input_layout CTest passed.
  • The control parser created 11 slot-57 PSOs. Six requests with their translated stages present reached backend validation but failed there, including missing COLOR0 and an invalid vertex format.
  • With this parser, the same pilot created 17 slot-57 PSOs. The backend input-layout and invalid-vertex-format diagnostics disappeared. The remaining requests still require more translated graphics stages.

Counts and API names only. The pilot verifies graphics PSO creation on this stack. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants