GPU: fix missed descriptor tables across the allocation cursor #148

Open
syrrath-creator wants to merge 1 commit from upstream-pr/148 into main
syrrath-creator commented 2026-11-25 15:08:43 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by syrrath-creator on 2026-11-25T14:53:50Z.


The dynamic descriptor allocator can reject a table that fits. Reserve all but the last 80 slots of a view heap, allocate 32, then release those 32. All 80 slots are now free. The old search cursor divides them into 32 and 48 slots, so dynamic(64) returns None. The failure cache can then reject further requests of the same size, and a draw or dispatch that needs the table can be skipped.

The search now wraps candidate start positions while keeping each table physically contiguous. An occupied slot rules out every candidate start up to that slot. The first valid position in next-fit order wins. The existing allocation lock, release handling and failure cache are preserved.

  • The regression failed on 90b529f after one successful fenced compute dispatch on a physical RTX 4090. The fixed allocator returned the requested 64 slots. The unit test also checks every occupation mask, cursor and request size for heaps with one through nine slots (67,578 cases).
  • A 40-minute RTX 4090 run completed 2,995,241 cycles and 5,990,482 fenced dispatches, checking 2,803,545,576 output DWORDs against a CPU reference. The shader reads through the allocated tables and checks guard descriptors. The test fails on a mismatch, a fence timeout or device removal.
  • On a synthetic fragmented 262,144-slot heap, an uncached miss took 210.63 µs before and 26.65 µs after (median over 36 observations per version). This measures CPU search time. No game frame time was measured.

Reproduce the hardware regression and soak · Reproduce the CPU comparison. Developed and tested with Codex.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6607276412 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/148). Originally posted by [syrrath-creator](https://github.com/syrrath-creator) on 2026-11-25T14:53:50Z. --- The dynamic descriptor allocator can reject a table that fits. Reserve all but the last 80 slots of a view heap, allocate 32, then release those 32. All 80 slots are now free. The old search cursor divides them into 32 and 48 slots, so `dynamic(64)` returns `None`. The failure cache can then reject further requests of the same size, and a draw or dispatch that needs the table can be skipped. The search now wraps candidate **start positions** while keeping each table physically contiguous. An occupied slot rules out every candidate start up to that slot. The first valid position in next-fit order wins. The existing allocation lock, release handling and failure cache are preserved. - The regression failed on `90b529f` after one successful fenced compute dispatch on a physical RTX 4090. The fixed allocator returned the requested 64 slots. The unit test also checks every occupation mask, cursor and request size for heaps with one through nine slots (67,578 cases). - A 40-minute RTX 4090 run completed **2,995,241 cycles and 5,990,482 fenced dispatches**, checking 2,803,545,576 output DWORDs against a CPU reference. The shader reads through the allocated tables and checks guard descriptors. The test fails on a mismatch, a fence timeout or device removal. - On a synthetic fragmented 262,144-slot heap, an uncached miss took 210.63 µs before and 26.65 µs after (median over 36 observations per version). This measures CPU search time. No game frame time was measured. [Reproduce the hardware regression and soak](https://github.com/syrrath-creator/ztrx/blob/cb69cc1608a1b70b41f9835e428ba1b2780db622/scripts/bench/descriptor-hardware.md) · [Reproduce the CPU comparison](https://github.com/syrrath-creator/ztrx/tree/2520e6d5cdb3dc04d316bf992bc50e0c8808bfe4/scripts/bench). Developed and tested with Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/148:upstream-pr/148'
git switch 'upstream-pr/148'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/148'
git switch 'upstream-pr/148'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/148'
git switch 'upstream-pr/148'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/148'
git switch 'main'
git merge --squash 'upstream-pr/148'
git switch 'main'
git merge --ff-only 'upstream-pr/148'
git switch 'main'
git merge 'upstream-pr/148'
git push origin 'main'
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
Zettrox/ztrx!148
No description provided.