Skip to content

video: a GPU index chosen in the menu replaces the remembered device - #19947

Open
Davey-Hughes wants to merge 1 commit into
libretro:masterfrom
Davey-Hughes:fix/gpu-selection-identity
Open

Davey-Hughes wants to merge 1 commit into
libretro:masterfrom
Davey-Hughes:fix/gpu-selection-identity

Conversation

@Davey-Hughes

Copy link
Copy Markdown
Contributor

Guidelines

  1. Rebase before opening a pull request
  2. If you are sending several unrelated fixes or features, use a branch and a separate pull request for each
  3. If possible try squashing everything in a single commit. This is particularly beneficial in the case of feature merges since it allows easy bisecting when a problem arises
  4. RetroArch codebase follows C89 coding rules for portability across many old platforms check using C89_BUILD=1

Description

Since 0e7a56f each GPU index (Vulkan, OpenGL/EGL, Direct3D 10/11/12, Metal) remembers the device it was chosen as, in video_gpu_name_*. Changing the index in the menu left the old name saved, so on the next driver init video_driver_gpu_index_resolve() found that name at its old position and went back to it: the log says the old GPU is now #1, not #2; using it and the new choice is ignored. On the EGL contexts (wayland, x/egl, drm) the menu value reverts as well. The only way out was to set the index to 0 first. This is on master only; 1.22.2 predates it.

Left, Right, the dropdown and reset now save the name of the device at the chosen index, through a new video_driver_gpu_index_select(). Index 0 clears the name, and an index past the end of the current list leaves it alone, so a stale out-of-range index still follows its device. Left no longer sets the index to -1 on an empty device list.

Testing

samples/gfx/gpu_index builds the production resolver, the Left/Right callbacks and the write-handler case from source and checks, for every API, that a menu change survives a driver reinit and that an out-of-range index keeps its device. It runs in the samples-gfx job, on Linux with ASan/UBSan and -std=c89, and under mingw + Wine. Run against master's callbacks, the same change-then-reinit sequence keeps the old GPU on Vulkan, GL, D3D11, D3D12 and Metal.

  • Linux (gcc, ASan/UBSan, C89 flags) and mingw-w64 under Wine: pass
  • Native Windows 11, MSYS2 UCRT64 gcc 16.2: pass
  • The four touched objects build clean with C89_BUILD=1
  • tools/ci_local.py selftest and tools/ci_apt_check.py pass

On a desktop with an RX 7900 XT, a Radeon 610M iGPU and llvmpipe: start on index 2, press Left once on Settings > Video > Output > GPU Index, quit, relaunch.

master this PR
Vulkan, llvmpipe → 610M llvmpipe again: GPU "llvmpipe (LLVM 23.1.3, 256 bits)" is now #2, not #1; using it. 610M
Vulkan with the iGPU listed first (MESA_VK_DEVICE_SELECT=1002:13c0), llvmpipe → 7900 XT llvmpipe again, same warning 7900 XT
GL, egl_x context, 7900 XT → 610M 7900 XT again, and gl_gpu_index back to 2 610M, index stays 1

Relaunching the 610M config with llvmpipe listed first (MESA_VK_DEVICE_SELECT=10005:0000) still picks the 610M, now at index 2, with the is now #2, not #1 warning. These ran under Xvfb, which can present only from llvmpipe, so the table shows the device each driver selected, from the log.

Related Issues

[Any issues this pull request may be addressing]

Related Pull Requests

[Any other PRs from related repositories that might be needed for this pull request to work]

Reviewers

[If possible @mention all the people that should review your pull request]

Since 0e7a56f each GPU index remembers the device it was chosen as,
but a change made in the menu left the old name saved. On the next
driver init the resolver found that name at its old position and went
back to it, so the new choice was ignored, and on EGL contexts the menu
value reverted too. Left, Right, the dropdown and reset now save the
name of the device at the chosen index, and index 0 clears it. An index
past the end of the list leaves the saved name alone. Left no longer
sets index -1 on an empty device list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant