vkback: reuse retired streaming images and cache format properties #190
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!190
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-190"
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 06:33 UTC · original
Mhyster:opt/imgmake-reuse-pool→main· +337 −31 · 5 files · 1 commits · openWhat
Overlap with open PRs:
#168and#178edit 5 lines ofgreenfield/vkback/src/imgmake.rs(inmake_linear_in_placeexternal-memory setup);#144/#147/#152do not touchimgmake.rsorimgview.rs.Addresses
docs/TASKS.md("Placed image creation in the streaming phase": "reuse images of the same description and size instead of creating new ones"):ImgPoolingreenfield/vkback/src/imgmake.rs):retire()completes retired arena-backed streaming textures (self.live,i.mem == vk::DeviceMemory::null(),arena_of.contains_key(&i.image),!i.depth,desc.flags & 7 == 0, GPU timeline serial passed, all views destroyed,shown == 0), parks them in a bounded pool keyed by exactImgReuseKey(ty,fmt,extent,mips,layers,samples,usage,flags,gtt) instead of callingvkDestroyImage+arena.freeimmediately.MAX_POOL_IMAGES = 128,MAX_POOL_BYTES = 32 MiB,MAX_ENTRY_BYTES = 8 MiB), with FIFO eviction of oldest entries when full.make_image, reuses the already-bound, already-GENERALvk::Imagedirectly — skippingvkCreateImage,vkGetImageMemoryRequirements,arena.alloc,vkBindImageMemory, and theUNDEFINED -> GENERALlayout transition barrier — while keepingself.arena.made(img.image, self.serial)(hold_new) andself.upload(id, &img, key)intact.arena_ofandlife(soover_line()accounts for their bytes), and are drained immediately by heap wheneverarena_memorywould otherwise wait or grow a new block (Arena::can_fit_ready), wheneverresidency::let_go_fromruns under memory pressure, and onDrop for VulkanBackend.ImgCache::fmt_props&linear_ext_ok):vkGetPhysicalDeviceFormatPropertiespervk::Formatacrossimgmake.rs(make_image,make_linear_in_place) andimgview.rs(view_for), and cachesvkGetPhysicalDeviceImageFormatProperties2external-handle support per(vk::Format, uav)inmake_linear_in_place.VulkanBackend::retire_passed_imagesinimgmake.rs(shrinkinglib.rsby 12 lines).The reference
No direct vkd3d-proton counterpart (D3D12 placed textures alias heap memory directly;
vkbackcreates optimalvk::Imagecopies per placed streaming texture inimgmake.rs/arena.rs, perdocs/TASKS.md"Placed image creation in the streaming phase").Evidence
Checks run (all passed on Linux x86_64)
imgmake::tests::img_pool_reuses_exact_key_respects_caps_and_drains_by_heap: testsImgPooldirectly for oversized rejection (> MAX_ENTRY_BYTES), exact-key LIFO reuse, heap/extent mismatch non-reuse, FIFO eviction underMAX_POOL_BYTES/MAX_POOL_IMAGES, and heap-selective (Some(true)vsNone) draining.cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked: passed (victory-core13,victory-formats49 passed / 5 ignored,victory-shader240 passed / 2 ignored,xtask6).(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked): passed (frame13,umem22,vkback169 passed / 3 ignored,policy6/6 includingfile_size).cargo clippy --all-targets --locked -- -D warnings: passed cleanly across root (-p victory-shader -p victory-formats -p victory-core -p xtask),greenfield,greenfield/wine, andgreenfield/vkback/translate.Checks NOT run (live game / GPU unavailable in this session)
The host GPU was not touched in this session:
VKB_LAT+greenfield/tools/frec/frames.py(fps, mean/p50/p90/p99/max, share > 33.3 ms).docs/tools.md, "Vulkan validation run").cargo xwin clippy ..., verified by 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)@vktory6 on GitHub · 2026-12-02 15:28 UTC · original
Thanks, reusing retired streaming images is one of the anti-stutter items ("Placed image creation in the streaming phase"), and the logic mirrors main's. Please:
clear_compressed.@firefloc on GitHub · 2026-12-02 17:32 UTC · original
The pool test at
9182f44checks bookkeeping with dummy handles. A readback regression would cover the ownership change: fill a texture with pattern A, retire it, verify that the next texture reuses the sameVkImage, then partially fill it with pattern B. At the first consumer, compare every accessible mip and layer against a fresh-image control and check the expected texel values independently. Filled texels should contain B, and holes and unheld mips should have the clear value. Include a deferred first fill followed by a retry. The RGBA8 case can stand on its own; add a BC case withImg::base > 0under Vulkan validation after #192. This tests that the shared clear path covers what the first fill leaves behind without erasing newly written texels.I exercised the readback assertions with four simulated inputs. They accept clean reuse and reject a pool miss, a stale mip, and identically wrong output in both arms. Connecting that check to Vulkan readback remains open.
One detail for the boat benchmark: #226's 0.03 ms for
vkCreateImage + memoryis the total in one window with 22 new images. Upload and fill preparation took 0.37 ms in that window. Both came from serialized profiling on the house scene. I would report pool hits, creation time, first-fill time, and frame-time tails separately on the boat.@firefloc on GitHub · 2026-12-02 18:50 UTC · original
The RGBA8 reuse/readback test now passes on
9182f44on RX 7900 XTX / RADV. I verified the old pattern across all ten mips, retired the image, and checked that the pool returned the sameVkImage. After the partial fill, the first readback matched the fresh-image control and the expected values: the two unfilled mips were zero and the other eight contained the new pattern. Final run: 1 passed, 0 failed.The test uses a direct Vulkan copy for readback. This covers the RGBA8 fixture. The application
Executereader, Vulkan validation, and the BC nonzero-base case after #192 remain open.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.