fix(vk): leave the Vulkan drivers to the loader, no VK_ICD_FILENAMES from DriverStore #1332

Merged
HumanBean merged 2 commits from madebyjordan/Longshot:fix/vk-icd-override into main 2026-11-17 03:50:15 +00:00
Member

Type: fix · Risk: low · Tested on: Windows 11, RX 6700 XT · Needs: none (the affected PCs' players can confirm on the next rc)

Why

On v3.0.0-rc.6 some players get a black window with music, and the start screen says "Vulkan didn't start on your graphics card. Update your graphics driver". The PCs are varied: an RTX 5080 with AMD built-in graphics, an RX 9070 alone on Windows 10, and an RTX 4060 Laptop. Their logs list no GPU at all (no vk: device line, then vk: no Vulkan 1.3 GPU), while vulkaninfo --summary on the same PCs lists every GPU.

Since #637, the game picks a Vulkan driver itself. Before loading the loader, it sets VK_ICD_FILENAMES to the first nv*\nv-vk64.json folder in Windows' DriverStore. That variable makes the loader take that one file and ignore every other driver. DriverStore keeps the packages of drivers that are no longer in use: older NVIDIA versions, or the NVIDIA card a PC used to have. The first match is often one of those, so the loader lists no GPU, on NVIDIA and AMD cards alike. The block isn't mentioned in #637's description; it reads as a setting from an Optimus laptop that was used for testing.

See #821 (the rc.6 reports gathered there; its first report, on rc.4, came before #637 and may be another cause). See #1312.

How to reproduce

Seen on: Windows 10 and 11, rc.6. RTX 5080 (621.24) + Radeon iGPU; RX 9070 (26.11.1); RTX 4060 Laptop + Ryzen 7 7735HS.
Settings and switches: defaults
Steps: start the game on a PC whose C:\Windows\System32\DriverStore\FileRepository holds an nv* folder with an nv-vk64.json that isn't the driver in use (an older NVIDIA driver's package, or one left from a replaced NVIDIA card).
Expected: vk: device 0: <the GPU> and the title screen.
Actual: no vk: device line, vk: no Vulkan 1.3 GPU, vk: pick_device failed, a black window, and the start-failure dialog.

On a PC without such a package, setting VK_ICD_FILENAMES to a stale nv-vk64.json shows the same mechanism by hand (below).

What changed

The game leaves the choice of Vulkan drivers to the loader again: load_global is what it was before #637, plus a note on why it sets no driver variable. The loader finds the drivers in use from the display adapters. The game still exports NvOptimusEnablement and AmdPowerXpressRequestHighPerformance (host/hos_main.c), and pick_device still prefers a discrete GPU, so Optimus laptops keep the NVIDIA GPU. RX_VK_DEVICE and the GPU row still choose another.

  • vk: load_global in gpu/vk/vk_main.cpp: the DriverStore search and SetEnvironmentVariableA("VK_ICD_FILENAMES", ...) removed.
  • tests: tests/test_vk_driver_choice.py (new) cuts load_global out with srccut.block, runs its Windows branch with stand-ins for the Win32 calls and a DriverStore holding an NVIDIA package, and fails if any of the loader's driver variables is set (VK_ICD_FILENAMES, VK_DRIVER_FILES, VK_ADD_DRIVER_FILES, VK_LOADER_DRIVERS_SELECT, VK_LOADER_DRIVERS_DISABLE). It also fails if vulkan-1.dll stops coming from System32 only.

Measurements

Verdict: fixed. The check fails on main for the bug's reason and passes here. In the game, the fixed renderer lists the GPU, and the variable this code used to set takes the GPU away.

Hardware: Windows 11, AMD Radeon RX 6700 XT (driver 0x800161), 32 GB
Scene: the start, up to the renderer's device line (headless, HOS_HEADLESS=1, a scratch --user folder)
Method: tests/test_vk_driver_choice.py with llvm-mingw clang++ 23.1.5; game runs through scripts/job_queue.py --mode shared, reading longshot_log.txt (the game's stderr)
How to reproduce: python -I -B tests/test_vk_driver_choice.py --cxx clang++ at each commit
Baseline: 243898e5 is main @ 6d72ca93 plus the new check alone (this PR's first commit). Main itself has no check to run, and vk_main.cpp there is byte-identical to 243898e5's.

Before: main + the check @ 243898e5 After: this PR @ 4701cfc9
tests/test_vk_driver_choice.py fails: VK_ICD_FILENAMES set to the DriverStore's NVIDIA package passes
Before (243898e5):
FAIL: load_global chose the Vulkan driver itself: VK_ICD_FILENAMES=C:\Windows\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_0a1b2c3d4e5f6a7b\nv-vk64.json (the loader then ignores every other driver, and lists no GPU when that file is not the driver in use)
After (4701cfc9):
ok: no Vulkan driver variable set; vulkan-1.dll from System32

In the game, on nightly-394 (8e3dfde6, #637's commit; the game's interface is version 27, so the fix was cherry-picked onto 8e3dfde6 for the renderer build):

nightly-394, VK_ICD_FILENAMES = an nv-vk64.json whose driver isn't installed (what the removed block sets on the affected PCs):
[hos MainThread] vk: vkCreateInstance failed
[hos MainThread] vk: create_instance failed
[hos MainThread] rx: mkwvk_init returned NULL: nothing is drawn
nightly-394 as installed (this PC's DriverStore has no nv*\nv-vk64.json, so the block finds nothing here):
[hos MainThread] vk: device 0: AMD Radeon RX 6700 XT, Vulkan 1.4, driver 0x800161, type 2, id 1002:73df
the fix's renderer (RX_VK_ONLY build of 8e3dfde6 + this fix, in a scratch copy of the game folder):
[hos MainThread] vk: device 0: AMD Radeon RX 6700 XT, Vulkan 1.4, driver 0x800161, type 2, id 1002:73df

On the players' PCs the stale package's DLL still exists, so the instance is made and the device list is empty (vk: no Vulkan 1.3 GPU). Here the named DLL is missing, so the instance fails instead. Either way, the named file is the only driver the loader uses.

Flags and settings

None.

Testing

Tested:

  • The new check, both ways, with llvm-mingw's clang++ and its g++ wrapper (Windows), including with VK_DRIVER_FILES set in the environment. A cold review by a second agent tried wrong fixes: VK_DRIVER_FILES, _putenv/_putenv_s and VK_LOADER_DRIVERS_SELECT all fail the check, and load_global from before #637 passes.
  • gpu/vk/vk_main.cpp whole, -fsyntax-only -Wall -Wextra with the renderer's include folders: the same 3 warnings on main and here.
  • python -I -B tests/run_all.py on Windows: 576 passed, 91 failed, 54 skipped. Main @ 6d72ca93 on the same PC: 575 passed, the same 91 failed (an identical list), 54 skipped. The one more pass is the new check.
  • In the game (RX 6700 XT, Windows 11): the runs above.

Not tested: a PC with a stale NVIDIA package in DriverStore, which is the case this fixes; I don't have one. Linux: load_global's Linux branch is unchanged, and the check builds its Windows branch on any OS (the Linux g++ run wasn't done here).

Must be tested:

  • None before merge. After the next rc, the players on #821 should confirm that the game starts (by hand: their longshot_log.txt shows vk: device 0:).

Risks

What could break: an Optimus laptop that only found its NVIDIA GPU because of this block. Before #637 these laptops ran on NvOptimusEnablement and pick_device's preference for a discrete GPU, and both are still there. RX_VK_DEVICE and the GPU row remain for any other choice.

Turning it off: revert the commit; a player can still set VK_ICD_FILENAMES themselves.

Compatibility: Nothing changes for saves, settings, caches or MKWVK_API_VERSION.

Issues

See #821
See #1312

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).
  • 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.
  • A game-free test added for the fix, failing on main and passing here.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** low · **Tested on:** Windows 11, RX 6700 XT · **Needs:** none (the affected PCs' players can confirm on the next rc) ## Why On v3.0.0-rc.6 some players get a black window with music, and the start screen says "Vulkan didn't start on your graphics card. Update your graphics driver". The PCs are varied: an RTX 5080 with AMD built-in graphics, an RX 9070 alone on Windows 10, and an RTX 4060 Laptop. Their logs list no GPU at all (no `vk: device` line, then `vk: no Vulkan 1.3 GPU`), while `vulkaninfo --summary` on the same PCs lists every GPU. Since #637, the game picks a Vulkan driver itself. Before loading the loader, it sets `VK_ICD_FILENAMES` to the first `nv*\nv-vk64.json` folder in Windows' DriverStore. That variable makes the loader take that one file and ignore every other driver. DriverStore keeps the packages of drivers that are no longer in use: older NVIDIA versions, or the NVIDIA card a PC used to have. The first match is often one of those, so the loader lists no GPU, on NVIDIA and AMD cards alike. The block isn't mentioned in #637's description; it reads as a setting from an Optimus laptop that was used for testing. See #821 (the rc.6 reports gathered there; its first report, on rc.4, came before #637 and may be another cause). See #1312. ## How to reproduce **Seen on:** Windows 10 and 11, rc.6. RTX 5080 (621.24) + Radeon iGPU; RX 9070 (26.11.1); RTX 4060 Laptop + Ryzen 7 7735HS. **Settings and switches:** defaults **Steps:** start the game on a PC whose `C:\Windows\System32\DriverStore\FileRepository` holds an `nv*` folder with an `nv-vk64.json` that isn't the driver in use (an older NVIDIA driver's package, or one left from a replaced NVIDIA card). **Expected:** `vk: device 0: <the GPU>` and the title screen. **Actual:** no `vk: device` line, `vk: no Vulkan 1.3 GPU`, `vk: pick_device failed`, a black window, and the start-failure dialog. On a PC without such a package, setting `VK_ICD_FILENAMES` to a stale `nv-vk64.json` shows the same mechanism by hand (below). ## What changed The game leaves the choice of Vulkan drivers to the loader again: `load_global` is what it was before #637, plus a note on why it sets no driver variable. The loader finds the drivers in use from the display adapters. The game still exports `NvOptimusEnablement` and `AmdPowerXpressRequestHighPerformance` (`host/hos_main.c`), and `pick_device` still prefers a discrete GPU, so Optimus laptops keep the NVIDIA GPU. `RX_VK_DEVICE` and the GPU row still choose another. - vk: `load_global` in `gpu/vk/vk_main.cpp`: the DriverStore search and `SetEnvironmentVariableA("VK_ICD_FILENAMES", ...)` removed. - tests: `tests/test_vk_driver_choice.py` (new) cuts `load_global` out with `srccut.block`, runs its Windows branch with stand-ins for the Win32 calls and a DriverStore holding an NVIDIA package, and fails if any of the loader's driver variables is set (`VK_ICD_FILENAMES`, `VK_DRIVER_FILES`, `VK_ADD_DRIVER_FILES`, `VK_LOADER_DRIVERS_SELECT`, `VK_LOADER_DRIVERS_DISABLE`). It also fails if `vulkan-1.dll` stops coming from System32 only. ## Measurements **Verdict:** fixed. The check fails on main for the bug's reason and passes here. In the game, the fixed renderer lists the GPU, and the variable this code used to set takes the GPU away. Hardware: Windows 11, AMD Radeon RX 6700 XT (driver 0x800161), 32 GB Scene: the start, up to the renderer's device line (headless, `HOS_HEADLESS=1`, a scratch `--user` folder) Method: `tests/test_vk_driver_choice.py` with llvm-mingw clang++ 23.1.5; game runs through `scripts/job_queue.py --mode shared`, reading `longshot_log.txt` (the game's stderr) How to reproduce: `python -I -B tests/test_vk_driver_choice.py --cxx clang++` at each commit Baseline: 243898e5 is main @ 6d72ca93 plus the new check alone (this PR's first commit). Main itself has no check to run, and `vk_main.cpp` there is byte-identical to 243898e5's. | | Before: main + the check @ 243898e5 | After: this PR @ 4701cfc9 | |---|---|---| | `tests/test_vk_driver_choice.py` | fails: `VK_ICD_FILENAMES` set to the DriverStore's NVIDIA package | passes | ``` Before (243898e5): FAIL: load_global chose the Vulkan driver itself: VK_ICD_FILENAMES=C:\Windows\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_0a1b2c3d4e5f6a7b\nv-vk64.json (the loader then ignores every other driver, and lists no GPU when that file is not the driver in use) After (4701cfc9): ok: no Vulkan driver variable set; vulkan-1.dll from System32 ``` In the game, on nightly-394 (`8e3dfde6`, #637's commit; the game's interface is version 27, so the fix was cherry-picked onto `8e3dfde6` for the renderer build): ``` nightly-394, VK_ICD_FILENAMES = an nv-vk64.json whose driver isn't installed (what the removed block sets on the affected PCs): [hos MainThread] vk: vkCreateInstance failed [hos MainThread] vk: create_instance failed [hos MainThread] rx: mkwvk_init returned NULL: nothing is drawn nightly-394 as installed (this PC's DriverStore has no nv*\nv-vk64.json, so the block finds nothing here): [hos MainThread] vk: device 0: AMD Radeon RX 6700 XT, Vulkan 1.4, driver 0x800161, type 2, id 1002:73df the fix's renderer (RX_VK_ONLY build of 8e3dfde6 + this fix, in a scratch copy of the game folder): [hos MainThread] vk: device 0: AMD Radeon RX 6700 XT, Vulkan 1.4, driver 0x800161, type 2, id 1002:73df ``` On the players' PCs the stale package's DLL still exists, so the instance is made and the device list is empty (`vk: no Vulkan 1.3 GPU`). Here the named DLL is missing, so the instance fails instead. Either way, the named file is the only driver the loader uses. ### Flags and settings None. ## Testing **Tested:** - The new check, both ways, with llvm-mingw's clang++ and its g++ wrapper (Windows), including with `VK_DRIVER_FILES` set in the environment. A cold review by a second agent tried wrong fixes: `VK_DRIVER_FILES`, `_putenv`/`_putenv_s` and `VK_LOADER_DRIVERS_SELECT` all fail the check, and `load_global` from before #637 passes. - `gpu/vk/vk_main.cpp` whole, `-fsyntax-only -Wall -Wextra` with the renderer's include folders: the same 3 warnings on main and here. - `python -I -B tests/run_all.py` on Windows: 576 passed, 91 failed, 54 skipped. Main @ 6d72ca93 on the same PC: 575 passed, the same 91 failed (an identical list), 54 skipped. The one more pass is the new check. - In the game (RX 6700 XT, Windows 11): the runs above. **Not tested:** a PC with a stale NVIDIA package in DriverStore, which is the case this fixes; I don't have one. Linux: `load_global`'s Linux branch is unchanged, and the check builds its Windows branch on any OS (the Linux g++ run wasn't done here). **Must be tested:** - None before merge. After the next rc, the players on #821 should confirm that the game starts (by hand: their `longshot_log.txt` shows `vk: device 0:`). ## Risks **What could break:** an Optimus laptop that only found its NVIDIA GPU because of this block. Before #637 these laptops ran on `NvOptimusEnablement` and `pick_device`'s preference for a discrete GPU, and both are still there. `RX_VK_DEVICE` and the GPU row remain for any other choice. **Turning it off:** revert the commit; a player can still set `VK_ICD_FILENAMES` themselves. **Compatibility:** Nothing changes for saves, settings, caches or `MKWVK_API_VERSION`. ## Issues See #821 See #1312 ## 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`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [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] A game-free test added for the fix, failing on `main` and passing here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
load_global (gpu/vk/vk_main.cpp) sets VK_ICD_FILENAMES to the first
nv*\nv-vk64.json in Windows' DriverStore (8e3dfde6, #637). The loader
then uses that one driver file and no other, so a PC whose DriverStore
keeps an old or unused NVIDIA package lists no GPU: "vk: no Vulkan 1.3
GPU" and a black window on v3.0.0-rc.6 (Longshot #821, #1312).

The check runs load_global's Windows branch with stand-ins for the
Win32 calls and a DriverStore holding an NVIDIA package, and fails
while it sets a loader driver variable. Fails on main 6d72ca93.

Assisted-by: Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): leave the Vulkan drivers to the loader: no VK_ICD_FILENAMES from DriverStore
All checks were successful
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
CI / Conventional Commit title (pull_request) Successful in 6s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 12s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Third-party parts / As their notes say (pull_request) Successful in 14s
PR description / Description follows the template (pull_request_target) Successful in 4s
4701cfc90e
load_global set VK_ICD_FILENAMES to the first nv*\nv-vk64.json in
Windows' DriverStore (8e3dfde6, #637, for an Optimus laptop). That makes
the loader take that one file and no other driver. DriverStore keeps the
packages of drivers no longer in use (older NVIDIA versions, a card that
was replaced), and the first one found is often not the driver in use.
Those PCs list no GPU at all, NVIDIA and AMD cards alike: "vk: no Vulkan
1.3 GPU" and a black window on v3.0.0-rc.6 (Longshot #821, #1312), while
vulkaninfo lists their GPUs.

The loader finds the drivers in use from the display adapters, and
pick_device already prefers a discrete GPU (RX_VK_DEVICE and the GPU row
choose another), so the block goes. load_global is again what it was
before #637, plus a note on why it sets no driver variable.

Assisted-by: Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11, RX 6700 XT (driver 0x800161), headless start through the job queue: nightly-394 (8e3dfde6, #637's commit) with VK_ICD_FILENAMES set to an NVIDIA nv-vk64.json whose driver isn't installed (what the removed block sets on the affected PCs) gets 'vk: vkCreateInstance failed' and no renderer; the fix's renderer (RX_VK_ONLY build of 8e3dfde6 + this fix, in a scratch copy of the game folder) lists 'vk: device 0: AMD Radeon RX 6700 XT, Vulkan 1.4' and starts. This PC has no stale NVIDIA package in DriverStore, so the exact rc.6 case (an empty device list) wasn't reproduced here.

Tested in game: Windows 11, RX 6700 XT (driver 0x800161), headless start through the job queue: nightly-394 (8e3dfde6, #637's commit) with VK_ICD_FILENAMES set to an NVIDIA nv-vk64.json whose driver isn't installed (what the removed block sets on the affected PCs) gets 'vk: vkCreateInstance failed' and no renderer; the fix's renderer (RX_VK_ONLY build of 8e3dfde6 + this fix, in a scratch copy of the game folder) lists 'vk: device 0: AMD Radeon RX 6700 XT, Vulkan 1.4' and starts. This PC has no stale NVIDIA package in DriverStore, so the exact rc.6 case (an empty device list) wasn't reproduced here.
madebyjordan changed title from WIP: fix(vk): leave the Vulkan drivers to the loader, no VK_ICD_FILENAMES from DriverStore to fix(vk): leave the Vulkan drivers to the loader, no VK_ICD_FILENAMES from DriverStore 2026-11-17 03:41:47 +00:00
HumanBean deleted branch fix/vk-icd-override 2026-11-17 03:50:15 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1332
No description provided.