Placed views keep the title's leftover padding bytes: every view a new shape, long-session leak and slowdown (found in another fork) #32

Open
opened 2026-12-01 07:41:48 +00:00 by github-bot · 2 comments
Owner

@⁠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.rs on cd811c1.

  • create_placed_srv / create_placed_uav (≈ line 1261) record View::Placed(unordered, resource, desc) exactly as the title passes it.
  • Placed views are then keyed by 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 at SHAPES = 1 << 22 and 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:

  • the resource description's padding (words 1 and 13);
  • the SRV description's padding (word 3);
  • the union words past the member that the view's dimension uses.

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 Shape table; see the comment on normal_placed in its crates/victory-gpu/src/descriptor.rs, and its README under "Memory leak in long play". Their run:

  • filled all 4,194,304 shapes in about 20 minutes of play;
  • then made 5.6 million table entries that are never freed, about 3.3 GB;
  • frame time doubled.

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] and resource[13];
  • for an SRV, desc[3];
  • the union words past the member that the view's dimension uses. They table the used words per dimension: UAV starts at word 2, SRV at word 4, up to word 10, where the address is.

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 towards 1 << 22 confirms it.

I'm happy to send the padding-clear part as a PR if you want it here.

**@⁠LOCKhart07** on GitHub · 2026-11-30 15:47 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/32) **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.rs` on `cd811c1`. - `create_placed_srv` / `create_placed_uav` (≈ line 1261) record `View::Placed(unordered, resource, desc)` exactly as the title passes it. - Placed views are then keyed by `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 at `SHAPES = 1 << 22` and 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: - the resource description's padding (words 1 and 13); - the SRV description's padding (word 3); - the union words past the member that the view's dimension uses. 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](https://github.com/readmet3xt-lab/foxhound) ran into this. It's a Windows VIctory fork with the same `Shape` table; see the comment on `normal_placed` in its `crates/victory-gpu/src/descriptor.rs`, and its README under "Memory leak in long play". Their run: - filled all 4,194,304 shapes in about 20 minutes of play; - then made 5.6 million table entries that are never freed, about 3.3 GB; - frame time doubled. 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]` and `resource[13]`; - for an SRV, `desc[3]`; - the union words past the member that the view's dimension uses. They table the used words per dimension: UAV starts at word 2, SRV at word 4, up to word 10, where the address is. 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 towards `1 << 22` confirms it. I'm happy to send the padding-clear part as a PR if you want it here.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:41:48 +00:00
Author
Owner

@⁠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 main at 37bb30f, sampled once per minute. Neither counter flattens.

minute shapes of placed views ranges written unmaps left as they were fps (log)
1 18,156 15,423 9,214 37.3
5 66,725 233,494 124,315 27.7
10 105,438 682,945 264,858 24.5
15 128,042 1,229,664 423,162 30.0
20 156,492 1,550,888 525,148 35.4
25 172,989 2,038,727 670,337 32.5
27 175,778 2,246,480 713,107 29.3

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=1 was set. That was wrong. My launcher's run.sh strips all VICTORY_* variables from the environment, so the flag never reached the game in this run (and with the flag passed correctly, the game logs no D3D12 debug layer error=0x887A002D on 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: 0x887A0005 and an amdgpu [gfxhub] page fault from vkd3d_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.

**@⁠SemmerSky** on GitHub · 2026-12-01 15:54 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/32#issuecomment-7316717794) · edited 2026-12-01 20:20 UTC Data point for the long-session growth on RDNA3 (RX 7900 XTX): a 28 min run on `main` at 37bb30f, sampled once per minute. Neither counter flattens. | minute | shapes of placed views | ranges written | unmaps left as they were | fps (log) | |---|---|---|---|---| | 1 | 18,156 | 15,423 | 9,214 | 37.3 | | 5 | 66,725 | 233,494 | 124,315 | 27.7 | | 10 | 105,438 | 682,945 | 264,858 | 24.5 | | 15 | 128,042 | 1,229,664 | 423,162 | 30.0 | | 20 | 156,492 | 1,550,888 | 525,148 | 35.4 | | 25 | 172,989 | 2,038,727 | 670,337 | 32.5 | | 27 | 175,778 | 2,246,480 | 713,107 | 29.3 | **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=1` was set. That was wrong. My launcher's `run.sh` strips all `VICTORY_*` variables from the environment, so the flag never reached the game in this run (and with the flag passed correctly, the game logs `no D3D12 debug layer error=0x887A002D` on 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: 0x887A0005` and an amdgpu `[gfxhub] page fault` from `vkd3d_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.
Author
Owner

@⁠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] and resource[13];
  • rest[3] for an SRV;
  • the union words past the member the view's dimension uses (rest[last..10]).

That has been there since 9f573f8 (28 Nov), so it is also in cd811c1, 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). At size_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):

  • Buffer views of one buffer at different FirstElement offsets, 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.
  • Words 12–15 of the view description, and views whose dimension is not in the table (the early return), are not normalised. I don't know whether the title leaves stale bytes there.
  • In that run VRAM was at 23.7 of 24 GB with swap growing, which looks more like #21 / #14 than the shape table.

I'm looking at the buffer part next.

**@⁠JohnVonWells** on GitHub · 2026-12-01 16:51 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/32#issuecomment-7318339204) 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]` and `resource[13]`; - `rest[3]` for an SRV; - the union words past the member the view's dimension uses (`rest[last..10]`). That has been there since `9f573f8` (28 Nov), so it is also in `cd811c1`, 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). At `size_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): - Buffer views of one buffer at different `FirstElement` offsets, 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. - Words 12–15 of the view description, and views whose dimension is not in the table (the early `return`), are not normalised. I don't know whether the title leaves stale bytes there. - In that run VRAM was at 23.7 of 24 GB with swap growing, which looks more like #21 / #14 than the shape table. I'm looking at the buffer part next.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/lobomfz--VIctory-xmem#32
No description provided.