feat(d3d12_x): rank Vulkan devices and let a setting choose the GPU #68

Manually merged
github merged 1 commit from gh-pr/68/head into gh-pr/68/base 2026-11-26 19:17:18 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-23 02:14 UTC · original
Dark3581:feat/device-selection → main · +89 −6 · 8 files · 1 commits · merged 2026-11-23 02:18 UTC

What

Vulkan device selection that holds up on machines with more than one Vulkan driver:

  • DeviceScore (vulkan/VulkanDevice.cpp), a pure function, ranks a native discrete GPU over a native integrated one, then a layered driver, then a virtual or CPU device. Mesa Dozen (Vulkan on D3D12, installed by the OpenCL/OpenGL Compatibility Pack) reports the device type of the GPU underneath it, so it used to tie with the real GPU and win when it enumerated first. It is now recognised by VK_DRIVER_ID_MESA_DOZEN from the 1.2 properties the selection already reads.
  • DeviceRequirements::preferredDevice: a case-insensitive part of a device name that wins over the ranking. If nothing matches, the ranking applies and PreferenceMissed() reports it, so the device object can log it.
  • DeviceRequirementsFromSettings fills the preference from the d3d12_x.vulkan_device setting (#66), for the device object to call. docs/dev/GAME_TESTING.md lists the key; the debt entry for VulkanDevice is updated.

Tested

Windows 10, RTX 3070 Ti (driver 621.14). This machine has a single Vulkan device.

  • New pso_probe device-selection, run by the pipeline_state test:
    • the selftest ranks synthetic devices: native discrete, native integrated, Dozen on a discrete GPU, then llvmpipe; a preference beats a better device; a non-matching preference changes nothing;
    • on the GPU, a preference made of part of the device's name selects it, and a nonsense preference falls back to it with PreferenceMissed() set.
  • The settings test sets d3d12_x.vulkan_device through ANYBOX_SET and reads it back through DeviceRequirementsFromSettings.
  • MinGW ctest: 73 of 73. With MSVC 2022, device-selection and pipeline_state pass, and every target builds except ab_gameinput, which needs gameinput.lib, which this machine doesn't have. python tools/check_conventions.py and debt_fold.py --check: ok.

Not tested on hardware: a machine with several GPUs or with Dozen installed. Only the pure ranking covers those cases.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: Vulkan specification (VkPhysicalDeviceVulkan12Properties::driverID, VK_DRIVER_ID_MESA_DOZEN)
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-23 02:14 UTC · [original](https://github.com/Dark3581/AnyBox/pull/68) `Dark3581:feat/device-selection` → `main` · +89 −6 · 8 files · 1 commits · merged 2026-11-23 02:18 UTC ### What Vulkan device selection that holds up on machines with more than one Vulkan driver: - **`DeviceScore`** (`vulkan/VulkanDevice.cpp`), a pure function, ranks a native discrete GPU over a native integrated one, then a layered driver, then a virtual or CPU device. Mesa Dozen (Vulkan on D3D12, installed by the OpenCL/OpenGL Compatibility Pack) reports the device type of the GPU underneath it, so it used to tie with the real GPU and win when it enumerated first. It is now recognised by `VK_DRIVER_ID_MESA_DOZEN` from the 1.2 properties the selection already reads. - **`DeviceRequirements::preferredDevice`**: a case-insensitive part of a device name that wins over the ranking. If nothing matches, the ranking applies and `PreferenceMissed()` reports it, so the device object can log it. - **`DeviceRequirementsFromSettings`** fills the preference from the `d3d12_x.vulkan_device` setting (#66), for the device object to call. `docs/dev/GAME_TESTING.md` lists the key; the debt entry for `VulkanDevice` is updated. ### Tested Windows 10, RTX 3070 Ti (driver 621.14). This machine has a single Vulkan device. - New `pso_probe device-selection`, run by the `pipeline_state` test: - the selftest ranks synthetic devices: native discrete, native integrated, Dozen on a discrete GPU, then llvmpipe; a preference beats a better device; a non-matching preference changes nothing; - on the GPU, a preference made of part of the device's name selects it, and a nonsense preference falls back to it with `PreferenceMissed()` set. - The settings test sets `d3d12_x.vulkan_device` through `ANYBOX_SET` and reads it back through `DeviceRequirementsFromSettings`. - MinGW `ctest`: 73 of 73. With MSVC 2022, `device-selection` and `pipeline_state` pass, and every target builds except `ab_gameinput`, which needs `gameinput.lib`, which this machine doesn't have. `python tools/check_conventions.py` and `debt_fold.py --check`: ok. Not tested on hardware: a machine with several GPUs or with Dozen installed. Only the pure ranking covers those cases. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: Vulkan specification (`VkPhysicalDeviceVulkan12Properties::driverID`, `VK_DRIVER_ID_MESA_DOZEN`) - [x] AI-assisted: yes
Native discrete and integrated GPUs rank above a layered driver such as Mesa Dozen, which had the same device type as the real GPU, and above CPU devices. The d3d12_x.vulkan_device setting picks a GPU by part of its name, falling back to that order when nothing matches.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:17:15 +00:00
github manually merged commit 4423d3f92a into gh-pr/68/base 2026-11-26 19:17:18 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.