d3d12: narrow a direct-indexed program's texture writes to what it can store through #303

Merged
NickStallman merged 9 commits from upstream-pr/303 into main 2026-11-27 08:25:30 +00:00
NickStallman commented 2026-11-27 07:13:21 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T07:13:21Z.


Refs #215 (proposal in Discussion #300). Stacked on #301; the first two commits here are #301's.

A program under a root that allows direct heap indexing could, as far as the provider knew, write any texture in the heap. So every placed texture with a UAV in the heap counted as written by the batch, and each such batch read back, re-tiled and republished all of them to title memory. In ProjectScarlett on an RTX 5090 that was about 275 textures and 760 MB per batch, and most of the #215 stall.

This narrows the write set using what the console program itself states, keeping title memory identical to today:

  1. A pipeline that cannot write an image (every stage is console code with no image store or image atomic) only reads the heap's textures (dxbc: tell whether a console program can write an image, d3d12: only read the heap's textures …).
  2. A pipeline whose image stores all go through fixed descriptor-table slots writes only the textures at those slots, and reads the rest of the heap (dxbc: name the table descriptors …, d3d12: count only the table descriptors …). The analysis traces each store's descriptor back to a table load. A store through a heap index, or one it can't trace, keeps the whole heap written. In one recorded ProjectScarlett set, 1,355 of 1,409 storing compute programs and 1,123 of 1,417 storing pixel programs store only through table slots.
  3. s_setreg doesn't overwrite a scalar register. The decoder lists its source field as a destination, which lost the traced descriptor in 153 of 294 otherwise untraced pixel programs.

Measured in ProjectScarlett's story intro, RTX 5090, 620.70.10: in the first world interval, 14,015 of 14,147 whole-heap draws and dispatches were narrowed. The stall isn't gone, though. The remaining un-narrowed draws still republish the whole heap, and the read-side snapshot compare is untouched. Discussion #300 covers that next step.

Tests (Lanes, lanes-bindless-compute suite, each in a wide and a constrained heap):

  • bindless-heap-read: a direct-indexed program with no image write; the title rewrites a heap UAV texture's memory while the dispatch is held, and those words must survive.
  • bindless-table-store: a direct-indexed program storing through one table slot; that texture must reach title memory, and another UAV texture in the heap must keep the title's words.
  • bindless-texture-store: a store through the heap still publishes, so this case keeps today's behaviour.

On AMD (RADV), #301 plus only these Lanes commits fails bindless-heap-read and bindless-table-store in both modes, and passes with this PR. There are also dxbc unit tests for each analysis, including s_setreg.

Checks (on fdff12b; the tree differs from this branch only by #301's Lanes test)

  • AMD Raphael iGPU (1002:13c0), RADV, GE-Proton11-14: full python tuxbox.py check passed, 141 gates.
  • RTX 5090 (10de:2b85), 620.70.10, GE-Proton11-14: full python tuxbox.py check passed, 141 gates.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5522736603 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/303). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T07:13:21Z. --- Refs #215 (proposal in Discussion #300). **Stacked on #301**; the first two commits here are #301's. A program under a root that allows direct heap indexing could, as far as the provider knew, write any texture in the heap. So every placed texture with a UAV in the heap counted as written by the batch, and each such batch read back, re-tiled and republished all of them to title memory. In ProjectScarlett on an RTX 5090 that was about 275 textures and 760 MB per batch, and most of the #215 stall. This narrows the write set using what the console program itself states, keeping title memory identical to today: 1. **A pipeline that cannot write an image** (every stage is console code with no image store or image atomic) only reads the heap's textures (`dxbc: tell whether a console program can write an image`, `d3d12: only read the heap's textures …`). 2. **A pipeline whose image stores all go through fixed descriptor-table slots** writes only the textures at those slots, and reads the rest of the heap (`dxbc: name the table descriptors …`, `d3d12: count only the table descriptors …`). The analysis traces each store's descriptor back to a table load. A store through a heap index, or one it can't trace, keeps the whole heap written. In one recorded ProjectScarlett set, 1,355 of 1,409 storing compute programs and 1,123 of 1,417 storing pixel programs store only through table slots. 3. **`s_setreg` doesn't overwrite a scalar register.** The decoder lists its source field as a destination, which lost the traced descriptor in 153 of 294 otherwise untraced pixel programs. **Measured** in ProjectScarlett's story intro, RTX 5090, 620.70.10: in the first world interval, 14,015 of 14,147 whole-heap draws and dispatches were narrowed. The stall isn't gone, though. The remaining un-narrowed draws still republish the whole heap, and the read-side snapshot compare is untouched. Discussion #300 covers that next step. **Tests** (Lanes, `lanes-bindless-compute` suite, each in a wide and a constrained heap): - `bindless-heap-read`: a direct-indexed program with no image write; the title rewrites a heap UAV texture's memory while the dispatch is held, and those words must survive. - `bindless-table-store`: a direct-indexed program storing through one table slot; that texture must reach title memory, and another UAV texture in the heap must keep the title's words. - `bindless-texture-store`: a store through the heap still publishes, so this case keeps today's behaviour. On AMD (RADV), #301 plus only these Lanes commits fails `bindless-heap-read` and `bindless-table-store` in both modes, and passes with this PR. There are also dxbc unit tests for each analysis, including `s_setreg`. **Checks** (on fdff12b; the tree differs from this branch only by #301's Lanes test) - AMD Raphael iGPU (1002:13c0), RADV, GE-Proton11-14: full `python tuxbox.py check` passed, 141 gates. - RTX 5090 (10de:2b85), 620.70.10, GE-Proton11-14: full `python tuxbox.py check` passed, 141 gates. 🤖 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!303
No description provided.