fix(vk): cut sparse unbinds at 8 MiB so the Steam Machine stops losing the device #2998

Merged
HumanBean merged 4 commits from decohered/Longshot:fix/sparse-unbind-8mib into main 2026-12-02 21:30:40 +00:00
Contributor

Summary

If you have a Steam Machine, you've probably run into #1622: you start the game, play for a few seconds, and as soon as a sparse mirror frees up some memory, it crashes with VK_ERROR_DEVICE_LOST.

I found the culprit: it's RADV. The Mesa that SteamOS 3.10 uses binds sparse memory via the new GEM_VA2 ioctl, and when it unbinds it fills the hole from an 8 MiB buffer of zeroes -- but it does so in chunks, and each chunk's mapping is the size of the entire unbind. So if the unbind is larger than 8 MiB, it overflows the buffer, the kernel rejects it, and Vulkan reports the device as lost. I saw this happen with kprobes on my machine. #1624 made it more likely to occur because it coalesces blocks returned one at a time into one long range.

  • Mesa 26.2.0-devel (git-b73996432f), kernel 7.3.1-valve3
  • The kernel's EINVAL comes from amdgpu_vm_verify_parameters; kprobes showed the 8 MiB buffer mapped for 0x870000 bytes
  • RADV's merge of touching binds is radv_sparse_buffer_bind_memory

I implemented this in sparse_bind_infos: on RADV, it breaks up every unbind into pieces of 8 MiB or less, always at the boundaries of the mirrors' blocks, or one block per piece if the block is larger than 8 MiB. There's a small wrinkle here: RADV will coalesce touching binds that share an info, which would re-join my pieces, so each piece that touches the previous one gets its own bind info. All other drivers get exactly what main gives them.

To see it on main: a Steam Machine on SteamOS 3.10 with sparse mirrors on (the default). Start the game and play; it crashes at the first mirror give-back. RX_VK_MIRROR_SPARSE=0 works around it.

Start with sparse_bind_infos in gpu/vk/vk_memory.cpp, then tests/test_sparse_bind_ranges.py.

Fixes #1622

Testing

Tested: I've been testing this on my own Steam Machine with sparse mirrors enabled. Before the fix it would crash a few seconds in; since the fix I've had 5 logged sessions, the longest of which was 132 minutes, and I've been all over Hyrule. I've had 52,392 sparse binds with zero refused and no device lost. Those builds also included a few other changes of mine -- this hunk is the same one and applies to current main as is.

  • Steam Machine: Navi 33 8 GB, SteamOS 3.10.1, kernel 7.3.1-valve3, RADV steamos-26.05.20

  • tests/test_sparse_bind_ranges.py fails on the test commit (bda665258), on the number of bind infos the driver gets, and passes on the fix (b1a978ad9), with clang++ and g++ 16.2.0. It fails again with the separate info per piece taken out.

  • After review (f2a802ec3), the cut is RADV's only and falls on the mirrors' block edges. The test checks that NVIDIA gets main's ranges and that blocks of 3 MiB and 16 MiB are cut on their edges; it fails at dae45c625 and passes at f2a802ec3 with clang++ and g++, and fails with the RADV check or the rounding to whole blocks taken out.

  • tests/test_sparse_mirror.py and tests/test_sparse_spare.py read the same file and pass.

  • The renderer builds whole at f2a802ec3 on Linux.

  • mise run test on Linux (at b1a978ad9): 863 pass, 10 skip (Windows only), 54 fail. The same 54 fail on main @ 56823e27a with the same tools (nixpkgs' toolchain rather than mise's pinned one), so none come from this change.

    The 54

    byte_compile_tracked, f2i_immediate, global_load_16, native_suatom, test_blocks_at_start, test_bug_report, test_check_cache, test_checks_container, test_cloth_kernels, test_control_picture, test_crash_record, test_crt_options, test_dav1d_av1, test_dev_update, test_draw_stream_visibility, test_framegen_hdr, test_framegen_resources, test_fsr_uniform_ownership, test_game_boundary, test_guest_holes, test_image_reaper_threads, test_image_view_retry, test_input_background, test_keyboard_option, test_lifter, test_lifter_semantics, test_linux_pressure, test_loaded_modules_drop, test_log_levels, test_menu_keys, test_menu_save_atomic, test_native_zstd, test_oot_cloth, test_oot_occ_raster, test_option_ids, test_perf_send, test_pipeline_tour, test_present_acquire_ahead, test_present_image_free, test_present_source_crop, test_program_cache_cleanup, test_program_cache_one_variant, test_readback_timeout_reuse, test_recording_admission, test_screensaver, test_switch_table, test_target_retention, test_temporal_present_bandwidth, test_tex_desc_memo, test_thinlto_tls, test_upscaler_round_trip, test_vram_compact, test_windows_display_startup, test_windows_on_linux

Still to test:

  • Steam Deck (RADV, SteamOS): play through a few zone changes with sparse mirrors on, expecting no device lost and no blocks not bound line in the log (@Beanstalk play through a few zone changes on a Steam Deck and check the log for sparse bind failures)

Measurements

This is a crash fix and it doesn't change anything on any driver other than RADV.

Risks

This is only visible to RADV: more and smaller unbinds of the same blocks. Revert to undo it. Saves, settings, and caches are not affected.

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).
  • 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.
  • A check under tests/ that reads changed source is updated, not weakened.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary If you have a Steam Machine, you've probably run into #1622: you start the game, play for a few seconds, and as soon as a sparse mirror frees up some memory, it crashes with `VK_ERROR_DEVICE_LOST`. I found the culprit: it's RADV. The Mesa that SteamOS 3.10 uses binds sparse memory via the new GEM_VA2 ioctl, and when it unbinds it fills the hole from an 8 MiB buffer of zeroes -- but it does so in chunks, and each chunk's mapping is the size of the entire unbind. So if the unbind is larger than 8 MiB, it overflows the buffer, the kernel rejects it, and Vulkan reports the device as lost. I saw this happen with kprobes on my machine. #1624 made it more likely to occur because it coalesces blocks returned one at a time into one long range. - Mesa 26.2.0-devel (git-b73996432f), kernel 7.3.1-valve3 - The kernel's EINVAL comes from `amdgpu_vm_verify_parameters`; kprobes showed the 8 MiB buffer mapped for 0x870000 bytes - RADV's merge of touching binds is `radv_sparse_buffer_bind_memory` I implemented this in `sparse_bind_infos`: on RADV, it breaks up every unbind into pieces of 8 MiB or less, always at the boundaries of the mirrors' blocks, or one block per piece if the block is larger than 8 MiB. There's a small wrinkle here: RADV will coalesce touching binds that share an info, which would re-join my pieces, so each piece that touches the previous one gets its own bind info. All other drivers get exactly what main gives them. To see it on main: a Steam Machine on SteamOS 3.10 with sparse mirrors on (the default). Start the game and play; it crashes at the first mirror give-back. `RX_VK_MIRROR_SPARSE=0` works around it. Start with `sparse_bind_infos` in `gpu/vk/vk_memory.cpp`, then `tests/test_sparse_bind_ranges.py`. Fixes #1622 ## Testing **Tested:** I've been testing this on my own Steam Machine with sparse mirrors enabled. Before the fix it would crash a few seconds in; since the fix I've had 5 logged sessions, the longest of which was 132 minutes, and I've been all over Hyrule. I've had 52,392 sparse binds with zero refused and no device lost. Those builds also included a few other changes of mine -- this hunk is the same one and applies to current main as is. - Steam Machine: Navi 33 8 GB, SteamOS 3.10.1, kernel 7.3.1-valve3, RADV steamos-26.05.20 - `tests/test_sparse_bind_ranges.py` fails on the test commit (bda665258), on the number of bind infos the driver gets, and passes on the fix (b1a978ad9), with clang++ and g++ 16.2.0. It fails again with the separate info per piece taken out. - After review (f2a802ec3), the cut is RADV's only and falls on the mirrors' block edges. The test checks that NVIDIA gets main's ranges and that blocks of 3 MiB and 16 MiB are cut on their edges; it fails at dae45c625 and passes at f2a802ec3 with clang++ and g++, and fails with the RADV check or the rounding to whole blocks taken out. - `tests/test_sparse_mirror.py` and `tests/test_sparse_spare.py` read the same file and pass. - The renderer builds whole at f2a802ec3 on Linux. - `mise run test` on Linux (at b1a978ad9): 863 pass, 10 skip (Windows only), 54 fail. The same 54 fail on main @ 56823e27a with the same tools (nixpkgs' toolchain rather than mise's pinned one), so none come from this change. <details><summary>The 54</summary> byte_compile_tracked, f2i_immediate, global_load_16, native_suatom, test_blocks_at_start, test_bug_report, test_check_cache, test_checks_container, test_cloth_kernels, test_control_picture, test_crash_record, test_crt_options, test_dav1d_av1, test_dev_update, test_draw_stream_visibility, test_framegen_hdr, test_framegen_resources, test_fsr_uniform_ownership, test_game_boundary, test_guest_holes, test_image_reaper_threads, test_image_view_retry, test_input_background, test_keyboard_option, test_lifter, test_lifter_semantics, test_linux_pressure, test_loaded_modules_drop, test_log_levels, test_menu_keys, test_menu_save_atomic, test_native_zstd, test_oot_cloth, test_oot_occ_raster, test_option_ids, test_perf_send, test_pipeline_tour, test_present_acquire_ahead, test_present_image_free, test_present_source_crop, test_program_cache_cleanup, test_program_cache_one_variant, test_readback_timeout_reuse, test_recording_admission, test_screensaver, test_switch_table, test_target_retention, test_temporal_present_bandwidth, test_tex_desc_memo, test_thinlto_tls, test_upscaler_round_trip, test_vram_compact, test_windows_display_startup, test_windows_on_linux </details> **Still to test:** - Steam Deck (RADV, SteamOS): play through a few zone changes with sparse mirrors on, expecting no device lost and no `blocks not bound` line in the log (@Beanstalk play through a few zone changes on a Steam Deck and check the log for sparse bind failures) ## Measurements This is a crash fix and it doesn't change anything on any driver other than RADV. ## Risks This is only visible to RADV: more and smaller unbinds of the same blocks. Revert to undo it. Saves, settings, and caches are not affected. ## 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. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [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. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test_sparse_bind_ranges feeds sparse_bind_infos 160 blocks of 64 KB given back
one by one, a mirror's 20 MiB run given back in one bind, a 16 MiB bind with
memory, and two unbinds that do not meet, and checks what reaches
vkQueueBindSparse: unbinds of 8 + 2 MiB in two infos, 8 + 8 + 4 MiB in three,
the bind with memory whole, the two apart in one info. It fails on main, which
merges the blocks into one 10 MiB unbind and hands the 20 MiB run over whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
fix(vk): unbind sparse mirrors in ranges of at most 8 MiB, each in its own bind info, so RADV's GEM_VA2 path no longer loses the device (#1622)
Some checks failed
PR description / Title and description (pull_request_target) Successful in 4s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
b1a978ad93
On SteamOS 3.10 (kernel 7.3.1-valve3, Mesa 26.2.0-devel git-b73996432f) RADV
binds sparse memory through the kernel's new GEM_VA2 ioctl. For a
sparse-resident buffer on every generation but GFX9 it maps the unbound blocks
from its 8 MiB zeroed buffer in chunks, but each chunk's mapping keeps the
whole unbind's size, so the kernel refuses an unbind over 8 MiB with EINVAL
(amdgpu_vm_verify_parameters: offset + size past that buffer) and
vkQueueBindSparse returns VK_ERROR_DEVICE_LOST. On a Steam Machine (Navi 33)
the game closed at the first sparse mirror given back, a run of 20 MB; kernel
probes showed the refused mapping, the 8 MiB buffer mapped for 0x870000 bytes.

sparse_bind_infos now cuts every unbind (a range with no memory) at 8 MiB,
merged or given in one bind, and puts each piece that meets the unbind before
it in a VkSparseBufferMemoryBindInfo of its own: RADV joins an info's
consecutive binds that meet (radv_sparse_buffer_bind_memory), unbinds
included, which undid the cut within one info. On every driver: a few more
ranges and infos for the same blocks. Binds with memory are merged as before.
Until now the workaround was RX_VK_MIRROR_SPARSE=0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Member

Possibly related, for context:

  • PR #2002 WIP: perf(vk): a sparse mirror's block span by shifts for a power-of-two block — Touches sparse mirror helpers and the same sparse-bind range test, but optimizes block-span calculations rather than unbind chunking.
  • PR #2892 WIP: perf(vk): sparse mirror binds stop holding frames: unbinds unwaited, give-back capped, new mirrors bound together — Sparse mirror bind/unbind work in the same vk_memory.cpp path; closed unmerged, not active overlap.
Possibly related, for context: - PR #2002 WIP: perf(vk): a sparse mirror's block span by shifts for a power-of-two block — Touches sparse mirror helpers and the same sparse-bind range test, but optimizes block-span calculations rather than unbind chunking. - PR #2892 WIP: perf(vk): sparse mirror binds stop holding frames: unbinds unwaited, give-back capped, new mirrors bound together — Sparse mirror bind/unbind work in the same vk_memory.cpp path; closed unmerged, not active overlap.
decohered changed title from WIP: fix(vk): unbind sparse mirrors in ranges of at most 8 MiB, so RADV on SteamOS 3.10 no longer loses the device to fix(vk): cut sparse unbinds at 8 MiB so the Steam Machine stops losing the device 2026-12-02 07:12:54 +00:00
Member
@review
BeanBot left a comment

Recommendation: Approve. The reported Steam Machine sessions support the fix, but the other Tier 1 systems whose sparse binds this changes still need coverage. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The change limits sparse unbinds to 8 MiB and separates touching pieces into bind infos, avoiding the reported RADV device loss. It adds bind ranges and infos on all drivers, with an unmeasured effect on give-back frame times.

Should fix (1): not blocking, but worth doing before merging.

  • L1 gpu/vk/vk_memory.cpp:4570: The fixed 8 MiB split does not account for the buffer's sparse block alignment. (more on the line) Do: Carry the sparse buffer alignment into this path and avoid creating sub-block unbinds; fall back from sparse mirrors when the affected driver cannot accept an aligned unbind within the limit.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 gpu/vk/vk_memory.cpp:4578: The additional bind infos are submitted on Windows AMD and NVIDIA without reported game or frame-time coverage. (more on the line) Do: Run the requested zone-change comparisons on AMD and NVIDIA Windows against the base, recording sparse bind activity and frame times. (@fix does its part first: Restrict the workaround to the affected driver path to remove the extra infos on unaffected systems.)
  • L3 gpu/vk/vk_memory.cpp:4578: Linux NVIDIA and Steam Deck coverage is also missing for the changed sparse submission path. (more on the line) Do: Run sparse-mirror zone changes on Linux NVIDIA and Steam Deck against the base, checking for bind failures and comparing give-back frame times. (@fix does its part first: Restrict the workaround to the affected driver path where it can be identified reliably.)

@fix can do L1, L2 and L3.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • gpu/vk/vk_memory.cpp:4543: Is there a reason to expect the other changes in the tested builds were necessary to prevent the device loss?

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven for this head: the author reports five sessions and 52,392 sparse binds without a device loss on a build containing this hunk and other changes. The game-free test checks the submitted ranges and reportedly fails without the fix.

Other systems: Sparse mirrors use this path on Windows and Linux when the device supports them. AMD and NVIDIA Windows, NVIDIA Linux, and Steam Deck coverage remains outstanding; the additional bind infos can affect driver work and frame pacing. Saves, audio, input and builds do not use the changed path.

Switches: None added, changed or removed. Existing RX_VK_MIRROR_SPARSE defaults on where supported and can disable sparse mirrors.

Reviewed: b1a978ad93 against 56823e27a1: Read the repository rules, PR template, standards, commits, full test, changed function and its sparse mirror callers and lifetime handling. Skimmed other portions of the 7,833-line vk_memory.cpp; it was not read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).

Checked and fine:

  • The test covers merged block unbinds, a single long unbind, bound memory and non-touching unbinds, and checks the structures passed to the queue.
  • The input bind arrays remain owned by the callers; reserved range storage keeps pointers stable for the submitted infos under the normal buffer-size bounds.
  • Both commits record AI assistance, and the diff contains no game-derived files, generated files or renderer API changes.

Testing: No commands from the project, builds or tests were run during review. CI is still running; the author's test results are reported in the PR.

Overlaps and merge order: Not checked; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The reported Steam Machine sessions support the fix, but the other Tier 1 systems whose sparse binds this changes still need coverage. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The change limits sparse unbinds to 8 MiB and separates touching pieces into bind infos, avoiding the reported RADV device loss. It adds bind ranges and infos on all drivers, with an unmeasured effect on give-back frame times. **Should fix (1)**: not blocking, but worth doing before merging. - **L1** `gpu/vk/vk_memory.cpp:4570`: The fixed 8 MiB split does not account for the buffer's sparse block alignment. (more on the line) **Do:** Carry the sparse buffer alignment into this path and avoid creating sub-block unbinds; fall back from sparse mirrors when the affected driver cannot accept an aligned unbind within the limit. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `gpu/vk/vk_memory.cpp:4578`: The additional bind infos are submitted on Windows AMD and NVIDIA without reported game or frame-time coverage. (more on the line) **Do:** Run the requested zone-change comparisons on AMD and NVIDIA Windows against the base, recording sparse bind activity and frame times. *(`@fix` does its part first: Restrict the workaround to the affected driver path to remove the extra infos on unaffected systems.)* - **L3** `gpu/vk/vk_memory.cpp:4578`: Linux NVIDIA and Steam Deck coverage is also missing for the changed sparse submission path. (more on the line) **Do:** Run sparse-mirror zone changes on Linux NVIDIA and Steam Deck against the base, checking for bind failures and comparing give-back frame times. *(`@fix` does its part first: Restrict the workaround to the affected driver path where it can be identified reliably.)* `@fix` can do L1, L2 and L3. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - `gpu/vk/vk_memory.cpp:4543`: Is there a reason to expect the other changes in the tested builds were necessary to prevent the device loss? **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for this head: the author reports five sessions and 52,392 sparse binds without a device loss on a build containing this hunk and other changes. The game-free test checks the submitted ranges and reportedly fails without the fix. **Other systems:** Sparse mirrors use this path on Windows and Linux when the device supports them. AMD and NVIDIA Windows, NVIDIA Linux, and Steam Deck coverage remains outstanding; the additional bind infos can affect driver work and frame pacing. Saves, audio, input and builds do not use the changed path. **Switches:** None added, changed or removed. Existing RX_VK_MIRROR_SPARSE defaults on where supported and can disable sparse mirrors. **Reviewed:** b1a978ad9361 against 56823e27a13a: Read the repository rules, PR template, standards, commits, full test, changed function and its sparse mirror callers and lifetime handling. Skimmed other portions of the 7,833-line vk_memory.cpp; it was not read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review). **Checked and fine:** - The test covers merged block unbinds, a single long unbind, bound memory and non-touching unbinds, and checks the structures passed to the queue. - The input bind arrays remain owned by the callers; reserved range storage keeps pointers stable for the submitted infos under the normal buffer-size bounds. - Both commits record AI assistance, and the diff contains no game-derived files, generated files or renderer API changes. **Testing:** No commands from the project, builds or tests were run during review. CI is still running; the author's test results are reported in the PR. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
@ -4555,2 +4567,4 @@
}
for (; !b.memory && b.size > kUnbindMost; b.resourceOffset += kUnbindMost, b.size -= kUnbindMost)
ranges.push_back({b.resourceOffset, kUnbindMost, VK_NULL_HANDLE, 0, b.flags});
ranges.push_back(b);
Member

L1 (should fix): The fixed 8 MiB split does not account for the buffer's sparse block alignment.

When: If a device reports a sparse buffer alignment greater than 8 MiB, a released block or spare-mirror range is split at an offset smaller than that alignment. The resulting sparse binds violate Vulkan's alignment requirements and may be rejected or produce undefined behavior.

Do: Carry the sparse buffer alignment into this path and avoid creating sub-block unbinds; fall back from sparse mirrors when the affected driver cannot accept an aligned unbind within the limit.

**L1** (should fix): The fixed 8 MiB split does not account for the buffer's sparse block alignment. *When:* If a device reports a sparse buffer alignment greater than 8 MiB, a released block or spare-mirror range is split at an offset smaller than that alignment. The resulting sparse binds violate Vulkan's alignment requirements and may be rejected or produce undefined behavior. **Do:** Carry the sparse buffer alignment into this path and avoid creating sub-block unbinds; fall back from sparse mirrors when the affected driver cannot accept an aligned unbind within the limit.
@ -4560,1 +4575,4 @@
if (k == first || meets) cut.push_back({info.buffer, 0, ranges.data() + k});
cut.back().bindCount++;
}
}
Member

L2 (should fix): The additional bind infos are submitted on Windows AMD and NVIDIA without reported game or frame-time coverage.

When: During mirror give-backs, these drivers receive more bind infos than on main; their handling and the effect on frame pacing have not been measured.

Do: Run the requested zone-change comparisons on AMD and NVIDIA Windows against the base, recording sparse bind activity and frame times.

**L2** (should fix): The additional bind infos are submitted on Windows AMD and NVIDIA without reported game or frame-time coverage. *When:* During mirror give-backs, these drivers receive more bind infos than on main; their handling and the effect on frame pacing have not been measured. **Do:** Run the requested zone-change comparisons on AMD and NVIDIA Windows against the base, recording sparse bind activity and frame times.
Member

L3 (should fix): Linux NVIDIA and Steam Deck coverage is also missing for the changed sparse submission path.

When: Where sparse mirrors are supported, give-backs submit the new ranges and infos on these Tier 1 systems too; no run shows their behavior or frame-time cost.

Do: Run sparse-mirror zone changes on Linux NVIDIA and Steam Deck against the base, checking for bind failures and comparing give-back frame times.

**L3** (should fix): Linux NVIDIA and Steam Deck coverage is also missing for the changed sparse submission path. *When:* Where sparse mirrors are supported, give-backs submit the new ranges and infos on these Tier 1 systems too; no run shows their behavior or frame-time cost. **Do:** Run sparse-mirror zone changes on Linux NVIDIA and Steam Deck against the base, checking for bind failures and comparing give-back frame times.
Owner
@fix
Member

I didn't fix this pull request: it doesn't allow edits from maintainers (the author can turn on Allow edits from maintainers).


Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

I didn't fix this pull request: it doesn't allow edits from maintainers (the author can turn on *Allow edits from maintainers*). --- <sub>Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
test_sparse_bind_ranges: another driver (NVIDIA's) gets main's ranges, the
160 blocks of 64 KB in one 10 MiB unbind and a 20 MiB run whole, one info
each; on RADV a cut falls on the mirrors' block edges, pieces of 6 MiB for
blocks of 3 MiB and one block each for blocks of 16 MiB. It fails on the head
before it, which cuts every driver's unbinds at 8 MiB whatever the block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): cut sparse unbinds at 8 MiB on RADV only, on the mirrors' block edges (#1622)
Some checks are pending
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 / 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 / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 7s
f2a802ec34
Review of #2998 (BeanBot, L1-L3): the cut at a fixed 8 MiB could fall inside a
block on a device whose sparse block is larger, and every driver got the
extra ranges and bind infos though only RADV needs them.

sparse_bind_infos now cuts only when the driver is RADV (dev.driver_id), and
at the largest whole number of the mirrors' blocks within 8 MiB, or one block
when a block is larger. sparse_fill notes the block (sparse_unbind_block, the
largest seen; alignments are powers of two, so every mirror's block divides
it). Another driver's ranges and infos are main's again.

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

I pushed f2a802ec3 which fixes L1-L3. The cut is now only on RADV and it's on the mirrors' block edges, so a block larger than 8 MiB is never split. All other drivers get the same ranges and bind info as main, so we no longer need to run Windows or NVIDIA. The test covers both: NVIDIA gets main's ranges, and blocks of 3 MiB and 16 MiB get cut correctly.

To answer your question: no, the other changes were not necessary. The build that fixed the crash was 805 nightly with this commit on top and no other changes.

I pushed f2a802ec3 which fixes L1-L3. The cut is now only on RADV and it's on the mirrors' block edges, so a block larger than 8 MiB is never split. All other drivers get the same ranges and bind info as main, so we no longer need to run Windows or NVIDIA. The test covers both: NVIDIA gets main's ranges, and blocks of 3 MiB and 16 MiB get cut correctly. To answer your question: no, the other changes were not necessary. The build that fixed the crash was 805 nightly with this commit on top and no other changes.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The RADV workaround preserves sparse block boundaries and avoids changing other drivers’ submitted ranges. The reported Steam Machine sessions support the crash fix, but Steam Deck testing and the required CI checks are still pending. Nothing blocking is left. Recommend approval; not approved on the forge.

The change limits RADV sparse unbind ranges to avoid the reported device loss, while keeping cuts on mirror block boundaries. It adds bind infos on RADV and test coverage for the packing behavior.

Since the last review (on b1a978ad93)
Resolved: L1 (The fixed 8 MiB split does not account for the buffer's sparse block alignment.); L2 (The additional bind infos are submitted on Windows AMD and NVIDIA without reported game or…); L3 (Linux NVIDIA and Steam Deck coverage is also missing for the changed sparse submission pat…)

Checks: Still running: 10 checks.

Also noticed (2; not asked for, not blocking)
  • A Steam Deck playthrough with sparse mirrors enabled and a check for bind failures remain useful before merge.
  • The listed CI checks are still running.
More: does it help, other systems, switches, what was read

Does it help: Yes: the author reports five Steam Machine sessions, up to 132 minutes and 52,392 sparse binds without a device loss, compared with a crash within seconds before the fix. The author says the successful build contained this change on top of nightly 805.

Other systems: The cut and additional bind infos are limited to RADV; other drivers retain the original ranges. Steam Deck also uses RADV and still needs the requested game run; Windows and NVIDIA no longer receive the workaround.

Switches: None added, changed or removed. The existing RX_VK_MIRROR_SPARSE switch controls sparse mirrors.

Reviewed: f2a802ec34 against 56823e27a1: Read the changed sparse submission and mirror-fill code, its unbind callers, the full sparse range test, the diff and commits, AGENTS.md and CONTRIBUTING.md. The rest of vk_memory.cpp and the referenced developer standards were not read in full.; nothing run (a code review).

Checked and fine:

  • The test covers RADV range splitting, separate infos for touching unbinds, block-sized cuts and unchanged NVIDIA ranges.
  • The submission retains the original bind lists for callers and preserves timeline signaling on success.

Testing: No commands from the project or tests were run. The author reports a Linux renderer build and game-free tests at the current head; the Steam Deck run and CI results are pending.

Overlaps and merge order: Not checked; network access is unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The RADV workaround preserves sparse block boundaries and avoids changing other drivers’ submitted ranges. The reported Steam Machine sessions support the crash fix, but Steam Deck testing and the required CI checks are still pending. Nothing blocking is left. Recommend approval; not approved on the forge. The change limits RADV sparse unbind ranges to avoid the reported device loss, while keeping cuts on mirror block boundaries. It adds bind infos on RADV and test coverage for the packing behavior. **Since the last review** (on b1a978ad9361) Resolved: L1 (The fixed 8 MiB split does not account for the buffer's sparse block alignment.); L2 (The additional bind infos are submitted on Windows AMD and NVIDIA without reported game or…); L3 (Linux NVIDIA and Steam Deck coverage is also missing for the changed sparse submission pat…) **Checks:** Still running: 10 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - A Steam Deck playthrough with sparse mirrors enabled and a check for bind failures remain useful before merge. - The listed CI checks are still running. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author reports five Steam Machine sessions, up to 132 minutes and 52,392 sparse binds without a device loss, compared with a crash within seconds before the fix. The author says the successful build contained this change on top of nightly 805. **Other systems:** The cut and additional bind infos are limited to RADV; other drivers retain the original ranges. Steam Deck also uses RADV and still needs the requested game run; Windows and NVIDIA no longer receive the workaround. **Switches:** None added, changed or removed. The existing RX_VK_MIRROR_SPARSE switch controls sparse mirrors. **Reviewed:** f2a802ec348a against 56823e27a13a: Read the changed sparse submission and mirror-fill code, its unbind callers, the full sparse range test, the diff and commits, AGENTS.md and CONTRIBUTING.md. The rest of vk_memory.cpp and the referenced developer standards were not read in full.; nothing run (a code review). **Checked and fine:** - The test covers RADV range splitting, separate infos for touching unbinds, block-sized cuts and unchanged NVIDIA ranges. - The submission retains the original bind lists for callers and preserves timeline signaling on success. **Testing:** No commands from the project or tests were run. The author reports a Linux renderer build and game-free tests at the current head; the Steam Deck run and CI results are pending. **Overlaps and merge order:** Not checked; network access is unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch fix/sparse-unbind-8mib 2026-12-02 21:30:40 +00:00
Some checks are pending
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 / 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 / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 7s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!2998
No description provided.