vkback: shift clear_compressed by Img::base and clear BC prefixes via copy #192
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!192
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-192"
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 07:00 UTC · original
Mhyster:fix/tex-bc-clear-base-level→main· +122 −32 · 2 files · 1 commits · openWhat
Fixes two Vulkan validation and out-of-bounds copy bugs when clearing streamed block-compressed (BC) textures:
clear_compressedmip extents byImg::base(fill.rsclear_compressed/clear_compressed_regions,imgmake.rsmake_image): when a streamed 2D placed texture is created from console levelbase > 0, the Vulkan image's level 0 has dimensions(width >> base, height >> base). Previously,clear_compressedcomputed(desc.width >> m, desc.height >> m)without addingbase, recordingvkCmdCopyBufferToImageextents 2^base× larger than the image (VUID-vkCmdCopyBufferToImage-imageExtent-00207, out-of-bounds GPU write on unfilled streamed BC textures). Nowclear_compressed_regionsshifts bybase + m(with overflow-safechecked_shr) and skips empty region lists.clear_compressed(orcmd_clear_depth_stencil_image) forfrom > img.baseprefix clears inupload(fill.rsupload): whenhold_fromkeeps levels starting atfrom > img.base(which happens on streamed BC textures wheneverwidth >> fromorheight >> fromis not block-aligned, sobase_levelstepsimg.basedown belowfrom),uploadpreviously calledvkCmdClearColorImageon a compressed image (VUID-vkCmdClearColorImage-image-00007). It now callsclear_compressedfor BC formats andcmd_clear_depth_stencil_imagefor depth formats.Reproduces console texture streaming without corrupting or issuing invalid clears on compressed mip chains.
The reference
crates/victory-gpu/src/resource.rs(base_level,placed_bytes_from): the D3D12 path creates reduced-base textures starting at a block-aligned level (base_level) and uploads fromread_fromonward (texture.rs), leaving unheld levels clear; D3D12 has novkCmdClearColorImagecompressed-format restriction (Vulkan specVUID-vkCmdClearColorImage-image-00007andVUID-vkCmdCopyBufferToImage-imageExtent-00207).Evidence
greenfield/vkback/src/fill.rs(clear_compressed_regions_shifts_extents_by_base_and_fits_zero_buffer): verifiesbase = 8on a 2048×1024 BC7 texture yields image mips[(0, 8, 4), (1, 4, 2), (2, 2, 1), (3, 1, 1)], prefix clear (from = 9, base = 8) yields only(0, 8, 4), empty mip count yields no regions, and 8192×8192 BC7 splits into 4-row-aligned bands each<= ZERO_BYTES.cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked)(169 passed, 3 ignored; 6/6 policy tests)cargo clippy --all-targets --locked -- -D warningson root native crates,greenfield,greenfield/wine, andgreenfield/vkback/translate.frames.py) could not be run in this session (no live game run performed);cargo xwin clippyruns in GitHub Actions CI.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited, the fixed 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)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.