vkback: pre-decode placed texture shapes and shrink placed_ids key to 12 bytes #176
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!176
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-176"
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-02 00:13 UTC · original
Mhyster:opt/predecode-placed-textures→main· +251 −28 · 4 files · 1 commits · openWhat
Pre-decodes placed texture shapes once per
Call::ViewShapeand replaces 64-byte(u64, [u32; 14])SipHashplaced_idslookups with lossless 12-byte(u64, u32)FxMaplookups:PlacedShape(greenfield/frame/src/views.rs):key_words(words[1]and[13]zeroed, matchingvictory-gpu'swithout_filler),ResourceDesc::from_words,first_mip(victory-gpu'sresource::first_mip), andfilled(flags & 7 == 0) once when a shape arrives inViewTable::apply(Call::ViewShape) orViewTable::parse.meta: Option<&PlacedShape>onViewRef::Placed(populated only for real shapes,Nonefor gap fillers and table-entryView::Placed), keepingPartialEqsemantics identical toView::as_ref().PlacedIdTable(greenfield/vkback/src/placed.rs,slotwrite.rs,lib.rs):[u32; 14]to a unique monotonicu32ID (desc_ids: FxMap<[u32; 14], u32>, never a lossy hash), cachesshape_index -> desc_idin O(1) (Vec<Option<u32>>), and keysidsby 12-byte(address: u64, desc_id: u32)inFxMap.placed_keysfromHashMaptoFxMap.FxMapoperations on the renderer thread — no file access, locks, or blocking (rule 11).The reference
crates/victory-gpu:descriptor/views.rs(ViewTable::shapes.push, line 165): shapes are append-only and immutable per shape number, which guaranteesshape_to_desc[shape_index]never goes stale once populated for a validViewShape.resource.rs(without_filler,first_mip): stack-filler words[1]and[13]are zeroed so two views of the same texture differing only in filler map to one texture ID;first_mipapplies to shader views of 2D textures (dimension == 4) only.ViewTable::shapescarryvalid = false(meta = None), falling back cleanly to on-demand stripping/decoding;View::Placedtable entries share the samedesc_idsinterner so both paths resolve identical(address, key_words)to the exact same texture ID.Evidence
placed::tests::placed_id_table_never_aliases_distinct_textures):PlacedIdTabledirectly (rule 27): verifies filler words[1]and[13]normalize to the same ID across indexed (Some(shape)) and unindexed (None) paths; verifies 64 distinct addresses with identical descriptions produce 64 distinct IDs; verifies flipping every single bit of all 12 non-filler words (12 × 32 = 384mutations) at the same address produces 384 strictly unique IDs; verifiesremovedeletes only the superseded texture and issues a fresh monotonic ID on re-insert.frame::views::tests::placed_shape_predecodes_filler_desc_mip_and_gap_validity):meta == Nonewhile valid shapes matchResourceDesc::from_words,without_filler,first_mip, andfilledbit-for-bit.cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked(all passed).(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked)(14frame, 22umem, 169vkback, 6policypassed;lib.rsshrank by 2 lines).--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/{frame,vkback}).Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited (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 15:28 UTC · original
Thanks, the 12-byte
(addr, desc_id)key and pre-decoded shapes look correct. Three things before it can merge:first_mip/filled/ the filler strip now live in two places,PlacedShape::from_shapeand the fallback in slotwrite. Please put them in one helper (rule 33).shape_to_desccache assumes a shape number is never redefined. The PE side is append-only today, butViewTable::applyaccepts an overwrite silently. Please make overwriting a valid shape fail loudly (rules 6/9).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.