GPU: mirror 256-byte aligned CBV tables in place without dynamic slots (fix on fork) #840
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#840
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?
@alessiodeia on GitHub · 2026-11-24 12:05 UTC · original
Fix ready on fork: alessiodeia/VIctory@1d21e06 (branch ix/reuse-aligned-cbv-tables, single commit on fe310e).
Problem
State::tables() (crates/victory-gpu/src/draw.rs) currently copies every descriptor table containing a ResourceType::Cbv into dynamic descriptor slots (and copies its constant data through list.scratch), even when every View::Constant in the table's span is already 256-byte aligned on the host and within host.count().
On capped shader-visible view heaps (1,000,000 views / MIN_DYNAMIC = 65,536 on NVIDIA), world frames record dozens of command lists in parallel before submission and exhaust all 65,536 dynamic slots - dropping 4,096+ draws/dispatches ( draw or dispatch dropped: no dynamic slots for its tables) even when finished lists' slots are reclaimed (#688).
Fix (1d21e06)
eadable():** refreshes the shadow range (shadow.refresh(list, address, size)) for View::Constant mirrored in place, keeping submission-time semantics while avoiding dynamic descriptor and scratch-buffer churn.
Verification
Windows 11 x64 (26300), Rust 1.98.1 (--locked), NVIDIA GeForce RTX 2070 SUPER (driver 617.42):
o dynamic slots for its tables drops went from 4,096+ to 0, with 0 constant buffer not 256-byte aligned warnings.
AI-assisted; no game files or assets attached.
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 12:55 UTC · original
I checked the padded-end case on
1d21e06. The original fixture uses offset4096 - 128, so it exercises the misalignment fallback. I moved it to offset4096in a4224-byte buffer and verified the host GPU address is aligned and exactly 128 bytes remain in its shadow.With that fixture, the fork still mirrors the tail in place. The padded
shadow::findcan return a different loose shadow, while creating the CBV looks up the unpadded range. The incremental patch uses the same shadow as CBV creation and checks the padded size against the bytes left in it.On Windows WARP, the aligned 256-byte control still used zero dynamic slots. The misaligned control and the aligned 128-byte tail each used the fallback. The diagnostics library suite passed 54 tests with one benchmark ignored.
AI-assisted. Verified with synthetic buffers.
Incremental patch on 1d21e06
@MichaelSmithAI on GitHub · 2026-11-24 12:56 UTC · original
Melissa verified the bytes seen by a compute shader after recording a dispatch and then changing the guest constant buffer before submission. On RTX 4090 under Wine/vkd3d-proton 3.2, successive dispatches through the aligned CBV read 17 and 29 with zero dynamic slots. The CBV at byte offset +16 read 43 using one dynamic slot.
One interaction with static table entries: when the shader metadata names slots 0 and 2 but slot 1 is also populated, the fresh-table path materializes slot 1. A preparation test on that layout selected zero fresh tables without the extra check and one after preserving the fresh path for the unnamed entry. The integration checks the entire span against its owning heap before scanning and incorporates the unpadded shadow lookup and aligned short-tail case already identified by andrewpozdnakov7-jpg.
On exact
eb1339c, the Win64 GPU suite had 51 passes, one ignored test and the existing Wine rejected-pipeline-library test failure. These synthetic tests verify submission-time contents and descriptor selection. Your 4,096+ to zero drop count remains the measurement from the title stack. Integration and regression tests@alessiodeia on GitHub · 2026-11-24 13:31 UTC · original
Thanks @andrewpozdnakov7-jpg and @MichaelSmithAI for the thorough reviews and hardware checks! Both edge cases are now fixed in
alessiodeia/VIctory@8fa463aonfix/reuse-aligned-cbv-tables:State::tables()now callsshadow::find(address, u64::from(size))(matchingmake()) and verifies boths.gpu(address).is_multiple_of(256)ands.left(address) >= u64::from(size).next_multiple_of(256). The tail-bounds unit test fixture now uses a 4224-byte buffer at aligned offset 4096 (size = 128) with explicit assertions ongpu(tail) % 256 == 0andleft(tail) == 128.0..nhost-heap bounds & unnamed populated slots (@MichaelSmithAI):State::tables()now checks that every slot in0..nfits inside the host heap (heap.index(handle).is_none_or(|i| i >= host.count())) and falls back to dynamic slots if any populated slot in0..nis not named inused, preserving dynamically-indexed descriptor-array entries. Added a unit test covering a sparse table (slots 0 and 2 named, slot 1 populated and unnamed) confirming dynamic-slot fallback.Verified locally on Windows:
cargo test -p victory-gpu --locked --offline -- --test-threads=1: 51 passed, 0 failedcargo clippy -p victory-gpu --all-targets -- -D warnings(default &--features diagnostics): cleancargo --offline xtask policy: 154 files ok@andrewpozdnakov7-jpg on GitHub · 2026-11-24 13:45 UTC · original
Thanks @MichaelSmithAI for including the aligned short-tail fix and regression in the integration. Commit
eb1339cCould you retain this Git trailer when carrying that contribution forward?
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>@alessiodeia on GitHub · 2026-11-24 16:57 UTC · original
@andrewpozdnakov7-jpg your shadow-lookup and padded-end fix is in our tip commit too, so I've added your trailer there:
fix/reuse-aligned-cbv-tablesis nowe5e227d. It's the same tree as8fa463a; only the commit message changed (Co-authored-by: andrewpozdnakov7-jpg <[email protected]>). Anyone who merged8fa463ahas identical code.@Marvisak on GitHub · 2026-11-25 03:54 UTC · original
Automated triage for the maintainers.
The behaviour this patch changes is no longer on
main. Since commit683ad7a("table constants read in place"),State::tablesincrates/victory-gpu/src/draw.rsno longer sends every table that holds a constant buffer to dynamic slots. Table constant buffers are now raw views of their data, refreshed at submission, and a table gets dynamic slots only when it reaches past a capped host heap (index >= host.count()). The fork branch (e5e227d, based onffe310e) targets the old code path.If you still see
no dynamic slots for its tablesdrops on currentmain, please post a new run report with the counts. The reclaiming of finished lists' slots is open as #688. Proposed for closing as fixed inmain; this will be closed in 48 hours unless the reporter replies or a maintainer removes the label.Generated by Claude Code
@alessiodeia on GitHub · 2026-11-25 09:40 UTC · original
Agreed. On
mainthe path this patch changed is gone: since683ad7a, table constant buffers are raw views refreshed at submission, and only tables past a capped host heap get dynamic slots. Thee5e227dbranch targets the old code, so I'm closing this as fixed inmain. Ifno dynamic slots for its tablesdrops come back on currentmain, I'll open a new report with counts.