Skip to content

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

Open
s3rius wants to merge 1 commit into
brcly:mainfrom
s3rius:d3d12/skip-gather-exclusivity
Open

s3rius wants to merge 1 commit into
brcly:mainfrom
s3rius:d3d12/skip-gather-exclusivity

Conversation

@s3rius

@s3rius s3rius commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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

Signed-off-by: Pavel Kirilin <s3riussan@gmail.com>
@s3rius
s3rius force-pushed the d3d12/skip-gather-exclusivity branch from f8217fe to 4362769 Compare December 3, 2026 02:50
@JeffreyBytes

Copy link
Copy Markdown
Contributor

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

@s3rius

s3rius commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

I ran it on RTX5090. Thanks, @JeffreyBytes .

@JeffreyBytes

Copy link
Copy Markdown
Contributor

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

JeffreyBytes commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants