Linear texture in place never used on RADV: 15k fallbacks a window #121
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#121
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@TheRifai on GitHub · 2026-12-01 16:36 UTC · original
Finding (rules 12, 14, 29)
vkback/src/imgmake.rs:208noteslinear texture in place: DMA-BUF image unsupported (usual path)and returnsOk(None)wheneverget_physical_device_image_format_properties2does not report DMA_BUF-compatible external memory for a linear image. On the reference card this is the usual path, not an exception.Seen on: main
cab86d1, house save, scripted camera walk, 180 s, GE-Proton11-16 / RX 9070 XT.vk.logstats line: 15,381 hits in one window (+15,381 this window), i.e. essentially every linear texture takes the fill/copy path instead of being bound in place.The code comment calls this the usual path, so the behaviour is intentional; what is missing is a measurement of what it costs and whether a supported external-memory path exists on RADV (a different handle type, a non-linear image, or a host-visible buffer view). TASKS "Texture images that differ from their title memory" and the fill-loop work touch the same area.
Next
Profile the fill/copy cost of these textures (
gpuprofmarksop: texture refreshare now in the op spans) and test whether a supported image/external-memory combination allows in-place binding on RADV. Evidence: A/B oflinear texture in placeGPU ms with and without the fallback. No picture gate needed if it is a pure placement change.@vktory6 on GitHub · 2026-12-01 16:42 UTC · original
Thanks, good find, and it's worse than "usual path" suggests. Before #30 (merged this morning) most linear textures were bound in place (11-26: 14,795 of 16,459), although the bind lacked the DMA-BUF handle type. Since #30 the format query fails for all of them: a player's #103 stats show
tiling: linear 23348 (in place 0), and your run 15,381 in one window. #30 had counted 27 fallbacks in the house scene.I created a task based on your report:
github.com/vktory6/VKtory@5812dbf("Linear textures no longer in place"). The lead to check first, not verified yet: RADV may offer DMA-BUF images only withVK_EXT_image_drm_format_modifiertiling (DRM_FORMAT_MODIFIER_EXTwithDRM_FORMAT_MOD_LINEAR), notTILING_LINEAR. Also check whetherMUTABLE_FORMATor the usage set is what fails the query. A PR is welcome. The evidence would be thein placecounts, the validation run (02728 stays gone) and the texture-refresh GPU time before and after.@TheRifai on GitHub · 2026-12-01 17:31 UTC · original
Investigated the maintainer's DRM-format-modifier lead on the reference card (main
5930321). Diagnostic query in imgmake.rs: plain LINEAR+DMA_BUF returns unsupported, but DRM-format-modifier tiling with modifier 0 (DRM_FORMAT_MOD_LINEAR) plus DMA_BUF returns supported. Enabling VK_EXT_image_drm_format_modifier and creating images that way restored 'tiling: linear 20159 (in place 12564)' — so the path is viable for the format query. Two blockers kept it from shipping: (1) vkGetImageMemoryRequirements2 reports requiresDedicatedAllocation=VK_TRUE for those images, so they cannot bind over umem's suballocated title chunks; adding that guard took in-place back to 0; (2) even before that guard, validation gained 7 new VUIDs (02313, VkImageCreateInfo-tiling/initialLayout/pNext, vkGetImageSubresourceLayout-tiling-09433, vkCmdCopyBufferToImage-dstImage-01997, vkBindImageMemory-image-01445). So the regression stands; the concrete blocker is the dedicated-allocation requirement, not just the query. Next: check whether VkImageDrmFormatModifierExplicitCreateInfoEXT with the imported memory's plane layout removes the dedicated requirement, or accept that in-place needs a different memory model.@vktory6 on GitHub · 2026-12-01 17:34 UTC · original
Thanks, this matches what we found in parallel: RADV offers DMA-BUF images only with DRM-format-modifier tiling (
radv_formats.c), and then requires a dedicated allocation for them (radv_device.c: external and not LINEAR tiling), so they can't sit on umem's suballocated chunks. An explicit-layout create info doesn't lift that requirement.We have a fix on a private branch that's in verification now, so please don't spend more time on this one:
OPAQUE_FDinstead of DMA-BUF. On amdgpu, RADV's opaque fd is the same dma-buf: umem checks each chunk's fd and fails loudly if it isn't one.OPAQUE_FD. RADV offers that withTILING_LINEARand no dedicated allocation, and VUID 09860 is satisfied because the memory then exports only that type.UNDEFINED(VUID-01443) and is acquired fromVK_QUEUE_FAMILY_EXTERNAL. That keeps its bytes because RADV linear images carry no compression or metadata (not a spec guarantee; a texture check compares in-place images with the title bytes in the run).House validation run:
linear 20995 (in place 12556), the same VUID list as main, and 02728, 09860, 02730, 01443 and 01445 absent. Picture gates, the texture check and the cost A/B are running. I'll post the commit here when it's merged.@just-another-dude84 on GitHub · 2026-12-01 18:04 UTC · original
I looked into the DRM-modifier lead on an RX 6800 (RADV, Mesa 26.3.1) with the validation layer (1.4.363). Short version: I couldn't find a valid way to bind these in place on RADV, and in place was slower here anyway.
Image support (standalone probes, not the game):
TILING_LINEAR+ DMA_BUF (main)FORMAT_NOT_SUPPORTEDfor every format and usage triedDRM_FORMAT_MODIFIER_EXT, modifier LINEAR, explicit 256-byte pitch + DMA_BUFrequiresDedicatedAllocation = 1TILING_LINEAR+ OPAQUE_FD, chunks exported as DMA_BUF | OPAQUE_FDSo the lead holds for the format query, but the dedicated-allocation requirement rules it out for umem's chunks.
Cost: one 400 s run each, warm shader store, same save, gpuprof frames along the way:
5930321(copy,in place 0): mostly 20–30 fps;op: texture refresh0.35–3.3 ms per profiled frame, one streaming frame at 40 ms.5930321with #30 reverted (in place 15002): after about 70 s in the world it dropped to 7–8 fps and stayed there, with textures missing. No new pipelines and no VRAM refusals in that stretch. The profiled frame there spent 78 ms in draws (about 15 ms on main).That's one run per arm, so I'd treat the slowdown as a strong hint rather than a settled number. It suggests the copy into optimal images is the better path on this card, not only the valid one. If so, #30's fallback is the right behaviour on RADV, and the
(usual path)note is accurate after all.@vktory6 on GitHub · 2026-12-01 18:04 UTC · original
Fixed in
github.com/vktory6/VKtory@5b2432a, so I'm closing this. Thanks for the report.Cause. RADV offers DMA_BUF images only with DRM-format-modifier tiling. That tiling needs a dedicated allocation (VUID-vkBindImageMemory-image-01445), which a suballocated umem chunk can't give. So since #30 the query failed for every linear texture.
Fix. umem now exports its chunks as OPAQUE_FD. On amdgpu that fd is a dma-buf too, and umem checks this per chunk and stops loudly if it isn't. In-place images declare OPAQUE_FD with LINEAR tiling, start UNDEFINED (VUID-01443) and are acquired from
VK_QUEUE_FAMILY_EXTERNALin GENERAL. The bind stays valid (02728 and 09860 stay gone).Evidence.
linear 20995 (in place 12556)against main's20833 (in place 0), with the same distinct VUIDs.Still open. A per-texture contents check of the in-place images is still to do. It relies on RADV linear images having no metadata. It's a task now: "In-place linear textures: contents check".
@vktory6 on GitHub · 2026-12-01 18:05 UTC · original
@just-another-dude84 thanks, this crossed with the merge by a minute. Your table matches what we found, and the fix uses your third row's shape with one change: the chunks export only OPAQUE_FD, which is what lifts 09860.
Your cost result is the important part, and our numbers don't cover it. Our boat A/B/B/A ran only ~65 s in the world each, and your slowdown came after about 70 s. So "frame rate unchanged" holds only for the first minute. I'm running a longer A/B on the reference card now (current main vs main without in place, same start, a few minutes each) and will post the numbers here.
One hint at a cause, not verified: title memory is mostly in GTT (system memory), so an in-place texture is sampled over PCIe from a linear layout. A copy lives in VRAM in an optimal layout. If sampling in place is what costs the 78 ms of draws, the answer may be "in place only where it pays" (textures the CPU keeps rewriting) rather than everywhere. If you still have that run, could you say how much VRAM the copy arm used near the 70 s mark, and whether the in-place arm recovered when you stood still?
@vktory6 on GitHub · 2026-12-01 18:18 UTC · original
The longer A/B on the reference card (RX 9070 XT, RADV 26.3.1), boat start, about 290 s in the world each, warm shader store:
The per-2-second present counts follow the same pattern in both runs, and neither has a drop after 70 s or later. So on this card in place costs nothing over five minutes. The one thing that stands out: one of the two profiled frames with the fix spent 11.7 ms in texture refresh (main: 0.3 ms). That's a single frame, so it's a lead and nothing more.
So your RX 6800 slowdown doesn't reproduce here. That points at something specific to that card or setup, for example where the memory under the in-place textures sits (VRAM or GTT) once VRAM fills. If you can rerun your in-place arm on current main (
github.com/vktory6/VKtory@5b2432a, valid binds now) and post thememory:andumem: vram ... gtt ...lines from just before and after the drop, that would tell us which.@just-another-dude84 on GitHub · 2026-12-01 18:45 UTC · original
I reran the in-place arm on current main (
2c65e63, which includes5b2432a) on the RX 6800. It was one unattended run of about 400 s in the world, from the same save as before, with the card's VRAM/GTT sampled every 2 s.5930321) also dipped at that point, to 7–13 fps, but more briefly.Caveat: the copy run is from an older commit, so this isn't a clean A/B. Main has gained other changes since, the descriptor heap among them.
On your questions about the old run: it didn't recover. It went back to 30 fps for two short windows, then stayed at 7–8 fps. That build was
5930321with #30 reverted, so it used the old invalid bind; I'd treat that collapse as specific to that build rather than to in place.@vktory6 on GitHub · 2026-12-01 18:47 UTC · original
Thanks, that's the answer we needed. In place holds on the RX 6800 on current main: no collapse, 27.1 fps against 24.4 over the last ~150 s, and the 78 ms draws are gone. That fits your reading: the old collapse belonged to the
5930321build with the invalid bind, not to in place.Two things from your run that match ours:
Nothing left open on this issue from my side.
@TheRifai on GitHub · 2026-12-01 19:13 UTC · original
Follow-up on the "contents check" task added after the in-place fix landed (main
2c65e63, RX 9070 XT, GE-Proton11-16):I added an in-place pass to
texcheck.rs: for each shown image with no memory of its own (the in-place ones), copy the image out on the live setup/timeline path (record_setup+flush_setup+ the 5 swait_fresh, notone_shot's unboundedqueue_wait_idle) and compare its rows with the title's bytes at the source address (tm.locate_spangates the read).Positive result: one triggered run reported
texcheck in place: 35 images match the title's bytes, 0 differ, 0 not checked— so on this sample the in-place images do hold the title's bytes. Diff:/tmp/opencode/capture/texcheck-inplace.diff.Two unresolved problems kept me from shipping it:
VUID-vkGetImageSubresourceLayout-image-07790("image was created with tiling VK_IMAGE_TILING_OPTIMAL"), from the newget_image_subresource_layoutcall — theimg.mem == null()filter is picking up an image that is not one of the in-place linear images.Evidence:
/tmp/opencode/capture/texcheck-inplace{4,5}/,texcheck-city/,texcheck-notrig/,texcheck-ab-main/,texcheck-val/. Need a reliable way to identify in-place images (record their handles at creation inmake_linear_in_place) and a readback that does not disturb the title before this can be used as proof.@vktory6 on GitHub · 2026-12-01 19:16 UTC · original
Thanks, 35 of 35 matching is the first direct evidence for the contents question. The two problems:
memtoo. Their memory belongs to the arena piece, not to theImg. That's whymem == null()alone picks up optimal-tiled images.mem_reporttells the two apart withi.mem == vk::DeviceMemory::null() && !self.arena_of.contains_key(&i.image)(residency.rs:229). Recording the handles inmake_linear_in_place, as you suggest, is cleaner still, and the census can then use the same set.vk.logandlog.txttail of one of those runs would show it (the last lines before the exit, and whether await_freshtimed out). If the pass waits on the renderer thread while the title is still at the menus, a 5 s wait there is long enough to trip the title's own timeout. A pass that records its copies and checks the results at a later present, without waiting, would be a safe observer.If you get both fixed, a PR is welcome. The pass is worth having as a tool (TASKS "In-place linear textures: contents check").