Skip to content

test: the crate's device tests ask the card with memory of its own, not the default one - #2995

Open
fiestorra wants to merge 2 commits into
ProjectLeonida:mainfrom
fiestorra:test-device-on-the-card
Open

fiestorra wants to merge 2 commits into
ProjectLeonida:mainfrom
fiestorra:test-device-on-the-card

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

test: the crate's device tests ask the card with memory of its own, not the default one

Every #[test] in this crate that makes a D3D12 device goes through host(), which
called D3D12CreateDevice(None, ..) - "Windows' default card". On a machine whose
monitor hangs off the motherboard that is the integrated chip, so the tests ran there:

  • pipeline::places' children print the vendor of the device they made, and on a
    7800X3D + RTX 4090 they printed vendor=1002 (AMD's) and not an NVIDIA card;
  • dlss_starts_on_this_card asked that Radeon whether it can start DLSS, got
    FeatureNotSupported - correct for it - and read as a statement about the 4090.

Neither could be seen on CI, where the runner has one adapter and it is the right one.

Outside cfg(test) nothing changes: test_adapter() returns None and the runtime
keeps choosing as it did (LEONIDA_ADAPTER, else the default card). In a test build it
picks the adapter with the most DedicatedVideoMemory that is not software - the card a
game would be run on, whatever its vendor.

Measured on main 1fff691 + this change, RTX 4090 / driver 621.24:

cargo test -p leonida-gpu --lib -- --test-threads=1
644 passed; 0 failed; 59 ignored (on the iGPU: 653 passed, 1 failed)
cargo clippy -p leonida-gpu --all-targets 1 warning, host.rs:7628, on main already

The one that failed on the iGPU and passes here is
descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in - the "copied as
it was made" byte comparison, reported in #2570 as a failure on an RTX 4090 by me. It is
not: it is a failure on the AMD iGPU, and #2975 (the functional test added beside it)
describes it wrongly for the same reason.

Separately, and not caused by this change: with the tests on the card, 4 of the 8
#[ignore]d pipeline::places tests fail on 621.24 (they pass vacuously on an iGPU,
which is how this went unnoticed). Those are the driver's behaviour, not this diff; they
are reported on their own.

Written with an AI assistant.

…ot the default one

Every `#[test]` in this crate that makes a D3D12 device goes through `host()`, which
called `D3D12CreateDevice(None, ..)` - "Windows' default card". On a machine whose
monitor hangs off the motherboard that is the integrated chip, so the tests ran there:

  * `pipeline::places`' children print the vendor of the device they made, and on a
    7800X3D + RTX 4090 they printed `vendor=1002` (AMD's) and `not an NVIDIA card`;
  * `dlss_starts_on_this_card` asked that Radeon whether it can start DLSS, got
    `FeatureNotSupported` - correct for it - and read as a statement about the 4090.

Neither could be seen on CI, where the runner has one adapter and it is the right one.

Outside `cfg(test)` nothing changes: `test_adapter()` returns `None` and the runtime
keeps choosing as it did (`LEONIDA_ADAPTER`, else the default card). In a test build it
picks the adapter with the most `DedicatedVideoMemory` that is not software - the card a
game would be run on, whatever its vendor.

Measured on `main` 1fff691 + this change, RTX 4090 / driver 621.24:

  cargo test -p leonida-gpu --lib -- --test-threads=1
      644 passed; 0 failed; 59 ignored          (on the iGPU: 653 passed, 1 failed)
  cargo clippy -p leonida-gpu --all-targets     1 warning, host.rs:7628, on main already

**The one that failed on the iGPU and passes here** is
`descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in` - the "copied as
it was made" byte comparison, reported in ProjectLeonida#2570 as a failure on an RTX 4090 by me. It is
not: it is a failure on the AMD iGPU, and ProjectLeonida#2975 (the functional test added beside it)
describes it wrongly for the same reason.

**Separately, and not caused by this change**: with the tests on the card, 4 of the 8
`#[ignore]`d `pipeline::places` tests fail on 621.24 (they pass vacuously on an iGPU,
which is how this went unnoticed). Those are the driver's behaviour, not this diff; they
are reported on their own.

Written with an AI assistant.
@andrew-ai

Copy link
Copy Markdown

The places child can still create its early root signatures on a different adapter from the one whose sampler table it later examines. In the existing sequence make=20,21;host, the first step reaches D3D12CreateDevice(None, ...) at pipeline/places/tests.rs:566. Only the later host step uses this PR's selector. The test expects the sampler state to carry across both handles on the same adapter.

At 2e2e163 I added temporary GetAdapterLuid logging to those two points and ran the child with diagnostics:

LEONIDA_D3D12_WARP make=20,21 host
0 RTX 5070, LUID 0:57968 RTX 5070, LUID 0:57968
1 RTX 5070, LUID 0:57968 Microsoft Basic Render Driver, LUID 0:63322

The WARP override makes the split reproducible on a single physical GPU. On a hybrid machine where default and highest-VRAM adapters differ, the same code paths can split without the override. The child reports only the host vendor today. Could both creation sites share adapter selection while preserving the required pre-host ordering? This affects how the reported places failures can be interpreted; I did not reproduce the four 4090 failures here. Codex-assisted.

andrew-ai measured the places child making its early root signatures on the card's
LUID while \host\ went to the Microsoft Basic Render Driver once LEONIDA_D3D12_WARP
was set: two devices in one run, where the test's premise is that they are one.

\	est_adapter()\ now returns None when that switch is on, so nothing is preferred and
the switch means what it says. Verified that it changes nothing otherwise: the suite is
644 passed / 0 failed with the card, as before.
@fiestorra

Copy link
Copy Markdown
Contributor Author

You are right, and thanks for instrumenting it rather than guessing. A run whose make= steps are on one device and whose host is on another is not testing what the module says it tests.

Fixed at 9e1e95930: test_adapter() now returns None when LEONIDA_D3D12_WARP is on (with diagnostics), so nothing is preferred and the switch means what it says.

One thing I could not reproduce, and it may tell you something about the harness: in my runs with LEONIDA_D3D12_WARP=1 the two steps are both on the card, because run() removes the switch for the child -

// pipeline/places/tests.rs:761-762
.env_remove("LEONIDA_ADAPTER")
.env_remove("LEONIDA_D3D12_WARP");
  • so the child never sees it and host cannot go to WARP from there. Your table must come from a harness that kept the switch (or from calling the steps directly); either way the guard is the behaviour you want, and if your instrumentation is easy to re-run, the new head is worth a look.

Measured at 9e1e95930, RTX 4090 / 621.24:

cargo test -p leonida-gpu --lib -- --test-threads=1
    644 passed; 0 failed; 59 ignored
cargo clippy -p leonida-gpu --all-targets
    1 warning, host.rs:7680, on main already (#2877 carries it)

AI-assisted: yes - DeepSeek v4.1 (flash).

Written with an AI assistant.

@andrew-ai

Copy link
Copy Markdown

Confirmed your observation about run(). My earlier reproduction invoked a_run directly. I reran both paths at 9e1e959 with the same diagnostics binary, make=20,21;host, and LEONIDA_D3D12_WARP=1 in the parent:

Entry point make device host device
run() spawning a_run RTX 5070 (LUID 0:57968) RTX 5070 (0:57968)
a_run directly RTX 5070 (0:57968) Microsoft Basic Render Driver (0:63322)

The wrapper strips the override as you said. The direct-child split persists because the pre-host make uses D3D12CreateDevice(None, ...) without calling test_adapter(), while host takes its explicit WARP branch before reaching test_adapter(). The new guard therefore does not change either measured path. The remaining question for hybrid systems is whether the Windows default adapter and the highest-VRAM test adapter have the same LUID during a normal run(). Logging both on the hybrid host would settle it. Codex-assisted.

@fiestorra

Copy link
Copy Markdown
Contributor Author

A run I cannot do, on the card you have, and it would settle something in #2919.

The question: on driver 621.24 the pipeline::places behaviour that places.rs guards against no longer happens (the_check_looks_at_every_kind_of_sampler gets places: "same", wrong: 0, read: [1, 2] where it used to get "differ"). On 616.64 the note in findings.md says it reproduced every time. Your 5070 is on 616.92 - between the two. If it reproduces on 616.92 and not on 621.24, the finding is a driver change with a version on each side instead of one card's word.

On this branch (9e1e95930, which is what makes these tests use a card at all):

cargo test -p leonida-gpu --features diagnostics --lib pipeline::places -- --ignored --nocapture --test-threads=1

What to report, whatever it says:

  1. vendor= from the PLACES line of any child (mine printed vendor=1002 before this branch, which was the whole story).
  2. test result: - 8 passed on 616.64 per the note; on 621.24 four fail.
  3. places: "same" or "differ" from the_check_looks_at_every_kind_of_sampler's panic/print, and the read: list ([[6, 7], [43, 44], [1, 2, 3]] is "its own", [[45, 46], [43, 44], [40, 41, 42]] is "another run's").

No test changes needed and it costs two minutes. If it fails the four, that is the answer: 616.92 behaves like 616.64 and 621.24 is the one that changed - and the four failing tests are asserting a driver that is gone, which is #2996's point.

AI-assisted: yes - DeepSeek v4.1 (flash).

Written with an AI assistant.

fiestorra added a commit to fiestorra/leonida-carry that referenced this pull request Dec 1, 2026
The note of 2026-11-27 says the fault reproduces every time, on an RTX 4060 Ti with
driver 616.64, and `pipeline/places.rs` is built against it. On an RTX 4090 with
621.24 it does not, and the reason is not luck:

  the_check_looks_at_every_kind_of_sampler, run "make=50;host;pipe=c:1,2p"
    places: "same", wrong: 0, read: [1, 2]     (the samplers it should read)

  the_table_of_static_samplers
    host:                places 0 to 15 hold [0, 1, 2, 3, …, 15]
    host;make=22,20,21:  places 0 to 15 hold [0, 1, 2, 3, …, 15]
    on 616.64:           [22, 20, 21, 0, 1, …, 12]

Three samplers made first take no place in this list's table, so a list's samplers are
numbered within the list and another run's order cannot move them - which is the fault's
mechanism, gone.

Measured without the game, with the tests' device on that card (they use
`D3D12CreateDevice(None, ..)`, which on this machine is the Radeon iGPU - ProjectLeonida#2995).

Four of the eight #[ignore]d places tests now fail, and each is asserting 616.64; they are
named in the section so that the next person does not read the red as a regression.

Not settled, and said so in the section: whether it is per root signature, per pipeline or
per device with another rule, and it is one card.

Written with an AI assistant.
@merzleckeier

Copy link
Copy Markdown
Contributor

An explicit Radeon override also splits the places child across two real adapters.

I added the same GetAdapterLuid trace before and after the host step at 2e2e16323 and 9e1e95930 on 002bd88f8, then invoked the ignored pipeline::places::tests::a_run directly with LEONIDA_PLACES_RUN="make=20,21;host". With both adapters visible and no override, both steps used the RTX 4070 SUPER. With LEONIDA_ADAPTER=Radeon and WARP unset, both heads made the early root signatures on NVIDIA and then used a different Radeon LUID for host. The direct D3D12CreateDevice(None, ...) in a_run bypasses the override as well as test_adapter(). With WARP requested, both heads reached the host WARP branch without entering the preference helper. DXVK does not provide a software WARP adapter here, so those lanes ended at PLACES none.

I also tried a local variant that moves the existing device creation into one helper, called both by host and by the early a_run step. Both steps then used the same Radeon LUID under the override and the same NVIDIA LUID in the default control. When WARP was requested, the shared path reached the unavailable WARP selection before making any root signatures on hardware. This covers device selection under Wine 11.22 / VKD3D-Proton 3.1.0, with RTX 4070 SUPER and Radeon Raphael visible. Synthetic test only. AI-assisted with OpenAI Codex and independent raw-log verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants