d3d12: give paged heap indices without a slot a null view #572

Merged
NickStallman merged 4 commits from upstream-pr/572 into main 2026-12-01 20:33:11 +00:00
NickStallman commented 2026-11-30 05:08:45 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T05:08:45Z.


Rebased onto current main (91f56511 on 9a19c767) and checked on both cards (see the update at the end). It does not fix #232 (see the game result). Refs #533, #232.

With descriptor paging, the resource index map starts as zeros and programs load it unchecked, so an index without a visible slot reads whatever view slot 0 holds. The visible heap now has one more slot, holding the null view that empty records already get, and the map starts there. Indices with a slot read what they did. HLSL and cache keys don't change. A heap of the host's largest size gives up one slot.

Why. On an RTX 5090, #567's counter showed over a million map indices without a slot that hold non-zero records in ProjectScarlett. It doesn't show a shader reads them, and in the run that lost the GPU slot 0 named "no image", which weighs against this being the cause of #232. No claim that it fixes #232. It removes one way to read a wrong view.

Game result (RTX 5090, 86a, integration build): the fix was active (a log line names the null view's slot, 999,999, and the counter's lines read "the null view … no image"), and the GPU was still lost 9 minutes into the world (minutes in the world itself, from when frames drop below one a second; I first counted from the start of story loading) (Xid 13, MMU fault). So this is not the fix for #232. It removes one way to read a wrong view, and nothing more is claimed.

Update (1 Dec): the first version broke the stride of paged heaps below the host's largest size (32 bytes became 25 to 31), which failed 8 Lanes suites on both cards. 99268c96 takes the stride from the arena; a failing unit test is in dc47a861. Probe on AMD (GE-Proton11-15): main + this draft alone fails those 8; with the fix 45 of 45 pass. A heap of the host's largest size (ProjectScarlett's) was not affected. Full python tuxbox.py check of this head (GE-Proton11-15): RTX 5090 (10de:2b85, 620.70.10) 202 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 201 pass, 0 fail, bindless-unwritten included.

Evidence: TuxBox check of 99268c96ed, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run
Evidence: TuxBox check of 99268c96ed, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run

What those checks don't cover: the branch is based on e5d2e913, 51 commits behind main. Six of the eight gates are in that base and pass on both cards. lanes-bindless-table-heap-store-wide and -constrained came to main later (539b8cb3), so they aren't in these checks: on 40a69c3f plus this change they pass on the AMD iGPU and have not been run on the 5090. An integration build on main 82109205 that carries this change with others (not a check of this head) passes both of those gates and the full check on both cards (209 and 208 pass, 0 fail). It still needs a rebase and one more check of its own on both cards before it leaves draft.

Tested

  • Two unit tests that fail without the fix and pass with it (20 pass and 2 fail, then 22 of 22), and Lanes bindless-unwritten (built; passed on an AMD iGPU 1002:13c0 in an earlier, pre-rebase form together with a second change).
  • python tuxbox.py check --no-gpu at 661b558f: 12 of 12; cargo fmt --check, clippy -D warnings and rustdoc pass on both commits.

Not run: Miri; a full check rebased on current main; the game on this head alone (integration builds with the fix have run).

Limits: the null is a Texture2D SRV, so another type read through it is a D3D12 mismatch, as it already is for empty records. An index past the heap still reads past the map (fixing that needs HLSL). Records a title copies to an index the API never wrote now read null, not the copy; following them takes many slots and may name ended textures, so it needs its own measurement.

Update (2 Dec): rebased onto 9a19c767. Upstream's 56627188 now bounds the map lookup (an index past the map reads slot 0); this PR still covers indices inside the map that no slot was written for, which read slot 0 on main. Two of its own tests now take the tables' read lock (they are an RwLock on main). Full python tuxbox.py check of 91f56511 (GE-Proton11-15): RTX 5090 (10de:2b85) 212 pass, AMD iGPU (1002:13c0) 211 pass; the one failure on each is lanes-selftest-texture-publication (#625, fails on main too).

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5559378664 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/572). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T05:08:45Z. --- **Rebased onto current main (91f56511 on 9a19c767) and checked on both cards (see the update at the end). It does not fix #232 (see the game result).** Refs #533, #232. With descriptor paging, the resource index map starts as zeros and programs load it unchecked, so an index without a visible slot reads whatever view slot 0 holds. The visible heap now has one more slot, holding the null view that empty records already get, and the map starts there. Indices with a slot read what they did. HLSL and cache keys don't change. A heap of the host's largest size gives up one slot. **Why.** On an RTX 5090, #567's counter showed over a million map indices without a slot that hold non-zero records in ProjectScarlett. It doesn't show a shader reads them, and in the run that lost the GPU slot 0 named "no image", which weighs against this being the cause of #232. **No claim that it fixes #232.** It removes one way to read a wrong view. **Game result (RTX 5090, 86a, integration build):** the fix was active (a log line names the null view's slot, 999,999, and the counter's lines read "the null view … no image"), and the GPU was still lost 9 minutes into the world (minutes in the world itself, from when frames drop below one a second; I first counted from the start of story loading) (Xid 13, MMU fault). So this is not the fix for #232. It removes one way to read a wrong view, and nothing more is claimed. **Update (1 Dec):** the first version broke the stride of paged heaps below the host's largest size (32 bytes became 25 to 31), which failed 8 Lanes suites on both cards. 99268c96 takes the stride from the arena; a failing unit test is in dc47a861. Probe on AMD (GE-Proton11-15): main + this draft alone fails those 8; with the fix 45 of 45 pass. A heap of the host's largest size (ProjectScarlett's) was not affected. Full `python tuxbox.py check` of this head (GE-Proton11-15): RTX 5090 (`10de:2b85`, 620.70.10) 202 pass, 0 fail; AMD iGPU (`1002:13c0`, RADV) 201 pass, 0 fail, `bindless-unwritten` included. Evidence: TuxBox check of 99268c96edf8, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run Evidence: TuxBox check of 99268c96edf8, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run **What those checks don't cover:** the branch is based on e5d2e913, 51 commits behind main. Six of the eight gates are in that base and pass on both cards. `lanes-bindless-table-heap-store-wide` and `-constrained` came to main later (539b8cb3), so they aren't in these checks: on 40a69c3f plus this change they pass on the AMD iGPU and have not been run on the 5090. An integration build on main 82109205 that carries this change with others (not a check of this head) passes both of those gates and the full check on both cards (209 and 208 pass, 0 fail). It still needs a rebase and one more check of its own on both cards before it leaves draft. ## Tested - Two unit tests that fail without the fix and pass with it (20 pass and 2 fail, then 22 of 22), and Lanes `bindless-unwritten` (built; passed on an AMD iGPU `1002:13c0` in an earlier, pre-rebase form together with a second change). - `python tuxbox.py check --no-gpu` at 661b558f: 12 of 12; `cargo fmt --check`, clippy `-D warnings` and rustdoc pass on both commits. **Not run:** Miri; a full check rebased on current main; the game on this head alone (integration builds with the fix have run). **Limits:** the null is a Texture2D SRV, so another type read through it is a D3D12 mismatch, as it already is for empty records. An index past the heap still reads past the map (fixing that needs HLSL). Records a title copies to an index the API never wrote now read null, not the copy; following them takes many slots and may name ended textures, so it needs its own measurement. **Update (2 Dec):** rebased onto 9a19c767. Upstream's 56627188 now bounds the map lookup (an index past the map reads slot 0); this PR still covers indices inside the map that no slot was written for, which read slot 0 on main. Two of its own tests now take the tables' read lock (they are an RwLock on main). Full `python tuxbox.py check` of 91f56511 (GE-Proton11-15): RTX 5090 (`10de:2b85`) 212 pass, AMD iGPU (`1002:13c0`) 211 pass; the one failure on each is `lanes-selftest-texture-publication` (#625, fails on main too). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
NickStallman commented 2026-11-30 22:41:06 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T22:41:06Z.


Correction: my warning above was too broad, please read this version. The draft does have a bug, but it doesn't affect ProjectScarlett's large heap, and I shouldn't have said your results or ours may be wrong because of it.

  • What's real (measured): our build with this draft fails 8 Lanes suites on an RTX 5090 and an AMD iGPU (the same eight). Plain main passes all, and main plus fix/heap-index-clamp passes all on the 5090. All eight are in suites that force a small descriptor heap.
  • Cause, by reading (a probe is queued): for a shader-visible paged heap below the host's largest size, the draft makes the native heap limit + 1 while the tracked range still covers limit, and commands/descriptors.rs derives the stride by dividing them (32 becomes 25 to 31). A fix takes it from GetDescriptorHandleIncrementSize.
  • Why ProjectScarlett's heap isn't affected: for a heap larger than 1,000,000 descriptors the arena gives up one slot, so the native heap is exactly 1,000,000 and the range covers exactly that; the division is exact. Our game log shows it (null view at slot 999,999, map of 1,245,184). Whether a smaller heap in the game takes the bad path I haven't checked; its log has 0 "skipped ... with a reflected table".
  • For tests: don't use this draft in a build whose Lanes results you rely on until it's fixed. Your game results with it are not called into question by this.

I said earlier that every build of ours from 86a may have published the wrong textures. That was a consequence I hadn't checked, and it's wrong.

<!-- greyfinch-sync:brcly/TuxBox:comment:7294169824 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/572#issuecomment-7294169824). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T22:41:06Z. --- **Correction: my warning above was too broad, please read this version.** The draft does have a bug, but it doesn't affect ProjectScarlett's large heap, and I shouldn't have said your results or ours may be wrong because of it. - **What's real (measured):** our build with this draft fails 8 Lanes suites on an RTX 5090 and an AMD iGPU (the same eight). Plain main passes all, and main plus `fix/heap-index-clamp` passes all on the 5090. All eight are in suites that force a small descriptor heap. - **Cause, by reading (a probe is queued):** for a shader-visible paged heap below the host's largest size, the draft makes the native heap `limit + 1` while the tracked range still covers `limit`, and `commands/descriptors.rs` derives the stride by dividing them (32 becomes 25 to 31). A fix takes it from `GetDescriptorHandleIncrementSize`. - **Why ProjectScarlett's heap isn't affected:** for a heap larger than 1,000,000 descriptors the arena gives up one slot, so the native heap is exactly 1,000,000 and the range covers exactly that; the division is exact. Our game log shows it (null view at slot 999,999, map of 1,245,184). Whether a smaller heap in the game takes the bad path I haven't checked; its log has 0 "skipped ... with a reflected table". - **For tests:** don't use this draft in a build whose Lanes results you rely on until it's fixed. Your game results with it are not called into question by this. I said earlier that every build of ours from 86a may have published the wrong textures. That was a consequence I hadn't checked, and it's wrong.
NickStallman commented 2026-11-30 22:52:36 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T22:52:36Z.


The probe has run (AMD iGPU 1002:13c0, RADV, GE-Proton11-15; the 5090 has not been probed):

Build The four suites that failed (45 tests)
main 40a69c3f + this draft only 8 fail, the same eight
that + a one-place stride fix 45 pass
our integration build + the same fix 45 pass

So this draft alone causes the 8 Lanes failures, and taking the stride from the arena (it holds the host's increment) repairs them. The unit test for it fails without the fix. I'll push it to this PR with the full checks on both cards.

<!-- greyfinch-sync:brcly/TuxBox:comment:7294419805 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/572#issuecomment-7294419805). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T22:52:36Z. --- The probe has run (AMD iGPU `1002:13c0`, RADV, GE-Proton11-15; the 5090 has not been probed): | Build | The four suites that failed (45 tests) | |---|---| | main 40a69c3f + this draft only | **8 fail**, the same eight | | that + a one-place stride fix | 45 pass | | our integration build + the same fix | 45 pass | So this draft alone causes the 8 Lanes failures, and taking the stride from the arena (it holds the host's increment) repairs them. The unit test for it fails without the fix. I'll push it to this PR with the full checks on both cards.
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!572
No description provided.