GPU: refresh table CBVs on fresh_tables cache hits #2848
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2850"
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?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:17:22Z.
Problem
In
State::tables(crates/victory-gpu/src/draw.rs:1299), when a descriptor table spills past the host descriptor heap cap (index >= host.count(), e.g., on NVIDIA/WARP clamping a 1.5M view heap to 934,464) and hits the per-listself.fresh_tablescache, the refresh loop skips constant buffers:Because table CBVs are mirrored as shadow-backed raw SRVs (
descriptor/host.rs) and rely onreadable(list, u, &view, true)(just asState::table_entryand fresh-table creation already do unconditionally), skippingResourceType::Cbvon afresh_tableshit leaves the host shadow buffer out of date in two cases within a command list:fresh_tables, a copy updates the CBV backing memory (clearingdeferred.refreshed), and Draw 2 hitsfresh_tables—skippingreadableleaves stale pre-copy data in the shadow buffer.Thas a CBV at slot 0 and an SRV at slot 1. Draw A uses only slot 1 (n = 2, hashing slots0..2into the cache key without callingreadableon slot 0). Draw B uses both slot 0 and slot 1, hits the same(table, hash)entry infresh_tables, skipsResourceType::Cbv, and never refreshes slot 0's shadow buffer (reading zeros).Fix
Call
readable(list, u, &view, true)for allentrieson afresh_tablescache hit (for u in entries). Unchanged ranges remain O(1) deduplicated bydeferred.refreshed.Verification
draw::tests::fresh_table_cache_hit_refreshes_cbv_after_copy_and_partial_first_usecovering both cases (fails onf3578e3before the 1-line fix:0x1111_1111vs0x2222_2222after copy,0vs0x3333_3333after partial first use).cargo test --locked -p victory-gpu --lib draw::tests -- --test-threads=1): 21/21 passed, no debug-layer errors.VICTORY_D3D12_WARP=1, default &--features diagnostics): 21/21 passed.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default &--features diagnostics): 0 warnings.cargo xtask policy: 190 files ok.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T22:50:52Z.
Review: COMMENTED
Correct: a fresh-table cache hit means the descriptors matched but the memory behind CBVs may have changed since first bind — skipping Cbv entries left stale constant data visible to the shader. Refreshing all entries on a hit is uniform and the test exercises the copy-then-partial-use path. LGTM.
Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-25T23:18:55Z.
Hardware result at head
6ae15a75, cherry-picked onto a fork stack, RTX 3080 Ti: the library tests pass with its new test; one 7-minute run in play without device removal, window scene median 675 ms a frame (688 in an earlier run without it, one run each).Ran with AI assistance (Claude Code).
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T00:00:14Z.
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
6ae15a7(on its basef3578e3).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 864 passed, 0 failed, 10 ignored.fresh_table_cache_hit_refreshes_cbv_after_copy_and_partial_first_use.--skipleaves out tests that fail on main842b0cbon this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:28:38Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):cargo test -p victory-gpu --lib draw::tests: 21 passed, 0 failed (including newfresh_table_cache_hit_refreshes_cbv_after_copy_and_partial_first_use).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T03:21:43Z.
Automated triage for the maintainers.
This is a one-line fix in
State::tables(crates/victory-gpu/src/draw.rs). On afresh_tablescache hit,mainrefreshes only non-CBV entries. When the table is made, the same function callsreadablefor every used entry, CBVs included, andreadablealready handlesView::Constantby refreshing its shadow range. Skipping CBVs on a hit therefore leaves a constant buffer stale after a copy in the same list, or never refreshed when an earlier draw used fewer slots of the same table. The PR drops the filter, anddeferred.refreshedstill avoids repeated refreshes. The new test covers both cases.Others' runs on an RTX 5070 Ti, an RTX 5090 and WARP pass. I found no other open PR doing the same.
Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.
Generated by Claude Code
upstream-sync referenced this pull request2026-11-26 06:03:33 +00:00
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.