Repository navigation
Conversation
Dukestar69
left a comment
There was a problem hiding this comment.
Verified on RTX 5090 against origin/main (63bcca4):
cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 14/14 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings&--features diagnostics: clean.cargo xtask policy: 191 files ok.
Cleanly splits heap-sync slot counts by outcome in the frame summary line.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
Windows 11,
Diagnostics-only change (the frame line splits a heap sync's slots by outcome), no test added. Synthetic only. AI-assisted. |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Two concrete counting bugs in HostHeap::mirror reproduce directly under --features diagnostics and break the stated counter breakdown:
-
Recursive retry double-counts
MirrorCalls, breaking the sum invariant (crates/victory-gpu/src/descriptor/host.rs:724,815):
copystat.rs:107-108documents that the outcome counters sum toMirrorCallson every pathHostHeap::mirrorcan take. However,MirrorCallsis incremented at entry (:724), and when a title thread overwrites the slot whileprepare(&view)runs without the lock, line815callsreturn self.mirror(index, handle, for_draw);, incrementingMirrorCallsagain without recording an outcome for the outer call.
Reproduced live via theWHILE_PREPARINGhook: a singleheap.mirror(...)call recordsd_calls = 2while the sum of all outcome counters (MirrorMade + MirrorDeferred + MirrorCurrent + MirrorNull + MirrorEmpty + MirrorPast) increments by1. Using aloopfor the retry (or an inner helper soMirrorCallsis incremented once per top-level call) keeps the invariant exact. -
Non-placed texture UAVs are misclassified as
MirrorBufferWrite, and placed buffers fall intoMirrorOther(crates/victory-gpu/src/descriptor/host.rs:850-860,1664-1679):is_texture(view)(:1664-1667) only checksis_placed_texture(view)andView::Shader(r, _)— unlikeprepare()(:1623), it does not checkView::Unordered(r, _, _)whentexture_memory(r).is_some(). As a result,buffer_write(view)(matches!(view, View::Unordered(..)) && !is_texture(view)) returnstruefor every non-placed texture UAV (RWTexture*), counting texture UAVs asMirrorBufferWriteinstead ofMirrorTexture. Reproduced live on RTX 5090: mirroring a texture created viacreate_uavincrementedMirrorTextureby0andMirrorBufferWriteby1.- Similarly, placed buffer views (
View::Placed(false/true, resource, _)withresource[0] == 1) match neitherView::Shader(..)norView::Unordered(..), so both placed buffer SRVs and UAVs fall through intoMirrorOtherinstead ofMirrorBufferRead/MirrorBufferWrite.
The frame line reports the time a heap sync takes and the slots it looks at, but not what it does with them. On the world's frames a sync looks at ~400,000-600,000 slots and mirrors ~160,000 of them; which of those get a view, which are already current and which name nothing decides whether a change to the sync can help — batching (#3139) only gains where many slots are unchanged — and today it can only be guessed.
This splits the clause. Measured line from a 300 s world run of the retail title on
main(63bcca4), diagnostics build:HostHeap::mirrorcounts what it does with a slot, on every path it can take:later), which creates nothing.prepare.The outcomes sum to the calls by construction (
made + deferred + current + nulled + empty + past == mirrors), which the two samples above show exactly: 64,340 + 828 + 74,847 + 21,877 = 161,892. That invariant is the property the first version of this change lacked, and it is why the counters are now reported against the mirror calls rather than against the sync's slot count:mirroralso runs from descriptor writes, table binding andmake_read, so only the call count is a valid denominator.What it shows
In this run 68% of the views made are "other" — constant buffers and memory views — not textures (already made lazily on their read marks) and not the per-page scan. That is the number to look at before changing the sync.
Cost and behaviour
No runtime change: the counters and the two predicates they use are
#[cfg(feature = "diagnostics")], and the enum's length is now asserted by construction (COUNTERSis the exact variant count, so a counter added without its slot fails to compile rather than reading past the array).Testing
cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warningscargo build --release -p victory --features diagnosticsNo game data is included in this PR.
Written with an AI assistant.