d3d12: reflect raster roots with several descriptor tables #168

Manually merged
github merged 1 commit from gh-pr/168/head into gh-pr/168/base 2026-11-26 06:35:51 +00:00
Owner

@⁠postblink on GitHub · 2026-11-25 12:51 UTC · original
postblink:fix/raster-multi-table-roots → main · +336 −15 · 4 files · 1 commits · merged 2026-11-25 14:21 UTC

Summary

ProjectScarlett creates most of its raster pipelines with root signatures that have several leading descriptor tables, for example [table, table, constants] or [table, table, table, root SRV, constants]. For raster pipelines, compute_table::reflected accepted only [table] or [table, constants], so it returned Unsupported for these. The pipeline then kept the guest root with the root-less prepared translations.

Those translations name table slots the guest root doesn't cover, so vkd3d-proton refuses the stage with dxil-spirv: Failed to remap <SRV|CBV|UAV> <space>:<register> (vkd3d result -3), and the title gets a stand-in.

This change reflects those roots:

  • dxbc, table records: under a root with several leading tables, a raster FSSM descriptor record names its table in the high half of its location, as compute records already do, and table N is read from s8 + N. root_bindings resolves these records and fails closed on any record whose table and SGPR disagree. Root constants name their parameter the same way, and the existing user-data check confirms them.

  • dxbc, more resource kinds under these roots only:

    • A root SRV (FSSM class 0x100, two SGPRs, user-data row [1, 0, 2]), read the way mesh_table reads it. The shader names it with its own register, which can differ from the root's, so it is returned as a ROOT_SRV binding for its parameter.
    • A four-dword UAV buffer, typed, raw or structured as PSV says. This is the rule compute records already use.
    • A four-dword typed SRV buffer, when PSV names no structured view for that register.

    Root-less, single-table and compute results are unchanged.

  • dxbc, merging stages: merge_raster_bindings merges the vertex and pixel bindings. It returns None when the stages disagree: one slot with two registers, or one register at two slots.

  • d3d12: reflected accepts raster roots with several leading tables followed by root descriptors and constants.

    • Root SRVs keep their parameter and take the register the shader names, as the mesh layout does.
    • A layout needs at least one table binding, because a reflected table binds through the resource heap at draw time.
    • Per-table state is sized to the root.
  • stream: for these roots, the reflected (or original) root is used only when it can be built, both stages have a translation against it, and the pixel shader doesn't export a stencil reference (draws refuse stencil export with a reflected table). Otherwise the pipeline is created exactly as before.

  • trace: with TUXBOX_TRACE_RASTER_ROOTS=1, the runtime logs running totals of how these pipelines were created, including which stage did not resolve.

Results on ProjectScarlett

These come from an RTX 5080. Title data stayed local; only aggregate counts are given here.

A/B. Two unattended 900 s runs, back to back, branch first, same settings (VKD3D_SHADER_DEBUG=warn, TUXBOX_TRACE_RASTER_ROOTS=1). The branch run used this commit before its later rebases: range-diff shows the two as identical, on 529c52d. The stock run was on 5dd0d84, four commits newer, including #165's faster cache lookups, which can only help stock.

Pipelines This branch main
Not delivered 2,556 4,594
Stand-ins 1,791 3,829
0x80070057 744 744
0x80004001 21 21
Failed to remap log lines 2,226 4,287

The refusal codes are unchanged. Neither run logged a kernel NVRM/Xid line.

The branch's trace covered 2,816 multi-table raster pipelines:

Outcome Pipelines
Reflected 2,218
Original root used 382
Guest root kept: pixel stage untranslated 141
Guest root kept: vertex stage untranslated 72
Unresolved 3

Offline, on captured (shader, root) pairs. A run at 5678a2f captured 3,545 pairs with TUXBOX_CAPTURE_RASTER_ROOTS and TUXBOX_CAPTURE_SHADER_INPUTS. A local hook, not part of this PR, also captured the unresolved vertex stages. root_bindings for the raster stages under roots with two or three leading tables:

Stage main This branch
Pixel 973 of 2,079 2,073 of 2,079
Vertex 57 of 569 565 of 569

The three gaps the vertex stages hit were the root SRV (its register differs from the root's in every failing capture), four-dword UAV buffers, and typed SRV buffers.

A parity check on the same captures shows that compute, single-table raster and root-less bindings() results are identical to main. Every capture that resolved on main still resolves. Under multi-table roots, 2,664 bindings that main placed in table 0 now name the table their record encodes. main never used those, because reflected refused these roots.

Not covered: if the host refuses the combined PSO after a rooted translation succeeds, this path does not retry with the guest root. The existing single-table path behaves the same way.

Verified on Lanes

  • python tuxbox.py check passed on this branch
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below

GPU, driver and backend: NVIDIA GeForce RTX 5080 (10de:2c02), driver 620.73.04, Proton Experimental 11.0-20261112. Present checks ran in a private rootful Xwayland on CachyOS (kernel 7.3.6), KDE Wayland. All 62 GPU checks passed.

This run used --windows-dxc with Microsoft's x64 DXC 1.8.2505.1. Xvfb isn't installed on this host, so the D3D12 regression controls ran through a local xvfb-run -a stand-in backed by TigerVNC's Xvnc. It gives a private headless X server with no TCP and passes back the command's exit status, and I tested it under the same bwrap sandbox the controls use.

Summary
  passed   Python tests (2s)
  passed   Shader compiler tests (0s)
  passed   DXBC tests (0s)
  passed   XG layout tests (1s)
  passed   D3D12 Windows typecheck (0s)
  passed   Build (19s)
  passed   Lanes and fixtures on the GPU (145s)
  passed   D3D12 regression controls (32s)

All checks passed.

Why there is no Lanes scenario yet. Lanes' one console shader (shader_fixture.py) is a single-instruction compute program with an empty root. Exercising this path needs console vertex and pixel programs whose FSSM records and PSV rows name descriptors in several root tables, plus a pipeline stream with such a root, and all of it must be accepted by the translator. I'd rather add that as a separate pull request than hand-write it into this one. If you want it here, say so. Until then, the DXBC tests below build complete synthetic shaders for the new decoding rules.

Checks

  • python -m unittest discover -s tests: 291 tests

  • Shader compiler: 279 + 2

  • dxbc with native-bindings: 58. That includes five new tests:

    • leading_tables_counts_only_the_first_run_of_tables
    • multi_table_raster_records_name_their_table
    • raster_stage_bindings_merge_only_when_they_agree
    • multi_table_root_srv_carries_the_shader_register
    • multi_table_raster_buffer_views_follow_psv

    The last two build complete synthetic DXBC containers (DXIL with XDAT/FSSM, and PSV0), using test helpers made pub(crate) in xdat.rs.

  • xg-layout: 14

  • cargo check --target x86_64-pc-windows-msvc -p tuxbox-d3d12

Each of these mutations makes a new test fail:

  • ignoring the SGPR
  • ignoring the leading-table bound
  • counting every table instead of the leading run
  • skipping the root SRV user-data check
  • accepting a root SRV for a non-SRV parameter
  • dropping the multi-table gate on the typed fallback
  • dropping the multi-table gate on the UAV rule
  • accepting a raw UAV that PSV names typed
  • merging stages that disagree, in either direction

No evidence JSON changed.

Prepared with an AI agent (Claude), with independent review passes by a second model (Codex) that found five fallback bugs, all fixed here. The numbers come from local runs and offline checks on the hardware listed.

**@⁠postblink** on GitHub · 2026-11-25 12:51 UTC · [original](https://github.com/brcly/TuxBox/pull/168) `postblink:fix/raster-multi-table-roots` → `main` · +336 −15 · 4 files · 1 commits · merged 2026-11-25 14:21 UTC ## Summary ProjectScarlett creates most of its raster pipelines with root signatures that have several leading descriptor tables, for example `[table, table, constants]` or `[table, table, table, root SRV, constants]`. For raster pipelines, `compute_table::reflected` accepted only `[table]` or `[table, constants]`, so it returned `Unsupported` for these. The pipeline then kept the guest root with the root-less prepared translations. Those translations name table slots the guest root doesn't cover, so vkd3d-proton refuses the stage with `dxil-spirv: Failed to remap <SRV|CBV|UAV> <space>:<register>` (`vkd3d result -3`), and the title gets a stand-in. This change reflects those roots: - **dxbc, table records:** under a root with several leading tables, a raster FSSM descriptor record names its table in the high half of its location, as compute records already do, and table N is read from s8 + N. `root_bindings` resolves these records and fails closed on any record whose table and SGPR disagree. Root constants name their parameter the same way, and the existing user-data check confirms them. - **dxbc, more resource kinds under these roots only:** - A root SRV (FSSM class `0x100`, two SGPRs, user-data row `[1, 0, 2]`), read the way `mesh_table` reads it. The shader names it with its own register, which can differ from the root's, so it is returned as a `ROOT_SRV` binding for its parameter. - A four-dword UAV buffer, typed, raw or structured as PSV says. This is the rule compute records already use. - A four-dword typed SRV buffer, when PSV names no structured view for that register. Root-less, single-table and compute results are unchanged. - **dxbc, merging stages:** `merge_raster_bindings` merges the vertex and pixel bindings. It returns `None` when the stages disagree: one slot with two registers, or one register at two slots. - **d3d12:** `reflected` accepts raster roots with several leading tables followed by root descriptors and constants. - Root SRVs keep their parameter and take the register the shader names, as the mesh layout does. - A layout needs at least one table binding, because a reflected table binds through the resource heap at draw time. - Per-table state is sized to the root. - **stream:** for these roots, the reflected (or original) root is used only when it can be built, both stages have a translation against it, and the pixel shader doesn't export a stencil reference (draws refuse stencil export with a reflected table). Otherwise the pipeline is created exactly as before. - **trace:** with `TUXBOX_TRACE_RASTER_ROOTS=1`, the runtime logs running totals of how these pipelines were created, including which stage did not resolve. ### Results on ProjectScarlett These come from an RTX 5080. Title data stayed local; only aggregate counts are given here. **A/B.** Two unattended 900 s runs, back to back, branch first, same settings (`VKD3D_SHADER_DEBUG=warn`, `TUXBOX_TRACE_RASTER_ROOTS=1`). The branch run used this commit before its later rebases: `range-diff` shows the two as identical, on `529c52d`. The stock run was on `5dd0d84`, four commits newer, including #165's faster cache lookups, which can only help stock. | Pipelines | This branch | `main` | |---|---|---| | Not delivered | **2,556** | 4,594 | | Stand-ins | **1,791** | 3,829 | | `0x80070057` | 744 | 744 | | `0x80004001` | 21 | 21 | | `Failed to remap` log lines | **2,226** | 4,287 | The refusal codes are unchanged. Neither run logged a kernel `NVRM`/`Xid` line. The branch's trace covered 2,816 multi-table raster pipelines: | Outcome | Pipelines | |---|---| | Reflected | 2,218 | | Original root used | 382 | | Guest root kept: pixel stage untranslated | 141 | | Guest root kept: vertex stage untranslated | 72 | | Unresolved | 3 | **Offline, on captured (shader, root) pairs.** A run at `5678a2f` captured 3,545 pairs with `TUXBOX_CAPTURE_RASTER_ROOTS` and `TUXBOX_CAPTURE_SHADER_INPUTS`. A local hook, not part of this PR, also captured the unresolved vertex stages. `root_bindings` for the raster stages under roots with two or three leading tables: | Stage | `main` | This branch | |---|---|---| | Pixel | 973 of 2,079 | 2,073 of 2,079 | | Vertex | 57 of 569 | 565 of 569 | The three gaps the vertex stages hit were the root SRV (its register differs from the root's in every failing capture), four-dword UAV buffers, and typed SRV buffers. A parity check on the same captures shows that compute, single-table raster and root-less `bindings()` results are identical to `main`. Every capture that resolved on `main` still resolves. Under multi-table roots, 2,664 bindings that `main` placed in table 0 now name the table their record encodes. `main` never used those, because `reflected` refused these roots. **Not covered:** if the host refuses the combined PSO after a rooted translation succeeds, this path does not retry with the guest root. The existing single-table path behaves the same way. ## Verified on Lanes - [x] `python tuxbox.py check` passed on this branch - [ ] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below GPU, driver and backend: NVIDIA GeForce RTX 5080 (`10de:2c02`), driver 620.73.04, Proton Experimental 11.0-20261112. Present checks ran in a private rootful Xwayland on CachyOS (kernel 7.3.6), KDE Wayland. All 62 GPU checks passed. This run used `--windows-dxc` with Microsoft's x64 DXC 1.8.2505.1. Xvfb isn't installed on this host, so the D3D12 regression controls ran through a local `xvfb-run -a` stand-in backed by TigerVNC's `Xvnc`. It gives a private headless X server with no TCP and passes back the command's exit status, and I tested it under the same `bwrap` sandbox the controls use. ```text Summary passed Python tests (2s) passed Shader compiler tests (0s) passed DXBC tests (0s) passed XG layout tests (1s) passed D3D12 Windows typecheck (0s) passed Build (19s) passed Lanes and fixtures on the GPU (145s) passed D3D12 regression controls (32s) All checks passed. ``` **Why there is no Lanes scenario yet.** Lanes' one console shader (`shader_fixture.py`) is a single-instruction compute program with an empty root. Exercising this path needs console vertex and pixel programs whose FSSM records and PSV rows name descriptors in several root tables, plus a pipeline stream with such a root, and all of it must be accepted by the translator. I'd rather add that as a separate pull request than hand-write it into this one. If you want it here, say so. Until then, the DXBC tests below build complete synthetic shaders for the new decoding rules. ## Checks - `python -m unittest discover -s tests`: 291 tests - Shader compiler: 279 + 2 - `dxbc` with `native-bindings`: 58. That includes five new tests: - `leading_tables_counts_only_the_first_run_of_tables` - `multi_table_raster_records_name_their_table` - `raster_stage_bindings_merge_only_when_they_agree` - `multi_table_root_srv_carries_the_shader_register` - `multi_table_raster_buffer_views_follow_psv` The last two build complete synthetic DXBC containers (DXIL with XDAT/FSSM, and PSV0), using test helpers made `pub(crate)` in `xdat.rs`. - `xg-layout`: 14 - `cargo check --target x86_64-pc-windows-msvc -p tuxbox-d3d12` Each of these mutations makes a new test fail: - ignoring the SGPR - ignoring the leading-table bound - counting every table instead of the leading run - skipping the root SRV user-data check - accepting a root SRV for a non-SRV parameter - dropping the multi-table gate on the typed fallback - dropping the multi-table gate on the UAV rule - accepting a raw UAV that PSV names typed - merging stages that disagree, in either direction No evidence JSON changed. Prepared with an AI agent (Claude), with independent review passes by a second model (Codex) that found five fallback bugs, all fixed here. The numbers come from local runs and offline checks on the hardware listed.
ProjectScarlett creates most of its raster pipelines with roots that
have several leading descriptor tables, such as [table, table,
constants] or [table, table, table, root SRV, constants]. reflected()
accepted only [table] and [table, constants] for raster pipelines, so
these kept the guest root with the root-less prepared translations.
Those translations name table slots the guest root does not cover, and
vkd3d-proton refused the stage ("Failed to remap", result -3).

- dxbc: under a root with several leading tables, a raster FSSM
  descriptor record names its table in the high half of its location,
  as compute records do, and table N is read from s8 + N. root_bindings
  resolves these records and fails closed on any record whose table and
  SGPR disagree. Raster root constants name their parameter the same
  way and are confirmed by the user-data check.
- dxbc: under these roots only, also read what their vertex and pixel
  stages use:
  - a root SRV (FSSM class 0x100, two SGPRs, user-data row [1, 0, 2]),
    as mesh_table reads it. The shader names it with its own register,
    so it is returned as a ROOT_SRV binding for its parameter;
  - a four-dword UAV buffer, typed, raw or structured as PSV says, the
    rule compute records already use;
  - a four-dword typed SRV buffer when PSV names no structured view for
    the register.
  Root-less, single-table and compute results are unchanged.
- dxbc: merge_raster_bindings merges the vertex and pixel bindings and
  returns None when the stages disagree (one slot with two registers,
  or one register at two slots).
- d3d12: reflected() accepts raster roots with several leading tables
  followed by root descriptors and constants. Root SRVs keep their
  parameter and take the register the shader names, as the mesh layout
  does. Per-table state is sized to the root.
- stream: for these roots the reflected (or original) root is used only
  when it can be built and both stages translate against it. Otherwise
  the pipeline is created exactly as before, so a pipeline that worked
  before is not refused now.
- With TUXBOX_TRACE_RASTER_ROOTS=1, the runtime logs running totals of
  how these pipelines were created, including which stage did not
  resolve.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:35:47 +00:00
github manually merged commit 95b242b216 into gh-pr/168/base 2026-11-26 06:35:51 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.