WIP: fix(vk): decode ASTC on the CPU for the Radeon 860M #1296

Draft
TrashPanda wants to merge 3 commits from TrashPanda/Longshot:fix/astc-cpu-860m into main
Contributor

Type: fix · Risk: low · Tested on: Linux, game-free only (g++ and clang++) · Needs: Windows, Radeon 860M

Why

A Radeon 860M (PCI 1002:1114) loses the device in Kokiri Forest while the GPU decodes two 1365x1365x90 ASTC arrays. The same arrays already force CPU decode on the Ryzen 7000 and 9000 desktop iGPUs (PCI 1002:164E and 1002:13C0). The 860M was not in that list, so it still used the GPU decoder. RX_VK_ASTC_CPU=1 avoids the loss. See #1040.

The 4,096 MB integrated-GPU texture cap is unchanged. CPU decode stores those arrays as RGBA8, about 5.2-6 GB, so a 32 GB PC can still thrash until RX_VK_VRAM_MB is raised. That cap applies to every integrated GPU.

How to reproduce

Seen on: Windows 11, Radeon 860M (1002:1114), AMD driver 26.10.1, 32 GB RAM. Reported in #1040. Not run on this PC.
Settings and switches: defaults. No RX_VK_ASTC_CPU.
Steps: load Kokiri Forest so the two 1365x1365x90 terrain arrays decode on the GPU.
Expected: the area loads. The log says ASTC is decoded on the CPU.
Actual: VK_ERROR_DEVICE_LOST after the GPU stalls on those arrays.

What changed

On Windows, astc_on_cpu() in gpu/vk/vk_texture.cpp also defaults to the CPU for PCI 1002:1114. RX_VK_ASTC_CPU=0 still forces the GPU decoder, and =1 still forces the CPU on every GPU. Other APUs (680M, 780M, 890M) are unchanged. The texture budget is unchanged.

Measurements

Verdict: the game-free check fails on main and passes here. No game run. Nothing was measured in Kokiri Forest.

Before: main @ e37ee60c, python -I -B tests/test_astc_cpu_860m.py --cxx g++

860M (PCI 1002:1114) still decodes ASTC on the GPU by default: vendor 0x1002 device 0x1114 env None got 0, want 1

After: this PR @ c11d6c5b, the same command with g++ and with clang++. Both print ok. With the 0x1114 term taken back out of the condition, g++ fails again with that same line, and the term was put back. After merging main @ f88e6e3a (this branch @ b0fda0b0), both compilers still print ok.

The check does not model the GPU, the driver, or the 4-6 second stall. It only checks which device id selects the CPU path, and that the switch still overrides it.

Flags and settings

None added. RX_VK_ASTC_CPU is unchanged: unset keeps the new default on the 860M, 0 forces the GPU decoder, 1 forces the CPU.

Testing

Tested: tests/test_astc_cpu_860m.py on Linux with g++ 15.2 and clang++ 21.1, compiling the Windows branch with -D_WIN32 and the Linux branch without it. The cut of astc_on_cpu() is compiled with -Wall -Wextra -Werror. The whole of vk_texture.cpp was not compiled. tests/run_all.py was not run. No other check names this function.

Not tested: the game, on any GPU. This PC may not run the game, and it has no 860M.

Must be tested:

  • Windows, Radeon 860M: start with no RX_VK_ASTC_CPU, load Kokiri Forest, expecting the log line that ASTC is decoded on the CPU and no VK_ERROR_DEVICE_LOST (by hand, or the Test Farm when a Windows iGPU is online). The 4096 MB budget may still thrash; that is not this change.

Risks

What could break: an 860M now pauses while those arrays decode on the CPU, about 6 seconds an array on the desktop parts, and the RGBA8 result can evict under the 4096 MB cap. A different AMD GPU that also uses device id 1002:1114 would take the same path. No other id changed.

Turning it off: RX_VK_ASTC_CPU=0.

Compatibility: nothing else changes. Saves, options, caches and the texture budget stay as they are. The first log line on an 860M names the CPU path.

Issues

See #1040

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).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing's Tested names only game-free checks, and the game was not run on any GPU.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks. Not ticked yet: Risks names a 4 to 6 second CPU decode pause per array, which Measurements leaves unmeasured.
  • 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 this turn. The new check was run on its own, g++ and clang++.
  • 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. Assisted-by: Grok is on both commits. No Co-Authored-By line.
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Docs updated.
**Type:** fix · **Risk:** low · **Tested on:** Linux, game-free only (g++ and clang++) · **Needs:** Windows, Radeon 860M ## Why A Radeon 860M (PCI 1002:1114) loses the device in Kokiri Forest while the GPU decodes two 1365x1365x90 ASTC arrays. The same arrays already force CPU decode on the Ryzen 7000 and 9000 desktop iGPUs (PCI 1002:164E and 1002:13C0). The 860M was not in that list, so it still used the GPU decoder. `RX_VK_ASTC_CPU=1` avoids the loss. See #1040. The 4,096 MB integrated-GPU texture cap is unchanged. CPU decode stores those arrays as RGBA8, about 5.2-6 GB, so a 32 GB PC can still thrash until `RX_VK_VRAM_MB` is raised. That cap applies to every integrated GPU. ## How to reproduce **Seen on:** Windows 11, Radeon 860M (1002:1114), AMD driver 26.10.1, 32 GB RAM. Reported in #1040. Not run on this PC. **Settings and switches:** defaults. No `RX_VK_ASTC_CPU`. **Steps:** load Kokiri Forest so the two 1365x1365x90 terrain arrays decode on the GPU. **Expected:** the area loads. The log says ASTC is decoded on the CPU. **Actual:** `VK_ERROR_DEVICE_LOST` after the GPU stalls on those arrays. ## What changed On Windows, `astc_on_cpu()` in `gpu/vk/vk_texture.cpp` also defaults to the CPU for PCI 1002:1114. `RX_VK_ASTC_CPU=0` still forces the GPU decoder, and `=1` still forces the CPU on every GPU. Other APUs (680M, 780M, 890M) are unchanged. The texture budget is unchanged. ## Measurements **Verdict:** the game-free check fails on main and passes here. No game run. Nothing was measured in Kokiri Forest. Before: main @ e37ee60c, `python -I -B tests/test_astc_cpu_860m.py --cxx g++` ``` 860M (PCI 1002:1114) still decodes ASTC on the GPU by default: vendor 0x1002 device 0x1114 env None got 0, want 1 ``` After: this PR @ c11d6c5b, the same command with g++ and with clang++. Both print `ok`. With the `0x1114` term taken back out of the condition, g++ fails again with that same line, and the term was put back. After merging main @ f88e6e3a (this branch @ b0fda0b0), both compilers still print `ok`. The check does not model the GPU, the driver, or the 4-6 second stall. It only checks which device id selects the CPU path, and that the switch still overrides it. ### Flags and settings None added. `RX_VK_ASTC_CPU` is unchanged: unset keeps the new default on the 860M, `0` forces the GPU decoder, `1` forces the CPU. ## Testing **Tested:** `tests/test_astc_cpu_860m.py` on Linux with g++ 15.2 and clang++ 21.1, compiling the Windows branch with `-D_WIN32` and the Linux branch without it. The cut of `astc_on_cpu()` is compiled with `-Wall -Wextra -Werror`. The whole of `vk_texture.cpp` was not compiled. `tests/run_all.py` was not run. No other check names this function. **Not tested:** the game, on any GPU. This PC may not run the game, and it has no 860M. **Must be tested:** - Windows, Radeon 860M: start with no `RX_VK_ASTC_CPU`, load Kokiri Forest, expecting the log line that ASTC is decoded on the CPU and no `VK_ERROR_DEVICE_LOST` (by hand, or the Test Farm when a Windows iGPU is online). The 4096 MB budget may still thrash; that is not this change. ## Risks **What could break:** an 860M now pauses while those arrays decode on the CPU, about 6 seconds an array on the desktop parts, and the RGBA8 result can evict under the 4096 MB cap. A different AMD GPU that also uses device id 1002:1114 would take the same path. No other id changed. **Turning it off:** `RX_VK_ASTC_CPU=0`. **Compatibility:** nothing else changes. Saves, options, caches and the texture budget stay as they are. The first log line on an 860M names the CPU path. ## Issues See #1040 ## 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). - [ ] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing's Tested names only game-free checks, and the game was not run on any GPU. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [ ] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. Not ticked yet: Risks names a 4 to 6 second CPU decode pause per array, which Measurements leaves unmeasured. - [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 this turn. The new check was run on its own, g++ and clang++. - [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. Assisted-by: Grok is on both commits. No Co-Authored-By line. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Docs updated.
PCI 1002:1114 loses the device on Kokiri Forest's two large arrays (#1040). The Windows default only covers the two desktop iGPUs, so this check fails until that id is included.

Assisted-by: Grok
PCI 1002:1114 loses the device on the same Kokiri Forest arrays as the desktop iGPUs (#1040). The 4096 MB texture cap is left alone.

Assisted-by: Grok
Merge origin/main into fix/astc-cpu-860m
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 7s
b0fda0b047
Owner

Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).

  • Tested on my own PC: not ticked: Testing's Tested names only game-free checks, and the game was not run on any GPU. Run it yourself on your PC (in the game, for a change the game runs) and say where and what you saw in Testing's Tested; or, when the fix's own case can't be run by hand, add a **Not testable by hand:** line saying why and what stands in for it. Then tick it.
  • Nothing gets worse that I know of: not ticked: Risks names a 4 to 6 second CPU decode pause per array, which Measurements leaves unmeasured. Measure that cost and state it in Risks, then tick it.
Brought up to the [ready-for-review standard](https://git.magicbean.dev/MagicBeanDev/Longshot/src/branch/main/CONTRIBUTING.md#ready-for-review-out-of-wip) (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know). - *Tested on my own PC*: not ticked: Testing's Tested names only game-free checks, and the game was not run on any GPU. Run it yourself on your PC (in the game, for a change the game runs) and say where and what you saw in Testing's *Tested*; or, when the fix's own case can't be run by hand, add a `**Not testable by hand:**` line saying why and what stands in for it. Then tick it. - *Nothing gets worse that I know of*: not ticked: Risks names a 4 to 6 second CPU decode pause per array, which Measurements leaves unmeasured. Measure that cost and state it in Risks, then tick it.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 7s
This pull request has changes conflicting with the target branch.
  • gpu/vk/vk_texture.cpp
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/astc-cpu-860m:TrashPanda-fix/astc-cpu-860m'
git switch 'TrashPanda-fix/astc-cpu-860m'
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!1296
No description provided.