Repository navigation
obs-gpu-status: Pick the Windows render GPU by LUID - #1198
Merged
zackees merged 2 commits intoOct 17, 2026
Merged
Conversation
3 of 6 tasks
vpacher
force-pushed
the
feat/gpu-render-adapter-windows
branch
from
October 17, 2026 08:42
5df6e2b to
6a7f585
Compare
libobs-d3d11 renders on EnumAdapters1(obs_video_info.adapter). The key for that adapter is its DXGI LUID, which PDH's "GPU Engine" counters (obs-rust#1022) also use in their instance names. AdapterDesc gets a `luid` field (still 0 from DXGI here) and RenderAdapter a Luid variant. dxgi::render_adapter_from_dxgi() is a stub that returns Unknown, so the cases that need a pick fail: an index among two identical RTX 3060s, one or two GPUs without an index, and a known GPU next to a virtio display adapter (as in devices_from_dxgi, an unknown vendor is not a GPU). Refs obs-rust#1020 Co-Authored-By: Claude Opus 5.5 <[email protected]>
dxgi::render_adapter_from_dxgi() takes the EnumAdapters1 index that libobs-d3d11 renders on (obs_video_info.adapter) and returns that adapter's LUID. Only GPUs count, with the same rule as devices_from_dxgi (not software, not Microsoft's, a known GPU vendor). An index on anything else (WARP, a VM's display adapter) or past the list is Unknown. Without an index, one GPU is the answer and two or more are Ambiguous. platform/windows.rs fills AdapterDesc::luid from AdapterLuid (HighPart in the upper 32 bits). platform::render_adapter() now takes a RenderHint: the EGL render node on Linux, the adapter index on Windows; macOS needs neither. A smoke test runs the host path on every platform (on CI's Windows runner: Microsoft adapters only). The probe example reads a number as the index and anything else as a node, and prints registry IDs and LUIDs in hex. Refs obs-rust#1020 Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
force-pushed
the
feat/gpu-render-adapter-windows
branch
from
October 17, 2026 10:51
6a7f585 to
0d6da23
Compare
Member
|
Rebased onto master now that #1195 merged as a squash: dropped its two commits, leaving only this PR's RED and GREEN Windows commits. Will queue once CI is green. |
This was referenced Oct 17, 2026
3 of 6 tasks
3 of 6 tasks
vpacher
added a commit
to vpacher/obs-studio
that referenced
this pull request
Oct 17, 2026
platform::usage_sources() asks the PDH GPU Engine counters (obs-rust#1022, LUID (obs-rust#1198) through pdh_utilization, the busiest engine as Task Manager shows it, for every vendor. NVML cannot map the LUID to a PCI address yet, so PDH also reads NVIDIA GPUs on Windows. One sample blocks for 100 ms on the obs-gpu-usage thread, never the UI thread. The JSON source name is "pdh". 125/125 crate tests pass on macOS; clippy -D warnings is clean for macOS and x86_64-pc-windows-msvc. Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
added a commit
to vpacher/obs-studio
that referenced
this pull request
Oct 17, 2026
platform::usage_sources() asks the PDH GPU Engine counters (obs-rust#1022, LUID (obs-rust#1198) through pdh_utilization, the busiest engine as Task Manager shows it, for every vendor. NVML cannot map the LUID to a PCI address yet, so PDH also reads NVIDIA GPUs on Windows. One sample blocks for 100 ms on the obs-gpu-usage thread, never the UI thread. The JSON source name is "pdh". 125/125 crate tests pass on macOS; clippy -D warnings is clean for macOS and x86_64-pc-windows-msvc. Co-Authored-By: Claude Opus 5.5 <[email protected]>
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 17, 2026
…t#1264) * obs-gpu-status: Windows GPU: x% from PDH (RED, Refs obs-rust#1025) Source::Pdh names the Windows PDH GPU Engine counters (obs-rust#1022) in the JSON; the stub name is empty, so source_names fails. A Windows-only test requires usage_sources() to ask NVML, then PDH; it fails on Windows, where PDH is not wired in yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> * obs-gpu-status: Windows GPU: x% from PDH (GREEN, Refs obs-rust#1025) platform::usage_sources() asks the PDH GPU Engine counters (obs-rust#1022, LUID (obs-rust#1198) through pdh_utilization, the busiest engine as Task Manager shows it, for every vendor. NVML cannot map the LUID to a PCI address yet, so PDH also reads NVIDIA GPUs on Windows. One sample blocks for 100 ms on the obs-gpu-usage thread, never the UI thread. The JSON source name is "pdh". 125/125 crate tests pass on macOS; clippy -D warnings is clean for macOS and x86_64-pc-windows-msvc. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: GPU: x% ledger line covers macOS and Windows (Refs obs-rust#1025) The features ledger line for the GPU: x% label names all three platforms and their sources: NVML and gpu_busy_percent on Linux, IOKit on macOS (obs-rust#1262, merged before the ledger existed) and PDH on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Stacked: on #1195 (macOS); #1194 (Linux) is merged. Review only the last two commits: f773709 (RED) and 6a7f585 (GREEN). Once #1195 merges, this PR shrinks to them.
Fixes #1020 (with #1194 for Linux and #1195 for macOS)
What and why
libobs-d3d11 renders on
EnumAdapters1(adapterIdx)(gs_device::InitAdapter), andadapterIdxisobs_video_info.adapter, which the frontend already reads inGpuStatus.cpp. The key for that adapter is its DXGI LUID, which PDH's "GPU Engine" counters (#1022) also use in their instance names (luid_0x..._0x..._phys_0).This PR:
AdapterDesc::luid(AdapterLuidas one number,HighPartin the upper 32 bits), filled inplatform/windows.rsfromDXGI_ADAPTER_DESC1, andRenderAdapter::Luid(u64).dxgi::render_adapter_from_dxgi(index, adapters)(pure). Only GPUs count, with the ruledevices_from_dxgialready uses (feat: Windows GPU detection through DXGI adapter enumeration #942): not a software adapter, not Microsoft's, a known GPU vendor. An index on anything else (WARP, a VM's display adapter, virtio) or past the list isUnknown. Without an index, one GPU is the answer and two or more areAmbiguous.platform::render_adapter()to take aRenderHint: the EGL render node on Linux, the adapter index on Windows; macOS needs neither. This replaces theOption<&str>argument from obs-gpu-status: Resolve the render node's PCI device (Linux) #1194, so each platform gets the identifier libobs actually has. The frontend does not call it yet; the first consumer is obs-gpu-status: NVIDIA utilization through NVML (dlopen), matched by PCI bus ID #1021/obs-gpu-status: Windows GPU utilization through PDH GPU Engine counters #1022.host_render_adapter_does_not_panic, that runs the real host path on every platform (sysfs, Metal/IOKit, DXGI).probeexample reads a number as the adapter index and anything else as a render node, and prints registry IDs and LUIDs in hex.Mapping a LUID to a PCI address (for NVML on Windows, #1021) is not part of this PR:
D3DKMTQueryAdapterInfo(KMTQAITYPE_ADAPTERADDRESS)can do it when #1021 needs it.RED → GREEN
tests/gpu_status/dxgi.rswith a stub that returnsUnknown. 4 fail: an index among two identical RTX 3060s with different LUIDs, one GPU without an index, two GPUs without an index, and a known GPU next to a virtio adapter. The 2Unknowncases (WARP or out-of-range index, a VM with Microsoft adapters only) pass with the stub. The 5 existing DXGI tests still pass.-D warningsis clean on macOS, Linux and forx86_64-pc-windows-msvc(soldr cargo clippy --target x86_64-pc-windows-msvc)../lintpasses on Linux (Debian 13, with--with pyyaml, see ci: the local gate's lint lane fails without a system PyYAML (test_ccache_launcher_installed.py) #1196).Unknown). On Linux, the probe with the newRenderHintstill resolves/dev/dri/renderD128toPci("0000:2b:00.0")(RTX 3060); on macOS it returnsRegistryId(0x100000b5b)(M1 Max).Checklist
master(or the description starts with a Stacked: note)-W..., ratchets): built with scripting ON (a flag change under cmake/ or build-aux/ runs the full builds) and cross-checked with clang and MSVC (not applicable: no flag changes)🤖 Generated with Claude Code