d3d12, dxbc: give literal sampler states the root lacks private registers above its own #241

Merged
NickStallman merged 1 commit from upstream-pr/241 into main 2026-11-26 17:06:33 +00:00
NickStallman commented 2026-11-26 15:33:44 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-26T15:33:44Z.


What was refused: the largest refusal group in the ProjectScarlett 1.0.2.1 shader cache: mimg at 0x_: sN not a sampler descriptor (Some(InlineWord(N))). That is 458 of the 24,832 recorded requests, 21% of all refusals.

Cause: the console compiles a static sampler's state into the program as literal words (s_movk/s_mov/s_brev). A title can pair the program with a root that has no static sampler in that state, so the translation finds nothing to bind. missing_literal_samplers (#216) appends private samplers in that case, but:

  • only for roots that don't index the heap (flag 0x800). Most of the group does.
  • only when inline_sampler::private accepts the program: PSV and FSSM must agree, and every sampler must be a literal.
  • its registers start at 0 in space 32765. The translator names a sampler by its register alone, so a program that also uses the root's own s0 is refused with static sampler sN overlaps another space. JeffreyBytes saw the same thing on the mesh path in #227: 43 of 126 programs.

The multi-table raster root restores only what omitted finds.

Change:

  • inline_sampler::unmatched(shader, stage, &root) lists each literal state that no static sampler visible to the stage has. Each one gets a register in space 32765, after every sampler register the root uses in any space (static samplers and sampler tables).
  • compute_table::literal_samplers calls unmatched first and keeps missing_literal_samplers for anything it doesn't cover. It is used by the reflected compute root, the single-table raster root and sampler_root, which now also take 0x800 roots. The multi-table raster root calls unmatched after omitted.
  • xshader is unchanged. It already binds a literal state to any static sampler in that state, the title's own first.

JeffreyBytes will build the mesh half on top of this (#227): mesh_table::reflected copies the title's static samplers and adds none.

Measured against the recorded requests, CPU only, without the game. The 458 refused requests were translated by the current xshader after appending to each request's recorded root the samplers that main and this branch would add (literal_samplers for compute, plus omitted for pixel). Three requests have no root and are left out:

translated still refused
main 151 of 455 296 InlineWord, 8 overlaps another space
this branch 429 of 455 21 unresolved image, 4 PS attr1 has no signature register, 1 dynamic soffset

No InlineWord refusals remain. The 26 left are other gaps that the samplers had been hiding. This is an upper bound: at runtime, a root gets the samplers only where reflected or sampler_root handles it, and raster pipelines whose layout is Unsupported still don't.

  • python tuxbox.py check passed on this branch on AMD and NVIDIA (below).
  • This changes code both vendors run, and the check passed on an AMD and an NVIDIA card.
  • Changed or new behaviour is covered by a Lanes scenario: raster-samplers.

Lanes: new scenario raster-samplers, run by the existing lanes-raster-tables suite after raster-tables.

  • raster_fixture.py adds a third hand-written console program. The pixel program samples a 2x1 texture of 1.0 and 3.0 at table 1 slot 0, at u = 0.375. Its sampler is linear and clamped, built from literal words (s_movk/s_mov). It declares that sampler as s0.
  • The root has the same two tables as raster-tables, plus a point-filtered static sampler at s0. Every texel must read 1.5, the linear result.
  • On main, the translation binds the root's s0, and every texel reads the point-filtered 1.0. The gate fails with texel 0,0 is 1: point-filtered by the root's s0, not the program's literal linear state. That was checked on the AMD iGPU with this branch's compute_table.rs reverted.
  • With this change, the provider reflects the root (created raster pipeline with 1 reflected FSSM descriptor slots), adds the private sampler, and the gate passes.
  • raster_tables and raster_samplers now share the root and draw helpers in selftest.cpp.

Unit tests cover the same case. inline_sampler: a literal state with no matching static sampler takes a private register, and private registers follow every sampler register of the root. sampler_heap: the translation is refused against the title's root, and translates once the private static sampler is appended.

Tested:

  • cargo test -p tuxbox-dxbc --features native-bindings: 68 passed. cargo test for tools/shader-compiler: 335 + 2 passed.
  • cargo check --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 --tests: clean.
  • python -m unittest discover -s tests -q: 379 tests, OK (18 skipped).
  • AMD Raphael iGPU (1002:13c0), RADV, GE-Proton11-14: full python tuxbox.py check --adapter 1002:13c0 --proton … --prefix … --windows-dxc … passed, 101 gates (including lanes-raster-samplers), including Lanes and the fixtures, the D3D12 regression controls and the translator GPU checks.
  • RTX 5090 (10de:2b85), driver 595.99.02, GE-Proton11-14: full python tuxbox.py check passed, 102 gates, including lanes-raster-samplers. This ran on the branch rebased onto 3b8a220; the AMD run was on c6ce497.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:6630006952 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/241). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-26T15:33:44Z. --- **What was refused:** the largest refusal group in the ProjectScarlett 1.0.2.1 shader cache: `mimg at 0x_: sN not a sampler descriptor (Some(InlineWord(N)))`. That is 458 of the 24,832 recorded requests, 21% of all refusals. **Cause:** the console compiles a static sampler's state into the program as literal words (`s_movk`/`s_mov`/`s_brev`). A title can pair the program with a root that has no static sampler in that state, so the translation finds nothing to bind. `missing_literal_samplers` (#216) appends private samplers in that case, but: - only for roots that don't index the heap (flag 0x800). Most of the group does. - only when `inline_sampler::private` accepts the program: PSV and FSSM must agree, and every sampler must be a literal. - its registers start at 0 in space 32765. The translator names a sampler by its register alone, so a program that also uses the root's own `s0` is refused with `static sampler sN overlaps another space`. JeffreyBytes saw the same thing on the mesh path in #227: 43 of 126 programs. The multi-table raster root restores only what `omitted` finds. **Change:** - `inline_sampler::unmatched(shader, stage, &root)` lists each literal state that no static sampler visible to the stage has. Each one gets a register in space 32765, after every sampler register the root uses in any space (static samplers and sampler tables). - `compute_table::literal_samplers` calls `unmatched` first and keeps `missing_literal_samplers` for anything it doesn't cover. It is used by the reflected compute root, the single-table raster root and `sampler_root`, which now also take 0x800 roots. The multi-table raster root calls `unmatched` after `omitted`. - `xshader` is unchanged. It already binds a literal state to any static sampler in that state, the title's own first. JeffreyBytes will build the mesh half on top of this (#227): `mesh_table::reflected` copies the title's static samplers and adds none. **Measured** against the recorded requests, CPU only, without the game. The 458 refused requests were translated by the current `xshader` after appending to each request's recorded root the samplers that `main` and this branch would add (`literal_samplers` for compute, plus `omitted` for pixel). Three requests have no root and are left out: | | translated | still refused | | --- | ---: | ---: | | `main` | 151 of 455 | 296 `InlineWord`, 8 `overlaps another space` | | this branch | 429 of 455 | 21 `unresolved image`, 4 `PS attr1 has no signature register`, 1 dynamic `soffset` | No `InlineWord` refusals remain. The 26 left are other gaps that the samplers had been hiding. This is an upper bound: at runtime, a root gets the samplers only where `reflected` or `sampler_root` handles it, and raster pipelines whose layout is `Unsupported` still don't. - [x] `python tuxbox.py check` passed on this branch on AMD and NVIDIA (below). - [x] This changes code both vendors run, and the check passed on an AMD and an NVIDIA card. - [x] Changed or new behaviour is covered by a Lanes scenario: `raster-samplers`. **Lanes:** new scenario `raster-samplers`, run by the existing `lanes-raster-tables` suite after `raster-tables`. - `raster_fixture.py` adds a third hand-written console program. The pixel program samples a 2x1 texture of 1.0 and 3.0 at table 1 slot 0, at u = 0.375. Its sampler is linear and clamped, built from literal words (`s_movk`/`s_mov`). It declares that sampler as `s0`. - The root has the same two tables as `raster-tables`, plus a point-filtered static sampler at `s0`. Every texel must read 1.5, the linear result. - On `main`, the translation binds the root's `s0`, and every texel reads the point-filtered 1.0. The gate fails with `texel 0,0 is 1: point-filtered by the root's s0, not the program's literal linear state`. That was checked on the AMD iGPU with this branch's `compute_table.rs` reverted. - With this change, the provider reflects the root (`created raster pipeline with 1 reflected FSSM descriptor slots`), adds the private sampler, and the gate passes. - `raster_tables` and `raster_samplers` now share the root and draw helpers in `selftest.cpp`. Unit tests cover the same case. `inline_sampler`: a literal state with no matching static sampler takes a private register, and private registers follow every sampler register of the root. `sampler_heap`: the translation is refused against the title's root, and translates once the private static sampler is appended. **Tested:** - `cargo test -p tuxbox-dxbc --features native-bindings`: 68 passed. `cargo test` for `tools/shader-compiler`: 335 + 2 passed. - `cargo check --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 --tests`: clean. - `python -m unittest discover -s tests -q`: 379 tests, OK (18 skipped). - AMD Raphael iGPU (1002:13c0), RADV, GE-Proton11-14: full `python tuxbox.py check --adapter 1002:13c0 --proton … --prefix … --windows-dxc …` passed, 101 gates (including `lanes-raster-samplers`), including Lanes and the fixtures, the D3D12 regression controls and the translator GPU checks. - RTX 5090 (10de:2b85), driver 595.99.02, GE-Proton11-14: full `python tuxbox.py check` passed, 102 gates, including `lanes-raster-samplers`. This ran on the branch rebased onto `3b8a220`; the AMD run was on `c6ce497`. 🤖 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!241
No description provided.