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

Open
xADEL wants to merge 1 commit from upstream-pr/261 into main
xADEL commented 2026-11-24 23:02:05 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by xADEL on 2026-11-24T23:02:05Z.


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).

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593156661 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/261). Originally posted by [xADEL](https://github.com/xADEL) on 2026-11-24T23:02:05Z. --- ## 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).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/261:upstream-pr/261'
git switch 'upstream-pr/261'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/261'
git switch 'upstream-pr/261'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/261'
git switch 'upstream-pr/261'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/261'
git switch 'main'
git merge --squash 'upstream-pr/261'
git switch 'main'
git merge --ff-only 'upstream-pr/261'
git switch 'main'
git merge 'upstream-pr/261'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!261
No description provided.