scripts: ask for the high-performance GPU on two-GPU laptops #126

Open
Logan-Gaillard wants to merge 1 commit from upstream-pr/126 into main
Logan-Gaillard commented 2026-11-25 14:10:59 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Logan-Gaillard on 2026-11-25T13:13:14Z.


On a laptop with an integrated GPU and a discrete one, Windows gives a newly built exe the power-saving GPU. There the game fails at once: on an RTX 5070 Laptop + Intel iGPU machine, fresh builds run without a preference died with E_OUTOFMEMORY (the log shows wave lanes 8–32 and a "card budget" that is shared RAM), as reported in the opening post of #91, until the exe was given the high-performance GPU.

scripts/play.ps1 now sets the per-application graphics preference for the exe it runs: current user only, the same setting as Settings → System → Display → Graphics (HKCU\Software\Microsoft\DirectX\UserGpuPreferences, GpuPreference=2). Nothing system-wide changes. -KeepGpuChoice leaves it alone.

Tested: this is the same registry value our test runner writes before every run (Set-GpuPreference), which is how all of that bench's runs got the discrete GPU. play.ps1 itself parses but was not run end to end.

From a three-agent test bench (reviewed by @1mlesc before posting). No game data.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6605292821 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/126). Originally posted by [Logan-Gaillard](https://github.com/Logan-Gaillard) on 2026-11-25T13:13:14Z. --- On a laptop with an integrated GPU and a discrete one, Windows gives a newly built exe the power-saving GPU. There the game fails at once: on an RTX 5070 Laptop + Intel iGPU machine, fresh builds run without a preference died with `E_OUTOFMEMORY` (the log shows `wave lanes 8–32` and a "card budget" that is shared RAM), as reported in the opening post of #91, until the exe was given the high-performance GPU. `scripts/play.ps1` now sets the per-application graphics preference for the exe it runs: current user only, the same setting as Settings → System → Display → Graphics (`HKCU\Software\Microsoft\DirectX\UserGpuPreferences`, `GpuPreference=2`). Nothing system-wide changes. `-KeepGpuChoice` leaves it alone. Tested: this is the same registry value our test runner writes before every run (`Set-GpuPreference`), which is how all of that bench's runs got the discrete GPU. `play.ps1` itself parses but was not run end to end. <sub>From a three-agent test bench (reviewed by @1mlesc before posting). No game data.</sub>
xiaotu030202 commented 2026-11-25 16:13:08 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T15:24:45Z.


I can confirm the mechanism on a real Windows 11 machine, including the exact value string — this is the kind of claim that is easy to get subtly wrong and cheap to check.

The registry key is real and already populated

HKCU:\Software\Microsoft\DirectX\UserGpuPreferences exists on this box (RTX 5070 Ti, Windows 11 22631) without anything having to create it, and four applications were already using it:

C:\Users\...\DoubaoWork\Application\app\pip_main.exe        GpuPreference=2;
C:\Program Files (x86)\ASUS\ArmouryDevice\asus_framework.exe GpuPreference=1;
C:\Users\...\Tencent\...\env_detect.exe                      GpuPreference=2;
C:\Users\...\Tencent\...\env_detect.exe  (25819)             GpuPreference=2;

Two things that follows:

The value format matches yours exactly — GpuPreference=2;, with the trailing semicolon. I wrote and read back a test entry to be sure the type and shape survive:

New-ItemProperty -Path $key -Name $exe -Value 'GpuPreference=2;' -PropertyType String -Force
(Get-ItemProperty -Path $key -Name $exe).$exe
# -> GpuPreference=2;

2 is what other applications use for "high performance" and 1 for "power saving", which is the same numbering the Settings > Graphics dropdown writes. Armoury Crate on this machine is explicitly set to 1 (it wants the iGPU); three other apps are 2. So your constant is the right one and the semantics are not something you inferred from documentation alone — they are observable in a real profile.

I also confirmed Resolve-Path $Exe is not decorative: the key is matched against the full path, and the existing entries above are all absolute. A relative .\target\release\victory.exe in the key would not match. Your line before the write is load-bearing.

Where I would push back slightly

Resolve-Path throws when the exe is missing, and it now does so before the old code would have failed.

Unpatched, a bad -Exe produced whatever error came later from Start-Process — after New-Item had created the cache and data directories, and after the Env: cleanup. Patched, Resolve-Path throws at that line, so $Cache/$Data are no longer created and VICTORY_CACHE_DIR is no longer set. That is arguably better (fail earlier, change nothing) but it is a behaviour change in the failure path that the PR description does not mention. Worth one sentence either way.

The write is not attempted under -KeepGpuChoice, but nothing tells the user the preference persists. The registry value outlives the script. Someone who runs play.ps1 once and later wants the default back has to go to Settings > Graphics, or pass -KeepGpuChoice before the first run — after the value is written, the switch does nothing. A line saying so, or a -DefaultGpuChoice that removes the value, would close that.

Neither is a blocker; the core change is right and the switch name is honest about what it does.

What I could not test

I have no second GPU, so I cannot demonstrate the failure it fixes — that a freshly built exe lands on the iGPU and dies with E_OUTOFMEMORY. The report's premise (Windows picks the power-saving adapter for a new binary) is consistent with what I see here — the fact that applications bother to write GpuPreference=2; at all is evidence that the default is not the discrete one — but the actual iGPU path is untested on this machine.

If you want that covered, a Get-ItemProperty check after a run on the two-GPU laptop would show the value stuck, which is the closest thing to a test this can have.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7166801428 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/126#issuecomment-7166801428). Originally posted by [xiaotu030202](https://github.com/xiaotu030202) on 2026-11-25T15:24:45Z. --- I can confirm the mechanism on a real Windows 11 machine, including the exact value string — this is the kind of claim that is easy to get subtly wrong and cheap to check. ## The registry key is real and already populated `HKCU:\Software\Microsoft\DirectX\UserGpuPreferences` exists on this box (RTX 5070 Ti, Windows 11 22631) **without anything having to create it**, and four applications were already using it: ``` C:\Users\...\DoubaoWork\Application\app\pip_main.exe GpuPreference=2; C:\Program Files (x86)\ASUS\ArmouryDevice\asus_framework.exe GpuPreference=1; C:\Users\...\Tencent\...\env_detect.exe GpuPreference=2; C:\Users\...\Tencent\...\env_detect.exe (25819) GpuPreference=2; ``` Two things that follows: **The value format matches yours exactly** — `GpuPreference=2;`, with the trailing semicolon. I wrote and read back a test entry to be sure the type and shape survive: ```powershell New-ItemProperty -Path $key -Name $exe -Value 'GpuPreference=2;' -PropertyType String -Force (Get-ItemProperty -Path $key -Name $exe).$exe # -> GpuPreference=2; ``` **`2` is what other applications use for "high performance" and `1` for "power saving"**, which is the same numbering the Settings > Graphics dropdown writes. Armoury Crate on this machine is explicitly set to `1` (it wants the iGPU); three other apps are `2`. So your constant is the right one and the semantics are not something you inferred from documentation alone — they are observable in a real profile. I also confirmed `Resolve-Path $Exe` is not decorative: the key is matched against the **full path**, and the existing entries above are all absolute. A relative `.\target\release\victory.exe` in the key would not match. Your line before the write is load-bearing. ## Where I would push back slightly **`Resolve-Path` throws when the exe is missing, and it now does so before the old code would have failed.** Unpatched, a bad `-Exe` produced whatever error came later from `Start-Process` — after `New-Item` had created the cache and data directories, and after the `Env:` cleanup. Patched, `Resolve-Path` throws at that line, so `$Cache`/`$Data` are no longer created and `VICTORY_CACHE_DIR` is no longer set. That is arguably better (fail earlier, change nothing) but it is a behaviour change in the failure path that the PR description does not mention. Worth one sentence either way. **The write is not attempted under `-KeepGpuChoice`, but nothing tells the user the preference persists.** The registry value outlives the script. Someone who runs `play.ps1` once and later wants the default back has to go to Settings > Graphics, or pass `-KeepGpuChoice` *before* the first run — after the value is written, the switch does nothing. A line saying so, or a `-DefaultGpuChoice` that removes the value, would close that. Neither is a blocker; the core change is right and the switch name is honest about what it does. ## What I could not test **I have no second GPU**, so I cannot demonstrate the failure it fixes — that a freshly built exe lands on the iGPU and dies with `E_OUTOFMEMORY`. The report's premise (Windows picks the power-saving adapter for a new binary) is consistent with what I see here — the fact that applications bother to write `GpuPreference=2;` at all is evidence that the default is not the discrete one — but the actual iGPU path is untested on this machine. If you want that covered, a `Get-ItemProperty` check after a run on the two-GPU laptop would show the value stuck, which is the closest thing to a test this can have.
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/126:upstream-pr/126'
git switch 'upstream-pr/126'

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/126'
git switch 'upstream-pr/126'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/126'
git switch 'upstream-pr/126'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/126'
git switch 'main'
git merge --squash 'upstream-pr/126'
git switch 'main'
git merge --ff-only 'upstream-pr/126'
git switch 'main'
git merge 'upstream-pr/126'
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
Zettrox/ztrx!126
No description provided.