GPU: Dynamic descriptor allocator can falsely report exhaustion when a free range crosses the search cursor #871
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#871
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@FunWithFlagsDev on GitHub · 2026-11-24 13:01 UTC · original
<html>Bug description
While reviewing the dynamic descriptor allocator, I identified an algorithmic issue in
HostHeap::dynamic()that can cause allocation failures even when a sufficiently large contiguous range of free descriptors exists.The current search divides the descriptor heap into two ranges at the current cursor. A valid contiguous free range that crosses this cursor may therefore be missed by both scans.
This creates false descriptor exhaustion independently of the actual heap capacity.
Affected code
File:
crates/victory-gpu/src/descriptor/host.rsFunction:
HostHeap::dynamic()https://github.com/Marvisak/VIctory/blob/main/crates/victory-gpu/src/descriptor/host.rs#L225-L257
Current implementation:
Minimal reproduction
Consider a descriptor heap with eight slots:
Search cursor: 3
Requested contiguous slots: 4
Available contiguous range: indices 1–4
The original algorithm searches indices 3–7, followed by indices 0–2.
Neither scan individually finds four contiguous free slots, although a valid allocation exists at index 1.
Expected result: successful allocation starting at index 1.
Actual result: allocation failure.
Proposed fix
Extend the second search range by up to
n - 1slots, bounded by the physical heap size.The existing discontinuity check remains unchanged, preventing allocations from wrapping around the physical end of the heap.
The existing input validation also ensures that
nis greater than zero before this calculation.Validation
I implemented a CPU-only model of the original and proposed algorithms and compared them against an independent reference allocator.
An exhaustive combinatorial analysis covered all occupancy configurations for heaps containing 1–10 slots, every valid cursor position, and every valid requested allocation size.
Regression tests cover:
Contiguous free ranges crossing the search cursor.
Prevention of invalid physical heap wraparound.
Allocation of an entirely free heap.
Exhaustive comparison against the reference allocator.
Potential relevance to descriptor exhaustion
This may be relevant to the descriptor allocation pressure discussed in #747.
Increasing heap capacity can alleviate genuine descriptor exhaustion, but it does not eliminate the algorithmic possibility of false exhaustion.
The proposed change addresses this specific search defect without increasing heap capacity or changing descriptor lifetime management.
Limitations
The issue is reproducible through static analysis and CPU-only algorithmic testing.
I have not established how frequently this condition occurs during GTA VI execution or whether it contributes significantly to the rendering failures reported in #747.
Full Rust compilation, integration testing, and GPU-side validation remain necessary.
Attachments
Proposed patch:
victory_descriptor_cursor.patchReproducible regression tests:
test_victory_descriptor_allocator.pyNo proprietary game files are required to reproduce the algorithmic defect.
Thank you for your work on this project.
</html>test_victory_descriptor_allocator.py
victory_descriptor_cursor.patch
@pushkarreddyy on GitHub · 2026-11-24 13:03 UTC · original
Claiming this issue.
Technical Analysis & Root Cause
In
crates/victory-gpu/src/descriptor/host.rs,HostHeap::dynamic(n)allocatesncontiguous dynamic descriptor slots by scanning from the search cursor*nextto the end of the heap, then wrapping around to scan0..*next:Because the second chained range abruptly stops at
*next, any contiguous free block that starts before the cursor (e.g., at*next - 1) and extends across the cursor into*next..*next + n - 1is truncated. Neither pass accumulates a run of lengthn, falsely reporting descriptor heap exhaustion ("no free dynamic descriptor slots: a table is not made").Proposed Fix
Extend the second search pass up to
cursor.saturating_add(n - 1).min(end):The existing discontinuity check (
at != last.wrapping_add(1)) guarantees that allocations never wrap across the physical heap boundary.Preparing a clean branch with regression tests and full Rust 2024 compliance.
@FunWithFlagsDev on GitHub · 2026-11-24 13:07 UTC · original
Thank you for implementing the fix and preparing the branch!
I reviewed commit
c1c3281, and the allocator change looks consistent with the proposed solution.However, I noticed a potential issue in the regression test setup:
HostHeap::new(false, 4)creates four title slots plus either 65,536 or 262,144 dynamic slots, rather than 16 dynamic slots.Some(20)rather thanSome(14).I suggest the following test setup to isolate the intended regression:
This fills the entire dynamic heap, positions the cursor at 12, and leaves slots 10–14 as the only available contiguous range.
I checked the algorithmic behavior for both supported dynamic heap capacities. The original implementation returns
None, while the corrected implementation returnsSome(14).Native Rust execution remains to be verified.
Thanks again for your contribution!
@Sunkiller-qc on GitHub · 2026-11-24 13:09 UTC · original
#251 (tcurtsinger, open since 01:50 UTC) fixes exactly this: free slots on both sides of the cursor, and a request that only fits across it fails on both passes. It applies the cursor to candidate start slots, so the second pass can extend past it. It comes with a regression test (a nine-slot request that failed on
d2a4bae). Testing or reviewing #251 would probably be the quickest way to get this in.@FunWithFlagsDev on GitHub · 2026-11-24 13:12 UTC · original
Thank you for pointing out #251. I missed the existing pull request during the initial duplicate check.
I reviewed tcurtsinger's implementation and independently evaluated its search algorithm using the exhaustive CPU-side model developed for this issue.
Across 169,978 combinations of heap occupancy, cursor position, and allocation size, covering heaps of 1–10 slots:
These results validate the algorithmic model, not native Rust execution or GPU behavior.
The additional fragmentation diagnostics in #251 are also valuable.
I agree that consolidating the work into #251 is preferable to maintaining another implementation. Thank you for the reference, and thanks to @pushkarreddyy for working on the proposed fix.
@MichaelSmithAI on GitHub · 2026-11-24 13:12 UTC · original
Confirmed on a real host heap. Melissa filled the dynamic region to capacity and released adjacent ranges around the cursor.
ffe310ereturned None for the four-slot request. The proposed search returned the expected host slot, 5. With one free slot at each physical end the two-slot request was still declined.I put the fixture directly on
c1c3281as a test-only follow-up. Both allocator tests passed there on RTX 4090 under Wine/vkd3d-proton 3.2. This confirms the allocator case; the fraction of in-game descriptor drops it explains remains unmeasured. Test PR@LAKSHYA-cmd-tech on GitHub · 2026-11-24 13:29 UTC · original
Implemented the proposed algorithm fix in https://github.com/LAKSHYA-cmd-tech/VIctory/pull/22, extending the second scan by up to
@pushkarreddyy on GitHub · 2026-11-24 14:13 UTC · original · edited 2026-11-24 14:21 UTC
Thanks @LAKSHYA-cmd-tech for integrating the algorithm into PR #22!
Our standalone branch fix/descriptor-cursor-range (commit c1be75f) has also incorporated the capacity fixture from @MichaelSmithAI (verified on RTX 4090 under Wine/vkd3d-proton 3.2). Ready for @Marvisak to merge.
@pushkarreddyy on GitHub · 2026-11-24 13:15 UTC · original · edited 2026-11-24 14:22 UTC
Thank you @MichaelSmithAI! Merged your test fixture into the branch on fork. The head commit is now c1be75f on branch fix/descriptor-cursor-range.
Compare: https://github.com/Marvisak/VIctory/compare/main...pushkarreddyy:VIctory:fix/descriptor-cursor-range
Ready for merge by @Marvisak @mercuryVM @LAKSHYA-cmd-tech.
@pushkarreddyy on GitHub · 2026-11-24 13:06 UTC · original · edited 2026-11-24 14:22 UTC
Verified Patch Ready on Fork
The implementation resolving false dynamic descriptor exhaustion is complete, verified, and available on my fork:
c1c3281based onmain(ffe310e)Changes (
crates/victory-gpu/src/descriptor/host.rs):Verification & Tests:
dynamic_allocation_finds_contiguous_range_crossing_search_cursor:10..14(length 4) while the cursor*nextis at 12.heap.dynamic(4)successfully discovers and allocates the contiguous blockSome(14), where the previous algorithm halted at cursor 12 and returnedNone.at != last.wrapping_add(1).cargo xtask policyclean, zero proprietary assets).rustfmt --edition 2024.ready for maintainer review or collaborator merge from the compare link above.
@pushkarreddyy on GitHub · 2026-11-24 14:37 UTC · original
Pull request is now open for review: #974.