xshader: fill the root constants of rooted vertex and pixel programs #611

Merged
NickStallman merged 4 commits from upstream-pr/611 into main 2026-12-01 20:31:27 +00:00
NickStallman commented 2026-12-01 06:09:05 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T06:09:05Z.


A vertex or pixel program translated against a root signature had its root constants bound for one shape only: a pixel program whose root is one table followed by them. Otherwise the registers the console fills with them started at zero, with no refusal, and the program was accepted.

The program's own records say where its constants are: exactly one user-data row (1 to 32 dwords), one used-resource row with the same register and location, and one constant-buffer binding at that register. The location numbers the root parameter, which must hold constants, at least as many, and be visible to the stage. They are bound at the register and space that parameter has.

A rooted vertex or pixel program is now refused if its constants aren't found and either a used-resource row says it uses them or the translator sees one of their registers read. The record matters because the translator's list of registers read misses some reads, such as the high half of a 64-bit scalar source. A program whose constants are read and never filled also gets a header line naming them (// unresolved inputs: s10 s13 (root constants)), and preparation reports it. Compute, mesh, amplification and packed roots are unchanged.

Refs #533 (claimed there).

What it changes in a title

In a title we traced, the lighting draws take a material index from a root constant and depth-test EQUAL against it; with the constant at zero they could only match material 0. The surface programs also read their material records at an offset from a root constant. In an integration build with this change, captures of one run (RTX 5090, 620.70.10, GE-Proton11-15) showed surface-colour targets that had been black now filled: of pixels drawn with a surface, albedo exactly zero went from 76–85% to 22%. Lighting needed a second fix (#613); with both, and #612, the picture became recognisable. No device loss, no refused submission.

Measured

  • Recorded translations with constants and a root, from one title (21,051, main 717a74c4): 12,878 change (pixel 11,011, vertex 1,449, linked pixel 418). None is newly refused or newly accepted; the record-based refusal was counted before it was enabled: 0 of 23,421 rooted vertex/pixel requests and links have a used row with unresolved constants. These are translations, not programs: many appear twice, with and without the index map. The head's output is identical to the first commit's for all 21,051.
  • DXC -O3 and dxv over all 12,878 changed: 11,298 distinct programs compiled and validated, 1,580 identical copies, 0 failures.
  • Unit tests for the vertex form, pixel behind two tables, register, space, visibility, size and record cases, both refusals and unread constants. Three existing tests gave a program a root lacking its constants and now have them. 27 mutations of the new code, all caught (one only after an assertion was added).
  • Lanes raster-vertex-constants: two tables then four constants; vertex depth from a constant under an EQUAL test, four draws, and the pixel result XORs all four. Passes on both cards (below). Control on the RTX 5090 with the scenario but without the translator change: lanes-selftest FAIL raster-vertex-constants: material 7, texel 0,0: expected 0x73b4e286, found 0.
  • Rebased onto fb17e160 (after #523's codegen rewrite): 21,054 requests and links, 12,879 change (one link request is new since the first survey), 698 refused before and after, none newly refused or accepted. DXC -O3 and dxv over all 12,879: 11,285 distinct programs compile and validate, 0 failures.
  • Evidence: TuxBox check of cd8f0c190fba, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run
  • Before the rebase, full python tuxbox.py check of 7d9a9938 (GE-Proton11-15): RTX 5090 (10de:2b85, 620.70.10) 209 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 208 pass, 0 fail.

Evidence: TuxBox check of 7d9a9938e3, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run
Evidence: TuxBox check of 7d9a9938e3, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run

Not covered

  • Root constants in a command signature are refused by the provider, before and after.
  • Mesh programs with more than four constants read zeros past the fourth (none recorded).
  • Rooted compute programs whose constants follow other parameters: a follow-up PR.
  • A program whose constants are reached through a chained entry (s_swappc, the layout emitter/bindings.rs describes) and read from the relocated registers: found by a synthetic probe, not in any recorded program. Its relocated register still reads zero.
  • A title that never sets a constant now reads whatever the host's root holds where it used to read zero.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5580130669 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/611). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T06:09:05Z. --- A vertex or pixel program translated against a root signature had its root constants bound for one shape only: a pixel program whose root is one table followed by them. Otherwise the registers the console fills with them started at zero, with no refusal, and the program was accepted. The program's own records say where its constants are: exactly one user-data row (1 to 32 dwords), one used-resource row with the same register and location, and one constant-buffer binding at that register. The location numbers the root parameter, which must hold constants, at least as many, and be visible to the stage. They are bound at the register and space that parameter has. A rooted vertex or pixel program is now refused if its constants aren't found and either a used-resource row says it uses them or the translator sees one of their registers read. The record matters because the translator's list of registers read misses some reads, such as the high half of a 64-bit scalar source. A program whose constants are read and never filled also gets a header line naming them (`// unresolved inputs: s10 s13 (root constants)`), and preparation reports it. Compute, mesh, amplification and packed roots are unchanged. Refs #533 (claimed there). ## What it changes in a title In a title we traced, the lighting draws take a material index from a root constant and depth-test EQUAL against it; with the constant at zero they could only match material 0. The surface programs also read their material records at an offset from a root constant. In an integration build with this change, captures of one run (RTX 5090, 620.70.10, GE-Proton11-15) showed surface-colour targets that had been black now filled: of pixels drawn with a surface, albedo exactly zero went from 76–85% to 22%. Lighting needed a second fix (#613); with both, and #612, the picture became recognisable. No device loss, no refused submission. ## Measured - **Recorded translations with constants and a root**, from one title (21,051, main 717a74c4): 12,878 change (pixel 11,011, vertex 1,449, linked pixel 418). None is newly refused or newly accepted; the record-based refusal was counted before it was enabled: 0 of 23,421 rooted vertex/pixel requests and links have a used row with unresolved constants. These are translations, not programs: many appear twice, with and without the index map. The head's output is identical to the first commit's for all 21,051. - **DXC -O3 and dxv over all 12,878 changed:** 11,298 distinct programs compiled and validated, 1,580 identical copies, 0 failures. - **Unit tests** for the vertex form, pixel behind two tables, register, space, visibility, size and record cases, both refusals and unread constants. Three existing tests gave a program a root lacking its constants and now have them. 27 mutations of the new code, all caught (one only after an assertion was added). - **Lanes `raster-vertex-constants`:** two tables then four constants; vertex depth from a constant under an EQUAL test, four draws, and the pixel result XORs all four. Passes on both cards (below). Control on the RTX 5090 with the scenario but without the translator change: `lanes-selftest FAIL raster-vertex-constants: material 7, texel 0,0: expected 0x73b4e286, found 0`. - Rebased onto fb17e160 (after #523's codegen rewrite): 21,054 requests and links, 12,879 change (one link request is new since the first survey), 698 refused before and after, none newly refused or accepted. DXC -O3 and dxv over all 12,879: 11,285 distinct programs compile and validate, 0 failures. - `Evidence: TuxBox check of cd8f0c190fba, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run` - Before the rebase, full `python tuxbox.py check` of 7d9a9938 (GE-Proton11-15): RTX 5090 (`10de:2b85`, 620.70.10) 209 pass, 0 fail; AMD iGPU (`1002:13c0`, RADV) 208 pass, 0 fail. Evidence: TuxBox check of 7d9a9938e38a, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run Evidence: TuxBox check of 7d9a9938e38a, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run ## Not covered - Root constants in a command signature are refused by the provider, before and after. - Mesh programs with more than four constants read zeros past the fourth (none recorded). - Rooted compute programs whose constants follow other parameters: a follow-up PR. - A program whose constants are reached through a chained entry (`s_swappc`, the layout `emitter/bindings.rs` describes) and read from the relocated registers: found by a synthetic probe, not in any recorded program. Its relocated register still reads zero. - A title that never sets a constant now reads whatever the host's root holds where it used to read zero. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
brcly/TuxBox!611
No description provided.