d3d12: evict descriptor tables in one pass and keep submission off the table lock #395

Merged
NickStallman merged 1 commit from upstream-pr/395 into main 2026-11-28 15:07:14 +00:00
NickStallman commented 2026-11-28 12:19:48 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T12:19:48Z.


Summary

When a shader-visible descriptor table didn't fit, each eviction scanned every resident table for the oldest unpinned one, and the allocation repeated that until a contiguous span opened.

  • Quadratic: on a fragmented arena with many tables, that is quadratic.
  • Under a shared lock: it ran under the tables lock, which ExecuteCommandLists also takes to pin tables and record its batch.

In ProjectScarlett (RTX 5090, 620.70.10), this showed up as the title's watchdog exiting with code 5, "Unsignaled CrossQueueBarrier":

  • The minidump has the submission thread waiting on that lock in push_in_flight while a recording thread runs evict_oldest.
  • The consequence: the label-writing lists that the compute queues wait for were never submitted.

Changes:

  • One-pass eviction. Resident tables are kept in a use-order set, and one allocation evicts from the oldest use in a single pass that skips pinned tables.
  • Submission off the table lock. Pin counts are shared atomics behind their own index, and submitted batches retire under their own lock. So pinning, committing and retiring a batch never wait for an allocation's evictions.
  • One entry and exit path. Tables enter and leave through one helper that keeps the use order, the id index, the pin index and #361's longest-table bound in step.
  • Logging. With TUXBOX_LOG, an allocation that evicts more than 64 tables, or takes over 20 ms, is logged with its cost.

This is rebased on #361, which already limits which tables a descriptor write visits, so that part is not repeated here.

Effect in game: not shown. Correction (29 Nov): this description first claimed that a run with the change had "its first minute in the world at 115 fps" with no forced label releases. Both were wrong: 115 was a screenshot brightness average from our run tool, not a frame rate. That run logged 9 forced label releases, the first about 21 s after the story load, and presented two frames of about 20 s each before the device was lost. The unit tests below and the minidump are the evidence for this change; I have no measured game speed-up.

Tested

  • 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

The new unit tests fail on main:

  • Large eviction: evicting 10,000 single-slot tables for one large table takes 5.5 s on main under Wine. The whole suite now runs in 0.08 s.
  • Lock independence: a batch committed while another thread holds the table lock waited on main, and doesn't now.
  • Use order: a further test covers the use order with a pinned table.

No Lanes scenario covers this: the behaviour is unchanged; only the cost and the lock scope change.

GPU, driver and backend:

  • RTX 5090 (10de:2b85), NVIDIA 620.70.10
  • AMD Raphael iGPU (1002:13c0), Mesa RADV 26.0.8
  • both on GE-Proton11-14

Commands run and their results:

python tuxbox.py check --adapter 10de:2b85 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64
  all 11 steps passed
python tuxbox.py check --adapter 1002:13c0 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64
  10 of 11 steps passed; Lanes failed one gate, lanes-selftest-texture-publication
python tuxbox.py verify --only lanes-selftest --adapter 1002:13c0 (three reruns on the same head)
  all passed, texture-publication included, each time
d3d12 unit tests under GE-Proton (5090): 227 passed, 0 failed

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5540056384 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/395). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-28T12:19:48Z. --- ## Summary When a shader-visible descriptor table didn't fit, each eviction scanned every resident table for the oldest unpinned one, and the allocation repeated that until a contiguous span opened. - **Quadratic:** on a fragmented arena with many tables, that is quadratic. - **Under a shared lock:** it ran under the `tables` lock, which `ExecuteCommandLists` also takes to pin tables and record its batch. **In ProjectScarlett** (RTX 5090, 620.70.10), this showed up as the title's watchdog exiting with code 5, "Unsignaled CrossQueueBarrier": - **The minidump** has the submission thread waiting on that lock in `push_in_flight` while a recording thread runs `evict_oldest`. - **The consequence:** the label-writing lists that the compute queues wait for were never submitted. **Changes:** - **One-pass eviction.** Resident tables are kept in a use-order set, and one allocation evicts from the oldest use in a single pass that skips pinned tables. - **Submission off the table lock.** Pin counts are shared atomics behind their own index, and submitted batches retire under their own lock. So pinning, committing and retiring a batch never wait for an allocation's evictions. - **One entry and exit path.** Tables enter and leave through one helper that keeps the use order, the id index, the pin index and #361's longest-table bound in step. - **Logging.** With `TUXBOX_LOG`, an allocation that evicts more than 64 tables, or takes over 20 ms, is logged with its cost. This is rebased on #361, which already limits which tables a descriptor write visits, so that part is not repeated here. **Effect in game: not shown.** **Correction (29 Nov):** this description first claimed that a run with the change had "its first minute in the world at 115 fps" with no forced label releases. Both were wrong: 115 was a screenshot brightness average from our run tool, not a frame rate. That run logged 9 forced label releases, the first about 21 s after the story load, and presented two frames of about 20 s each before the device was lost. The unit tests below and the minidump are the evidence for this change; I have no measured game speed-up. ## Tested - [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 - [x] Where the table calls for AMD and NVIDIA, they passed on both The new unit tests fail on `main`: - **Large eviction:** evicting 10,000 single-slot tables for one large table takes 5.5 s on `main` under Wine. The whole suite now runs in 0.08 s. - **Lock independence:** a batch committed while another thread holds the table lock waited on `main`, and doesn't now. - **Use order:** a further test covers the use order with a pinned table. No Lanes scenario covers this: the behaviour is unchanged; only the cost and the lock scope change. GPU, driver and backend: - RTX 5090 (10de:2b85), NVIDIA 620.70.10 - AMD Raphael iGPU (1002:13c0), Mesa RADV 26.0.8 - both on GE-Proton11-14 Commands run and their results: ```text python tuxbox.py check --adapter 10de:2b85 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64 all 11 steps passed python tuxbox.py check --adapter 1002:13c0 --proton GE-Proton11-14 --prefix PREFIX --windows-dxc DXC/bin/x64 10 of 11 steps passed; Lanes failed one gate, lanes-selftest-texture-publication python tuxbox.py verify --only lanes-selftest --adapter 1002:13c0 (three reruns on the same head) all passed, texture-publication included, each time d3d12 unit tests under GE-Proton (5090): 227 passed, 0 failed ``` 🤖 Generated with [Claude Code](https://claude.com/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!395
No description provided.