GPU: constant buffer views at most 64 KiB (NVIDIA removed the device for a larger one) #911
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!911
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-911"
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?
@douline on GitHub · 2026-11-25 12:28 UTC · original
douline:fix/cbv-64k→main· +29 −2 · 1 files · 1 commits · openWhat
CreateConstantBufferViewis called with sizes over 64 KiB: the title names constant buffer views of more than 4,096 vectors (the one we caught: 1,306,368 bytes, in the world, minutes after entering it). D3D12 takes at mostD3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT× 16 = 65,536 bytes; on NVIDIA the call is invalid and the device is removed on the spot withDXGI_ERROR_INVALID_CALL(0x887A0001).Both places that make constant views (
makeforView::Constant, andHostHeap::constant_at) now cap the size at 64 KiB (constant_view_size). A shader cannot read more than 4,096 vectors through a constant view, so nothing it can read is lost. Logged once when it happens.How it was found
RTX 5070 Ti, release build, world entry with
VICTORY_LATE_WAIT=3: the device was removed every 5-20 minutes, always detected in the heap-views pass ("the host device went while buffer views of the heap were made"), without the debug layer able to catch it (diagnostics builds were too slow to reach it). A local check ofGetDeviceRemovedReasonright before and after each view/resource creation named the call:View::Constant(…, 1306368).Measured
Same machine and settings, after the fix: 30 minutes in the world without a device loss (it could not get past 5-20 before), 2.5 frames a second steady; then 50 minutes in a diagnostics build with the D3D12 debug layer and DRED on: no removal, no debug-layer error.
cargo test -p victory-gpu --lib constant_views: passes (new testconstant_views_are_at_most_64_kib).AI-assisted (Claude).
@avt0m4t48 on GitHub · 2026-11-25 12:50 UTC · original
One boundary case in
constant_view_size: round after capping the input. I ran the exact helper on an authoredu32::MAXsize with Rust 1.98.1. The checked build overflows innext_multiple_ofand the optimized build returns zero. A 64 KiB pre-cap gives 65,536 in both cases. Moving the existing warning and early return ahead of the alignment also preserves the warning for every oversized request.#104 covers the adjacent staging path: it applies the cap before sizing the scratch allocation and deferred copy, so the unused tail never reaches
constant_at.AI-assisted source review and synthetic helper test.
@ArturoWolff on GitHub · 2026-11-25 12:56 UTC · original
One follow-up for memory pressure, separate from the invalid D3D12 call this fixes and the staging cap in #104. On
1087538,make(View::Constant)still passes the originalsizetoshadow::findbefore cappingSizeInBytes. If no registered buffer covers the full ask,lookupfalls back toloose, where the ask determines the window key.I ran the branch's
window_ofunchanged on Linux with the 1,306,368-byte size reported above and the default 4 MiB grid. At synthetic address0x1003e0000, the original ask selects an 8 MiB window; the 65,536-byte prefix selects a 4 MiB window. Control at0x100000000: both select 4 MiB. This is a window-selection result, not a measured allocation or a Linux device-loss reproduction. The title address and backing of the reported CBV are unknown.I'd treat that as a separate optimization, not a blocker for the descriptor fix. If narrowing the shadow lookup, check that descriptor creation and any later refresh resolve the same backing, particularly when only the capped prefix fits a registered buffer. The boundary case above would make a small regression fixture.
AI disclosure: Hermes Agent traced the lookup and ran the CPU fixture on ArturoWolff's behalf.
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.