fix(menu): the GPU device row keeps its card, not its place in the list #736
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/upscaling
beanstalk: approved @ 1697603
beanstalk: approved @ 2c5a62e
beanstalk: approved @ 4fd82b7
beanstalk: approved @ 64d6d09
beanstalk: approved @ 6f91fae
beanstalk: approved @ 70a78f9
beanstalk: approved @ 8d361dc
beanstalk: approved @ 9d8356e
beanstalk: approved @ abf2227
beanstalk: approved @ d82f202
beanstalk: approved @ e5f1e40
beanstalk: approved @ ee8ab5f
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
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!736
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:fix/gpu-by-card"
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, RTX 3080 (game-free checks) · Needs: Windows or Linux with two GPUs (a laptop's, or a second card)
Why
On a PC with more than one graphics card, the GPU device row can pick the wrong card after an update. It was saved as a number, the card's place in the list (
gpu_device=2). That place changes when a card is added or taken out, when a driver lists the cards in another order, or when an update into a new folder loses Windows' own GPU choice for the program. The same number then picked another card, or Auto. Players saw their chosen GPU not kept after updating.How to reproduce
Seen on: Windows, two GPUs (an integrated and a dedicated one), any driver
Settings and switches: GPU device set to the second card listed
Steps: change the order the cards are listed in (move the program's Windows graphics preference, update the driver, or plug in an eGPU), then start the game
Expected: the same card
Actual: another card, or Auto when the list got shorter
What changed
The row is now saved as the card itself:
gpu_device_id=<vendor>:<device>:<n>, the card's PCI ids in hex, with n telling two of the same model apart. At the start, that card is found wherever it is in this run's list.gpu/vk/gpu_choice.h:card_idandmenu_of_card, plain functions with tests.gpu/vk/vk_main.cpppick_device: lists the usable GPUs' models (gpu_device_cards, declared invk_internal.h). The log'svk: devicelines now name each card's ids.gpu/vk/vk_menu.cpp:menu_set_gpu_count: finds the saved card before the row's range and its restart value are set, and logs where it is (vk: GPU device: the saved card ...).save(): writesgpu_device_id=for the chosen card.gpu_device=) and saves the card at its next save.Measurements
Nothing to measure: which card is picked at the start, not the frame. The checks under Testing are what count.
Flags and settings
One new ini key, written by the menu; no switch or menu row changes.
gpu_device_id(longshot_options.ini)<vendor>:<device>:<n>Testing
Tested:
tests/test_gpu_choice.cpp(new cases):tests/test_gpu_choice.py(new wiring checks):pick_devicelists the models before the row is counted;menu_set_gpu_countfinds the saved card before the range and restart value are set;save()writes the card, drops its old line, and keeps a missing card;menu_initreads it.tests/test_auto_settings.py,test_menu_env_overrides.py,test_upscaler_round_trip.pyandtest_menu_keys.pypass with the new names added to their stubs.python -I -B tests/run_all.pyon Windows: 497 passed, and the failures beside the one this PR fixed (see below) are the 17 that fail on a cleanmainon this PC: test_appimage_player_build, test_bake_portability, test_cpm_discovery, test_cpp_preflight, test_crash_dialog, test_env_on, test_lift_cleanup_error, test_linux_preflight, test_make_game_cache, test_make_game_prepare, test_missing_nup, test_oot_state_tap, test_readback_late, test_tested_configurations, test_vk_pgo, test_vram_budget_row, test_walk_key. The first run caughttest_auto_settingsreading a line ofsave()that this PR had changed; the new key went on its own line, and the test passes. After the rebase ontoa4821d56, the affected checks were run again: 21 passed.vk_main.cppandvk_menu.cppcompile with the build's flags (llvm-mingw, Windows). On Linux (WSL Ubuntu, g++): test_gpu_choice, test_menu_env_overrides, test_upscaler_round_trip, test_menu_keys and test_auto_settings pass.Not tested:
Must be tested:
Windows or Linux with two GPUs:
gpu_device_id=is inlongshot_options.ini.Expect the same card, and
vk: GPU device: the saved card (...) is <n>: <name> nowin the log when its place changed (by hand).Risks
What could break: on a PC with two identical cards, the card is told apart by its order among that model (
n). If those two swap places, it's still "the second of that model", as before this PR. A hand-editedgpu_device_idthat doesn't parse is ignored, and the row'sgpu_device=is used as before.Turning it off: revert the commit. Deleting the
gpu_device_id=line also goes back to the place in the list.Compatibility:
longshot_options.inigets agpu_device_id=line at the next save once a card is chosen. Builds from before ignore it and keep readinggpu_device=, which is still written. Nothing else changes: no cache, save or renderer interface.Issues
See MagicBeanDev/LongshotLauncher#90 (settings lost between updates).
None found for this exact case (the tracker searched). See Longshot #729 and LongshotLauncher #84, which keep settings across updates.
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.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
WIP: fix(menu): the GPU device row keeps its card, not its place in the listto fix(menu): the GPU device row keeps its card, not its place in the list