perf(draw): skip Set*Root32BitConstants when the host list already holds those user-data dwords under the same root signature #642

Open
github-bot wants to merge 1 commit from github-bot/gh-642 into main AGit
Owner

@⁠Raptorbk45 on GitHub · 2026-12-05 22:37 UTC · original
Raptorbk45:perf/skip-same-root-constants → main · +39 −6 · 1 files · 1 commits · open

Every bind calls SetGraphicsRoot32BitConstants/SetComputeRoot32BitConstants with the user data of each stage, even when the list already holds exactly those dwords for that parameter. In vkd3d-proton that marks the root constants dirty and pushes them again at the next draw.

State now keeps, per pipeline kind, the dwords last set per root parameter (user_sent) and skips the call when they are equal. Everything that computes values (root_word, host_word, material records, the diagnostics copy) still runs; only the D3D12 call is skipped.

Invalidation: root arguments are undefined after the root signature of that kind is set again, so user_sent[kind] is cleared exactly where bind calls Set{Graphics,Compute}RootSignature (the host_roots branch) and after the ambient ScreenHits reflection path re-sets the compute root signature. Every other place that clobbers the list's root state (external_compute, replay, the ambient/lightprobe/indirect batch/window paths) already zeroes host_roots, which forces that branch and therefore the clear; State::reset starts from Default. So a skip can only happen when no root signature of that kind was set on the list since the dwords were set.

How it was checked

Run after the final edit, on Linux (CachyOS), against main at 8c4e6633:

  • ./build.sh check (release, MSVC target): passes; the one warning (room_lately never used, resource.rs) is already on main
  • cargo xtask policy: passes
  • PROFILE=diag ./build.sh check: passes

Not run: the game, on this branch. A version of this change ran on our fork in play since 1 December 2026 without a broken image we could tie to it; that is not a test.

Branch head: 0ed70339.

Not measured on its own: it removes D3D12 calls and push-constant uploads for repeated user data, which our profiling of the translating threads (our fork, December 2026) showed among the per-draw costs, but we have no A/B of this change alone. No unit test: it needs a host command list; correctness rests on the invalidation argument above, please check it against any path I missed.

Checks

  • One subject
  • N/A: switch (same output, fewer redundant calls)
  • N/A: docs
  • N/A: unit test (see above)
  • Queue checked: no open PR touches the user-data block in draw.rs
  • cargo xtask policy
**@⁠Raptorbk45** on GitHub · 2026-12-05 22:37 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/642) `Raptorbk45:perf/skip-same-root-constants` → `main` · +39 −6 · 1 files · 1 commits · open Every bind calls `SetGraphicsRoot32BitConstants`/`SetComputeRoot32BitConstants` with the user data of each stage, even when the list already holds exactly those dwords for that parameter. In vkd3d-proton that marks the root constants dirty and pushes them again at the next draw. `State` now keeps, per pipeline kind, the dwords last set per root parameter (`user_sent`) and skips the call when they are equal. Everything that computes `values` (`root_word`, `host_word`, material records, the diagnostics copy) still runs; only the D3D12 call is skipped. Invalidation: root arguments are undefined after the root signature of that kind is set again, so `user_sent[kind]` is cleared exactly where `bind` calls `Set{Graphics,Compute}RootSignature` (the `host_roots` branch) and after the ambient `ScreenHits` reflection path re-sets the compute root signature. Every other place that clobbers the list's root state (`external_compute`, `replay`, the ambient/lightprobe/indirect batch/window paths) already zeroes `host_roots`, which forces that branch and therefore the clear; `State::reset` starts from `Default`. So a skip can only happen when no root signature of that kind was set on the list since the dwords were set. ## How it was checked Run after the final edit, on Linux (CachyOS), against `main` at 8c4e6633: - `./build.sh check` (release, MSVC target): passes; the one warning (`room_lately` never used, `resource.rs`) is already on `main` - `cargo xtask policy`: passes - `PROFILE=diag ./build.sh check`: passes Not run: the game, on this branch. A version of this change ran on our fork in play since 1 December 2026 without a broken image we could tie to it; that is not a test. Branch head: `0ed70339`. Not measured on its own: it removes D3D12 calls and push-constant uploads for repeated user data, which our profiling of the translating threads (our fork, December 2026) showed among the per-draw costs, but we have no A/B of this change alone. No unit test: it needs a host command list; correctness rests on the invalidation argument above, please check it against any path I missed. ## Checks - [x] One subject - N/A: switch (same output, fewer redundant calls) - N/A: docs - N/A: unit test (see above) - [x] Queue checked: no open PR touches the user-data block in `draw.rs` - [x] `cargo xtask policy`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 22:39:37 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/642/head:github-bot/gh-642'
git switch 'github-bot/gh-642'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-642'
git switch 'github-bot/gh-642'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-642'
git switch 'github-bot/gh-642'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-642'
git switch 'main'
git merge --squash 'github-bot/gh-642'
git switch 'main'
git merge --ff-only 'github-bot/gh-642'
git switch 'main'
git merge 'github-bot/gh-642'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.