fix(vk): leave the Vulkan drivers to the loader, no VK_ICD_FILENAMES from DriverStore #1332
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1332
Loading…
Reference in a new issue
No description provided.
Delete branch "madebyjordan/Longshot:fix/vk-icd-override"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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: deviceline, thenvk: no Vulkan 1.3 GPU), whilevulkaninfo --summaryon the same PCs lists every GPU.Since #637, the game picks a Vulkan driver itself. Before loading the loader, it sets
VK_ICD_FILENAMESto the firstnv*\nv-vk64.jsonfolder 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\FileRepositoryholds annv*folder with annv-vk64.jsonthat 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: deviceline,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_FILENAMESto a stalenv-vk64.jsonshows the same mechanism by hand (below).What changed
The game leaves the choice of Vulkan drivers to the loader again:
load_globalis 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 exportsNvOptimusEnablementandAmdPowerXpressRequestHighPerformance(host/hos_main.c), andpick_devicestill prefers a discrete GPU, so Optimus laptops keep the NVIDIA GPU.RX_VK_DEVICEand the GPU row still choose another.load_globalingpu/vk/vk_main.cpp: the DriverStore search andSetEnvironmentVariableA("VK_ICD_FILENAMES", ...)removed.tests/test_vk_driver_choice.py(new) cutsload_globalout withsrccut.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 ifvulkan-1.dllstops 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--userfolder)Method:
tests/test_vk_driver_choice.pywith llvm-mingw clang++ 23.1.5; game runs throughscripts/job_queue.py --mode shared, readinglongshot_log.txt(the game's stderr)How to reproduce:
python -I -B tests/test_vk_driver_choice.py --cxx clang++at each commitBaseline:
243898e5is main @6d72ca93plus the new check alone (this PR's first commit). Main itself has no check to run, andvk_main.cppthere is byte-identical to 243898e5's.243898e54701cfc9tests/test_vk_driver_choice.pyVK_ICD_FILENAMESset to the DriverStore's NVIDIA packageIn the game, on nightly-394 (
8e3dfde6, #637's commit; the game's interface is version 27, so the fix was cherry-picked onto8e3dfde6for the renderer build):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:
VK_DRIVER_FILESset in the environment. A cold review by a second agent tried wrong fixes:VK_DRIVER_FILES,_putenv/_putenv_sandVK_LOADER_DRIVERS_SELECTall fail the check, andload_globalfrom before #637 passes.gpu/vk/vk_main.cppwhole,-fsyntax-only -Wall -Wextrawith the renderer's include folders: the same 3 warnings on main and here.python -I -B tests/run_all.pyon Windows: 576 passed, 91 failed, 54 skipped. Main @6d72ca93on the same PC: 575 passed, the same 91 failed (an identical list), 54 skipped. The one more pass is the new check.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:
longshot_log.txtshowsvk: 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
NvOptimusEnablementandpick_device's preference for a discrete GPU, and both are still there.RX_VK_DEVICEand the GPU row remain for any other choice.Turning it off: revert the commit; a player can still set
VK_ICD_FILENAMESthemselves.Compatibility: Nothing changes for saves, settings, caches or
MKWVK_API_VERSION.Issues
See #821
See #1312
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.🤖 Generated with Claude Code
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 of8e3dfde6+ 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.WIP: fix(vk): leave the Vulkan drivers to the loader, no VK_ICD_FILENAMES from DriverStoreto fix(vk): leave the Vulkan drivers to the loader, no VK_ICD_FILENAMES from DriverStore