fix(vk): an allowance AMD's driver gives as the count itself is taken as past it #1091

Merged
HumanBean merged 2 commits from HumanBean/Longshot:vram-at-count into main 2026-11-16 08:02:01 +00:00
Owner

Type: fix · Risk: low · Tested on: Linux, RTX 3090 (a test allowance that reports like AMD's Windows driver) · Needs: Windows, AMD with 8 GB or less

Why

On Windows with an AMD card of 8 GB or less, the game freezes for 1 to 15 seconds at a time in heavy areas like Hyrule Field and the Market, once video memory fills. The renderer is meant to give textures back before that happens, but AMD's driver tells it there is still room, so it never does, and Windows moves video memory out to system memory instead.

AMD's Windows driver reports a process that is over what it allows as allowed exactly what it uses. In the logs on #1025 (RX 6600, nightly-322) and #933 (RX 6600, rc.4), the allowance follows the count up as the scene loads:

#933:  VRAM 5.1 of 6.4 GB · 5.3 of 6.5 · 5.3 of 6.5 (slowest 942.6 ms) · 6.6 of 6.6 (slowest 1231.6 ms) · 6.6 of 6.6 · 6.6 of 6.6 (slowest 1272.3 ms)
#933:  VRAM 5.3 of 6.4 GB (slowest 955.5 ms) · 6.6 of 6.6 (slowest 15723.2 ms) · 6.6 of 6.6 (slowest 273.6 ms)
#1025: VRAM 3.4 of 7.2 GB · 5.8 of 5.8 (slowest 1431.9 ms) · 5.7 of 5.8 · 5.8 of 5.9 (slowest 572.9 ms)
#1025: vk: VRAM: 5940 MB used of 5940 MB allowed (746 MB of it free in the blocks); textures 1634 MB (budget 751 MB), 1100 textures (at the driver's limit, room in the blocks: not squeezed)

Read as it is, the count is within the allowance (used <= allowed):

  • vram_compact::room_in_blocks is true, so the 97% squeeze waits;
  • the hold's line and the 90% rule are taken from an allowance that rises with the count, so they never catch up.

Fixes #1025's VRAM part (its other finding, the write-backs' share of the GPU frame, is separate). See #933, #939.

How to reproduce

Seen on: Windows 11, AMD RX 6600 8 GB, driver 26.10.1 (#1025); rc.4 on another RX 6600 (#933)
Settings and switches: 2560x1440 output, 67% render resolution, the game's own upscaler
Steps: play into Hyrule Field, with other programs using some VRAM
Expected: the renderer gives textures back as VRAM runs short; no freezes
Actual: VRAM: 5940 MB used of 5940 MB allowed ... (at the driver's limit, room in the blocks: not squeezed) and frames of 1.2-15.7 s

On any card, with this PR's diagnostic switches: RX_VK_TEST_ALLOWED_FILE=<file> holding 7378, changed to 5000 once in Hyrule Field, with RX_VK_TEST_ALLOWED_FOLLOW=1 RX_VK_IMAGE_PREALLOC=9 RX_VK_ALLOWED_AT_COUNT=0. The log then shows the same line:

vk: VRAM: 5768 MB used of 5768 MB allowed (1718 MB of it free in the blocks); textures 2228 MB (budget 1940 MB), 1330 textures (at the driver's limit, room in the blocks: not squeezed)

What changed

An allowance the driver reports as equal to the count (within 16 MB) is now taken as past it: a tenth under the count. Every rule that reads the allowance then sees the count past it and gives memory back, until the driver again reports an allowance above the count.

  • vk/vram: vram_compact::past_allowance(used, allowed) in gpu/vk/vram_compact.h. Used by vram_usage() in gpu/vk/vk_vma.cpp, so texture_frame's rules, the mirrors' and the status line all read the same allowance. It logs its first 8 uses: vk: the driver's allowance is the count itself (... MB used of ...): past it, taken as ... MB. An allowance already under the count, or one that isn't known, is left as it is.
  • vk/vram (diagnostic): RX_VK_TEST_ALLOWED_FILE, the test bound read from a file once a second so it can shrink in play; and RX_VK_TEST_ALLOWED_FOLLOW=1, which reports the allowance as the count once past the bound, as AMD's driver does.
  • tests: tests/test_vram_compact.cpp checks past_allowance on the two cards' numbers, the cases left alone, and that room_in_blocks stops waiting on its result.
  • docs: the three switches in docs/development.md.

Measurements

Verdict: On the RTX 3090 with the allowance reported as AMD's driver does, the fix takes the count back under the real allowance (mostly 4,844-4,936 MB of 5,000, against at or past it in about 3 of 4 samples without the fix). Frame rate is unchanged within the spread. The freezes themselves can't happen on Linux, where nothing is paged out at the allowance, so whether they are gone is for the Windows AMD run below.

Hardware: Linux (CachyOS, kernel 7.3.3), RTX 3090 24 GB, NVIDIA 620.70.06, Ryzen 9 7900X, 30 GB
Scene: Hyrule Field (teleport), 5 s walking forward then 20 s walking while turning the camera; 2560x1440 output, 67% render resolution, the game's own upscaler, uncapped, V-Sync off, no frame generation
Method: each run from a fresh session. The test allowance is 7,378 MB from the start and 5,000 MB from 3 s after Hyrule Field loads, with RX_VK_TEST_ALLOWED_FOLLOW=1 RX_VK_IMAGE_PREALLOC=9 (the RX 6600's 9 starting blocks). The vk: VRAM: lines after the drop, and fps and frame times from RX_VK_FRAME_LOG over the walk and the turn. RX_VK_PASS_TIMING=1 on both sides. Interleaved: a warm-up, then off, on, off, on.
How to reproduce: the switches above, RX_VK_ALLOWED_AT_COUNT=0 for the "before" column.
Baseline: the same build with RX_VK_ALLOWED_AT_COUNT=0, which is main's behaviour. Measured on e4d035e9 with this change (the renderer built from it, in a game folder of e4d035e9); rebased since onto f7922126, whose commits don't touch these files.

Before: RX_VK_ALLOWED_AT_COUNT=0 (warm-up, run 1, run 2) After: this PR @ 10468ad5 (run 1, run 2)
VRAM samples at or past the real 5,000 MB, after the drop 1 of 4 · 3 of 4 · 4 of 5 1 of 5 · 4 of 5 (the 4 at exactly 5,000)
Allowance the rules use the count (5000 of 5000, 5768 of 5768) a tenth under it (5000 of 4500)
Textures' budget after the drop 1,066-1,940 MB 665-1,684 MB
fps, turning 64.5 · 61.2 · 78.6 73.3 · 70.4
fps, walking 60.3 · 63.2 · 79.4 79.4 · 77.8
Frames over 33 ms, turning 8 · 11 · 1 2 · 18
before: vk: VRAM: 5768 MB used of 5768 MB allowed (1718 MB of it free in the blocks); textures 2228 MB (budget 1940 MB), 1330 textures (at the driver's limit, room in the blocks: not squeezed)
before: vk: VRAM: 5000 MB used of 5000 MB allowed (1012 MB of it free in the blocks); textures 2145 MB (budget 1449 MB)
after:  vk: the driver's allowance is the count itself (5000 MB used of 5000): past it, taken as 4500 MB (RX_VK_ALLOWED_AT_COUNT=0: as the driver says)
after:  vk: VRAM: 5000 MB used of 4500 MB allowed (1818 MB of it free in the blocks); textures 1403 MB (budget 665 MB)
after:  vk: VRAM: 4844 MB used of 5000 MB allowed (983 MB of it free in the blocks); textures 1675 MB (budget 1233 MB)

In the second run with the fix, the count held at exactly 5,000 MB in 4 of 5 samples, with the textures' budget at 665-1,144 MB under 1.4-2.1 GB of textures. What stays is textures used in the last 60 frames, which the eviction keeps on purpose (RX_VK_EVICT_MIN_UNUSED; 8 brought back textures made again in a loop and empty rendered ones, vk_texture.cpp). This PR doesn't change that. Whether more needs to give back on Windows is for the run below to show.

Flags and settings

One switch with a default for everyone, and two diagnostic ones.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_ALLOWED_AT_COUNT Whether an allowance equal to the count is taken as past it (none: taken as within) on (0: as the driver says) The VRAM rules give back once AMD's driver reports the allowance as the count Helps on the RTX 3090 with AMD's reporting emulated; untested on a real AMD card on Windows On for everyone: on a driver that reports an allowance over the count it never applies
RX_VK_TEST_ALLOWED_FILE The test allowance, read from a file once a second (none) unset Lets a run shrink the allowance in play Reproduced #1025's state on an RTX 3090 Off: only for testing
RX_VK_TEST_ALLOWED_FOLLOW Reports the allowance as the count once past the test bound (none) off Emulates AMD's Windows driver on any card Reproduced #1025's state on an RTX 3090 Off: only for testing

Testing

Tested: Linux, RTX 3090, NVIDIA 620.70.06, in the game: Hyrule Field with the allowance shrinking in play and reported as AMD's driver does. Reproduced #1025's not squeezed state with the fix off, and saw it taken as past the allowance and given back with the fix on (table above). The renderer built from this change runs in a game folder built from e4d035e9.

Not tested:

  • python -I -B tests/run_all.py, including the new past_allowance checks in tests/test_vram_compact.cpp: not run on this PC. The person I work for runs no test suites on it, so this is left to CI.
  • The check failing on main: on main past_allowance doesn't exist, so test_vram_compact.cpp doesn't build there (not run, for the same reason).
  • A real AMD card on Windows: the freezes come from Windows' paging, which doesn't happen on Linux.

Must be tested:

  • Windows, AMD with 8 GB or less (RX 6600 class): Hyrule Field and Castle Town Market for a few minutes each at 2560x1440 output and 67% render resolution, on main and on this PR. Expecting on main VRAM: N MB used of N MB allowed ... not squeezed lines and slow frames of 1 s or more; on this PR the driver's allowance is the count itself lines, used falling under the allowance, and no frames over 1 s (Test Farm: @Beanstalk windows, amd, 8 GB or less: Hyrule Field and the Market, main against this PR, longshot_log.txt's vk: VRAM: and slow frame lines)

Risks

What could break: a driver that reports the allowance within 16 MB of the count while the process really is within it. The renderer would then give back textures it could keep: more uploads near the limit, not wrong pictures, since the eviction's own rules about what may go are unchanged. Every allowance more than 16 MB over the count is left as it is.

Turning it off: RX_VK_ALLOWED_AT_COUNT=0

Compatibility: Nothing changes: no cache, save or options file, and the renderer's interface is unchanged.

Issues

Fixes #1025
See #933
See #939

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). Not run on this PC (no test suites run on it); left to CI.
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A game-free test added for the fix, failing on main and passing here. Added (tests/test_vram_compact.cpp, its own commit first); not run on this PC.
  • A check under tests/ that reads changed source updated in this PR, not weakened. tests/test_vram_compact.cpp gains the past_allowance checks; the checks that read vk_vma.cpp cut blocks_at_start, make_pool and the pools, which are unchanged, and the ones using vram_usage give it a stand-in of their own.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Built on Linux (the renderer alone, with the Builder's toolchain); not yet built for Windows. The Test Farm's Windows run builds it. It adds only <chrono>, <cstdio> and fopen of a path from the environment (a diagnostic switch).
  • Docs updated.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** low · **Tested on:** Linux, RTX 3090 (a test allowance that reports like AMD's Windows driver) · **Needs:** Windows, AMD with 8 GB or less ## Why On Windows with an AMD card of 8 GB or less, the game freezes for 1 to 15 seconds at a time in heavy areas like Hyrule Field and the Market, once video memory fills. The renderer is meant to give textures back before that happens, but AMD's driver tells it there is still room, so it never does, and Windows moves video memory out to system memory instead. AMD's Windows driver reports a process that is over what it allows as allowed exactly what it uses. In the logs on [#1025](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1025) (RX 6600, nightly-322) and [#933](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/933) (RX 6600, rc.4), the allowance follows the count up as the scene loads: ``` #933: VRAM 5.1 of 6.4 GB · 5.3 of 6.5 · 5.3 of 6.5 (slowest 942.6 ms) · 6.6 of 6.6 (slowest 1231.6 ms) · 6.6 of 6.6 · 6.6 of 6.6 (slowest 1272.3 ms) #933: VRAM 5.3 of 6.4 GB (slowest 955.5 ms) · 6.6 of 6.6 (slowest 15723.2 ms) · 6.6 of 6.6 (slowest 273.6 ms) #1025: VRAM 3.4 of 7.2 GB · 5.8 of 5.8 (slowest 1431.9 ms) · 5.7 of 5.8 · 5.8 of 5.9 (slowest 572.9 ms) #1025: vk: VRAM: 5940 MB used of 5940 MB allowed (746 MB of it free in the blocks); textures 1634 MB (budget 751 MB), 1100 textures (at the driver's limit, room in the blocks: not squeezed) ``` Read as it is, the count is within the allowance (`used <= allowed`): - `vram_compact::room_in_blocks` is true, so the 97% squeeze waits; - the hold's line and the 90% rule are taken from an allowance that rises with the count, so they never catch up. Fixes [#1025](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1025)'s VRAM part (its other finding, the write-backs' share of the GPU frame, is separate). See [#933](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/933), [#939](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/939). ## How to reproduce **Seen on:** Windows 11, AMD RX 6600 8 GB, driver 26.10.1 ([#1025](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1025)); rc.4 on another RX 6600 ([#933](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/933)) **Settings and switches:** 2560x1440 output, 67% render resolution, the game's own upscaler **Steps:** play into Hyrule Field, with other programs using some VRAM **Expected:** the renderer gives textures back as VRAM runs short; no freezes **Actual:** `VRAM: 5940 MB used of 5940 MB allowed ... (at the driver's limit, room in the blocks: not squeezed)` and frames of 1.2-15.7 s On any card, with this PR's diagnostic switches: `RX_VK_TEST_ALLOWED_FILE=<file>` holding `7378`, changed to `5000` once in Hyrule Field, with `RX_VK_TEST_ALLOWED_FOLLOW=1 RX_VK_IMAGE_PREALLOC=9 RX_VK_ALLOWED_AT_COUNT=0`. The log then shows the same line: ``` vk: VRAM: 5768 MB used of 5768 MB allowed (1718 MB of it free in the blocks); textures 2228 MB (budget 1940 MB), 1330 textures (at the driver's limit, room in the blocks: not squeezed) ``` ## What changed An allowance the driver reports as equal to the count (within 16 MB) is now taken as past it: a tenth under the count. Every rule that reads the allowance then sees the count past it and gives memory back, until the driver again reports an allowance above the count. - vk/vram: `vram_compact::past_allowance(used, allowed)` in `gpu/vk/vram_compact.h`. Used by `vram_usage()` in `gpu/vk/vk_vma.cpp`, so `texture_frame`'s rules, the mirrors' and the status line all read the same allowance. It logs its first 8 uses: `vk: the driver's allowance is the count itself (... MB used of ...): past it, taken as ... MB`. An allowance already under the count, or one that isn't known, is left as it is. - vk/vram (diagnostic): `RX_VK_TEST_ALLOWED_FILE`, the test bound read from a file once a second so it can shrink in play; and `RX_VK_TEST_ALLOWED_FOLLOW=1`, which reports the allowance as the count once past the bound, as AMD's driver does. - tests: `tests/test_vram_compact.cpp` checks `past_allowance` on the two cards' numbers, the cases left alone, and that `room_in_blocks` stops waiting on its result. - docs: the three switches in `docs/development.md`. ## Measurements **Verdict:** On the RTX 3090 with the allowance reported as AMD's driver does, the fix takes the count back under the real allowance (mostly 4,844-4,936 MB of 5,000, against at or past it in about 3 of 4 samples without the fix). Frame rate is unchanged within the spread. **The freezes themselves can't happen on Linux**, where nothing is paged out at the allowance, so whether they are gone is for the Windows AMD run below. Hardware: Linux (CachyOS, kernel 7.3.3), RTX 3090 24 GB, NVIDIA 620.70.06, Ryzen 9 7900X, 30 GB Scene: Hyrule Field (teleport), 5 s walking forward then 20 s walking while turning the camera; 2560x1440 output, 67% render resolution, the game's own upscaler, uncapped, V-Sync off, no frame generation Method: each run from a fresh session. The test allowance is 7,378 MB from the start and 5,000 MB from 3 s after Hyrule Field loads, with `RX_VK_TEST_ALLOWED_FOLLOW=1 RX_VK_IMAGE_PREALLOC=9` (the RX 6600's 9 starting blocks). The `vk: VRAM:` lines after the drop, and fps and frame times from `RX_VK_FRAME_LOG` over the walk and the turn. `RX_VK_PASS_TIMING=1` on both sides. Interleaved: a warm-up, then off, on, off, on. How to reproduce: the switches above, `RX_VK_ALLOWED_AT_COUNT=0` for the "before" column. Baseline: the same build with `RX_VK_ALLOWED_AT_COUNT=0`, which is main's behaviour. Measured on e4d035e9 with this change (the renderer built from it, in a game folder of e4d035e9); rebased since onto f7922126, whose commits don't touch these files. | | Before: `RX_VK_ALLOWED_AT_COUNT=0` (warm-up, run 1, run 2) | After: this PR @ 10468ad5 (run 1, run 2) | |---|---|---| | VRAM samples at or past the real 5,000 MB, after the drop | 1 of 4 · 3 of 4 · 4 of 5 | 1 of 5 · 4 of 5 (the 4 at exactly 5,000) | | Allowance the rules use | the count (`5000 of 5000`, `5768 of 5768`) | a tenth under it (`5000 of 4500`) | | Textures' budget after the drop | 1,066-1,940 MB | 665-1,684 MB | | fps, turning | 64.5 · 61.2 · 78.6 | 73.3 · 70.4 | | fps, walking | 60.3 · 63.2 · 79.4 | 79.4 · 77.8 | | Frames over 33 ms, turning | 8 · 11 · 1 | 2 · 18 | ``` before: vk: VRAM: 5768 MB used of 5768 MB allowed (1718 MB of it free in the blocks); textures 2228 MB (budget 1940 MB), 1330 textures (at the driver's limit, room in the blocks: not squeezed) before: vk: VRAM: 5000 MB used of 5000 MB allowed (1012 MB of it free in the blocks); textures 2145 MB (budget 1449 MB) after: vk: the driver's allowance is the count itself (5000 MB used of 5000): past it, taken as 4500 MB (RX_VK_ALLOWED_AT_COUNT=0: as the driver says) after: vk: VRAM: 5000 MB used of 4500 MB allowed (1818 MB of it free in the blocks); textures 1403 MB (budget 665 MB) after: vk: VRAM: 4844 MB used of 5000 MB allowed (983 MB of it free in the blocks); textures 1675 MB (budget 1233 MB) ``` In the second run with the fix, the count held at exactly 5,000 MB in 4 of 5 samples, with the textures' budget at 665-1,144 MB under 1.4-2.1 GB of textures. What stays is textures used in the last 60 frames, which the eviction keeps on purpose (`RX_VK_EVICT_MIN_UNUSED`; 8 brought back textures made again in a loop and empty rendered ones, `vk_texture.cpp`). This PR doesn't change that. Whether more needs to give back on Windows is for the run below to show. ### Flags and settings One switch with a default for everyone, and two diagnostic ones. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_ALLOWED_AT_COUNT` | Whether an allowance equal to the count is taken as past it | (none: taken as within) | on (`0`: as the driver says) | The VRAM rules give back once AMD's driver reports the allowance as the count | Helps on the RTX 3090 with AMD's reporting emulated; untested on a real AMD card on Windows | On for everyone: on a driver that reports an allowance over the count it never applies | | `RX_VK_TEST_ALLOWED_FILE` | The test allowance, read from a file once a second | (none) | unset | Lets a run shrink the allowance in play | Reproduced #1025's state on an RTX 3090 | Off: only for testing | | `RX_VK_TEST_ALLOWED_FOLLOW` | Reports the allowance as the count once past the test bound | (none) | off | Emulates AMD's Windows driver on any card | Reproduced #1025's state on an RTX 3090 | Off: only for testing | ## Testing **Tested:** Linux, RTX 3090, NVIDIA 620.70.06, in the game: Hyrule Field with the allowance shrinking in play and reported as AMD's driver does. Reproduced #1025's `not squeezed` state with the fix off, and saw it taken as past the allowance and given back with the fix on (table above). The renderer built from this change runs in a game folder built from e4d035e9. **Not tested:** - `python -I -B tests/run_all.py`, including the new `past_allowance` checks in `tests/test_vram_compact.cpp`: not run on this PC. The person I work for runs no test suites on it, so this is left to CI. - The check failing on main: on main `past_allowance` doesn't exist, so `test_vram_compact.cpp` doesn't build there (not run, for the same reason). - A real AMD card on Windows: the freezes come from Windows' paging, which doesn't happen on Linux. **Must be tested:** - Windows, AMD with 8 GB or less (RX 6600 class): Hyrule Field and Castle Town Market for a few minutes each at 2560x1440 output and 67% render resolution, on main and on this PR. Expecting on main `VRAM: N MB used of N MB allowed ... not squeezed` lines and slow frames of 1 s or more; on this PR `the driver's allowance is the count itself` lines, `used` falling under the allowance, and no frames over 1 s (Test Farm: @Beanstalk windows, amd, 8 GB or less: Hyrule Field and the Market, main against this PR, longshot_log.txt's `vk: VRAM:` and `slow frame` lines) ## Risks **What could break:** a driver that reports the allowance within 16 MB of the count while the process really is within it. The renderer would then give back textures it could keep: more uploads near the limit, not wrong pictures, since the eviction's own rules about what may go are unchanged. Every allowance more than 16 MB over the count is left as it is. **Turning it off:** `RX_VK_ALLOWED_AT_COUNT=0` **Compatibility:** Nothing changes: no cache, save or options file, and the renderer's interface is unchanged. ## Issues Fixes #1025 See #933 See #939 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). Not run on this PC (no test suites run on it); left to CI. - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [ ] A game-free test added for the fix, failing on `main` and passing here. Added (`tests/test_vram_compact.cpp`, its own commit first); not run on this PC. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. `tests/test_vram_compact.cpp` gains the `past_allowance` checks; the checks that read `vk_vma.cpp` cut `blocks_at_start`, `make_pool` and the pools, which are unchanged, and the ones using `vram_usage` give it a stand-in of their own. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Built on Linux (the renderer alone, with the Builder's toolchain); not yet built for Windows. The Test Farm's Windows run builds it. It adds only `<chrono>`, `<cstdio>` and `fopen` of a path from the environment (a diagnostic switch). - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The compaction's check asks past_allowance() for the RX 6600 of #1025 (5940 of
5940 MB used) and the one of #933 (6.6 of 6.6 GB), and that room_in_blocks then
lets the squeeze run. On main there is no past_allowance: the check does not build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): an allowance AMD's driver gives as the count itself is taken as past it (#1025)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval approved by HumanBean (reviewed)
PR description / Description follows the template (pull_request_target) Failing after 6s
beanstalk/windows+amd+vram-le8gb 0/1 pass, 0 running, 0 queued
10468ad564
Once a process is over what it allows, AMD's Windows driver reports the allowance
as the process's own count: an RX 6600 entered Hyrule Field at 5940 of 5940 MB,
another went from 5.3 of 6.5 GB to 6.6 of 6.6 (#933, #1025). Read as it is, the
count was within the allowance: room in the blocks kept the 97% squeeze waiting
('at the driver's limit, room in the blocks: not squeezed') and the hold's line
rose with the count, while the driver paged VRAM out: frames of 1.2-15.7 s.

vram_usage() now takes such an allowance (within 16 MB of the count) as a tenth
under the count (vram_compact::past_allowance), so every rule that reads it sees
the count past it and gives back until the driver reports an allowance over the
count again. RX_VK_ALLOWED_AT_COUNT=0 keeps the driver's word.

Two diagnostic switches reproduce it on any card: RX_VK_TEST_ALLOWED_FILE (the
test bound read from a file once a second, so it can shrink in play) and
RX_VK_TEST_ALLOWED_FOLLOW=1 (past the bound, the allowance is reported as the
count, as AMD's driver does).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Tested in game: RTX 3090, NVIDIA 620.70.06, Linux (CachyOS): Hyrule Field at 2560x1440 / 67%, the test allowance shrinking 7378 -> 5000 MB in play and reported as AMD's Windows driver does (RX_VK_TEST_ALLOWED_FILE + RX_VK_TEST_ALLOWED_FOLLOW, RX_VK_IMAGE_PREALLOC=9). Fix off: '5768 MB used of 5768 MB allowed ... not squeezed', as on the RX 6600 of #1025. Fix on: 'the driver's allowance is the count itself ... taken as 4500 MB' and the count back to 4,844-4,936 of 5,000 MB in most samples; fps the same within the spread (no paging on Linux, so the freezes need the Windows AMD run).

Tested in game: RTX 3090, NVIDIA 620.70.06, Linux (CachyOS): Hyrule Field at 2560x1440 / 67%, the test allowance shrinking 7378 -> 5000 MB in play and reported as AMD's Windows driver does (RX_VK_TEST_ALLOWED_FILE + RX_VK_TEST_ALLOWED_FOLLOW, RX_VK_IMAGE_PREALLOC=9). Fix off: '5768 MB used of 5768 MB allowed ... not squeezed', as on the RX 6600 of #1025. Fix on: 'the driver's allowance is the count itself ... taken as 4500 MB' and the count back to 4,844-4,936 of 5,000 MB in most samples; fps the same within the spread (no paging on Linux, so the freezes need the Windows AMD run).
Author
Owner

@Beanstalk windows, amd, a card with 8 GB or less (RX 6600 class): Hyrule Field and Castle Town Market, a few minutes each at 2560x1440 output and 67% render resolution with the game's own upscaler, on main and on this PR. On main I expect vk: VRAM: N MB used of N MB allowed ... (at the driver's limit, room in the blocks: not squeezed) lines and slow frames of 1 s or more once VRAM fills. On this PR I expect vk: the driver's allowance is the count itself lines, used falling under the allowance after them, and no frames over 1 s. Please keep longshot_log.txt's vk: VRAM:, vk: status: and slow frame lines from both.

@Beanstalk windows, amd, a card with 8 GB or less (RX 6600 class): Hyrule Field and Castle Town Market, a few minutes each at 2560x1440 output and 67% render resolution with the game's own upscaler, on main and on this PR. On main I expect `vk: VRAM: N MB used of N MB allowed ... (at the driver's limit, room in the blocks: not squeezed)` lines and slow frames of 1 s or more once VRAM fills. On this PR I expect `vk: the driver's allowance is the count itself` lines, `used` falling under the allowance after them, and no frames over 1 s. Please keep longshot_log.txt's `vk: VRAM:`, `vk: status:` and `slow frame` lines from both.
Member

Beanstalk test farm

Commit 10468ad · tier reviewed · approved by HumanBean · dashboard

What will be tested · AI plan (gpt-6.1-terra)

A Windows AMD PC with at most 8 GB of VRAM will run Hyrule Field and Castle Town Market for two minutes each on main and the PR; the target may wait for a matching tester. The plan measures VRAM and frame times and compares scene images; a crash, a measured frame of one second or longer on either build, or a large image difference fails the run. The farm cannot specify 2560×1440 output or identify the 67% render-resolution value from the available settings, so those requested conditions are not guaranteed. It also cannot enforce the requested side-specific log sequence or retention of selected log lines; reaching driver pressure is not guaranteed. No tester online now matches windows+amd+vram-le8gb: that target waits for one.

  • Where: windows+amd+vram-le8gb (8 GB VRAM or less, 1 report).
  • field-market: from a new save (settings dlss=0, frame_generation=0), then teleport to Hyrule Field, move the stick, take the picture field to compare with main, measure field for 2 min (after 5 s warm-up), teleport to Market, take the picture market to compare with main, measure market for 2 min (after 5 s warm-up); 1 run on each side.
  • Measured: crashes, frame times, stutters and hitches, VRAM use.
  • The PR fails if: it crashes; or a picture differs from main by more than 10%; or worst frame time is above 999.
  • Time: about 21 min of game runs per tester (2 game starts), plus the two builds.

Done. Comment @Beanstalk to run it again.

Target Reports Crash Frame p99 (ms) vs main VRAM peak (MB) vs main Result
windows+amd+vram-le8gb 0/1 — — — queued
<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `10468ad` · tier **reviewed** · approved by HumanBean · [dashboard](https://beanstalk.magicbean.dev/prs/1091) **What will be tested** · AI plan (`gpt-6.1-terra`) A Windows AMD PC with at most 8 GB of VRAM will run Hyrule Field and Castle Town Market for two minutes each on main and the PR; the target may wait for a matching tester. The plan measures VRAM and frame times and compares scene images; a crash, a measured frame of one second or longer on either build, or a large image difference fails the run. The farm cannot specify 2560×1440 output or identify the 67% render-resolution value from the available settings, so those requested conditions are not guaranteed. It also cannot enforce the requested side-specific log sequence or retention of selected log lines; reaching driver pressure is not guaranteed. No tester online now matches windows+amd+vram-le8gb: that target waits for one. - **Where:** windows+amd+vram-le8gb (8 GB VRAM or less, 1 report). - **field-market:** from a new save (settings dlss=0, frame_generation=0), then teleport to Hyrule Field, move the stick, take the picture field to compare with main, measure field for 2 min (after 5 s warm-up), teleport to Market, take the picture market to compare with main, measure market for 2 min (after 5 s warm-up); 1 run on each side. - **Measured:** crashes, frame times, stutters and hitches, VRAM use. - **The PR fails if:** it crashes; or a picture differs from main by more than 10%; or worst frame time is above 999. - **Time:** about 21 min of game runs per tester (2 game starts), plus the two builds. Done. Comment `@Beanstalk` to run it again. | Target | Reports | Crash | Frame p99 (ms) vs main | VRAM peak (MB) vs main | Result | | --- | --- | --- | --- | --- | --- | | windows+amd+vram-le8gb | 0/1 | — | — | — | queued |
Collaborator

Possibly related, for context:

  • PR #1073 WIP:perf(vk): use smaller VMA block sizes on < 7 GB GPUs — Overlapping constrained-VRAM VMA block-pressure changes
  • issue #1040 AMD Radeon 860M (APU): Kokiri Forest VK_ERROR_DEVICE_LOST without RX_VK_ASTC_CPU=1 & 4096 MB budget thrashing with it — AMD Windows iGPU report of memory-budget thrashing
Possibly related, for context: - PR #1073 WIP:perf(vk): use smaller VMA block sizes on < 7 GB GPUs — Overlapping constrained-VRAM VMA block-pressure changes - issue #1040 AMD Radeon 860M (APU): Kokiri Forest VK_ERROR_DEVICE_LOST without RX_VK_ASTC_CPU=1 & 4096 MB budget thrashing with it — AMD Windows iGPU report of memory-budget thrashing
HumanBean changed title from WIP: fix(vk): an allowance AMD's driver gives as the count itself is taken as past it to fix(vk): an allowance AMD's driver gives as the count itself is taken as past it 2026-11-16 08:01:55 +00:00
HumanBean deleted branch vram-at-count 2026-11-16 08:02:01 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!1091
No description provided.