d3d12: pipeline direct index fix #610

Merged
s3rius merged 3 commits from upstream-pr/610 into main 2026-12-01 03:22:54 +00:00
s3rius commented 2026-12-01 02:52:50 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by s3rius on 2026-12-01T02:52:50Z.


Summary

Until now, a pipeline whose root signature sets CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED
could not be served by the guest root unchanged once descriptors are paged: the
draw path had no layout to bind, so draws (and, in the compute path, dispatches)
for such pipelines were dropped at the consumer with "its root indexes the
resource heap directly"
. In ProjectScarlett this skipped thousands of draws.
This adds the missing reflected-table construction to the two graphics paths,
mirroring what the compute path and the vertex/pixel stream path already do:

  • Regular graphics pipelines (slot 60, graphics.rs) — the regular path
    never built a reflected table. For direct-indexed roots it now builds the
    reflected table (guest root + index map appended), translates VS/PS against
    it (with the heap-stride retry), and creates the pipeline with the table's
    native root, so the draw binds through the paged layout. The screen-rectangle
    path, unparseable roots, stencil-exporting pixel shaders and untranslatable
    stages keep the previous guest-root/skip behaviour.
  • Mesh pipelines (slot 86, mesh_table.rs) — the mesh path only built a
    reflected table when the mesh program rewrote declared resources, and never
    appended the index map, so direct-indexed mesh pipelines carried no table at
    all. It now builds the reflected table whenever the root is direct-indexed —
    including the no-rewrite case — appending the index map to both the host root
    and the root the pixel program is translated against (same layout as the
    raster/compute tables, including the room check and pixel-root inclusion).

Tested

Run the checks relevant to this change.

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them:

GPU, driver and backend: nvidia-open-dkms-620.73.04-1

The Evidence: line tuxbox.py check prints last, one per card (it names the commit it tested; run it on this pull request's head):

Evidence: TuxBox check of b40cffca0394, no uncommitted changes, GPU default adapter: 17 passed, 0 failed, 0 not run

Commands run and their results:

> xvfb-run -a python tuxbox.py check

Summary
  passed   Build the shader compiler (0s)
  passed   Python tests (55s)
  passed   Synthetic shaders through the runtime's DXC flags (0s)
  passed   Shader compiler tests (1s)
  passed   DXBC tests (0s)
  passed   XG layout tests (9s)
  passed   XG entry point tests (0s)
  passed   BVH layout tests (1s)
  passed   Storage codec tests (0s)
  passed   ACP HAL tests (0s)
  passed   Windows typecheck (0s)
  passed   Clippy (0s)
  passed   Formatting (1s)
  passed   Build (31s)
  passed   Lanes and fixtures on the GPU (197s)
  passed   D3D12 regression controls (120s)
  passed   Shader translator on the GPU (308s)

Checks

CI runs the code checks: the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU.

If this pull request changes evidence JSON, regenerate the results table and the progress map and include both files:

python tuxbox.py status > docs/RESULTS.md
python tuxbox.py status --svg docs/progress.svg
<!-- greyfinch-sync:brcly/TuxBox:issue:5577982617 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/610). Originally posted by [s3rius](https://github.com/s3rius) on 2026-12-01T02:52:50Z. --- ## Summary Until now, a pipeline whose root signature sets `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` could not be served by the guest root unchanged once descriptors are paged: the draw path had no layout to bind, so draws (and, in the compute path, dispatches) for such pipelines were dropped at the consumer with *"its root indexes the resource heap directly"*. In ProjectScarlett this skipped thousands of draws. This adds the missing reflected-table construction to the two graphics paths, mirroring what the compute path and the vertex/pixel stream path already do: - **Regular graphics pipelines (slot 60, `graphics.rs`)** — the regular path never built a reflected table. For direct-indexed roots it now builds the reflected table (guest root + index map appended), translates VS/PS against it (with the heap-stride retry), and creates the pipeline with the table's native root, so the draw binds through the paged layout. The screen-rectangle path, unparseable roots, stencil-exporting pixel shaders and untranslatable stages keep the previous guest-root/skip behaviour. - **Mesh pipelines (slot 86, `mesh_table.rs`)** — the mesh path only built a reflected table when the mesh program rewrote declared resources, and never appended the index map, so direct-indexed mesh pipelines carried no table at all. It now builds the reflected table whenever the root is direct-indexed — including the no-rewrite case — appending the index map to both the host root and the root the pixel program is translated against (same layout as the raster/compute tables, including the room check and pixel-root inclusion). ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: GPU, driver and backend: nvidia-open-dkms-620.73.04-1 The `Evidence:` line `tuxbox.py check` prints last, one per card (it names the commit it tested; run it on this pull request's head): ```text Evidence: TuxBox check of b40cffca0394, no uncommitted changes, GPU default adapter: 17 passed, 0 failed, 0 not run ``` Commands run and their results: ```text > xvfb-run -a python tuxbox.py check Summary passed Build the shader compiler (0s) passed Python tests (55s) passed Synthetic shaders through the runtime's DXC flags (0s) passed Shader compiler tests (1s) passed DXBC tests (0s) passed XG layout tests (9s) passed XG entry point tests (0s) passed BVH layout tests (1s) passed Storage codec tests (0s) passed ACP HAL tests (0s) passed Windows typecheck (0s) passed Clippy (0s) passed Formatting (1s) passed Build (31s) passed Lanes and fixtures on the GPU (197s) passed D3D12 regression controls (120s) passed Shader translator on the GPU (308s) ``` ## Checks CI runs the [code checks](../CONTRIBUTING.md#code-checks): the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU. If this pull request changes evidence JSON, regenerate the results table and the progress map and include both files: ```sh python tuxbox.py status > docs/RESULTS.md python tuxbox.py status --svg docs/progress.svg ```
s3rius commented 2026-12-01 02:53:12 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by s3rius on 2026-12-01T02:53:12Z.


Needs AMD gpu run.

<!-- greyfinch-sync:brcly/TuxBox:comment:7299096651 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/610#issuecomment-7299096651). Originally posted by [s3rius](https://github.com/s3rius) on 2026-12-01T02:53:12Z. --- Needs AMD gpu run.
NickStallman commented 2026-12-01 03:22:13 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T03:22:13Z.


@s3rius we have this overlap: it's the same class of skipped draws we chased today, with a separate fix in our integration branch (an extra commit on #390's). I'll drop ours if this goes in. Some measurements, a code question, and the AMD run you asked for.

Measured with our version (RTX 5090, 620.70.10, GE-Proton11-15, ProjectScarlett's world): one depth-only cascade-shadow mesh pipeline was skipped about 338 times a frame for exactly this reason (no table changes, so mesh_table::reflected returned none, with direct_resources set). With a table carrying only the map, it is drawn 344 times a frame and skipped 0, and skipped calls fell from 236,000–307,000 to 58,000 in 18 minutes (that build has other changes too). Details on #390.

A question, from reading 2a09f062, not from a test. The mesh path appends the map to the native root and to the pixel root, but stream.rs:289 still translates the mesh stage with mesh_stage(code, stage, guest_root.payload()), the title's root, without the map. So a mesh program that itself reads the heap would, as I read it, be drawn using the title's raw indices, where today the draw is skipped. #390 translates the mesh (and amplification) stage against the mapped root, and our commit uses the table only if that translation exists. Similarly, rooted[1] stays None if the pixel stage doesn't translate against the new pixel root, and the pipeline then keeps the earlier pixel code, which has no map either. Is either handled somewhere I haven't seen? Your Lanes case can't show it (its mesh program doesn't read the heap).

AMD and NVIDIA checks of 2a09f062 are queued behind our running game runs, and I'll post the results here; the evidence line in the description is from b40cffca, which is not the head.

<!-- greyfinch-sync:brcly/TuxBox:comment:7299634585 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/610#issuecomment-7299634585). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T03:22:13Z. --- @s3rius we have this overlap: it's the same class of skipped draws we chased today, with a separate fix in our integration branch (an extra commit on #390's). I'll drop ours if this goes in. Some measurements, a code question, and the AMD run you asked for. **Measured with our version** (RTX 5090, 620.70.10, GE-Proton11-15, ProjectScarlett's world): one depth-only cascade-shadow mesh pipeline was skipped about 338 times a frame for exactly this reason (no table changes, so `mesh_table::reflected` returned none, with `direct_resources` set). With a table carrying only the map, it is drawn 344 times a frame and skipped 0, and skipped calls fell from 236,000–307,000 to 58,000 in 18 minutes (that build has other changes too). Details on #390. **A question, from reading 2a09f062, not from a test.** The mesh path appends the map to the native root and to the pixel root, but `stream.rs:289` still translates the mesh stage with `mesh_stage(code, stage, guest_root.payload())`, the title's root, without the map. So a mesh program that itself reads the heap would, as I read it, be drawn using the title's raw indices, where today the draw is skipped. #390 translates the mesh (and amplification) stage against the mapped root, and our commit uses the table only if that translation exists. Similarly, `rooted[1]` stays `None` if the pixel stage doesn't translate against the new pixel root, and the pipeline then keeps the earlier pixel code, which has no map either. Is either handled somewhere I haven't seen? Your Lanes case can't show it (its mesh program doesn't read the heap). **AMD and NVIDIA checks of 2a09f062** are queued behind our running game runs, and I'll post the results here; the evidence line in the description is from b40cffca, which is not the head.
JeffreyBytes commented 2026-12-01 03:24:59 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-01T03:24:59Z.


@brcly this went in 41 seconds after Nick's comment above, so I think his question got missed. From reading main at 717a74c4 (not from a run), it's still there:

  • stream.rs:296 translates the mesh stage with mesh_stage(code, stage, guest_root...), and stream.rs:1002 links with mesh_link_source(mesh_code, guest_root...), both on the title's root without the map. Now that index_map is set, these draws aren't skipped anymore, so a mesh program that reads the heap directly runs with the title's raw indices as visible slots under paging. Before this it was skipped.
  • If the pixel stage doesn't translate against the new pixel_root, rooted[1] stays None and the pipeline keeps the pixel code without the map too.

The Lanes case added here doesn't read the heap from the mesh program, so neither shows up in check.

This also matters for AMD. #390's description says that once these terrain mesh draws run, RADV hung on the first terrain draw with a non-zero packed root constant (MS_VS_TransformTerrainNormalTint) in 3 of 5 runs, with a hard recovery and no memory fault. On my RX 6700 XT a failed ring reset like that has needed a reboot. Nothing about that was tested on AMD before this merged, so I'd treat world runs on main past 717a74c4 on AMD as risky until it's checked.

Could the mesh half either use #390's approach (translate the mesh and amplification stages on the mapped root and only use the table when that translation exists, which is what Nick's integration branch does) or be reverted to the skip until that lands? The graphics half can stay as it is.

<!-- greyfinch-sync:brcly/TuxBox:comment:7299681781 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/610#issuecomment-7299681781). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-01T03:24:59Z. --- @brcly this went in 41 seconds after Nick's comment above, so I think his question got missed. From reading main at 717a74c4 (not from a run), it's still there: - `stream.rs:296` translates the mesh stage with `mesh_stage(code, stage, guest_root...)`, and `stream.rs:1002` links with `mesh_link_source(mesh_code, guest_root...)`, both on the title's root without the map. Now that `index_map` is set, these draws aren't skipped anymore, so a mesh program that reads the heap directly runs with the title's raw indices as visible slots under paging. Before this it was skipped. - If the pixel stage doesn't translate against the new `pixel_root`, `rooted[1]` stays `None` and the pipeline keeps the pixel code without the map too. The Lanes case added here doesn't read the heap from the mesh program, so neither shows up in `check`. This also matters for AMD. #390's description says that once these terrain mesh draws run, RADV hung on the first terrain draw with a non-zero packed root constant (`MS_VS_TransformTerrainNormalTint`) in 3 of 5 runs, with a hard recovery and no memory fault. On my RX 6700 XT a failed ring reset like that has needed a reboot. Nothing about that was tested on AMD before this merged, so I'd treat world runs on main past 717a74c4 on AMD as risky until it's checked. Could the mesh half either use #390's approach (translate the mesh and amplification stages on the mapped root and only use the table when that translation exists, which is what Nick's integration branch does) or be reverted to the skip until that lands? The graphics half can stay as it is.
NickStallman commented 2026-12-01 03:56:36 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T03:56:36Z.


The AMD run of 2a09f062 (this PR's head; it merged while the check ran). GE-Proton11-15, AMD iGPU (1002:13c0, RADV): 207 pass, 0 fail, lanes-mesh-direct-indexed included.

Evidence: TuxBox check of 2a09f062a6, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run

I stopped the 5090 half when it merged, so there is no NVIDIA check of this head from me. This doesn't answer the question above: the mesh program in that Lanes case doesn't read the heap, and nothing in the check does from a mesh stage. Our integration build on main translates the mesh, amplification and pixel stages on the mapped root and carries the map only when all translate; I can put that up as a PR if you'd take it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7300218938 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/610#issuecomment-7300218938). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T03:56:36Z. --- The AMD run of 2a09f062 (this PR's head; it merged while the check ran). GE-Proton11-15, AMD iGPU (`1002:13c0`, RADV): 207 pass, 0 fail, `lanes-mesh-direct-indexed` included. Evidence: TuxBox check of 2a09f062a610, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run I stopped the 5090 half when it merged, so there is no NVIDIA check of this head from me. This doesn't answer the question above: the mesh program in that Lanes case doesn't read the heap, and nothing in the check does from a mesh stage. Our integration build on main translates the mesh, amplification and pixel stages on the mapped root and carries the map only when all translate; I can put that up as a PR if you'd take it.
s3rius commented 2026-12-01 20:49:38 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by s3rius on 2026-12-01T20:49:38Z.


@NickStallman, @JeffreyBytes yeah, you're both right.

Sorry, wasn't available today, so I didn't see your comment. However, I see that @NickStallman has filled the gap in #617 and resolved the issue. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7325331559 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/610#issuecomment-7325331559). Originally posted by [s3rius](https://github.com/s3rius) on 2026-12-01T20:49:38Z. --- @NickStallman, @JeffreyBytes yeah, you're both right. Sorry, wasn't available today, so I didn't see your comment. However, I see that @NickStallman has filled the gap in #617 and resolved the issue. Thanks!
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!610
No description provided.