fix(vk): 256 MB of pool mirrors, none past 90% VRAM, on AMD's Windows driver on GCN; sparse_keep's Auto off #3331

Open
tobim6 wants to merge 1 commit from tobim6/Longshot:mirror-small into main
Contributor

Summary

Follow-up to #3256, which did not fix what it was for. AMD's Windows driver on GCN 1-4 (RX 400/500) stops the whole PC
with a bugcheck in amdkmdag.sys (0x50 PAGE_FAULT_IN_NONPAGED_AREA, or 0x7E with C0000005). Every kernel dump has
the same stack, symbolized against Microsoft's dxgmms2.sys symbols:

VidMmWorkerThreadProc → VIDMM_GLOBAL::PageInOneAllocation → CommitVirtualAddressRange
 → VIDMM_PAGE_TABLE::Convert64K_4K → VIDMM_PAGE_TABLE::UpdatePageTable
 → ADAPTER_RENDER::DdiBuildPagingBuffer → amdkmdag.sys+0x23fa0

Windows pages an allocation in, has to demote a page table from 64 KB to 4 KB entries, and AMD's driver faults building
that update. Anything that makes Windows page in or remap is a chance at it: mirrors made and freed, sparse blocks bound
and unbound, and evictions when the process is past what the driver allows.

#3256 removed one of those (sparse block give-backs). With it, the same RX 580 bugchecked twice more with the same stack,
and an RX 580 2048SP on AMD's current driver lost frames to it. What kept both cards up: RX_VK_MIRROR_TIGHT=1 with
RX_VK_MIRROR_MB=256, which on the 2048SP cost no frame rate. Few mirrors are few made, freed, bound and evicted.

This makes those two the default there: device_policy.h mirror_small (f.amd_win() && f.arch() == GpuArch::AmdGcn, the devices #3256 used) makes mirror_budget()'s Auto 256 MB and turns on RX_VK_MIRROR_TIGHT's rule
(no mirror, and no trim's parts, while VRAM is over 90% of the allowance). sparse_keep's Auto goes back to off
everywhere; its setting still turns it on. A hidden setting, system/memory-settings:mirror_small (RX_VK_MIRROR_SMALL,
Auto/Off/On), overrides the new rule; mirror_budget_mb still sets the budget outright.

Read first: gpu/vk/device_policy.h (mirror_small, the rule line, sparse_keep's note), gpu/vk/vk_memory.cpp
(mirror_budget(), the two tight_rule lines).

Testing

Tested: Windows 11 (build 26200), RX 580 8 GB, Adrenalin 23.10.01.14 (driver 0x800106): RX_VK_MIRROR_TIGHT=1 with RX_VK_MIRROR_MB=256 (what this makes the default there), on a build with #3256: no bugcheck in a session like the ones that bugchecked; with #3256 alone, two more bugchecks with the stack above. An RX 580 2048SP 8 GB on AMD's current driver (Discord): the same two switches without #3256, no bugcheck and no frame-rate loss; #3256 cost it frames.

Kernel dumps: three with the stack above on the RX 580 (0x800106), one of them with #3256's sparse_keep on and the
session's log showing given back 0. Game-free checks: schema-gen --check; tests/test_device_policy.py (the new field
on all 26 PCs, its switch cases, rule edges: on for GCN 0x67DF/0x6FDF on AMD's Windows driver, off for Vega 0x687F, RDNA,
Linux and RADV; sparse_keep off by its rule), test_mirror_budget.py (256 MB under mirror_small, after the setting; the
tight rule at both sites), test_switch_table.py, test_menu_ini_keys.py, test_i18n_complete.py, test_sparse_mirror.py,
test_mirror_trim.py, test_mirror_gpu_only.py pass. The full suite: CI's tests job on this PR.

Still to test:

  • Windows, AMD RDNA: nothing changes, mirror_small off in the log (@Beanstalk)

Measurements

Frame rate on an RX 580 2048SP (AMD's current driver), from the Discord report: the two switches cost nothing measurable, and #3256 cost frames; no capture of my own.

Risks

  • Only AMD's Windows driver on GCN 1-4 changes the mirrors; elsewhere mirror_small is off and mirrors are as on main.
  • There, pools past 256 MB of mirrors are read in system memory: slower for a pool the GPU binds much. The 2048SP saw no
    loss; mirror_budget_mb or mirror_small Off restores main's budget.
  • sparse_keep off everywhere is main before #3256.
  • Settings: a new hidden key, mirror_small, in settings.toml's options; LS_SETTINGS_LAYOUT changes (schema-gen).
    Revert is enough to undo.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (CI's tests job: ticked once it passes)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. (test_device_policy.py's mirror_small rule edges, test_mirror_budget.py)
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def. (a SETTING row; Auto)
  • A check under tests/ that reads changed source is updated, not weakened. (test_device_policy.py, test_menu_ini_keys.py, test_mirror_budget.py)
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: built for the test above; CI builds Linux)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

🤖 Generated with Claude Code

## Summary Follow-up to #3256, which did not fix what it was for. AMD's Windows driver on GCN 1-4 (RX 400/500) stops the whole PC with a bugcheck in `amdkmdag.sys` (0x50 `PAGE_FAULT_IN_NONPAGED_AREA`, or 0x7E with `C0000005`). Every kernel dump has the same stack, symbolized against Microsoft's `dxgmms2.sys` symbols: ``` VidMmWorkerThreadProc → VIDMM_GLOBAL::PageInOneAllocation → CommitVirtualAddressRange → VIDMM_PAGE_TABLE::Convert64K_4K → VIDMM_PAGE_TABLE::UpdatePageTable → ADAPTER_RENDER::DdiBuildPagingBuffer → amdkmdag.sys+0x23fa0 ``` Windows pages an allocation in, has to demote a page table from 64 KB to 4 KB entries, and AMD's driver faults building that update. Anything that makes Windows page in or remap is a chance at it: mirrors made and freed, sparse blocks bound and unbound, and evictions when the process is past what the driver allows. #3256 removed one of those (sparse block give-backs). With it, the same RX 580 bugchecked twice more with the same stack, and an RX 580 2048SP on AMD's current driver lost frames to it. What kept both cards up: `RX_VK_MIRROR_TIGHT=1` with `RX_VK_MIRROR_MB=256`, which on the 2048SP cost no frame rate. Few mirrors are few made, freed, bound and evicted. This makes those two the default there: `device_policy.h` `mirror_small` (`f.amd_win() && f.arch() == GpuArch::AmdGcn`, the devices #3256 used) makes `mirror_budget()`'s Auto 256 MB and turns on `RX_VK_MIRROR_TIGHT`'s rule (no mirror, and no trim's parts, while VRAM is over 90% of the allowance). `sparse_keep`'s Auto goes back to off everywhere; its setting still turns it on. A hidden setting, `system/memory-settings:mirror_small` (`RX_VK_MIRROR_SMALL`, Auto/Off/On), overrides the new rule; `mirror_budget_mb` still sets the budget outright. Read first: `gpu/vk/device_policy.h` (`mirror_small`, the rule line, `sparse_keep`'s note), `gpu/vk/vk_memory.cpp` (`mirror_budget()`, the two `tight_rule` lines). ## Testing **Tested:** Windows 11 (build 26200), RX 580 8 GB, Adrenalin 23.10.01.14 (driver 0x800106): RX_VK_MIRROR_TIGHT=1 with RX_VK_MIRROR_MB=256 (what this makes the default there), on a build with #3256: no bugcheck in a session like the ones that bugchecked; with #3256 alone, two more bugchecks with the stack above. An RX 580 2048SP 8 GB on AMD's current driver (Discord): the same two switches without #3256, no bugcheck and no frame-rate loss; #3256 cost it frames. Kernel dumps: three with the stack above on the RX 580 (0x800106), one of them with #3256's `sparse_keep` on and the session's log showing `given back 0`. Game-free checks: `schema-gen --check`; `tests/test_device_policy.py` (the new field on all 26 PCs, its switch cases, rule edges: on for GCN 0x67DF/0x6FDF on AMD's Windows driver, off for Vega 0x687F, RDNA, Linux and RADV; `sparse_keep` off by its rule), `test_mirror_budget.py` (256 MB under `mirror_small`, after the setting; the tight rule at both sites), `test_switch_table.py`, `test_menu_ini_keys.py`, `test_i18n_complete.py`, `test_sparse_mirror.py`, `test_mirror_trim.py`, `test_mirror_gpu_only.py` pass. The full suite: CI's `tests` job on this PR. **Still to test:** - Windows, AMD RDNA: nothing changes, `mirror_small` off in the log (@Beanstalk) ## Measurements Frame rate on an RX 580 2048SP (AMD's current driver), from the Discord report: the two switches cost nothing measurable, and #3256 cost frames; no capture of my own. ## Risks - Only AMD's Windows driver on GCN 1-4 changes the mirrors; elsewhere `mirror_small` is off and mirrors are as on `main`. - There, pools past 256 MB of mirrors are read in system memory: slower for a pool the GPU binds much. The 2048SP saw no loss; `mirror_budget_mb` or `mirror_small` Off restores `main`'s budget. - `sparse_keep` off everywhere is `main` before #3256. - Settings: a new hidden key, `mirror_small`, in `settings.toml`'s options; `LS_SETTINGS_LAYOUT` changes (schema-gen). Revert is enough to undo. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). (CI's `tests` job: ticked once it passes) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. (`test_device_policy.py`'s `mirror_small` rule edges, `test_mirror_budget.py`) - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. (a `SETTING` row; Auto) - [x] A check under `tests/` that reads changed source is updated, not weakened. (`test_device_policy.py`, `test_menu_ini_keys.py`, `test_mirror_budget.py`) - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: built for the test above; CI builds Linux) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(vk): 256 MB of pool mirrors, none past 90% VRAM, on AMD's Windows driver on GCN; sparse_keep's Auto off
Some checks are pending
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
f2eb221270
AMD's Windows driver on GCN stops the system (amdkmdag.sys, 0x50 and 0x7E) building
the page-table update for Windows' VIDMM_PAGE_TABLE::Convert64K_4K as it pages an
allocation in. #3256 kept sparse mirror blocks bound on that driver: it still
crashed (two more kernel dumps, the same stack, an RX 580 on 0x800106), and it
cost frames on an RX 580 2048SP on AMD's current driver.

What kept that driver up, on both cards: RX_VK_MIRROR_TIGHT=1 with
RX_VK_MIRROR_MB=256, the 2048SP at no frame-rate cost. Few mirrors are few made,
freed, bound and evicted: few page-ins and page-table changes.

device_policy.h mirror_small (Auto on there, system/memory-settings:mirror_small,
RX_VK_MIRROR_SMALL) makes those two the default: mirror_budget()'s Auto is 256 MB,
and RX_VK_MIRROR_TIGHT's rule is on for the mirrors and their trims. sparse_keep's
Auto is off everywhere; its setting still turns it on.

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

Tested in game: Windows 11 (build 26200), RX 580 8 GB, Adrenalin 23.10.01.14 (driver 0x800106): RX_VK_MIRROR_TIGHT=1 with RX_VK_MIRROR_MB=256 (what this makes the default there), on a build with #3256: no bugcheck in a session like the ones that bugchecked; with #3256 alone, two more bugchecks with the stack above. An RX 580 2048SP 8 GB on AMD's current driver (Discord): the same two switches without #3256, no bugcheck and no frame-rate loss; #3256 cost it frames.

Tested in game: Windows 11 (build 26200), RX 580 8 GB, Adrenalin 23.10.01.14 (driver 0x800106): RX_VK_MIRROR_TIGHT=1 with RX_VK_MIRROR_MB=256 (what this makes the default there), on a build with #3256: no bugcheck in a session like the ones that bugchecked; with #3256 alone, two more bugchecks with the stack above. An RX 580 2048SP 8 GB on AMD's current driver (Discord): the same two switches without #3256, no bugcheck and no frame-rate loss; #3256 cost it frames.
Member

Possibly related, for context:

  • issue #2520 Idea: Fix BC array foliage corruption on RX 580 2048SP and reduce traversal stutter — Open RX 580 2048SP report includes related amdkmdag driver faults and memory-pressure concerns
Possibly related, for context: - issue #2520 Idea: Fix BC array foliage corruption on RX 580 2048SP and reduce traversal stutter — Open RX 580 2048SP report includes related amdkmdag driver faults and memory-pressure concerns
tobim6 changed title from WIP: fix(vk): 256 MB of pool mirrors, none past 90% VRAM, on AMD's Windows driver on GCN; sparse_keep's Auto off to fix(vk): 256 MB of pool mirrors, none past 90% VRAM, on AMD's Windows driver on GCN; sparse_keep's Auto off 2026-12-06 10:01:34 +00:00
Some checks are pending
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'mirror-small:tobim6-mirror-small'
git switch 'tobim6-mirror-small'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!3331
No description provided.