d3d12: skip texture gather exclusivity when a batch copies nothing #668

Open
s3rius wants to merge 1 commit from upstream-pr/668 into main
s3rius commented 2026-12-03 02:46:12 +00:00 (Migrated from github.com)

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


Summary

The queued-texture-copy gate held every batch's native images exclusively — a per-batch busy-wait over ~2,000 shared images — even when the batch copies nothing (all reads fresh, no writes, no label waits). That serialized every queue against every other and made the story intro collapse to ~0.2 fps. This change skips only the exclusivity step for such batches: the record, the copies and the fence dance are unchanged, so the images still stay alive through the fence and the copy lifetimes are identical. Batches with real copies (fresh or not) still hold exclusively, and regathers after a label wait still hold. Not yet verified in a game — the gate is only one of the causes of the stall (see below).

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:

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):

Commands run and their results:

xvfb-run -a python tuxbox.py check

Summary
  passed   Build the shader compiler (0s)
  passed   Python tests (57s)
  passed   Synthetic shaders through the runtime's DXC flags (0s)
  passed   Shader compiler tests (5s)
  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 (3s)
  passed   Clippy (4s)
  passed   Formatting (1s)
  passed   Build (32s)
  FAILED   Lanes and fixtures on the GPU (232s)  # as on main
  passed   D3D12 regression controls (157s)
  passed   Shader translator on the GPU (353s)

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:5618849301 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/668). Originally posted by [s3rius](https://github.com/s3rius) on 2026-12-03T02:46:12Z. --- ## Summary The queued-texture-copy gate held every batch's native images exclusively — a per-batch busy-wait over ~2,000 shared images — even when the batch copies nothing (all reads fresh, no writes, no label waits). That serialized every queue against every other and made the story intro collapse to ~0.2 fps. This change skips only the exclusivity step for such batches: the record, the copies and the fence dance are unchanged, so the images still stay alive through the fence and the copy lifetimes are identical. Batches with real copies (fresh or not) still hold exclusively, and regathers after a label wait still hold. Not yet verified in a game — the gate is only one of the causes of the stall (see below). ## 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: 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 ``` Commands run and their results: ```text xvfb-run -a python tuxbox.py check Summary passed Build the shader compiler (0s) passed Python tests (57s) passed Synthetic shaders through the runtime's DXC flags (0s) passed Shader compiler tests (5s) 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 (3s) passed Clippy (4s) passed Formatting (1s) passed Build (32s) FAILED Lanes and fixtures on the GPU (232s) # as on main passed D3D12 regression controls (157s) passed Shader translator on the GPU (353s) ``` ## 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 ```
JeffreyBytes commented 2026-12-03 03:32:47 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T03:32:47Z.


Testing this now on RX 6700 XT. What GPU did you run on @s3rius ?

<!-- greyfinch-sync:brcly/TuxBox:comment:7366681006 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/668#issuecomment-7366681006). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T03:32:47Z. --- Testing this now on RX 6700 XT. What GPU did you run on @s3rius ?
s3rius commented 2026-12-03 03:44:44 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by s3rius on 2026-12-03T03:44:44Z.


I ran it on RTX5090. Thanks, @JeffreyBytes .

<!-- greyfinch-sync:brcly/TuxBox:comment:7366889659 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/668#issuecomment-7366889659). Originally posted by [s3rius](https://github.com/s3rius) on 2026-12-03T03:44:44Z. --- I ran it on RTX5090. Thanks, @JeffreyBytes .
JeffreyBytes commented 2026-12-03 04:27:11 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T04:27:11Z.


Checks all pass and the changes seem to be okay, but I'm getting some mixed results with testing. Doing a few more runs to get a better average. Results soon. Please hold this PR for now.

<!-- greyfinch-sync:brcly/TuxBox:comment:7367661043 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/668#issuecomment-7367661043). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T04:27:11Z. --- Checks all pass and the changes seem to be okay, but I'm getting some mixed results with testing. Doing a few more runs to get a better average. Results soon. Please hold this PR for now.
JeffreyBytes commented 2026-12-03 05:21:17 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T05:21:17Z.


Results from more runs. RX 6700 XT 12 GB, Mesa 26.3.1 RADV, GE-Proton11-15.

The full check on the head passed:

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

In game I did 10 runs of ProjectScarlett's intro, 5 on #667 alone and 5 on #667 with this merged on top. The last 5 alternated between the two builds. Setup: section-import=substituted, private views on, TUXBOX_STALL_DUMP=1, TUXBOX_FRAME_LOG=1. "Placement/min" is the placement time from all slow frames in the run, in seconds per minute of game time, since runs end at different times.

Build Ended Placement/min Longest slow frame (placement) Waits held past 5 s
#667 exit 5 at 506 s 10.4 s 64.2 s (60.5 s) 3
#667 exit 5 at 362 s 8.3 s 25.7 s (25.5 s) 1
#667 exit 5 at 485 s 10.5 s 59.1 s (56.5 s) 3
#667 GPU fault at 349 s 3.5 s 22.0 s (0.1 s) 0
#667 exit 5 at 341 s 11.7 s 49.0 s (45.3 s) 0
#667 + #668 exit 5 at 438 s 2.5 s 10.0 s (0.2 s) 0
#667 + #668 GPU fault at ~466 s 6.7 s 17.3 s (17.3 s) 5
#667 + #668 exit 5 at 443 s 3.1 s 9.4 s (0.1 s) 3
#667 + #668 exit 5 at 404 s 11.5 s 30.5 s (29.3 s) 7
#667 + #668 exit 5 at 390 s 3.5 s 30.7 s (0.1 s) 7

So it looks like it helps, but not every time. The median placement/min goes from 10.4 s to 3.5 s, and long placement frames showed up in 2 of 5 runs with it vs 4 of 5 without. One run with it (11.5 s/min, a 29 s placement frame) looks just like #667 alone, though. With 5 runs each, the difference isn't significant (Mann-Whitney, one-sided p ≈ 0.11). The waits held past 5 s weren't fewer with it either.

Every run on both builds that didn't fault ended in exit 5 (the title's watchdog), at about the same time. In the runs I looked at closely, the last stall had the GPU mostly idle and the queues waiting on the texture publication fence, so I think that's the other cause you mentioned.

The two GPU faults were gfx-ring TCP permission faults, and the ring reset worked both times. One happened on #667 alone, so I don't think it's from this PR.

I don't see any reason to hold it back from what I measured. It just isn't the whole fix for the stall.

<!-- greyfinch-sync:brcly/TuxBox:comment:7368648561 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/668#issuecomment-7368648561). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T05:21:17Z. --- Results from more runs. RX 6700 XT 12 GB, Mesa 26.3.1 RADV, GE-Proton11-15. The full check on the head passed: ```text Evidence: TuxBox check of 4362769ef1ae, no uncommitted changes, GPU default adapter: 17 passed, 0 failed, 0 not run ``` In game I did 10 runs of ProjectScarlett's intro, 5 on #667 alone and 5 on #667 with this merged on top. The last 5 alternated between the two builds. Setup: `section-import=substituted`, private views on, `TUXBOX_STALL_DUMP=1`, `TUXBOX_FRAME_LOG=1`. "Placement/min" is the placement time from all slow frames in the run, in seconds per minute of game time, since runs end at different times. | Build | Ended | Placement/min | Longest slow frame (placement) | Waits held past 5 s | |---|---|---|---|---| | #667 | exit 5 at 506 s | 10.4 s | 64.2 s (60.5 s) | 3 | | #667 | exit 5 at 362 s | 8.3 s | 25.7 s (25.5 s) | 1 | | #667 | exit 5 at 485 s | 10.5 s | 59.1 s (56.5 s) | 3 | | #667 | GPU fault at 349 s | 3.5 s | 22.0 s (0.1 s) | 0 | | #667 | exit 5 at 341 s | 11.7 s | 49.0 s (45.3 s) | 0 | | #667 + #668 | exit 5 at 438 s | 2.5 s | 10.0 s (0.2 s) | 0 | | #667 + #668 | GPU fault at ~466 s | 6.7 s | 17.3 s (17.3 s) | 5 | | #667 + #668 | exit 5 at 443 s | 3.1 s | 9.4 s (0.1 s) | 3 | | #667 + #668 | exit 5 at 404 s | 11.5 s | 30.5 s (29.3 s) | 7 | | #667 + #668 | exit 5 at 390 s | 3.5 s | 30.7 s (0.1 s) | 7 | So it looks like it helps, but not every time. The median placement/min goes from 10.4 s to 3.5 s, and long placement frames showed up in 2 of 5 runs with it vs 4 of 5 without. One run with it (11.5 s/min, a 29 s placement frame) looks just like #667 alone, though. With 5 runs each, the difference isn't significant (Mann-Whitney, one-sided p ≈ 0.11). The waits held past 5 s weren't fewer with it either. Every run on both builds that didn't fault ended in exit 5 (the title's watchdog), at about the same time. In the runs I looked at closely, the last stall had the GPU mostly idle and the queues waiting on the texture publication fence, so I think that's the other cause you mentioned. The two GPU faults were gfx-ring TCP permission faults, and the ring reset worked both times. One happened on #667 alone, so I don't think it's from this PR. I don't see any reason to hold it back from what I measured. It just isn't the whole fix for the stall.
s3rius commented 2026-12-03 15:26:32 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by s3rius on 2026-12-03T15:26:32Z.


@JeffreyBytes, thanks for such a deep analysis. Yes, it's not the whole fix. I'm still investigating what could be the reason for this whole fencing thing.

Probably will publish some more other small updates today. As of right now everything points at CPU. Since my GPU is loaded by 20% at its peak load during the launch. Could be something there.

<!-- greyfinch-sync:brcly/TuxBox:comment:7383147713 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/668#issuecomment-7383147713). Originally posted by [s3rius](https://github.com/s3rius) on 2026-12-03T15:26:32Z. --- @JeffreyBytes, thanks for such a deep analysis. Yes, it's not the whole fix. I'm still investigating what could be the reason for this whole fencing thing. Probably will publish some more other small updates today. As of right now everything points at CPU. Since my GPU is loaded by 20% at its peak load during the launch. Could be something there.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/668:upstream-pr/668'
git switch 'upstream-pr/668'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/668'
git switch 'upstream-pr/668'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/668'
git switch 'upstream-pr/668'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/668'
git switch 'main'
git merge --squash 'upstream-pr/668'
git switch 'main'
git merge --ff-only 'upstream-pr/668'
git switch 'main'
git merge 'upstream-pr/668'
git push origin 'main'
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!668
No description provided.