GPU: prefer high-performance adapter and add VICTORY_D3D12_ADAPTER #261

Open
github-bot wants to merge 1 commit from github-bot/gh-261 into main AGit
Owner

@⁠xADEL on GitHub · 2026-11-24 23:02 UTC · original
xADEL:gpu/adapter-selection → main · +303 −34 · 3 files · 1 commits · open

Problem

Both crates/victory-gpu/src/host.rs and crates/victory-shader/src/emit/host.rs pass None to D3D12CreateDevice, which selects DXGI adapter 0. On hybrid-graphics laptops (e.g. Intel UHD Graphics + NVIDIA RTX discrete GPU), adapter 0 is the integrated GPU — which often lacks mesh shaders for the world and differs in wave size/driver behavior — and neither host logs which adapter was chosen or lets the user pick one.

Related to #197 (which adds an opt-in VICTORY_SHADER_ADAPTER override for victory-shader tests only, keeping Windows' default adapter when unset). This PR selects the high-performance hardware adapter by default and adds a single VICTORY_D3D12_ADAPTER override plus adapter logging for both the main runtime (victory-gpu) and the shader test host (victory-shader).

What is in it

  • crates/victory-gpu/src/host.rs:
    • Prefer IDXGIFactory6::EnumAdapterByGpuPreference(..., DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) (skipping software adapters), falling back to D3D12CreateDevice(None, ...).
    • Allow overriding via VICTORY_D3D12_ADAPTER (0-based DXGI index or case-insensitive adapter description substring).
    • Log the selected host D3D12 adapter name, PCI vendor/device IDs, and dedicated VRAM (vram_mb).
    • Unit test adapter_selector_matches_index_or_substring.
  • crates/victory-shader/src/emit/host.rs:
    • Same high-performance preference and VICTORY_D3D12_ADAPTER override, keeping the SM 6.6 check and the software-adapter rejection needed on GPU-less CI runners (7b0f736).
    • Unit test adapter_selector_matches_index_or_substring.
  • README.md: Document VICTORY_D3D12_ADAPTER in the environment variable table.

Tested

  • Hardware: Windows 11 x64, Intel Core i5-12450HX, 24 GB RAM, NVIDIA GeForce RTX 3050 6GB Laptop GPU (driver 32.0.16.2124, wave32, SM 6.6, mesh shaders) + Intel(R) UHD Graphics (driver 32.0.101.7026, no mesh shaders), Windows SDK 10.0.26100.0 (dxil.dll active).
  • cargo xtask policy -> 169 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings -> 0 warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings -> 0 warnings
  • cargo test --workspace --locked -> 498 passed, 0 failed, 7 ignored (automatically selected RTX 3050 6GB, including a_mesh_pipeline_loads_from_the_library and all hardware shader tests; verified VICTORY_D3D12_ADAPTER=intel selects Intel UHD Graphics and VICTORY_D3D12_ADAPTER=nvidia selects RTX 3050).
  • Live title launch (target\release\victory.exe run ... --execute): logged host D3D12 adapter adapter=NVIDIA GeForce RTX 3050 6GB Laptop GPU vendor=0x10de device=0x25ec vram_mb=6001 and booted menus at 30.0 fps.

Not tested

  • Multi-dGPU desktops, AMD GPUs, or Wine/Proton (DXGI behavior on Linux).

AI use

Written and verified with Antigravity (model name not exposed in the agent environment).

**@⁠xADEL** on GitHub · 2026-11-24 23:02 UTC · [original](https://github.com/fxceless/victory-fork/pull/261) `xADEL:gpu/adapter-selection` → `main` · +303 −34 · 3 files · 1 commits · open ## Problem Both `crates/victory-gpu/src/host.rs` and `crates/victory-shader/src/emit/host.rs` pass `None` to `D3D12CreateDevice`, which selects DXGI adapter 0. On hybrid-graphics laptops (e.g. Intel UHD Graphics + NVIDIA RTX discrete GPU), adapter 0 is the integrated GPU — which often lacks mesh shaders for the world and differs in wave size/driver behavior — and neither host logs which adapter was chosen or lets the user pick one. Related to #197 (which adds an opt-in `VICTORY_SHADER_ADAPTER` override for `victory-shader` tests only, keeping Windows' default adapter when unset). This PR selects the high-performance hardware adapter by default and adds a single `VICTORY_D3D12_ADAPTER` override plus adapter logging for both the main runtime (`victory-gpu`) and the shader test host (`victory-shader`). ## What is in it - **`crates/victory-gpu/src/host.rs`**: - Prefer `IDXGIFactory6::EnumAdapterByGpuPreference(..., DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)` (skipping software adapters), falling back to `D3D12CreateDevice(None, ...)`. - Allow overriding via `VICTORY_D3D12_ADAPTER` (0-based DXGI index or case-insensitive adapter description substring). - Log the selected host D3D12 adapter name, PCI vendor/device IDs, and dedicated VRAM (`vram_mb`). - Unit test `adapter_selector_matches_index_or_substring`. - **`crates/victory-shader/src/emit/host.rs`**: - Same high-performance preference and `VICTORY_D3D12_ADAPTER` override, keeping the SM 6.6 check and the software-adapter rejection needed on GPU-less CI runners (`7b0f736`). - Unit test `adapter_selector_matches_index_or_substring`. - **`README.md`**: Document `VICTORY_D3D12_ADAPTER` in the environment variable table. ## Tested - **Hardware:** Windows 11 x64, Intel Core i5-12450HX, 24 GB RAM, NVIDIA GeForce RTX 3050 6GB Laptop GPU (driver `32.0.16.2124`, wave32, SM 6.6, mesh shaders) + Intel(R) UHD Graphics (driver `32.0.101.7026`, no mesh shaders), Windows SDK `10.0.26100.0` (`dxil.dll` active). - `cargo xtask policy` -> `169 files ok` - `cargo clippy --workspace --all-targets --locked -- -D warnings` -> 0 warnings - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` -> 0 warnings - `cargo test --workspace --locked` -> **498 passed, 0 failed, 7 ignored** (automatically selected RTX 3050 6GB, including `a_mesh_pipeline_loads_from_the_library` and all hardware shader tests; verified `VICTORY_D3D12_ADAPTER=intel` selects Intel UHD Graphics and `VICTORY_D3D12_ADAPTER=nvidia` selects RTX 3050). - Live title launch (`target\release\victory.exe run ... --execute`): logged `host D3D12 adapter adapter=NVIDIA GeForce RTX 3050 6GB Laptop GPU vendor=0x10de device=0x25ec vram_mb=6001` and booted menus at 30.0 fps. ## Not tested - Multi-dGPU desktops, AMD GPUs, or Wine/Proton (DXGI behavior on Linux). ## AI use Written and verified with Antigravity (model name not exposed in the agent environment).
Both victory-gpu::host and victory-shader::emit::host passed None to
D3D12CreateDevice, which selects DXGI adapter 0 (the integrated GPU on
hybrid laptops, often lacking mesh shaders).

Prefer IDXGIFactory6::EnumAdapterByGpuPreference with
DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE (skipping software adapters and
checking SM 6.6 in the shader host, with fallback to D3D12CreateDevice
default), allow overriding via VICTORY_D3D12_ADAPTER (0-based DXGI index
or case-insensitive name substring), and log the chosen adapter name,
PCI IDs, and dedicated VRAM in victory-gpu::host.

Assisted-by: Antigravity
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:39:27 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/261/head:github-bot/gh-261'
git switch 'github-bot/gh-261'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-261'
git switch 'github-bot/gh-261'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-261'
git switch 'github-bot/gh-261'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-261'
git switch 'main'
git merge --squash 'github-bot/gh-261'
git switch 'main'
git merge --ff-only 'github-bot/gh-261'
git switch 'main'
git merge 'github-bot/gh-261'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.