gpu/adapter: fall back to numeric model token when index is out of range #81

Merged
certified-retart merged 1 commit from upstream-pr/82 into main 2026-11-23 10:36:03 +00:00
certified-retart commented 2026-11-23 01:56:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by certified-retart on 2026-11-23T01:56:57Z.


Summary

Allows numeric GPU model selectors like XCL_ADAPTER=5070, XCL_ADAPTER=3080, or XCL_ADAPTER=7900 to work naturally without breaking numeric adapter index selection (0, 1, ...).

Previously, Selector::parse turned any integer string into Selector::Index(n) and matched only by adapter index, so XCL_ADAPTER=5070 reported no match even when "NVIDIA GeForce RTX 5070" was present.

Changes

  • crates/xcl/src/gpu/adapter.rs:
    • Require canonical non-negative ASCII digits ("0" or no leading zero, no leading +) for Selector::Index, preserving inputs like "+1" or "007" as Selector::Name.
    • Added contains_numeric_token and select_indices: when Selector::Index(n) is out of range (n >= names.len()), fall back to matching n as a standalone numeric token bounded by non-digits (so 5070 matches RTX 5070, 7900 matches RX 7900XTX, and 770 matches Arc A770, while an out-of-range index like 2 does not falsely match RTX 2080).
    • Wired candidates through select_indices.
  • crates/xcl/src/gpu/adapter_tests.rs:
    • Added unit tests for 0, 007, +1, in-range index precedence, out-of-range model fallback (5070, 7900, 770) with Unicode ™/® names, empty adapter lists, and non-digit token boundary rejection (2, 208, 80 against RTX 2080).

Verification

  • cargo test -p xcl --lib gpu::adapter::tests -- --test-threads=2: 3 passed; 0 failed.
<!-- greyfinch-sync:ivall/xcl:issue:6550690900 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/82). Originally posted by [certified-retart](https://github.com/certified-retart) on 2026-11-23T01:56:57Z. --- ## Summary Allows numeric GPU model selectors like `XCL_ADAPTER=5070`, `XCL_ADAPTER=3080`, or `XCL_ADAPTER=7900` to work naturally without breaking numeric adapter index selection (`0`, `1`, ...). Previously, `Selector::parse` turned any integer string into `Selector::Index(n)` and matched only by adapter index, so `XCL_ADAPTER=5070` reported no match even when `"NVIDIA GeForce RTX 5070"` was present. ### Changes - **`crates/xcl/src/gpu/adapter.rs`**: - Require canonical non-negative ASCII digits (`"0"` or no leading zero, no leading `+`) for `Selector::Index`, preserving inputs like `"+1"` or `"007"` as `Selector::Name`. - Added `contains_numeric_token` and `select_indices`: when `Selector::Index(n)` is out of range (`n >= names.len()`), fall back to matching `n` as a standalone numeric token bounded by non-digits (so `5070` matches `RTX 5070`, `7900` matches `RX 7900XTX`, and `770` matches `Arc A770`, while an out-of-range index like `2` does not falsely match `RTX 2080`). - Wired `candidates` through `select_indices`. - **`crates/xcl/src/gpu/adapter_tests.rs`**: - Added unit tests for `0`, `007`, `+1`, in-range index precedence, out-of-range model fallback (`5070`, `7900`, `770`) with Unicode `™`/`®` names, empty adapter lists, and non-digit token boundary rejection (`2`, `208`, `80` against `RTX 2080`). ### Verification - `cargo test -p xcl --lib gpu::adapter::tests -- --test-threads=2`: **3 passed; 0 failed**.
upstream-sync closed this pull request 2026-11-24 06:57:04 +00:00
ivall commented 2026-11-24 07:00:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T10:36:37Z.


Merged. Tested on Windows 11 with an RX 9070 (RDNA4): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7098217720 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/82#issuecomment-7098217720). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T10:36:37Z. --- Merged. Tested on Windows 11 with an RX 9070 (RDNA4): `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with `XCL_SPLIT_WAVE64=1`; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!
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
xcl-dev/xcl!81
No description provided.