Fix GPU Stats not cycling through multiple GPUs#48503
Open
pratnala wants to merge 1 commit into
Open
Conversation
ddccd54 to
6db961d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Command Palette’s Performance Monitor GPU cycling on multi-GPU systems by switching GPU identity from the perf-counter phys_N token (which collapses to phys_0 on modern Windows) to the adapter LUID, and improves the dock band UX by showing the active GPU name.
Changes:
- Key GPU perf-counter accumulation by adapter LUID and discover adapters dynamically as counters appear.
- Resolve friendly GPU names via DXGI (CsWin32) and filter out software adapters (WARP / Microsoft Basic Render Driver).
- Show the active GPU name in the dock band subtitle so Prev/Next GPU cycling is visible.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PerformanceMonitor/PerformanceWidgetsPage.cs | Adds band subtitle support to show the active GPU name. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PerformanceMonitor/NativeMethods.txt | Extends CsWin32 inputs with DXGI factory/adapter APIs and structs. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PerformanceMonitor/NativeMethods.json | Adds CsWin32 generation settings (no marshaling; preserve COM HRESULT signatures). |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PerformanceMonitor/DevHome/Helpers/GPUStats.cs | Switches GPU bucketing to LUID, adds on-tick GPU discovery, and integrates adapter naming. |
| src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PerformanceMonitor/DevHome/Helpers/GpuAdapterNames.cs | New DXGI-based adapter enumeration to map LUID → (name, software flag). |
| /// <c>(HighPart << 32) | LowPart</c>. Returns an empty map on any failure; | ||
| /// callers fall back to generic names. | ||
| /// </summary> | ||
| internal static unsafe Dictionary<long, AdapterInfo> GetByLuid() |
|
|
||
| var luidKey = ((long)(uint)desc.AdapterLuid.HighPart << 32) | desc.AdapterLuid.LowPart; | ||
| var isSoftware = ((uint)desc.Flags & DxgiAdapterFlagSoftware) != 0; | ||
| var description = desc.Description.ToString().TrimEnd('\0'); |
Comment on lines
+143
to
+147
| // A GPU can register counter instances after we were constructed | ||
| // (e.g. a discrete GPU coming out of an idle low-power state), so | ||
| // keep discovering here rather than only in the constructor. | ||
| AddGpuIfNew(luidKey); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Command Palette's Performance Monitor dock band exposes "Previous GPU" / "Next GPU" commands, but on multi-GPU machines they did nothing and only one GPU was ever shown.
Root cause:
GPUStatskeyed GPUs by thephys_Ntoken in the "GPU Engine" perf-counter instance names, assuming it enumerated physical adapters. On modern Windows that token is effectively alwaysphys_0(verified on a desktop with an RTX 4090 + AMD iGPU — all 1640 instances werephys_0), so every adapter collapsed into one bucket and the reported usage was the sum across adapters. The real per-adapter identifier is the LUID.PR Checklist
Microsoft.CmdPal.Ext.PerformanceMonitorso did not add any.Detailed Description of the Pull Request / Additional comments
phys.IDXGIFactory1/IDXGIAdapter1through CsWin32, AOT-safe) and filter out software adapters (Microsoft Basic Render Driver / WARP).Validation Steps Performed
Tested on a desktop (RTX 4090 + AMD Radeon iGPU). Prev/Next GPU now cycles between "NVIDIA GeForce RTX 4090" and "AMD Radeon(TM) Graphics", each showing its own utilization; WARP is hidden.