Skip to content

startup: link stream pixel attributes to vertex parameters by semantic - #2144

Merged
R0Y00 merged 9 commits into
R0Y00:mainfrom
NiiRoZz:startup/stream-interface-by-semantic
Nov 25, 2026
Merged

R0Y00 merged 9 commits into
R0Y00:mainfrom
NiiRoZz:startup/stream-interface-by-semantic

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Change

In a slot-86 stream pipeline the pixel shader's attribute N is not vertex parameter N. Until now gfx2hlsl.py
paired them by number. A pixel shader that reads only some of the vertex outputs could then interpolate the wrong
one, for example a constant colour where it expects a texture coordinate.

Each container states its side of the interface in its native header:

  • Vertex: one 6-byte record per exported parameter from +0x1dc (output-signature register, parameter index); the
    count is at +0x29c.
  • Pixel: one 8-byte record per attribute from +0x138 (input-signature register, component mask, attribute index,
    interpolation); the count is at +0x238.

gfx2hlsl.py now links each attribute to the vertex parameter whose output register carries the same semantics, with
the same semantic index and the same components. It refuses, with a reason:

  • packed or unexpected records, a pixel table that lists a register twice, and a pixel mask that differs from its
    signature;
  • unmatched semantics or components, and semantics that come from more than one vertex register;
  • headers of another size;
  • reads of attributes the table does not list.

Raw programs without signatures keep pairing by number. A pixel shader that declares no inputs reads no tables.
draw_translated is unchanged. The shader cache revision moves to x2w-startup-shader-8 on both the offline and
runtime sides, so translations paired by number are not reused.

Refs #1142. AI-assisted (Claude Code).

Verification

Head 5b1fe802 (merged with main at 097f7539).

  • Device-free: python -B tests/startup_stream_interface_check.py, also startup_stream_interface_translate and
    the Linux job. Attribute 0 links to the TEXCOORD parameter, including by semantic index (TEXCOORD1). It also checks
    13 refusals: packed pixel record, packed vertex record, different components, semantic not output, pixel header
    size, vertex header size, attribute beyond the table, record mask, two vertex sources, duplicate pixel register,
    pixel count 0, no pixel signature.
  • Draws: ctest --preset release --no-tests=error -R '^startup_stream_interface_(warp|hardware)$' -V.
    • The source-built vertex shader exports a constant COLOR as parameter 0 and a varying TEXCOORD as parameter 1. The
      pixel shader reads only TEXCOORD, as attribute 0.
    • On an 8×4 target, red follows TEXCOORD column by column (16, 48, 80, 112, each within 1) on WARP and on an
      RTX 5090.
    • The same pipeline translated with pairing by number reads COLOR and fails the check.
  • Mutations: seven mutants of the linking code are each caught by the device-free check: semantic name without
    index, pixel count not read, first of several vertex sources, no inputs paired by number, vertex header check
    skipped, no duplicate-register check, record mask not compared.
  • Existing tests: ctest --preset release --no-tests=error -R '^startup_stream_' -j1 and the startup checks in
    the pure-Python list pass.
  • Local requests: 7,470 requests translate identically at base and at this change (17 are stream pipelines).

Evidence and follow-up

The record layouts were checked offline against the signatures of one local shader archive (local files, not in
the repository; counts only, using the translator's own record checks):

  • Vertex: of the 2,041 programs whose image inflates, 1,536 have the simple records and 505 use packed records.
    A pipeline that needs packed records is now refused.
  • Pixel: of the 10,862 programs that declare inputs, 5,975 have the simple records and 4,887 use packed or other
    records. These are refused instead of being paired by number. The 1,239 without inputs need no table.
  • Components: a vertex output whose components differ from the pixel input's is refused. For example, a
    four-component output that feeds a two-component input.
  • Not covered: packed interfaces, raw slot-57 programs (no signatures; they keep pairing by number), and
    depth-test state without a depth format (a separate change).
  • Local run: a console executable was run locally with this change and the partial-tile views of startup: publish BC3/BC7 memory SRVs whose last tile row or column is partial #2105. One
    calibration panel that was flat background before is now drawn: a dark panel with its symbol. Every other checked
    screen is pixel-identical. Before the change, a capture showed that pipeline's pixel shader interpolating COLOR (the
    constant (1, 1, 1, 1)) as its texture coordinate, so it wrote the background level everywhere.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

🤖 Generated with Claude Code

NiiRoZz and others added 8 commits November 25, 2026 00:21
A slot-86 pixel shader's attribute N is not vertex parameter N. Both
containers state their side of the interface in the native header: the vertex
shader one 6-byte record per exported parameter from +0x1dc (count at +0x29c),
the pixel shader one 8-byte record per attribute from +0x138 (count at
+0x238). gfx2hlsl links each attribute to the vertex parameter whose output
register carries the same semantics with the same components, and refuses
packed records, unmatched semantics, a pixel header of another size and reads
of attributes the table does not list. Raw programs without signatures still
pair by number. The shader cache revision moves to x2w-startup-shader-6.

startup_stream_interface_translate (also in the Linux job) checks the link and
each refusal without a device; startup_stream_interface_{warp,hardware} draws a
TEXCOORD gradient that pairing by number fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… inputs

Stream fixtures whose pixel shader declares no inputs keep translating; a read
of an attribute is then refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Takes upstream's request loading (load_request, request_refusals) and threads
the interface map through it and both Pipeline sites; the cache revision moves
past upstream's shader-6 to shader-7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he interface map

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Linking pixel attributes by semantic changes container translations; main
already uses shader-7, so the revision moves past it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Refuse a pixel record whose mask differs from the input signature's mask for
  its register, and a pixel table that lists one register twice.
- Translator-only cases for the semantic index (TEXCOORD1), two vertex sources
  for one attribute, a duplicate pixel register, a vertex header of another
  size, a pixel count of 0 and a pixel container without an input signature.
- load_request always returns seven items; the translator check's mock uses
  that shape.
- Remove a duplicated table the earlier merge copied; order the CMake entries;
  state the archive counts with their populations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps upstream's new pure-Python list entries next to the interface check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head 5b1fe802441009b35a74d980983b43c28bbf6830 (comment only, no approval).

Scope: stream_interface() in tools/startup/gfx2hlsl.py links pixel attributes to vertex parameters by semantic (name + index + component mask) through both containers' interface tables. It refuses anything unverified. The cache revision is bumped to x2w-startup-shader-8. New test tests/startup_stream_interface_check.py is wired into CMake for translate and for each backend.

Checks run locally in a worktree of this head:

  • gh pr checks 2144: Linux Python checks, gfx1013 fixtures, Windows build and test all pass. The /O2 job is skipped and the chart publish is skipped.
  • python3 -B tests/startup_stream_interface_check.py: all cases pass (semantic index link, TEXCOORD parameter reorder, packed pixel record refused, packed vertex record refused, header size refused, mask mismatch refused, two vertex sources refused, duplicate pixel register refused, count 0, no pixel signature).
  • python3 -B tests/startup_translator_check.py: 0 failed.
  • python3 tests/docs_links_check.py: pass (18 files, 398 links).
  • python3 tests/bidi_controls_check.py: pass.
  • git diff --check origin/main...HEAD: clean.
  • Mutation 1: mapping[attr] = params[...] changed to mapping[attr] = attr. The interface test fails on the param1 assertion. Killed.
  • Mutation 2: the component mask comparison output[1] != mask replaced by False. The "different components" case fails. Killed.
  • Worktree restored with git checkout -- . after each mutation.

Findings:

  • P1: none.
  • P2: none.
  • nit (tools/startup/gfx2hlsl.py, stream_interface): the same 8-byte and 6-byte record slice is written twice, once to unpack and once for the error message. Binding it to a local would be shorter.
  • nit: stream_interface is about 55 lines. Splitting the pixel-record loop and the vertex-record loop into helpers would match the file's usual function size.
  • nit: this PR changes translator output for stream pairs, so the Windows D3D12 WARP stream draw tests (startup_stream_interface_<backend>) are the real proof of the behavior. They ran green in the Windows CI job. I did not run a separate Win2025 pipeline job. The CI result was enough for a refusal-heavy table change.

Clean-room and title: the title is neutral and there are no vendor or game names in the diff. mergeable is UNKNOWN at review time. The head is a merge of main, so the CI above covers the merged state.

AI-assisted; commands listed were executed locally.

@R0Y00

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

I kept the semantic-linking path and added refusals for an undeclared component read, duplicate vertex output semantics and interface tables that exceed their header regions. Local Windows Release passed the translation, WARP and RTX 4060 Laptop cases (3/3, no skips), including the wrong-by-number GPU control. The startup translator regression also passes.

@R0Y00
R0Y00 merged commit 726fc36 into R0Y00:main Nov 25, 2026
5 checks passed
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.

3 participants