d3d12: the relay off by default on AMD cards #3403

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u origin "fix/amd-relay-default:fix/amd-relay-default"
git switch "fix/amd-relay-default"
Open
leonida/mandy
MoonEyes wants to merge 1 commit from fix/amd-relay-default into main

This pull request has changes conflicting with the target branch.

Merge manually to resolve the conflicts.

Conversation
Reviewers 0 approvals
  • No reviewers
Details

This pull request has changes conflicting with the target branch.

Merge manually to resolve the conflicts.

  • d3d12/docs/findings.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'fix/amd-relay-default:fix/amd-relay-default'
git switch 'fix/amd-relay-default'
Member

Change

With LEONIDA_RELAY unset and the host's card an AMD one (VendorId 0x1002), the relay is now off, as with LEONIDA_RELAY=0, and the log says so once. The card checked is the one the host device is made on: the one LEONIDA_ADAPTER names, otherwise DXGI's first (host::host_card_vendor, asked without making a device). A value that is set always wins, on any card. Other cards keep the relay on by default, as before.

The choice is a pure function, relay_wanted(var, vendor) in d3d12/crates/leonida-gpu/src/shadow.rs, called from shadow::relay(). Notes added to findings.md, switches.md regenerated.

Important: the launcher's scripts (d3d12/scripts/play.ps1, play-nvidia.ps1, scripts/play-linux.sh) set LEONIDA_RELAY=2 for every card. They belong to OreoFR's launcher and are not touched here. So AMD players get this default only once the launcher leaves the variable unset on AMD cards (follow-up for OreoFR).

Credit

From tyr0nsur/Darner (apps/darner/src/play.rs, around lines 2429-2447). Darner is GPL-3.0-or-later like this repository. In its players' AMD runs (2026-12-02/03, ray tracing off): 4.8 device losses an hour at stage 2 with Resizable BAR and 16 without, losses at stage 1 too (RX 6800), and 20 to 50 minutes clean at stage 0 for three players who lost the card every run before (RX 6700 XT, RX 6800, RX 7900 GRE). The cost: stage 0 halved the frame rate there.

Tests

  • cargo test -p leonida-gpu --locked: 731 passed, 0 failed, 59 ignored (Windows 11).
  • New unit tests shadow::relay_default_tests: unset gives off on AMD only, on for NVIDIA, Intel or an unknown card; a value that is set wins on every card.
  • python -I tests/test_d3d12_switches.py: OK. python -I scripts/check_no_game_data.py on the touched files: clean.
  • No AMD card here, and the game was not run.

In-game run required

An AMD volunteer runs an A/B of 30 minutes each: LEONIDA_RELAY=0 against LEONIDA_RELAY=2 (same spot, same settings, ray tracing off), and counts the 0x887A0005 losses and the frame rate in each. Merge only if relay 0 clearly loses the card less and the frame-rate cost is acceptable.

AI-assisted: written by Claude Opus 5.5 (claude-opus-5-5) in Claude Code. Independent review: pending (a separate reviewer will post its verdict here).

🤖 Generated with Claude Code

### Change With `LEONIDA_RELAY` unset and the host's card an AMD one (`VendorId` 0x1002), the relay is now off, as with `LEONIDA_RELAY=0`, and the log says so once. The card checked is the one the host device is made on: the one `LEONIDA_ADAPTER` names, otherwise DXGI's first (`host::host_card_vendor`, asked without making a device). A value that is set always wins, on any card. Other cards keep the relay on by default, as before. The choice is a pure function, `relay_wanted(var, vendor)` in `d3d12/crates/leonida-gpu/src/shadow.rs`, called from `shadow::relay()`. Notes added to `findings.md`, `switches.md` regenerated. **Important:** the launcher's scripts (`d3d12/scripts/play.ps1`, `play-nvidia.ps1`, `scripts/play-linux.sh`) set `LEONIDA_RELAY=2` for every card. They belong to OreoFR's launcher and are not touched here. So AMD players get this default only once the launcher leaves the variable unset on AMD cards (follow-up for OreoFR). ### Credit From tyr0nsur/Darner (`apps/darner/src/play.rs`, around lines 2429-2447). Darner is GPL-3.0-or-later like this repository. In its players' AMD runs (2026-12-02/03, ray tracing off): 4.8 device losses an hour at stage 2 with Resizable BAR and 16 without, losses at stage 1 too (RX 6800), and 20 to 50 minutes clean at stage 0 for three players who lost the card every run before (RX 6700 XT, RX 6800, RX 7900 GRE). The cost: stage 0 halved the frame rate there. ### Tests - `cargo test -p leonida-gpu --locked`: 731 passed, 0 failed, 59 ignored (Windows 11). - New unit tests `shadow::relay_default_tests`: unset gives off on AMD only, on for NVIDIA, Intel or an unknown card; a value that is set wins on every card. - `python -I tests/test_d3d12_switches.py`: OK. `python -I scripts/check_no_game_data.py` on the touched files: clean. - No AMD card here, and the game was not run. ### In-game run required An AMD volunteer runs an A/B of 30 minutes each: `LEONIDA_RELAY=0` against `LEONIDA_RELAY=2` (same spot, same settings, ray tracing off), and counts the 0x887A0005 losses and the frame rate in each. Merge only if relay 0 clearly loses the card less and the frame-rate cost is acceptable. AI-assisted: written by Claude Opus 5.5 (claude-opus-5-5) in Claude Code. Independent review: pending (a separate reviewer will post its verdict here). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With LEONIDA_RELAY unset and the host's card an AMD one (VendorId 0x1002:
the card LEONIDA_ADAPTER names, else DXGI's first), the relay is off as with
LEONIDA_RELAY=0, and the log says so once. A value set always decides, on
any card; other cards keep the relay on by default.

From tyr0nsur/Darner (apps/darner/src/play.rs; GPL-3.0-or-later like this
repository): in its players' AMD runs, 4.8 to 16 device losses an hour at
stage 2, and 20 to 50 minutes clean at stage 0 for three players who lost
the card every run (stage 0 cost about half the frame rate there).

The launcher's scripts still set LEONIDA_RELAY=2 for every card, so AMD
players get this default only once they leave it unset there.
Unit tests: shadow::relay_default_tests. AI-assisted (Claude Opus 5.5).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Member

Independent code review (separate read-only reviewer, Claude Opus 5.5): ACCEPT for the code; the AMD A/B is still required before merging.

  • Clean merge with main; test_d3d12_switches.py 22 OK on the branch; check_no_game_data.py clean.
  • A set value always wins (relay_wanted, shadow.rs:1595-1600); relay() is cached in a OnceLock, host_card_vendor runs once per process and follows Host::new's adapter order (WARP, LEONIDA_ADAPTER, then adapter 0).
  • Faithful to Darner's default (play.rs:2436-2447, amd_loss_guard), credit present.
  • Minor: Darner's split mode (keep the relay with Resizable BAR, turn PLACED_CONSTANTS off) and its "player set PLACED_CONSTANTS" exception are not ported; the "relay is off" line is also written when keeps() would have turned it off anyway; no player gets the default until the launcher stops setting LEONIDA_RELAY=2 (follow-up for OreoFR).
Independent code review (separate read-only reviewer, Claude Opus 5.5): **ACCEPT** for the code; the AMD A/B is still required before merging. - Clean merge with main; `test_d3d12_switches.py` 22 OK on the branch; `check_no_game_data.py` clean. - A set value always wins (`relay_wanted`, `shadow.rs:1595-1600`); `relay()` is cached in a `OnceLock`, `host_card_vendor` runs once per process and follows `Host::new`'s adapter order (WARP, `LEONIDA_ADAPTER`, then adapter 0). - Faithful to Darner's default (`play.rs:2436-2447`, `amd_loss_guard`), credit present. - Minor: Darner's `split` mode (keep the relay with Resizable BAR, turn `PLACED_CONSTANTS` off) and its "player set PLACED_CONSTANTS" exception are not ported; the "relay is off" line is also written when `keeps()` would have turned it off anyway; no player gets the default until the launcher stops setting `LEONIDA_RELAY=2` (follow-up for OreoFR).
OreoFR referenced this pull request from a commit 2026-12-04 02:26:46 +00:00
First-time contributor

Thanks @MoonEyes, here are the results.

The A/B on an RX 6800 XT (RDNA 2, driver 32.0.21045.29003), with scripts/game-gate.ps1 run -WorldSeconds 1800 -PlayArgs '-SeriesS' on main 68427be7e. Setting LEONIDA_RELAY=0 in -More gives what this PR makes the default on AMD. Both runs use LEONIDA_THIN=0, since THIN=1 loses this card at world entry (#3264). Ray tracing off, same data folder and caches, and both start from the same copy of the same save. I played the same thing in both: the first Jason mission, from the boat to the plane.

LEONIDA_RELAY Result Time in the world Device losses Mean fps Median fps p5 fps Frame p95 Longest gap Draws/frame (median)
0 (this PR) PASS 1,804 s 0 10.2 10.1 7.5 132.9 ms 3.4 s 5,192
2 (default) PASS 1,803 s 0 20.0 19.9 13.1 76.4 ms 2.3 s 5,058

The mean fps is the gate's frame count over the time it covers (the world minus its first 60 s); the rest is from summary.json. Neither run has a device loss, an ERROR line or a crash, and video memory stayed under budget in both.

So on this card, relay 0 did not lose the card less (neither run lost it in 30 min), and it halved the frame rate. By the PR's own merge condition, that does not support turning it off by default here.

Two other things:

  • The launcher sets the relay itself. d3d12/scripts/play-nvidia.ps1 line 187 sets LEONIDA_RELAY = '2' in its defaults, and this PR does not change that file. My gate runs show it: without my setting anything, their settings line had LEONIDA_RELAY=2. So the new default would only apply to runs that don't go through the launcher.
  • An observation I can't confirm: the car's lights worked in the relay 0 run but not in the relay 2 run. It may be something I did differently in game; I'm only mentioning it in case it rings a bell.

One more run, for #3264: LEONIDA_THIN=1 (6 threads) with LEONIDA_RELAY=0 passed: 301 s in the world, no device loss, 10.4 fps mean (10.4 median, 9.0 p5). With the default relay, every THIN=1 run on this card has lost the device a few seconds after the world first draws. It is only one run, though, and slow: like run 6 in #3264 (LIST_POOL=0, about 3 fps), it may pass only because it is slow. I'll post it on #3264 too.

Logs (gate run folders, Windows user and PC names replaced): mandy-3403-relay0-rx6800xt.zip, mandy-3403-relay2-rx6800xt.zip, mandy-3403-thin1-relay0-rx6800xt.zip.

AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).

Thanks @MoonEyes, here are the results. The A/B on an RX 6800 XT (RDNA 2, driver 32.0.21045.29003), with `scripts/game-gate.ps1 run -WorldSeconds 1800 -PlayArgs '-SeriesS'` on main `68427be7e`. Setting `LEONIDA_RELAY=0` in `-More` gives what this PR makes the default on AMD. Both runs use `LEONIDA_THIN=0`, since `THIN=1` loses this card at world entry (#3264). Ray tracing off, same data folder and caches, and both start from the same copy of the same save. I played the same thing in both: the first Jason mission, from the boat to the plane. | `LEONIDA_RELAY` | Result | Time in the world | Device losses | Mean fps | Median fps | p5 fps | Frame p95 | Longest gap | Draws/frame (median) | |---|---|---|---|---|---|---|---|---|---| | `0` (this PR) | **PASS** | 1,804 s | 0 | 10.2 | 10.1 | 7.5 | 132.9 ms | 3.4 s | 5,192 | | `2` (default) | **PASS** | 1,803 s | 0 | 20.0 | 19.9 | 13.1 | 76.4 ms | 2.3 s | 5,058 | The mean fps is the gate's frame count over the time it covers (the world minus its first 60 s); the rest is from `summary.json`. Neither run has a device loss, an `ERROR` line or a crash, and video memory stayed under budget in both. So on this card, relay 0 did not lose the card less (neither run lost it in 30 min), and it halved the frame rate. By the PR's own merge condition, that does not support turning it off by default here. Two other things: - **The launcher sets the relay itself.** `d3d12/scripts/play-nvidia.ps1` line 187 sets `LEONIDA_RELAY = '2'` in its defaults, and this PR does not change that file. My gate runs show it: without my setting anything, their settings line had `LEONIDA_RELAY=2`. So the new default would only apply to runs that don't go through the launcher. - **An observation I can't confirm:** the car's lights worked in the relay 0 run but not in the relay 2 run. It may be something I did differently in game; I'm only mentioning it in case it rings a bell. One more run, for #3264: **`LEONIDA_THIN=1` (6 threads) with `LEONIDA_RELAY=0` passed**: 301 s in the world, no device loss, 10.4 fps mean (10.4 median, 9.0 p5). With the default relay, every `THIN=1` run on this card has lost the device a few seconds after the world first draws. It is only one run, though, and slow: like run 6 in #3264 (`LIST_POOL=0`, about 3 fps), it may pass only because it is slow. I'll post it on #3264 too. Logs (gate run folders, Windows user and PC names replaced): `mandy-3403-relay0-rx6800xt.zip`, `mandy-3403-relay2-rx6800xt.zip`, `mandy-3403-thin1-relay0-rx6800xt.zip`. AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).
Collaborator

Checked the vendor path: chosen_adapter_logged(false) returns the LEONIDA_ADAPTER match, and host_card_vendor falls back to DXGI's first adapter, the one Host::new uses without a name. The unit tests cover unset, set and unknown. One point to state in the pull request: the play scripts set LEONIDA_RELAY=2 for every card, so this default only reaches players who run leonida.exe directly until the launcher stops setting it on AMD - your findings note says so, it deserves a line in the description too.

Checked the vendor path: `chosen_adapter_logged(false)` returns the `LEONIDA_ADAPTER` match, and `host_card_vendor` falls back to DXGI's first adapter, the one `Host::new` uses without a name. The unit tests cover unset, set and unknown. One point to state in the pull request: the play scripts set `LEONIDA_RELAY=2` for every card, so this default only reaches players who run `leonida.exe` directly until the launcher stops setting it on AMD - your findings note says so, it deserves a line in the description too.
Sign in to join this conversation.
No description provided.