Descriptors: a slot flipped ahead waits for the submissions begun when it was queued (#545) #636
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/Belobug--VIctory-Belobug-AMD!636
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-636"
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?
@MamaLeVrai on GitHub · 2026-11-27 15:37 UTC · original
MamaLeVrai:desc-fix→a-publier· +326 −19 · 3 files · 4 commits · openUpdate (
1fb4f9f): @ANDREANIADS showed the first version (74b6c8e, which captured a submission number) was only partial: a submission begun after the number was captured can still read the neutral descriptor when the flip is applied. A captured number can't fix that, so the rule is now checked at apply time.Host::when_at_resttakes the submission lock (try_lock) and applies a flip only if every submission begun has finished (STARTEDmoves only insidesubmit, under that lock, so nothing can begin while the slot is written).Flip.afteris gone. A guaranteed rest point:Host::submitapplies held flips before it begins a submission (in the default non-late mode each submission settles the previous one, so it is at rest); on the late/relay path only the 1.5 s sweep rests, so a flip waiting more than 250 ms (FLIP_SETTLE_MS) makes the sweep settle sooner.show_new_laterflips use the same rule.Tests (RX 6950 XT): the original test and ANDREANIADS's
a_slot_flip_waits_for_a_reader_submitted_after_it_was_queuedshare one body. With the rest check removed (Some(f())) both fail withleft: [4, 4], right: [1, 1]; with it both pass (0 failures in 30 parallel runs). Full suite: 398 passed, 0 failed, 34 ignored in one run; the failures I saw in other runs were all the knownwatch::tests::*flake (#450). The ignoreddescriptors_written_under_readers,new_blocks_under_readersandtextures_read_in_another_dimensionpass.Only an in-game run can show: whether the 250 ms forced settle (a GPU drain, about 4 a second at most and only while a slot waits) is acceptable with the relay and present-ahead; that
flip_heldfires at each submission (it needs a registered title heap, which a test heap is not); and lock contention (the texture pass usestry_lock, so it skips the flip while a submission is preparing, and the next submission's rest point applies it). Not fixed:texture_views_remade(RESHOWN_AFTER) rewrites slots in place with the same "begun when queued" number and has the same hole; it should be treated the same way separately.Part of #545 (the other part is not fixed here, see below).
What
With flights in the air (
VICTORY_RELAY=2, the default),texture_slot_show_aheadqueued its flip withafter: 0. When the upload-ahead job ran, the slot was rewritten from the neutral texture to the real one at once, while lists already sent still read that slot by index, recorded against the neutral texture. D3D12 lets a table's descriptors change only until the list executes, not while it is in the air, even forDESCRIPTORS_VOLATILEtables.Now
queue_flip_ahead(descriptor/host.rs) takesafteras the newest submission begun at the moment the job completes (crate::host::submissions().0).texture_slots_flipalready flips only whenafter <= finished, and that runs on every draw pass and when an upload finishes. With nothing in the air the slot flips at once, as before. With flights in the air it flips once they have landed, a few frames later. The non-aheadflipandshow_new_lateralready used the submission count, so only this path was missing the wait.test_begin_submission/test_finish_submission(host.rs) and a helper inresource.rsare#[cfg(test)]only.Test
descriptor::host::tests::a_slot_flipped_ahead_changes_under_a_list_in_the_air(from #545, no longer ignored): a compute list reads the slot through a volatile table and is held on the card behind a fence; the flip is queued astexture_slot_show_aheadqueues it. It asserts the list reads[1, 1], the slot is not flipped while that submission is unfinished, and it flips after it finished. On an RX 6950 XT (RDNA 2):after = 0(the old code): FAILED,left: [4, 4], right: [1, 1] (slot flipped while it was in the air: true);cargo test --release -p victory-gpu --lib: 397 passed, 0 failed, 34 ignored (one earlier run had awatch::testsflake, which #450 fixes). The ignored GPU testsdescriptors_written_under_readers(VICTORY_BENCH_S=5),new_blocks_under_readersandtextures_read_in_another_dimensionpass.Not done
show_later's write of the neutral texture is left immediate. Most of the time it replaces a null slot with the neutral one (placeholder to placeholder), and delaying it would leave newer lists reading a black null slot, which is the black-line symptom. When it replaces a different real texture, keeping the old one is theVICTORY_KEEP_SHOWN=2behaviour that is deliberately off by default, and an incompatible old view would give the shader a mismatched view dimension.VICTORY_RELAY=2; how late textures appear (crate::texlateand the "slots shown after their upload" line report it); and whether a slot can stay grey when no draw pass runs after the flights land. I judged that harmless, since only drawn slots matter.AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
descriptor::host::tests::a_slot_flipped_ahead_changes_under_a_list_in_the_air (ignored: fails until flips wait for lists in the air). A slot shows the neutral texture (1x1) while its own upload runs ahead; a list reading it is submitted and held on the card behind a fence; the flip that texture_slot_show_ahead queues (Flip { after: 0 }) is made by texture_slots_flip; the list then runs and reads 4x4: the new texture, the slot rewritten while the list was submitted and not finished. The table is DESCRIPTORS_VOLATILE, which allows changes only until the list executes. resource::title_texture_for_test makes a title texture for such tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>texture_slot_show_ahead queued Flip { after: 0 }: the slot was made from its new texture the moment the upload ahead of the lists had run, while submissions sent before (up to 256 lists with the relay) were still in the air and read the slot by index, recorded against the neutral texture. D3D12 allows a table's descriptors to change only until the list executes, not while it does. The flip now carries after = the newest submission begun when it is queued (queue_flip_ahead) and texture_slots_flip makes it only once that has finished (every pass of the texture queue and the end of an upload look). No list sent before the flip finds the slot changed; a texture is shown a few frames later while flights are in the air, at once when none is. The test a_slot_flipped_ahead_changes_under_a_list_in_the_air is no longer ignored: it stands a begun submission for its list in the air, queues the flip as the code does, and checks that the list reads the neutral 1x1 and that the slot is shown once the submission has finished (it reads 4x4 with after = 0). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 15:37 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@ANDREANIADS on GitHub · 2026-11-27 16:20 UTC · original
I reproduced the original test on an RTX 3070 (driver 621.40, Windows, Rust 1.98.1): it passes at
74b6c8e. Extending your fixture with a second submitted reader exposes a remaining in-flight rewrite:queue_flip_aheadsnapshots A's submission number.texture_slots_flipnow accepts A'saftervalue and rewrites the descriptor.[4, 4]rather than the neutral[1, 1];flipped_under_lateris true. Device removal was not reported.The extended test failed identically in three consecutive runs. It uses a separate command list/allocator for B and releases its fence before the final assertion.
Reproduction commit, directly on top of this PR:
github.com/ANDREANIADS/VIctory-Belobug-AMD@d3fadcc31dThis is an intentionally failing regression fixture, not a proposed fix. The original fixture and implementation are MamaLeVrai's; my contribution is the later-reader extension and NVIDIA validation. A captured submission number protects earlier readers, but does not itself exclude newer readers of the same slot. I have not tested gameplay or established a complete descriptor-generation solution.
AI-assisted with Codex.
@MamaLeVrai on GitHub · 2026-11-27 16:29 UTC · original
Thanks @ANDREANIADS, you are right, and I reproduced your test on an RX 6950 XT (RDNA 2):
a_slot_flip_waits_for_a_reader_submitted_after_it_was_queuedfails at74b6c8ewithleft: [4, 4], right: [1, 1](flipped under it: true). A capturedafterprotects the lists already sent when the flip is queued; a list sent after that, recorded against the neutral descriptor, can still be in the air when the flip is applied. So this PR is a partial fix: the original case is covered, yours is not, and I won't call it done.I have started on a version that also covers later readers and will run both tests against it (and check that slots can't starve under continuous submissions). I'll push it here only if both pass and I can explain why it is correct. If you already have a direction in mind, I'd be glad to hear it.
AI-assisted (Claude Code); no game data.
@adrianmjim on GitHub · 2026-11-27 16:29 UTC · original
Since you are reworking it, here are the test results from RDNA 3 and three points from reading
74b6c8e. Points 1 and 2 are cases the next version should also cover; point 3 is about the test.Tested on an RX 7900 XT (RDNA 3), Windows 11 26300, test profile, at
74b6c8eand atc8e93aa(the test alone, ona-publier4eb6cfd).The flip test, run on its own with
--exact --test-threads=1c8e93aa, test only, run with--ignored[4, 4]instead of[1, 1]74b6c8e, with the fixOther tests at
74b6c8edescriptor::run serially: 47 passed, 0 failed.victory-gpulib run in parallel (plaincargo test -p victory-gpu --lib), 3 times:descriptor/host.rs:6222,shown once nothing reads the slot, with leftSome(0)and rightSome(4294967300). That is the counter race in point 3 below.Not run here: a game pass with the default relay. That is running on this card now. I will add it, though it is for
74b6c8e.Reading the code (
74b6c8eagainst4eb6cfd; this part was read, not run)The fix does what its test checks. A slot flipped through
queue_flip_aheadnow waits untilFINISHED >= after. Withafter: 0the test reads[4, 4]and theassert_nefails too.Besides @ANDREANIADS's later-reader case, three things for the next version. Both
VICTORY_SHOW_AFTERandVICTORY_UPLOAD_AHEADare off by default, butscripts/play.ps1turns them on outside-Safe, so this path runs in normal play.The list that shows the neutral is not always covered.
afteris read when the ahead copy finishes:Job::thenon the upload worker,ahead.rs:319-321→descriptor/host.rs:530. It is not read when the list that wrote the neutral (show_later, from the texture pass atdraw.rs:2648) is begun.STARTEDonly goes up athost.rs:5808. So if the copy finishes while that list (L0) is still being recorded, or is waiting in the submit line,after = Nand L0 later becomes N+1. If an earlier submission is still in flight then, the nexttexture_slots_fliporflip_nowafterFINISHED >= Nrewrites the slot while L0 runs. That is the #545 case again.flip()doesn't have this: it readsafterinlist.defer_host, which runs afterSTARTED.fetch_add(host.rs:5890).queue::queued(), asretire()does (host.rs:590-592), would not cover a list still being recorded.afterat the asking list's submission would. For example, pass the list totexture_slot_show_aheadand take the max of that and the job's value.after(~6190-6197), so it can't catch this order.afterwas read. This one is narrower: it is the list that wrote the neutral and asked for the flip.Paths that mirror the slot during the wait skip it. While the flip waits, the slot has
made = 0andahead::there()is already true. Anything that mirrors it then writes the real texture at once:mirror(draw.rs:3391) ormirror_after(draw.rs:3611,3662→descriptor/host.rs:2411-2424);samebranch →at_once()(draw.rs:2612-2625);show_new_lateronly defers toSTARTEDwhen the host texture was made, which is no later than the flip'safter. So lists recorded against the neutral can still be in flight. This existed before, but the window was one frame; now it lasts untilafterlands. One option: while aFlipwaits for (heap, index, key), haveat_once,mirror_afterandmirrordefer to it.The test can fail when tests run in parallel.
STARTEDandFINISHEDare process-wide.test_begin_submissionbumpsSTARTEDoutside thesubmittedlock, and every real submission ends with a plainFINISHED.store(this_submission)(host.rs:6108, also5200,5663). In a plaincargo test, which CI's test-default job runs without--test-threads=1, another test'shost.executethat starts and finishes during this test's GPU wait lets the flip through early, so theassert_neat6219fails. Less likely: it reads[4, 4], or an older store lowersFINISHEDbefore the finalassert_eq. A shared lock for tests that submit, orfetch_maxon the sync path, would close it. Small:Finish(sent)could be made right aftertest_begin_submission, before theunwrap()s.Nit: in
resource.rs:2924the newtitle_texture_for_testwent in between/// Device method 0x3f8, inferred from the title's callsand the rest ofcreate_committed3's doc, so that first line now documents the helper.@MamaLeVrai on GitHub · 2026-11-27 17:00 UTC · original
Pushed
1fb4f9f, which covers @ANDREANIADS's later reader. The first version captured a submission number; any number leaves a later reader exposed, so the rule is now checked when the flip is applied: only with every submission begun already finished, under the submission lock, so nothing can begin during the write. The details and the open points are at the top of the description.On an RX 6950 XT, both the original test and the later-reader test fail with
[4, 4]when the rest check is removed and pass with it (0 failures in 30 parallel runs). The part I cannot show without a game run is the cost of the 250 ms forced settle on the relay path. @rpmaster2, @adrianmjim, @ANDREANIADS: an in-game run of this head against your base is what would settle it.AI-assisted (Claude Code); no game data.
@ANDREANIADS on GitHub · 2026-11-27 17:08 UTC · original
Retested
1fb4f9fon Windows with an NVIDIA GeForce RTX 3070 (driver 621.40, Rust 1.98.1). Both fence-based regressions passed on the unchanged checkout. I then added a local test-only assertion that requires a D3D12 device and heap and checks the actual adapter via its DXGI LUID, so a skipped test or fallback adapter cannot look like a pass. With that guard, both tests passed in 11 serial runs (22/22). The completevictory-gpulib suite also passed three times with default parallelism: 398 passed, 0 failed, 34 ignored each time. I did not reproduce the earlier parallel failure on this head.This independently verifies the original and later-reader cases on NVIDIA. I did not run the title; the relay/present-ahead frame-time cost of the 250 ms forced settle is still unmeasured here. This result does not cover
texture_views_remade/RESHOWN_AFTER.AI-assisted with Codex.
@ANDREANIADS on GitHub · 2026-11-27 17:18 UTC · original
I followed up on the deferred
texture_views_remadepath called out in the updated description. Candidate on top of1fb4f9f:github.com/ANDREANIADS/VIctory-Belobug-AMD@2614eb7c99The post-upload remake stays queued until the GPU is idle under the existing submission lock; lock contention leaves it pending. On the relay/present-ahead path it shares the existing overdue-flip settle, rather than introducing a second wait mechanism. The direct
levels_changedpath is unchanged.Windows / RTX 3070 (621.40), Rust 1.98.1: 40 descriptor-host tests passed serially; full
victory-gpulibrary suite: 399 passed, 0 failed, 34 ignored; Clippy passed with warnings denied. The new test covers pending-queue retention and drain at rest. I have no gameplay or frame-time measurement for this candidate, so I left it on a separate branch instead of opening a stacked upstream PR.AI-assisted with Codex.
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.