Placed views keep the title's leftover padding bytes: every view a new shape, long-session leak and slowdown (found in another fork) #32
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/lobomfz--VIctory-xmem#32
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?
@LOCKhart07 on GitHub · 2026-11-30 15:47 UTC · original
Summary: placed views are recorded with the title's leftover bytes in fields no view reads, so equal views become distinct shapes. Another VIctory fork measured the result as a long-session leak and slowdown. This repo has the same code path and doesn't clear those bytes.
So far this comes from reading the code. I haven't reproduced it on xmem: my sessions have been 3–5 minutes, and the leak needs about 20.
Where:
crates/victory-gpu/src/descriptor.rsoncd811c1.create_placed_srv/create_placed_uav(≈ line 1261) recordView::Placed(unordered, resource, desc)exactly as the title passes it.Shape = (bool, [u32; 14], [u32; 14])(≈ line 640). That's the resource description, plus the view's words without the address. The table is capped atSHAPES = 1 << 22and beyond that falls back to table entries.The problem: the title fills these structs from the stack and leaves stale bytes in fields no view reads:
Two views of the same kind of texture or buffer therefore rarely compare equal, and nearly every placed view becomes a new shape.
Measured elsewhere: readmet3xt-lab/foxhound ran into this. It's a Windows VIctory fork with the same
Shapetable; see the comment onnormal_placedin itscrates/victory-gpu/src/descriptor.rs, and its README under "Memory leak in long play". Their run:Player reports matching it: 5 fps after about 10 minutes, stuttering sound, a white picture. After clearing the unused fields, memory stayed flat over 25 minutes and frame time stayed at 33–34 ms.
Suggested fix (theirs,
VICTORY_PLACED_NORMAL, on by default there): before recording a placed view, zero:resource[1]andresource[13];desc[3];They also fold a buffer view's first element into its address and set the buffer's width to the bytes the view reads, so views of one ring buffer at many offsets become one shape. That part changes what is recorded, so it's riskier; the padding clear alone addresses the leak.
Repro idea: a 20+ minute session with the shape count from
views_kept()logged over time. A count that keeps climbing towards1 << 22confirms it.I'm happy to send the padding-clear part as a PR if you want it here.
@SemmerSky on GitHub · 2026-12-01 15:54 UTC · original · edited 2026-12-01 20:20 UTC
Data point for the long-session growth on RDNA3 (RX 7900 XTX): a 28 min run on
mainat37bb30f, sampled once per minute. Neither counter flattens.Setup: Ryzen 9 7950X3D, RX 7900 XTX (RADV, Mesa 26.3.1 with the repo's patches), 32 GB RAM, Fedora 45, kernel 7.3.6, wine 11.21 (Staging), gamescope. Series X profile, ray tracing on, 3840x2160 output from a 2560x1440 render (game's own upscaler, 67%), no frame generation.
Build: this was the diagnostics build of the same commit, not the release build. Correction: an earlier version of this comment said
VICTORY_D3D12_DEBUG=1was set. That was wrong. My launcher'srun.shstrips allVICTORY_*variables from the environment, so the flag never reached the game in this run (and with the flag passed correctly, the game logsno D3D12 debug layer error=0x887A002Don my setup, so the layer is not available here anyway).Play: a long drive looking for a helicopter at the start, then flying over the city for the rest of the run. Textures stream in late.
Other numbers: MangoHud over the whole time in the world (16,555 samples): average 28.8 fps, 1% low about 10 fps (p99 frame time 98 ms), worst frame 410 ms. VRAM up to 23.7 GB of 24 GB, game RSS 3.4-4.1 GB, swap 4.0 -> 5.0 GB, free RAM often below 1 GB. The game was closed normally at the end. No GPU error in the kernel log and no D3D12 debug layer message.
Earlier crashes: two runs on the same commit crashed after about 4-5 minutes in the world, one with the same diagnostics build and one with the release build. Both ended with
device removed: 0x887A0005and an amdgpu[gfxhub] page faultfromvkd3d_queue(SQC data, PERMISSION_FAULTS). The run above used the same diagnostics build as the first crashing run, with the same settings, and did not crash. No D3D12 debug flag was active in any of the three runs. So the difference is not the flag. It may be how I played (different route, no map open), or chance. This is not measured.For scale, #36 (closed,
baf0468) reported about 229k ranges and 116k unmaps on the same GPU class. This run reaches 10x that over 28 min, but it is a different commit and different settings, so I would not compare them directly.I can attach the per-minute CSV if that is useful.
@JohnVonWells on GitHub · 2026-12-01 16:51 UTC · original
Read through this on
main(37bb30f). The padding clear described here is already in this repo, so I don't think it explains the growth.What the code does.
shape_of(crates/victory-gpu/src/descriptor.rs:692) clears, before a placed view becomes a shape:resource[1]andresource[13];rest[3]for an SRV;rest[last..10]).That has been there since
9f573f8(28 Nov), so it is also incd811c1, the commit this issue cites. I checked the per-dimension word table against the D3D12 SRV/UAV layouts and it matches.What the 28 min run above shows. 175,778 shapes is about 4% of
SHAPES, and the growth slows (roughly 48k, 39k, 23k, 28k, 16k per 5 minutes). Atsize_of::<Shape>()= 116 bytes plus the index that is around 50 MB, not the 3.3 GB foxhound measured. The other two columns ("ranges written", "unmaps left as they were") are cumulative event counters printed by the Mesa patch (radv_amdgpu_um_flush), not memory held.What is still open (from reading only, not measured):
FirstElementoffsets, or with different resource widths, are still distinct shapes. That is the second, riskier part of foxhound's fix and the likely source of the remaining growth.return), are not normalised. I don't know whether the title leaves stale bytes there.I'm looking at the buffer part next.