Shaders: name the adapter on translate --pipelines verdicts (FIND-3) #2454

Closed
makmatvey wants to merge 1 commit from upstream-pr/2456 into main
makmatvey commented 2026-11-25 13:51:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by makmatvey on 2026-11-25T13:51:56Z.


FIND-3: VICTORY_D3D12_ADAPTER (index or description substring) selects the
offline emit host; each pipeline created/refused line names that adapter.

Rebased onto 63bcca4, and merged with upstream's WARP work

Upstream added a shared WARP device, a WARP_LOCK and a warp field to the
same code this PR rewrites. Rather than choose one side, the two are merged:

  • the WARP device stays shared and serialised exactly as upstream made it;
  • the adapter is read from that device by LUID instead of being enumerated a
    second time, so the lock covers one create_device, not two enumerations
    that have to agree.

d58745e ("annotate EnumWarpAdapter as IDXGIAdapter") is dropped as obsolete:
its one-line type annotation fixed the PR's own warp_adapter_index helper,
which this merge removes. The surviving code binds EnumWarpAdapter directly
to IDXGIAdapter1 and compiles on both clippy passes.

The triage items, and what closed them

Refuse software adapters in the VICTORY_D3D12_ADAPTER path. selected_adapter
now rejects an adapter carrying DXGI_ADAPTER_FLAG_SOFTWARE rather than
honouring it, with an error saying so. The checks behind this path are
hardware-only, and a software device answers them wrongly in a way that reads
as a pass.

No fabricated index. adapter_index is Option<u32>; adapter_label
omits the index when there is none instead of printing 0, and says
"an unenumerated adapter" when it has neither. In victory-gpu, the
placeholder adapter_index: 0 / empty name is gone: that call site is now
Host::from_device(device.clone()), which upstream had already introduced, so
this PR no longer touches victory-gpu/src/host.rs at all.

Print WARP without a made-up index — verified on the hardware, not read off
the code. Probed through Host::new on an RTX 3060:

Host::new(false): index=Some(0) name="NVIDIA GeForce RTX 3060"
Host::new(true):  index=Some(1) name="Microsoft Basic Render Driver"

The software adapter is a real entry in EnumAdapters1 here (index 1, flagged
software), so the label names what the device actually runs on. Where DXGI does
not list it the label reports no adapter rather than inventing one.

A defect found while verifying, and its regression test

The default path constructed its device and never asked that device which
adapter it landed on, so a verdict from a normal run reported no adapter at all
while the selector path reported a real one. Fixed by resolving through the
device in that branch too.

the_default_device_names_its_adapter guards it. Reverted fix, test kept:

panicked: the default device is on an enumerated adapter, so a verdict should
name it: got index None, name ""

Restored fix, it passes. Also fixed here: LUIDs are compared by field, not as
structs, since LUID carries padding DXGI does not promise to zero.

Verification on this machine

Check Result
cargo build --workspace --locked clean
cargo clippy --workspace --all-targets --locked -- -D warnings clean
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean
cargo xtask policy 204 files ok
cargo test -p victory-shader --lib (skip the #2571 crash) 303 passed, 3 failed
cargo test -p victory-gpu --lib 229 passed, 2 failed

The 3 + 2 failures are the pre-existing hardware-only ones in #2571 and #3178,
identical to the same suites on 63bcca4 with nothing applied. None is caused
by this change.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5492650481 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2456). Originally posted by [makmatvey](https://github.com/makmatvey) on 2026-11-25T13:51:56Z. --- FIND-3: `VICTORY_D3D12_ADAPTER` (index or description substring) selects the offline emit host; each pipeline created/refused line names that adapter. ## Rebased onto `63bcca4`, and merged with upstream's WARP work Upstream added a shared WARP device, a `WARP_LOCK` and a `warp` field to the same code this PR rewrites. Rather than choose one side, the two are merged: - the WARP device stays shared and serialised exactly as upstream made it; - the adapter is read from that device by LUID instead of being enumerated a second time, so the lock covers one `create_device`, not two enumerations that have to agree. `d58745e` ("annotate EnumWarpAdapter as IDXGIAdapter") is dropped as obsolete: its one-line type annotation fixed the PR's own `warp_adapter_index` helper, which this merge removes. The surviving code binds `EnumWarpAdapter` directly to `IDXGIAdapter1` and compiles on both clippy passes. ## The triage items, and what closed them **Refuse software adapters in the `VICTORY_D3D12_ADAPTER` path.** `selected_adapter` now rejects an adapter carrying `DXGI_ADAPTER_FLAG_SOFTWARE` rather than honouring it, with an error saying so. The checks behind this path are hardware-only, and a software device answers them wrongly in a way that reads as a pass. **No fabricated index.** `adapter_index` is `Option<u32>`; `adapter_label` omits the index when there is none instead of printing `0`, and says `"an unenumerated adapter"` when it has neither. In `victory-gpu`, the placeholder `adapter_index: 0` / empty name is gone: that call site is now `Host::from_device(device.clone())`, which upstream had already introduced, so this PR no longer touches `victory-gpu/src/host.rs` at all. **Print WARP without a made-up index** — verified on the hardware, not read off the code. Probed through `Host::new` on an RTX 3060: ``` Host::new(false): index=Some(0) name="NVIDIA GeForce RTX 3060" Host::new(true): index=Some(1) name="Microsoft Basic Render Driver" ``` The software adapter is a real entry in `EnumAdapters1` here (index 1, flagged software), so the label names what the device actually runs on. Where DXGI does not list it the label reports no adapter rather than inventing one. ## A defect found while verifying, and its regression test The default path constructed its device and never asked that device which adapter it landed on, so a verdict from a normal run reported no adapter at all while the selector path reported a real one. Fixed by resolving through the device in that branch too. `the_default_device_names_its_adapter` guards it. Reverted fix, test kept: ``` panicked: the default device is on an enumerated adapter, so a verdict should name it: got index None, name "" ``` Restored fix, it passes. Also fixed here: LUIDs are compared by field, not as structs, since `LUID` carries padding DXGI does not promise to zero. ## Verification on this machine | Check | Result | |-------|--------| | `cargo build --workspace --locked` | clean | | `cargo clippy --workspace --all-targets --locked -- -D warnings` | clean | | `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` | clean | | `cargo xtask policy` | 204 files ok | | `cargo test -p victory-shader --lib` (skip the #2571 crash) | 303 passed, 3 failed | | `cargo test -p victory-gpu --lib` | 229 passed, 2 failed | The 3 + 2 failures are the pre-existing hardware-only ones in #2571 and #3178, identical to the same suites on `63bcca4` with nothing applied. None is caused by this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DenRakEiw commented 2026-11-25 13:54:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:54:27Z.

Review: COMMENTED


Tested against origin/main (940d32f) on Windows 11:

  • Compile error on Windows (victory-shader):
    error[E0282]: type annotations needed
       --> crates\victory-shader\src\emit\host.rs:190:21
        |
    190 |                 let warp_adapter = factory.EnumWarpAdapter().map_err(err)?;
        |                     ^^^^^^^^^^^^
    191 |                 let adapter: IDXGIAdapter1 = warp_adapter.cast().map_err(err)?;
        |                                              ------------ type must be known at this point
    
    IDXGIFactory4::EnumWarpAdapter is generic over T: Interface, so calling let adapter: IDXGIAdapter1 = factory.EnumWarpAdapter().map_err(err)?; directly (or specifying ::<IDXGIAdapter>) will fix the Windows build.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6058884866 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2456#pullrequestreview-6058884866). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T13:54:27Z. **Review:** COMMENTED --- Tested against `origin/main` (`940d32f`) on Windows 11: - **Compile error on Windows (`victory-shader`):** ``` error[E0282]: type annotations needed --> crates\victory-shader\src\emit\host.rs:190:21 | 190 | let warp_adapter = factory.EnumWarpAdapter().map_err(err)?; | ^^^^^^^^^^^^ 191 | let adapter: IDXGIAdapter1 = warp_adapter.cast().map_err(err)?; | ------------ type must be known at this point ``` `IDXGIFactory4::EnumWarpAdapter` is generic over `T: Interface`, so calling `let adapter: IDXGIAdapter1 = factory.EnumWarpAdapter().map_err(err)?;` directly (or specifying `::<IDXGIAdapter>`) will fix the Windows build. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 14:11:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:26Z.

Review: COMMENTED


VICTORY_D3D12_ADAPTER for the offline translate --pipelines host, verdicts name the adapter. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Complements the adapter-selection cluster (#1889/#2367/#2371) — those cover runtime, this covers offline translate; fine as its own PR.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059179956 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2456#pullrequestreview-6059179956). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:11:26Z. **Review:** COMMENTED --- VICTORY_D3D12_ADAPTER for the offline translate --pipelines host, verdicts name the adapter. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Complements the adapter-selection cluster (#1889/#2367/#2371) — those cover runtime, this covers offline translate; fine as its own PR.
kotekompotek commented 2026-11-25 15:04:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T14:24:21Z.


Reviewed — clean addition. Adapter selection covers index and case-insensitive substring, WARP index resolved by LUID rather than assumed, and naming the adapter on every verdict makes "hardware" results self-describing (a verdict on GTX 1050 vs RTX means different things — this is exactly the ambiguity pipeline reports had). The gpu-side fuses_fmad construction fills defaults; adapter_label is not called there, so harmless. Selector is unit-tested.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165227354 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2456#issuecomment-7165227354). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T14:24:21Z. --- Reviewed — clean addition. Adapter selection covers index and case-insensitive substring, WARP index resolved by LUID rather than assumed, and naming the adapter on every verdict makes "hardware" results self-describing (a verdict on GTX 1050 vs RTX means different things — this is exactly the ambiguity pipeline reports had). The gpu-side `fuses_fmad` construction fills defaults; `adapter_label` is not called there, so harmless. Selector is unit-tested.
Marvisak commented 2026-11-25 16:09:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:55:28Z.


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main (conflicts in crates/victory-gpu/src/host.rs and crates/victory-shader/src/emit/host.rs). It will be reviewed again once it is rebased.

From the earlier needs-work note, still open: refuse software adapters in the VICTORY_D3D12_ADAPTER path, print WARP without a made-up index, and avoid the placeholder adapter_index: 0 / empty name in victory-gpu's Host.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167433880 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2456#issuecomment-7167433880). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:55:28Z. --- <!-- victory-triage v1 head=d58745e1c97895618938eb9d8156efeeece94dcb verdict=needs-rebase at=2026-11-25T22:32:40Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/host.rs` and `crates/victory-shader/src/emit/host.rs`). It will be reviewed again once it is rebased. From the earlier needs-work note, still open: refuse software adapters in the `VICTORY_D3D12_ADAPTER` path, print WARP without a made-up index, and avoid the placeholder `adapter_index: 0` / empty name in `victory-gpu`'s `Host`. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-27 00:05:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:05:12Z.

Review: APPROVED


LGTM — verified rustfmt, cargo xtask policy, cargo clippy (--all-targets and --all-features across victory-shader and victory), victory tests (18 passed), and emit::host:: on both hardware and WARP (6 passed on each, including the_default_device_names_its_adapter and adapter_selector_tests).

The VICTORY_D3D12_ADAPTER matching, software-adapter rejection, LUID-based describe_adapter / Host::from_device identification, and translate --pipelines / VICTORY_PAIRS verdict formatting are all solid and clean.

A few minor non-blocking notes:

  • In translate.rs:176, 222, 641, worker threads build their own Host while formatting verdicts with the preflight pipeline_adapter label (unlike VICTORY_PAIRS, which uses the Host it builds).
  • In host.rs:156, 306, describe_adapter and selected_adapter call GetDesc1 a second time after already obtaining the descriptor.
  • In host.rs:263, 291, selected_adapter treats any EnumAdapters1 error as end-of-enumeration while aborting early if GetDesc1 fails on an earlier adapter.
  • README.md:215 could optionally note that an empty VICTORY_D3D12_ADAPTER="" errors rather than falling back, that VICTORY_WARP=1 takes precedence over it, and that it also applies to VICTORY_PAIRS.
<!-- greyfinch-sync:Marvisak/VIctory:review:6081843184 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2456#pullrequestreview-6081843184). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T00:05:12Z. **Review:** APPROVED --- LGTM — verified `rustfmt`, `cargo xtask policy`, `cargo clippy` (`--all-targets` and `--all-features` across `victory-shader` and `victory`), `victory` tests (18 passed), and `emit::host::` on both hardware and WARP (6 passed on each, including `the_default_device_names_its_adapter` and `adapter_selector_tests`). The `VICTORY_D3D12_ADAPTER` matching, software-adapter rejection, LUID-based `describe_adapter` / `Host::from_device` identification, and `translate --pipelines` / `VICTORY_PAIRS` verdict formatting are all solid and clean. A few minor non-blocking notes: - In `translate.rs:176, 222, 641`, worker threads build their own `Host` while formatting verdicts with the preflight `pipeline_adapter` label (unlike `VICTORY_PAIRS`, which uses the `Host` it builds). - In `host.rs:156, 306`, `describe_adapter` and `selected_adapter` call `GetDesc1` a second time after already obtaining the descriptor. - In `host.rs:263, 291`, `selected_adapter` treats any `EnumAdapters1` error as end-of-enumeration while aborting early if `GetDesc1` fails on an earlier adapter. - `README.md:215` could optionally note that an empty `VICTORY_D3D12_ADAPTER=""` errors rather than falling back, that `VICTORY_WARP=1` takes precedence over it, and that it also applies to `VICTORY_PAIRS`.

Pull request closed

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
Marvisak/VIctory!2454
No description provided.