d3d12: record the root a raster pipeline is created with #585

Merged
NathansDomainSolutions merged 2 commits from upstream-pr/585 into main 2026-12-01 03:22:46 +00:00
NathansDomainSolutions commented 2026-11-30 08:12:29 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NathansDomainSolutions on 2026-11-30T08:12:29Z.


Problem. On my prefix (RTX 4070, GE-Proton11-14) the preparation replay creates only 6,159 of 23,142 recorded pipelines. All 16,983 failures are graphics, and VKD3D_DEBUG=warn / VKD3D_SHADER_DEBUG=trace on a sample shows the same thing every time:

err:vkd3d-proton:vkd3d_dxil_log_callback: dxil-spirv: Failed to remap CBV 1:12.
err:vkd3d-proton:vkd3d_dxil_log_callback: dxil-spirv: Failed to convert function.
warn:vkd3d-proton:vkd3d_compile_shader_stage: Failed to compile shader, vkd3d result -3.

The cause: when a raster pipeline's root is reflected (TableLayout::Reflected in stream.rs), the provider writes the reflected table's native root into the stream, but graphics_root, which the PSO recorder saves as root.bin, is still the title's serialized root. The replay then pairs translated stages, which were built against the reflected root, with the title's root, which lacks their space-1 CBVs. So those graphics pipelines are never warmed and all compile in game.

Fix.

  • stream.rs: when the effective raster root differs from the title's, keep a copy of its serialized bytes (used_root) and record that.
  • pso_record.rs: records now carry root_used 1. A record without it is written again the next time its pipeline is created, so existing prefixes heal on their next run.
  • Preparation's _rebuild_graphics translates rooted stages with --root root.bin. It now gets the reflected root, which is what the runtime translates against (raster_with_root(source, root.payload())).

Checks: clippy (-D warnings) and fmt are clean. d3d12 tests under Wine: pso_record 6/6, stream 12/12, placement 103/103. Not yet re-measured end to end. The next run records with the fix, then prep replays. Pairs with #579, which runs the replay on several threads.

This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5561500122 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/585). Originally posted by [NathansDomainSolutions](https://github.com/NathansDomainSolutions) on 2026-11-30T08:12:29Z. --- **Problem.** On my prefix (RTX 4070, GE-Proton11-14) the preparation replay creates only 6,159 of 23,142 recorded pipelines. All 16,983 failures are graphics, and `VKD3D_DEBUG=warn` / `VKD3D_SHADER_DEBUG=trace` on a sample shows the same thing every time: ``` err:vkd3d-proton:vkd3d_dxil_log_callback: dxil-spirv: Failed to remap CBV 1:12. err:vkd3d-proton:vkd3d_dxil_log_callback: dxil-spirv: Failed to convert function. warn:vkd3d-proton:vkd3d_compile_shader_stage: Failed to compile shader, vkd3d result -3. ``` The cause: when a raster pipeline's root is reflected (`TableLayout::Reflected` in `stream.rs`), the provider writes the reflected table's native root into the stream, but `graphics_root`, which the PSO recorder saves as `root.bin`, is still the title's serialized root. The replay then pairs translated stages, which were built against the reflected root, with the title's root, which lacks their space-1 CBVs. So those graphics pipelines are never warmed and all compile in game. **Fix.** - `stream.rs`: when the effective raster root differs from the title's, keep a copy of its serialized bytes (`used_root`) and record that. - `pso_record.rs`: records now carry `root_used 1`. A record without it is written again the next time its pipeline is created, so existing prefixes heal on their next run. - Preparation's `_rebuild_graphics` translates rooted stages with `--root root.bin`. It now gets the reflected root, which is what the runtime translates against (`raster_with_root(source, root.payload())`). **Checks:** clippy (`-D warnings`) and fmt are clean. d3d12 tests under Wine: pso_record 6/6, stream 12/12, placement 103/103. Not yet re-measured end to end. The next run records with the fix, then prep replays. Pairs with #579, which runs the replay on several threads. This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
brcly commented 2026-11-30 09:51:42 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T09:51:42Z.


Thanks, and good diagnosis. I read it through, and the code agrees with you:

  • Under a reflected table, the stream carries the native root, and the stages are translated with raster_with_root(source, root.payload()).
  • The record keeps graphics_root, the title's root.
  • So preparation's --root root.bin rebuild and the replay are both working from a root the pipeline was never created with.

The fix is small and in the right place. I merged #579 just now.

I'd like the end-to-end number before merging this too, since that's what it's for. Once a run has re-recorded under this branch and preparation has replayed, please post the receipt line (threads=… records=… graphics=… failed=…). The failed count should drop from 16,983 to roughly the records that weren't re-recorded in that run. If any graphics records still fail with root_used 1 in their recipe, list a couple of their vkd3d lines, because those would be a second cause.

Two small things to check while you're there:

  • The comparison title != root.serialized() compares the whole serialized blob, while CompiledRoot::matches compares payloads. Is there a case where the bytes differ but the payload is the same? Recording the native root then is harmless, but say so in the comment if it's expected.
  • Every existing record is rewritten the first time its pipeline is created, during play, which is several hundred megabytes in our prefix. If that shows up as stutter in the first run, mention it.
<!-- greyfinch-sync:brcly/TuxBox:comment:7274786474 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/585#issuecomment-7274786474). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T09:51:42Z. --- Thanks, and good diagnosis. I read it through, and the code agrees with you: - Under a reflected table, the stream carries the native root, and the stages are translated with `raster_with_root(source, root.payload())`. - The record keeps `graphics_root`, the title's root. - So preparation's `--root root.bin` rebuild and the replay are both working from a root the pipeline was never created with. The fix is small and in the right place. I merged #579 just now. I'd like the end-to-end number before merging this too, since that's what it's for. Once a run has re-recorded under this branch and preparation has replayed, please post the receipt line (`threads=… records=… graphics=… failed=…`). The `failed` count should drop from 16,983 to roughly the records that weren't re-recorded in that run. If any graphics records still fail with `root_used 1` in their recipe, list a couple of their vkd3d lines, because those would be a second cause. Two small things to check while you're there: - The comparison `title != root.serialized()` compares the whole serialized blob, while `CompiledRoot::matches` compares payloads. Is there a case where the bytes differ but the payload is the same? Recording the native root then is harmless, but say so in the comment if it's expected. - Every existing record is rewritten the first time its pipeline is created, during play, which is several hundred megabytes in our prefix. If that shows up as stutter in the first run, mention it.
NathansDomainSolutions commented 2026-11-30 23:49:33 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NathansDomainSolutions on 2026-11-30T23:49:33Z.


Pushed 593c21d, which answers both questions; the receipt line still needs a game run.

  • Bytes vs payload: you're right, so the check now compares payloads, the same way CompiledRoot::matches does. Two roots can have the same payload inside different containers (hash, chunk order). That happens on the TUXBOX_RASTER_ROOT_FALLBACK path, which hands back the title's root unchanged. When the payloads match, the record keeps the title's bytes. Recording the native bytes there would also replay correctly, and the comment now says so.
  • Rewrite cost: each old record is written once more, the first time its pipeline is created. I'll watch for stutter on that first run and report it with the receipt.
  • Receipt: my GPU is busy right now, so I haven't done the re-record and replay run yet. I'll post threads=… records=… graphics=… failed=… and any vkd3d lines left from root_used 1 records once it's done.

(Written with AI assistance: Claude Code.)

<!-- greyfinch-sync:brcly/TuxBox:comment:7295568879 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/585#issuecomment-7295568879). Originally posted by [NathansDomainSolutions](https://github.com/NathansDomainSolutions) on 2026-11-30T23:49:33Z. --- Pushed 593c21d, which answers both questions; the receipt line still needs a game run. - **Bytes vs payload:** you're right, so the check now compares payloads, the same way `CompiledRoot::matches` does. Two roots can have the same payload inside different containers (hash, chunk order). That happens on the `TUXBOX_RASTER_ROOT_FALLBACK` path, which hands back the title's root unchanged. When the payloads match, the record keeps the title's bytes. Recording the native bytes there would also replay correctly, and the comment now says so. - **Rewrite cost:** each old record is written once more, the first time its pipeline is created. I'll watch for stutter on that first run and report it with the receipt. - **Receipt:** my GPU is busy right now, so I haven't done the re-record and replay run yet. I'll post `threads=… records=… graphics=… failed=…` and any vkd3d lines left from `root_used 1` records once it's done. (Written with AI assistance: 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!585
No description provided.