vkback: co-locate SlotMasks dirty bits into SlotFlags #172
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/vktory6--VKtory!172
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-172"
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?
@Mhyster on GitHub · 2026-12-01 23:51 UTC · original
Mhyster:opt/colocate-slot-masks→main· +154 −164 · 3 files · 1 commits · openWhat
Co-locates
SlotMasks's 9-bit per-slot dirty descriptor-binding mask (bits0..=8, bindings0..=6plus raw-twin bindings4/5) withSlotFlags's 4-bit per-slot flags (FLAG_HOOK | FLAG_BUFFER | FLAG_IMAGE | FLAG_RETRY, bits9..=12) into a singleBox<[u16]>insideSlotFlags(greenfield/vkback/src/slotcache.rs):SlotFlags::nibbles1 MiB +Aside::dirty4 MiB = 5 MiB) to one contiguous 4 MiB array (32 slots per 64-byte cache line), sowrite_null_slot_with_stride,queue_desc, andrun_jobhit one cache line instead of two.SlotMasksfromRefCell<Aside>:queue_desc,run_job, andaside_null_slotread/update dirty bits directly onself.slot_flagswith zeroRefCellborrow.aside_null_slotnulls an already-clean slot withstride_entry == None, it returns immediately without borrowingself.asideat all.DIRTY_ALL(0x1ff) fallback forindex >= RAW_TWIN.The reference
crates/victory-gpu/src/descriptor/host.rs(HostHeap::make_at/null_for) writes a single D3D12 descriptor per slot;vkbackfans each console slot across 9 Vulkan descriptor-buffer bindings (0..=6atindex, plus raw twins4/5atindex + RAW_TWIN).null_fillinitializes all 9 bindings tonull_blobs[b], anduse_direct_descriptorscopiesdbuf0byte-for-byte, so initial mask0matchesdbuf0.queue_desc(SlotFlags::mark_desc) orrun_job(SlotFlags::mark_dirtywithBufJob::write_mask).aside_null_slot(SlotFlags::take_dirty) whenJob::Nullis queued for all dirty bits, or inrun_job(SlotFlags::clear_dirty) when a synchronousBufJobfails (Located::Uncommitted/Located::Short) and nullsnull_mask.index >= RAW_TWINconservatively returnsDIRTY_ALL;queue_writecontinues to report any write todbuf0bypassingqueue_descand descriptor jobs.Evidence
cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked(all passed, includingxtaskasset policy).(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked)(13frame, 22umem, 168vkback, 6policypassed; includes newslot_flags_dirty_masks_and_twins_preserve_flagsand updatedcollect_null_and_stride_writes_fuse_or_skip_empty).--locked -- -D warnings: native root crates,greenfield,greenfield/wine, andgreenfield/vkback/translateall clean.VKB_LAT+greenfield/tools/frec/frames.py).VK_LAYER_KHRONOS_validation).cargo xwin clippy(CI will verify; this change touches onlygreenfield/vkback/src/{slotcache,descjob,lib}.rs).Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited, the related item named above (rule 29)unsafeblock has a// SAFETY:comment; no raw pointer around the borrow checker (rule 36)TRANSLATOR_VERSIONbumped if the translator's output changes (rule 27)@vktory6 on GitHub · 2026-12-02 19:45 UTC · original
Thanks. I read it against
HostHeap::make_at/null_for. Your invalidation summary matches the code: marks inqueue_desc/run_job, clears only inaside_null_slotand on a failed synchronous job,DIRTY_ALLat and pastRAW_TWIN. One array instead of two, with noRefCellborrow on the clean path, is the cleaner layout.Two things are missing before a merge, and both need the card you have (the RX 9070 XT is our reference card too):
START=boat, cutscenes not skipped, about 140 world s,VKB_LAT+frames.py), with renderer CPU per frame and fps for each arm. If it shows no gain, the rule-24 questions decide keep or drop on purpose. Fewer allocations and no borrow would most likely count as "keep" then.VK_LAYER_KHRONOS_validation, with the distinct errors listed.Overlap: the "Descriptor heap as one array" task (#57) will change this mask again, from 9 bits to 3. That is no reason to hold this one; whichever lands second adapts.
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.