dxbc: trace more image stores, so fewer batches copy back a whole heap #460

Merged
NickStallman merged 5 commits from upstream-pr/460 into main 2026-11-29 11:25:23 +00:00
NickStallman commented 2026-11-29 08:54:27 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T08:54:27Z.


Summary

A program whose image writes can't be traced makes every writable texture of its heap count as written, and each is copied back after the batch. In ProjectScarlett's world a few programs do this for 504 textures (939 MiB per batch).

Two rules gave up on what the code settles, and a third case is now followed:

  • A comparison was taken to write two scalar registers where a 32-lane mask is one. An odd destination in reached code proves 32 lanes (a 64-lane mask starts at an even register), and then lane masks clobber one register.
  • A store that may use one of several known table slots by path now names them all, if every dword of the descriptor is one load's on each path. Anything else stays unknown.
  • A descriptor address spilled to a vector lane at a constant index, and read back, is followed when nothing else can write that register.

Over 19,051 distinct recorded programs (table_image_writes), unknown ones go from 211 to 141 (compute 91 to 21, pixel 120 to 120). No known program changed, and every slot named is one the program's own records declare.

TUXBOX_CHECK_NARROWED=1 tests the result at run time: it copies back what a batch is taken not to write, compares, and logs a change. It is heavier than normal play and skips batches with label waits.

Measured in ProjectScarlett (RTX 5090, main at 28717263 plus #436, #389, #390 and diagnostics; one run each, warm)

without with
Batches counted as writing the whole heap 34 of 606 1 of 339
Windows showing the 504-texture set 7 of 11 1 of 9
Copied back in a 5 s window late in the world 2.9 to 9.7 GB mostly 7 to 28 MB, then one 1.0 GB

Weak evidence: the run with the change ended about 44 s into the world, against 64 s, so it didn't reach as far into the world, and both are single runs. An earlier version of this branch (compare and path rules only). Offline, 15 to 28 of the 34 batches were expected to remain, because 119 recorded pixel programs pick a UAV by a constant-buffer index and can't be traced; two of them appear in that run's log. The likeliest reason fewer remained is that this run reached a shorter, earlier scene (44 s in the world, one such batch) than the one without (64 s, 14 of them), so the 1 of 339 shouldn't be read as the result. Most of those 339 batches also lie before the world.

Not claimed

  • Any frame time on this card. (DrArroway measured 5.50 s per frame with this and 8.29 without on an RX 6900 XT, one run each.) My first check-mode run on the 5090 produced no output; a later one did (below).
  • That the pixel programs above stop counting the whole heap: they don't, and they are 14 of the 34 batches in the run without.

Tested

  • python tuxbox.py check --no-gpu: passed on this head.
  • Tracer unit tests; several mutations each fail one. One rule (copying a merged descriptor) isn't covered by a mutation. Device-free D3D12 unit tests.
  • Full tuxbox.py check on 6ac9fbf7: RTX 5090 (620.70.10) 185 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 184 pass, 0 fail, guest-present-4k-splash skipped (software display). Both include bindless-table-compare and bindless-table-select, wide and constrained. Those two were not run against main's tracer on a GPU; offline it returns unknown for both and this change names their slots.
  • By others on 6ac9fbf7: brcly, lanes-bindless-compute 22/22 on an RTX 4070 Ti SUPER and a Radeon 610M, in a build with #439 and #462. DrArroway on an RX 6900 XT, lanes-bindless-compute 20/20 and a game run of the check mode: changed=0 over 1,461 mips. That compared 2 batches only and skipped 14,202 textures whose publication was pending, so it is a small sample.
  • Check mode in a game on the RTX 5090 (in a build with #462 and others, about 50 s of the world): changed=0 over 7,966 mips, 11 batches compared, 10,408 skipped.
  • Not run: Windows.

With #439: #439 shares one readback buffer per queue, relying on the queue waiting for each publication. The check mode's copies have no such wait, so with both merged the next readback could overwrite them and log false changes. Whichever merges second should give the check its own buffer. Normal play isn't affected.

This changes runtime/dxbc, so the next launch prepares again; the translator is unchanged.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5549184087 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/460). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T08:54:27Z. --- ## Summary A program whose image writes can't be traced makes every writable texture of its heap count as written, and each is copied back after the batch. In ProjectScarlett's world a few programs do this for 504 textures (939 MiB per batch). Two rules gave up on what the code settles, and a third case is now followed: - A comparison was taken to write two scalar registers where a 32-lane mask is one. An odd destination in reached code proves 32 lanes (a 64-lane mask starts at an even register), and then lane masks clobber one register. - A store that may use one of several known table slots by path now names them all, if every dword of the descriptor is one load's on each path. Anything else stays unknown. - A descriptor address spilled to a vector lane at a constant index, and read back, is followed when nothing else can write that register. Over 19,051 distinct recorded programs (`table_image_writes`), unknown ones go from 211 to 141 (compute 91 to 21, pixel 120 to 120). No known program changed, and every slot named is one the program's own records declare. `TUXBOX_CHECK_NARROWED=1` tests the result at run time: it copies back what a batch is taken not to write, compares, and logs a change. It is heavier than normal play and skips batches with label waits. ## Measured in ProjectScarlett (RTX 5090, `main` at 28717263 plus #436, #389, #390 and diagnostics; one run each, warm) | | without | with | |---|---|---| | Batches counted as writing the whole heap | 34 of 606 | 1 of 339 | | Windows showing the 504-texture set | 7 of 11 | 1 of 9 | | Copied back in a 5 s window late in the world | 2.9 to 9.7 GB | mostly 7 to 28 MB, then one 1.0 GB | **Weak evidence:** the run with the change ended about 44 s into the world, against 64 s, so it didn't reach as far into the world, and both are single runs. An earlier version of this branch (compare and path rules only). Offline, 15 to 28 of the 34 batches were expected to remain, because 119 recorded pixel programs pick a UAV by a constant-buffer index and can't be traced; two of them appear in that run's log. The likeliest reason fewer remained is that this run reached a shorter, earlier scene (44 s in the world, one such batch) than the one without (64 s, 14 of them), so **the 1 of 339 shouldn't be read as the result.** Most of those 339 batches also lie before the world. ## Not claimed - Any frame time on this card. (DrArroway measured 5.50 s per frame with this and 8.29 without on an RX 6900 XT, one run each.) My first check-mode run on the 5090 produced no output; a later one did (below). - That the pixel programs above stop counting the whole heap: they don't, and they are 14 of the 34 batches in the run without. ## Tested - `python tuxbox.py check --no-gpu`: passed on this head. - Tracer unit tests; several mutations each fail one. One rule (copying a merged descriptor) isn't covered by a mutation. Device-free D3D12 unit tests. - Full `tuxbox.py check` on 6ac9fbf7: RTX 5090 (620.70.10) 185 pass, 0 fail; AMD iGPU (`1002:13c0`, RADV) 184 pass, 0 fail, guest-present-4k-splash skipped (software display). Both include `bindless-table-compare` and `bindless-table-select`, wide and constrained. Those two were not run against `main`'s tracer on a GPU; offline it returns unknown for both and this change names their slots. - **By others on 6ac9fbf7:** brcly, `lanes-bindless-compute` 22/22 on an RTX 4070 Ti SUPER and a Radeon 610M, in a build with #439 and #462. DrArroway on an RX 6900 XT, `lanes-bindless-compute` 20/20 and a game run of the check mode: `changed=0` over 1,461 mips. That compared 2 batches only and skipped 14,202 textures whose publication was pending, so it is a small sample. - Check mode in a game on the RTX 5090 (in a build with #462 and others, about 50 s of the world): `changed=0` over 7,966 mips, 11 batches compared, 10,408 skipped. - **Not run:** Windows. **With #439:** #439 shares one readback buffer per queue, relying on the queue waiting for each publication. The check mode's copies have no such wait, so with both merged the next readback could overwrite them and log false changes. Whichever merges second should give the check its own buffer. Normal play isn't affected. This changes `runtime/dxbc`, so the next launch prepares again; the translator is unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
brcly commented 2026-11-29 10:19:52 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T10:19:52Z.


Tested combined with #439 and a heap write bitmap for what this can't trace (#462, stacked on both), on an RTX 4070 Ti SUPER (620.73.04) and a Radeon 610M (RADV 26.3.1), GE-Proton11-14:

  • lanes-bindless-compute: 22/22 on both cards, including your table-compare and table-select.
  • lanes-raster-tables 8/8, d3d12-placement, lanes-selftest 27/27 on NVIDIA.
  • dxbc 96, d3d12 --lib 376 under Wine, Python 635: all pass.

I'd independently landed on the same two rules (odd compare destination, slot sets over paths) before seeing this, and dropped mine for yours since it also follows the lane spills and adds the check mode. Over our recorded corpus mine got compute from 91 to 25; yours gets 21.

In ProjectScarlett the programs left untraced are pixel shaders in mesh pipelines (store slot from a constant buffer), so the 504-texture batches persist without #462. With both, the world load shows no whole-heap batch.

One interaction to know about: #462 puts the textures a bitmap may name in read-only ranges, so it passes them to narrowed::choose as writes to keep the check mode from flagging them.

Could this come out of draft? #462 needs it on main first.

<!-- greyfinch-sync:brcly/TuxBox:comment:7254362056 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/460#issuecomment-7254362056). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T10:19:52Z. --- Tested combined with #439 and a heap write bitmap for what this can't trace (#462, stacked on both), on an RTX 4070 Ti SUPER (620.73.04) and a Radeon 610M (RADV 26.3.1), GE-Proton11-14: - `lanes-bindless-compute`: 22/22 on both cards, including your `table-compare` and `table-select`. - `lanes-raster-tables` 8/8, `d3d12-placement`, `lanes-selftest` 27/27 on NVIDIA. - dxbc 96, d3d12 `--lib` 376 under Wine, Python 635: all pass. I'd independently landed on the same two rules (odd compare destination, slot sets over paths) before seeing this, and dropped mine for yours since it also follows the lane spills and adds the check mode. Over our recorded corpus mine got compute from 91 to 25; yours gets 21. In ProjectScarlett the programs left untraced are pixel shaders in mesh pipelines (store slot from a constant buffer), so the 504-texture batches persist without #462. With both, the world load shows no whole-heap batch. One interaction to know about: #462 puts the textures a bitmap may name in read-only ranges, so it passes them to `narrowed::choose` as writes to keep the check mode from flagging them. Could this come out of draft? #462 needs it on `main` first.
DrArroway commented 2026-11-29 10:21:09 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T10:21:09Z.


Tested #460 (6ac9fbf7) on AMD Radeon RX 6900 XT (1002:73bf, RADV NAVI21, Mesa 26.3.1, Linux 7.3.6, GE-Proton11-14), built on main (75453953) + #455 (361df2d4) + #441 (f244a687) + #460 (6ac9fbf7, without #439 for standalone & check-mode runs, plus a separate normal-play run with #439 962a1cee).

1. Targeted AMD Checks (1002:73bf)

  • cargo test -p tuxbox-dxbc --features native-bindings: 93 passed; 0 failed
  • tuxbox.py verify --only lanes-bindless-compute: 20/20 PASS (including lanes-bindless-table-compare-wide, lanes-bindless-table-compare-constrained, lanes-bindless-table-select-wide, lanes-bindless-table-select-constrained)

2. ProjectScarlett TUXBOX_CHECK_NARROWED=1 Run (389.9s, 11 3D frames in 67s, 0 GPU faults)

  • Final check counter:
    narrowed write check: batches copied=2 textures chosen=967 mips compared=1461 changed=0 skipped=14202, in all
  • changed=0 across 1,461 compared mips (967 textures).
  • Note on why batches copied stopped at 2 while skipped reached 14,202: the remaining pixel-program 939.3 MiB / 504 textures dumps keep overlapping publications pending on the worker, so narrowed::choose() skips subsequent doubted textures while those publications are still in flight.

3. ProjectScarlett 4-Point 3D World Comparison (TUXBOX_SUBMIT_PROFILE=1)

Metric (RX 6900 XT) Baseline (no #439/#460) #460 alone (492.7s) #439 alone (623.6s) #460 + #439 normal (361.3s)
3D frame cadence 21 / 174s (8.29 s/f, 0.121 FPS) 12 / 66s (5.50 s/f, 0.182 FPS, 1.51× faster) 27 / 107s (3.96 s/f, 0.252 FPS) 25 / 88s (3.52 s/f incl. transition; steady 16 / 76s = 4.75 s/f)
placement publication 83.2% wall, avg 685.9 ms (~3,435 MiB/frame) 70.7% wall, avg 435.6 ms (~1,699 MiB/frame, 50.5% less) 42.0% wall, avg 165.0 ms 30.8% wall, avg 123.7 ms (max 816.3 ms)
Avg readback MiB / batch 342.0 MiB (240 batches) 193.7 MiB (144 batches, 43.4% less) 346.8 MiB (306 batches) 178.6 MiB (226 batches)
Readback buffers created / reuse 189 (88.7 GiB, 21.2%) 100 (29.4 GiB, 30.6%) 32 (1.50 GiB, 89.5%) (0 in steady state) 61 (11.7 GiB, 73.0%)
GPU faults / DEVICE_LOST 0 0 0 0

Notes

  • Standalone, #460 cuts published MiB per 3D frame in half (~3,435 → ~1,699 MiB/frame) and speeds up 3D frames by ~1.51×.
  • Together with #439, placement publication drops to 30.8% of wall time (123.7 ms/batch). However, because #460 narrows compute batches into varied medium sizes (~269 MiB, etc.) while the remaining pixel-program batches still dump 939.3 MiB, #439's per-size readback pool begins churning again (~1.4 GiB / 5s, 61 buffers created / 11.7 GiB vs 32 / 1.50 GiB with #439 alone), pushing direct queue placement= from 503–684 ms up to 840–1,139 ms / 5s.
<!-- greyfinch-sync:brcly/TuxBox:comment:7254376403 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/460#issuecomment-7254376403). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T10:21:09Z. --- Tested `#460` (`6ac9fbf7`) on AMD Radeon RX 6900 XT (`1002:73bf`, RADV NAVI21, Mesa 26.3.1, Linux 7.3.6, `GE-Proton11-14`), built on `main` (`75453953`) + `#455` (`361df2d4`) + `#441` (`f244a687`) + `#460` (`6ac9fbf7`, without `#439` for standalone & check-mode runs, plus a separate normal-play run with `#439` `962a1cee`). ### 1. Targeted AMD Checks (`1002:73bf`) - `cargo test -p tuxbox-dxbc --features native-bindings`: `93 passed; 0 failed` - `tuxbox.py verify --only lanes-bindless-compute`: `20/20 PASS` (including `lanes-bindless-table-compare-wide`, `lanes-bindless-table-compare-constrained`, `lanes-bindless-table-select-wide`, `lanes-bindless-table-select-constrained`) ### 2. ProjectScarlett `TUXBOX_CHECK_NARROWED=1` Run (`389.9s`, `11` 3D frames in `67s`, `0` GPU faults) - Final check counter: `narrowed write check: batches copied=2 textures chosen=967 mips compared=1461 changed=0 skipped=14202, in all` - **`changed=0`** across `1,461` compared mips (`967` textures). - Note on why `batches copied` stopped at `2` while `skipped` reached `14,202`: the remaining pixel-program `939.3 MiB / 504 textures` dumps keep overlapping publications pending on the worker, so `narrowed::choose()` skips subsequent doubted textures while those publications are still in flight. ### 3. ProjectScarlett 4-Point 3D World Comparison (`TUXBOX_SUBMIT_PROFILE=1`) | Metric (RX 6900 XT) | Baseline (no `#439`/`#460`) | `#460` alone (`492.7s`) | `#439` alone (`623.6s`) | `#460` + `#439` normal (`361.3s`) | |---|---:|---:|---:|---:| | **3D frame cadence** | `21` / `174s` (`8.29 s/f`, `0.121 FPS`) | `12` / `66s` (`5.50 s/f`, `0.182 FPS`, **`1.51×` faster**) | `27` / `107s` (`3.96 s/f`, `0.252 FPS`) | `25` / `88s` (`3.52 s/f` incl. transition; steady `16` / `76s` = `4.75 s/f`) | | **`placement publication`** | `83.2%` wall, avg `685.9 ms` (`~3,435 MiB/frame`) | `70.7%` wall, avg `435.6 ms` (`~1,699 MiB/frame`, **`50.5%` less**) | `42.0%` wall, avg `165.0 ms` | **`30.8%` wall**, avg `123.7 ms` (max `816.3 ms`) | | **Avg readback MiB / batch** | `342.0 MiB` (`240` batches) | `193.7 MiB` (`144` batches, **`43.4%` less**) | `346.8 MiB` (`306` batches) | **`178.6 MiB`** (`226` batches) | | **Readback buffers created / reuse** | `189` (`88.7 GiB`, `21.2%`) | `100` (`29.4 GiB`, `30.6%`) | **`32` (`1.50 GiB`, `89.5%`)** (`0` in steady state) | `61` (`11.7 GiB`, `73.0%`) | | **GPU faults / `DEVICE_LOST`** | `0` | `0` | `0` | `0` | ### Notes - Standalone, `#460` cuts published MiB per 3D frame in half (`~3,435` → `~1,699 MiB/frame`) and speeds up 3D frames by `~1.51×`. - Together with `#439`, `placement publication` drops to `30.8%` of wall time (`123.7 ms/batch`). However, because `#460` narrows compute batches into varied medium sizes (`~269 MiB`, etc.) while the remaining pixel-program batches still dump `939.3 MiB`, `#439`'s per-size readback pool begins churning again (`~1.4 GiB / 5s`, `61` buffers created / `11.7 GiB` vs `32` / `1.50 GiB` with `#439` alone), pushing `direct` queue `placement=` from `503–684 ms` up to `840–1,139 ms` / `5s`.
NickStallman commented 2026-11-29 10:49:51 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T10:49:51Z.


Thank you both. @brcly: yes. The full check of 6ac9fbf7 is running now on an AMD iGPU and follows on an RTX 5090; I'll take this out of draft when both pass, and post it if one doesn't. #439 is already out of draft.

The pixel shaders #462 covers are the part I couldn't do: I'd only logged that the index stayed the same over 30 draws on the 5090, with a possible GPU write I couldn't rule out, so recording the slots is better and I've dropped mine. I'll run #462 in the game on the 5090.

@DrArroway: changed=0 over 1,461 mips is the first result the check mode has given; with 2 batches copied it's a small sample, as you say, so I'll put it in the description as that. The pool churn with #439 is worth knowing: the pool is per size, and #460 makes the sizes vary.

<!-- greyfinch-sync:brcly/TuxBox:comment:7254697245 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/460#issuecomment-7254697245). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T10:49:51Z. --- Thank you both. @brcly: yes. The full check of `6ac9fbf7` is running now on an AMD iGPU and follows on an RTX 5090; I'll take this out of draft when both pass, and post it if one doesn't. #439 is already out of draft. The pixel shaders #462 covers are the part I couldn't do: I'd only logged that the index stayed the same over 30 draws on the 5090, with a possible GPU write I couldn't rule out, so recording the slots is better and I've dropped mine. I'll run #462 in the game on the 5090. @DrArroway: `changed=0` over 1,461 mips is the first result the check mode has given; with 2 batches copied it's a small sample, as you say, so I'll put it in the description as that. The pool churn with #439 is worth knowing: the pool is per size, and #460 makes the sizes vary.
NickStallman commented 2026-11-29 11:48:46 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T11:48:46Z.


First TUXBOX_CHECK_NARROWED=1 game run on NVIDIA (RTX 5090, 620.70.10; your #462 with this, on main 75453953, plus #455, #441, #440, #390, #459), one run, about 50 s of the world:

batches copied=11 textures chosen=5283 mips compared=7966 changed=0 skipped=10408, in all

No missed write in what it compared. Two windows in this run did show the 504-texture set, which the run before without the check mode never did; I think those are the check's own copies, but I haven't confirmed it. The run then ended in a GPU MMU fault (Xid 13), as the one without the check did.

The check has its own readback buffer in that build (the collision with #439 I mentioned).

<!-- greyfinch-sync:brcly/TuxBox:comment:7255367209 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/460#issuecomment-7255367209). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T11:48:46Z. --- First `TUXBOX_CHECK_NARROWED=1` game run on NVIDIA (RTX 5090, 620.70.10; your #462 with this, on `main` 75453953, plus #455, #441, #440, #390, #459), one run, about 50 s of the world: `batches copied=11 textures chosen=5283 mips compared=7966 changed=0 skipped=10408, in all` No missed write in what it compared. Two windows in this run did show the 504-texture set, which the run before without the check mode never did; I think those are the check's own copies, but I haven't confirmed it. The run then ended in a GPU MMU fault (Xid 13), as the one without the check did. The check has its own readback buffer in that build (the collision with #439 I mentioned).
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!460
No description provided.