d3d12, dxbc: lay out a mesh pipeline's pixel tables as the pixel program reads them #177

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

@⁠3kynox on GitHub · 2026-11-25 16:37 UTC · original
3kynox:pr-mesh-pixel-layout → main · +247 −8 · 5 files · 1 commits · merged 2026-11-25 17:59 UTC

Summary

Follow-up to #157, #158 and #163.

After #163, ProjectScarlett still loses most of its mesh pipelines to 0x80070057: vkd3d-proton refuses the pixel stage with dxil-spirv: Failed to remap <SRV|CBV> <space>:<register>. On main at 682a0e4 that was 2,579 distinct mesh pipelines seven minutes into a run.

The cause is the title's root signature. For the pixel stage of these pipelines it does not describe the table the program reads. Like the mesh program, the pixel program carries its own physical layout in its FSSM records. Where the two disagree, the console follows the program: it takes the table's address from a scalar register and reads the slot. The declaration is not consulted.

One of these pipelines, root parameter 1 (visible to all stages, space 1):

slot 0 slot 1 slot 2 slot 3 slot 4 slot 6
Title's root t12 t69 t20 t6 b0 none
Pixel program reads t96 b5

The program's resource list names t96 and b5 in space 1. The root declares neither. The pixel stage is translated against the guest root (#157), so it declares two registers that no parameter of the host root has, and the host refuses the pipeline.

This change reads the pixel program's layout the way MeshLayout already reads the mesh program's, and uses it:

  • dxbc: MeshLayout::from_pixel_shader reads a pixel program under the same rules as a mesh program. Two rules depend on the stage. A root parameter must be visible to all stages or to the stage being read. A pixel program can hold unordered-access textures (FSSM class 0x303, eight words), which become UAV ranges.
  • d3d12, host root: where the pixel layout differs from the root for a table that is visible to all stages, the pixel-only copy of that table (mirrors, #158) is laid out as the pixel program reads it. If the mesh layout did not rewrite that table, the title's declaration is kept for the mesh stage only.
  • d3d12, translation: the pixel stage is then translated against a root that has those tables in place of the title's (ComputeTable::pixel_root). The translated program and the host root name the same registers at the same slots.

A pipeline whose pixel layout agrees with the root, or cannot be read, is built exactly as before: same root, same copies, same translation.

Not handled: a table visible to the pixel stage only, root descriptors and root constants. In the 2,397 pixel programs I captured with their roots, every table that differs is visible to all stages.

#168 does the matching work for vertex/pixel pipelines and brings their stand-ins down. Its table shows the 0x80070057 count unchanged (744 and 744). That count is what this pull request is about: in my runs every 0x80070057 row is a mesh pipeline.

Measured on ProjectScarlett

Two unattended offline runs, one after the other, taken before today's merges. Only d3d12_xs.dll differed: it was built from main at 682a0e4 for one run and from this change on top of 682a0e4 for the other. The branch was then rebased onto 7b22d71. The code is the same as in the measured build, except that a helper of a few lines in stream.rs is now written inline and the two tests moved to src/tests/mesh_table.rs. Every other provider, the launcher, the translator binary (TUXBOX_XSHADER) and the prepared shader cache were the same files. Both runs used TUXBOX_RUNTIME_SHADER_JOBS=8, TUXBOX_TRACE_PRESENT=600 and TUXBOX_LOG_TIME=1, left the first screen through an injected key press at about 40 s, and started with the translations of an earlier run in the cache. The counts are distinct pipelines in the run's pipeline-failures file.

Pipelines not delivered main, 420 s This branch, 600 s
Mesh, 0x80070057 2,579 81
Mesh, 0x80004001 71 68
Mesh, 0x80004005 22 16
Other pipelines, stand-in 2,769 2,759

The branch run got more time because it has more work per pipeline: it compiles the pipelines main gives up on. The stand-in row is the control. It shows the two runs covered the same part of the title's loading: the branch's 2,759 stand-in pipelines are all among main's 2,769.

  • Every mesh pipeline that fails on the branch (165) also fails on main, with the same code. None is new.
  • Offline, from the recorded rooted pixel requests of the 2,579 pipelines refused on main: in 2,349 the pixel layout differs from the root in at least one table. In 225 the pixel stage has no rooted translation, and in 5 the layout cannot be read.
  • Of the 81 still refused on the branch, 74 have no rooted pixel translation and 5 have a layout the reader refuses. I have not explained the last 2.
  • The provider's and vkd3d-proton's warning and error lines of the two logs, compared by class: the branch adds none. Failed to compile shader, vkd3d result -3 falls from 13,078 lines to 3,644.

This is evidence about pipeline creation only. Both runs were still on the loading screen when they ended, and I have not seen a world frame on this machine yet, so nothing here shows these pipelines drawing. At draw time they take the path #158 added for pixel-only copies: the copy binds the same guest table, now at the program's slots.

Title data stayed on my machine. Only counts and register names are given here.

Verified on Lanes

  • python tuxbox.py check passed on this branch (every step passes except one Lanes scenario that #172 added today, lanes-selftest-descriptor-reclaim. It fails the same way on main at 9ca0060 on this host. Details below.)
  • 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 4070 Ti SUPER (10de:2705), driver 595.112.07, Proton Experimental 11.0-20261112. NixOS, Linux 7.2.11, Intel Core i9-12900K, Hyprland (Wayland).

On this commit (on 7b22d71), with --proton, --prefix and --windows-dxc (Microsoft's x64 DXC 1.8.2505.1):

Summary
  passed   Build the shader compiler (10s)
  passed   Python tests (5s)
  passed   Shader compiler tests (7s)
  passed   DXBC tests (1s)
  passed   XG layout tests (1s)
  passed   D3D12 Windows typecheck (1s)
  passed   Build (40s)
  FAILED   Lanes and fixtures on the GPU (257s)
  passed   D3D12 regression controls (103s)
  passed   Shader translator on the GPU (267s)

63 of the 64 guest checks and all 17 regression cases pass. The one failure:

lanes-selftest FAIL descriptor-reclaim: expected E_OUTOFMEMORY on unsubmitted pin overflow, got 0x00000000

main built and run the same way (at 9ca0060, the merge of #172) fails that scenario with the same line. The scenario's last step counts on a resident limit of 1,000,000 descriptors. CreateDescriptorHeap takes the host's MaxViewDescriptorHeapSize when that is larger. I have not read the value this host reports, but with TUXBOX_DESCRIPTOR_HEAP_LIMIT=1000000 in the environment the scenario passes on main, so without the cap the 63 pinned tables fit. #178 fixes the scenario.

Before #172 was merged, the same change on 1d821cb passed every step (63 of 63 guest checks, 17 regression cases).

The present checks sampled the private rootful Xwayland that verify starts on a Wayland desktop. The host is NixOS, so the command ran inside its FHS environment (steam-run): the regression controls start Proton's wine directly, and it needs /lib/ld-linux.so.2.

Why there is no Lanes scenario. The existing mesh check (d3d12-mesh, runtime/d3d12/mesh_guest.cpp) compiles its mesh and pixel shaders from HLSL with DXC. Desktop DXIL has no FSSM records, so mesh_table::reflected returns before this code for it. The only console program in the tree is the single-instruction compute shader in examples/lanes/shader_fixture.py. A scenario for this path needs a hand-assembled console mesh program and pixel program whose FSSM records place descriptors in root tables, a root that declares one of those tables differently, and a pipeline stream the translator accepts from end to end. The two new DXBC tests build synthetic FSSM programs for the reading rules instead.

Checks

  • python -m unittest discover -s tests -q
  • cargo test for tools/shader-compiler (303 + 2), tuxbox-dxbc with native-bindings (63) and tuxbox-xg-layout (14)
  • cargo check --target x86_64-pc-windows-msvc -p tuxbox-d3d12

Two of the DXBC tests are new:

  • pixel_programs_can_hold_unordered_access_textures: a pixel program's UAV texture becomes a UAV range at the slot the program reads, under a root visible to all stages or to the pixel stage. The same program read as a mesh program, or under a root for another stage, is refused.
  • pixel_layout_replaces_a_table_the_root_declares_one_slot_short: the root places a constant buffer one slot before the slot the program reads it at, and declares no texture where the program reads one. The replacement table follows the program, and a table the program does not read is left alone.

No evidence JSON changed.

**@⁠3kynox** on GitHub · 2026-11-25 16:37 UTC · [original](https://github.com/brcly/TuxBox/pull/177) `3kynox:pr-mesh-pixel-layout` → `main` · +247 −8 · 5 files · 1 commits · merged 2026-11-25 17:59 UTC ## Summary Follow-up to #157, #158 and #163. After #163, ProjectScarlett still loses most of its mesh pipelines to `0x80070057`: vkd3d-proton refuses the pixel stage with `dxil-spirv: Failed to remap <SRV|CBV> <space>:<register>`. On `main` at 682a0e4 that was 2,579 distinct mesh pipelines seven minutes into a run. The cause is the title's root signature. For the pixel stage of these pipelines it does not describe the table the program reads. Like the mesh program, the pixel program carries its own physical layout in its FSSM records. Where the two disagree, the console follows the program: it takes the table's address from a scalar register and reads the slot. The declaration is not consulted. One of these pipelines, root parameter 1 (visible to all stages, space 1): | | slot 0 | slot 1 | slot 2 | slot 3 | slot 4 | slot 6 | | --- | --- | --- | --- | --- | --- | --- | | Title's root | `t12` | `t69` | `t20` | `t6` | `b0` | none | | Pixel program reads | | `t96` | | | | `b5` | The program's resource list names `t96` and `b5` in space 1. The root declares neither. The pixel stage is translated against the guest root (#157), so it declares two registers that no parameter of the host root has, and the host refuses the pipeline. This change reads the pixel program's layout the way `MeshLayout` already reads the mesh program's, and uses it: - **dxbc:** `MeshLayout::from_pixel_shader` reads a pixel program under the same rules as a mesh program. Two rules depend on the stage. A root parameter must be visible to all stages or to the stage being read. A pixel program can hold unordered-access textures (FSSM class `0x303`, eight words), which become UAV ranges. - **d3d12, host root:** where the pixel layout differs from the root for a table that is visible to all stages, the pixel-only copy of that table (`mirrors`, #158) is laid out as the pixel program reads it. If the mesh layout did not rewrite that table, the title's declaration is kept for the mesh stage only. - **d3d12, translation:** the pixel stage is then translated against a root that has those tables in place of the title's (`ComputeTable::pixel_root`). The translated program and the host root name the same registers at the same slots. A pipeline whose pixel layout agrees with the root, or cannot be read, is built exactly as before: same root, same copies, same translation. Not handled: a table visible to the pixel stage only, root descriptors and root constants. In the 2,397 pixel programs I captured with their roots, every table that differs is visible to all stages. #168 does the matching work for vertex/pixel pipelines and brings their stand-ins down. Its table shows the `0x80070057` count unchanged (744 and 744). That count is what this pull request is about: in my runs every `0x80070057` row is a mesh pipeline. ### Measured on ProjectScarlett Two unattended offline runs, one after the other, taken before today's merges. Only `d3d12_xs.dll` differed: it was built from `main` at 682a0e4 for one run and from this change on top of 682a0e4 for the other. The branch was then rebased onto 7b22d71. The code is the same as in the measured build, except that a helper of a few lines in `stream.rs` is now written inline and the two tests moved to `src/tests/mesh_table.rs`. Every other provider, the launcher, the translator binary (`TUXBOX_XSHADER`) and the prepared shader cache were the same files. Both runs used `TUXBOX_RUNTIME_SHADER_JOBS=8`, `TUXBOX_TRACE_PRESENT=600` and `TUXBOX_LOG_TIME=1`, left the first screen through an injected key press at about 40 s, and started with the translations of an earlier run in the cache. The counts are distinct pipelines in the run's `pipeline-failures` file. | Pipelines not delivered | `main`, 420 s | This branch, 600 s | | --- | --- | --- | | Mesh, `0x80070057` | 2,579 | **81** | | Mesh, `0x80004001` | 71 | 68 | | Mesh, `0x80004005` | 22 | 16 | | Other pipelines, stand-in | 2,769 | 2,759 | The branch run got more time because it has more work per pipeline: it compiles the pipelines `main` gives up on. The stand-in row is the control. It shows the two runs covered the same part of the title's loading: the branch's 2,759 stand-in pipelines are all among `main`'s 2,769. - Every mesh pipeline that fails on the branch (165) also fails on `main`, with the same code. None is new. - Offline, from the recorded rooted pixel requests of the 2,579 pipelines refused on `main`: in 2,349 the pixel layout differs from the root in at least one table. In 225 the pixel stage has no rooted translation, and in 5 the layout cannot be read. - Of the 81 still refused on the branch, 74 have no rooted pixel translation and 5 have a layout the reader refuses. I have not explained the last 2. - The provider's and vkd3d-proton's warning and error lines of the two logs, compared by class: the branch adds none. `Failed to compile shader, vkd3d result -3` falls from 13,078 lines to 3,644. This is evidence about pipeline creation only. Both runs were still on the loading screen when they ended, and I have not seen a world frame on this machine yet, so nothing here shows these pipelines drawing. At draw time they take the path #158 added for pixel-only copies: the copy binds the same guest table, now at the program's slots. Title data stayed on my machine. Only counts and register names are given here. ## Verified on Lanes - [ ] `python tuxbox.py check` passed on this branch *(every step passes except one Lanes scenario that #172 added today, `lanes-selftest-descriptor-reclaim`. It fails the same way on `main` at 9ca0060 on this host. Details below.)* - [ ] 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 4070 Ti SUPER (`10de:2705`), driver 595.112.07, Proton Experimental 11.0-20261112. NixOS, Linux 7.2.11, Intel Core i9-12900K, Hyprland (Wayland). On this commit (on 7b22d71), with `--proton`, `--prefix` and `--windows-dxc` (Microsoft's x64 DXC 1.8.2505.1): ```text Summary passed Build the shader compiler (10s) passed Python tests (5s) passed Shader compiler tests (7s) passed DXBC tests (1s) passed XG layout tests (1s) passed D3D12 Windows typecheck (1s) passed Build (40s) FAILED Lanes and fixtures on the GPU (257s) passed D3D12 regression controls (103s) passed Shader translator on the GPU (267s) ``` 63 of the 64 guest checks and all 17 regression cases pass. The one failure: ```text lanes-selftest FAIL descriptor-reclaim: expected E_OUTOFMEMORY on unsubmitted pin overflow, got 0x00000000 ``` `main` built and run the same way (at 9ca0060, the merge of #172) fails that scenario with the same line. The scenario's last step counts on a resident limit of 1,000,000 descriptors. `CreateDescriptorHeap` takes the host's `MaxViewDescriptorHeapSize` when that is larger. I have not read the value this host reports, but with `TUXBOX_DESCRIPTOR_HEAP_LIMIT=1000000` in the environment the scenario passes on `main`, so without the cap the 63 pinned tables fit. #178 fixes the scenario. Before #172 was merged, the same change on 1d821cb passed every step (63 of 63 guest checks, 17 regression cases). The present checks sampled the private rootful Xwayland that `verify` starts on a Wayland desktop. The host is NixOS, so the command ran inside its FHS environment (`steam-run`): the regression controls start Proton's `wine` directly, and it needs `/lib/ld-linux.so.2`. **Why there is no Lanes scenario.** The existing mesh check (`d3d12-mesh`, `runtime/d3d12/mesh_guest.cpp`) compiles its mesh and pixel shaders from HLSL with DXC. Desktop DXIL has no FSSM records, so `mesh_table::reflected` returns before this code for it. The only console program in the tree is the single-instruction compute shader in `examples/lanes/shader_fixture.py`. A scenario for this path needs a hand-assembled console mesh program and pixel program whose FSSM records place descriptors in root tables, a root that declares one of those tables differently, and a pipeline stream the translator accepts from end to end. The two new DXBC tests build synthetic FSSM programs for the reading rules instead. ## Checks - `python -m unittest discover -s tests -q` - `cargo test` for `tools/shader-compiler` (303 + 2), `tuxbox-dxbc` with `native-bindings` (63) and `tuxbox-xg-layout` (14) - `cargo check --target x86_64-pc-windows-msvc -p tuxbox-d3d12` Two of the DXBC tests are new: - `pixel_programs_can_hold_unordered_access_textures`: a pixel program's UAV texture becomes a UAV range at the slot the program reads, under a root visible to all stages or to the pixel stage. The same program read as a mesh program, or under a root for another stage, is refused. - `pixel_layout_replaces_a_table_the_root_declares_one_slot_short`: the root places a constant buffer one slot before the slot the program reads it at, and declares no texture where the program reads one. The replacement table follows the program, and a table the program does not read is left alone. No evidence JSON changed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:36:33 +00:00
github manually merged commit 934fc97029 into gh-pr/177/base 2026-11-26 06:36:36 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 16:42 UTC · original · reviewed

Copilot was unable to review this pull request due to rate limiting. Please try again later. See Usage limits for GitHub Copilot for details.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 16:42 UTC · [original](https://github.com/brcly/TuxBox/pull/177#pullrequestreview-6061390756) · **reviewed** Copilot was unable to review this pull request due to rate limiting. Please try again later. See [Usage limits for GitHub Copilot](https://docs.github.com/en/copilot/concepts/rate-limits) for details.
This discussion has been locked. Commenting is limited to contributors.
No description provided.