GPU: hold SHADER_HEAPS while a shader-visible heap is used (port of upstream 628b95d) #668
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!668
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-668"
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?
@coderanonymus on GitHub · 2026-11-25 04:16 UTC · original
coderanonymus:shader-heaps-lock→main· +100 −22 · 5 files · 2 commits · openPort of upstream
628b95d(by Manuel Pérez). It is stacked on #642, which fixes the clippy failure onmain.I left this commit out of #653 because it doesn't build on the fork as it stands. It merges cleanly with #653.
Why
shader_slot()takes theSHADER_HEAPSlock, finds the heap and returns&Heapafter the lock is released. A title that releases a descriptor heap on one thread while another writes a descriptor can therefore haveHeap::dropfree the heap while it is still being read.The fork has a second caller with the same window.
make_waiting()reads the slot (view(handle)) and makes the host view from a heap it no longer holds. The fork's own comment there notes the handle is "read only while its heap is there", but nothing kept the heap there.What
mirror()keepsSHADER_HEAPSlocked for its whole run.copy_simple()returns on an invalid heap kind.create_heaprefuses a placed heap whose address + size wraps.resolve_querieschecksoffset + count * bytesfor overflow, with a test (resolve_queries_rejects_overflowing_offset).make_waiting()finds the heap the same way and keepsSHADER_HEAPSheld while it reads the slot and callsHostHeap::mirror(.., true).shader_slot()is gone.Review
Ultracode-reviewed: three independent read-only reviewers traced the fork's code.
HostHeap::mirrorfor bothfor_drawvalues,wait_for,host_copy, host texture creation andretire. Nothing takesSHADER_HEAPSagain, records a descriptor, or drops a heap.SHADER_HEAPSis taken:submitted,RELEASING, a queue's held lock,list.state. Locks taken under it:pending,made,VIEWS,WAITING,MADE_LATE, resource, shadow and card locks. No path takes the two sets in the opposite order, so the order is acyclic.copy_simple's old behaviour, and the new test needs no host device.The cost is wait time, not deadlock. Descriptor writes on other threads can now wait while a slot's host view is made, which can create a host texture. That's a short wait per slot. The first
Heap::host()on a heap replays its queued writes while holdingpending, so writes to any heap wait once per heap at startup.Verification
cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features, forx86_64-pc-windows-msvc(cross-checked from Linux): clean.No game data used.
🤖 Generated with Claude Code
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 04:16 UTC · original
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.90ecea5ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 04:16 UTC · original
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.