Repository navigation
obs-gpu-status: Pick the macOS render GPU by registry ID - #1195
Merged
Merged
Conversation
zackees
approved these changes
Oct 17, 2026
vpacher
force-pushed
the
feat/gpu-render-adapter-macos
branch
from
October 17, 2026 07:39
0a7b98f to
7bdd8c0
Compare
Member
Author
This was referenced Oct 17, 2026
Member
On macOS the key for the render GPU is its IORegistry entry ID: MTLDevice.registryID of the default Metal device equals the entry ID of its IOAccelerator, which also holds the PerformanceStatistics that obs-rust#1026 reads (checked on an M1 Max: both 0x100000b5b). render_adapter_from_registry() and RenderAdapter::RegistryId are a stub that returns Unknown, so the cases that need a pick fail: Apple Silicon, the discrete GPU of a two-GPU MacBook Pro, a Metal ID without an IOKit list, and one or two GPUs without a Metal device. Refs obs-rust#1020 Co-Authored-By: Claude Opus 5.5 <[email protected]>
render_adapter_from_registry() takes the registry ID of Metal's default GPU and the registry IDs of the IOAccelerator services. A Metal ID is the answer if IOKit lists it or lists nothing; one IOKit says is not there is Unknown. Without a Metal device, one GPU is the answer and two or more are Ambiguous. platform/macos.rs reads both sources: MTLCreateSystemDefaultDevice and -registryID through objc_msgSend, and IOServiceGetMatchingServices for "IOAccelerator" with IORegistryEntryGetRegistryEntryID. Metal, IOKit and libobjc are opened with libloading (macOS-only dependency, already in the workspace for obs-nvenc), so no framework is added to the link. Both renderers use Metal's default GPU: libobs-metal creates its device with MTLCreateSystemDefaultDevice, and the Cocoa OpenGL context does not allow offline renderers. Refs obs-rust#1020 Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
force-pushed
the
feat/gpu-render-adapter-macos
branch
from
October 17, 2026 08:42
7bdd8c0 to
9ce881c
Compare
Member
Author
|
Rebased onto master (f861687) with #1194's commits dropped ( |
This was referenced Oct 17, 2026
vpacher
added a commit
to vpacher/obs-studio
that referenced
this pull request
Oct 17, 2026
obs-rust#1262) * obs-gpu-status: macOS Device Utilization % parser (RED, Refs obs-rust#1026) Tier 1 tests for iokit::device_utilization on a PerformanceStatistics dictionary captured from an M1 Max (macOS 26.7.1) while the GPU was busy. The stub returns Unavailable: the captured dictionary and the 0 and 100 bounds fail; a missing key and values outside 0 to 100 pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> * obs-gpu-status: macOS Device Utilization % parser (GREEN, Refs obs-rust#1026) iokit::device_utilization takes the PerformanceStatistics number entries and returns Device Utilization % as the whole-GPU percent. Renderer and Tiler Utilization % are parts of the GPU and do not stand in for it. A missing key or a value outside 0 to 100 is Unavailable. 129/129 crate tests pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> * obs-gpu-status: macOS GPU: x% from IOKit (Fixes obs-rust#1026) platform::usage_sources() gets an IOKit source on macOS. It reads the PerformanceStatistics dictionary of the IOAccelerator service with the render adapter's registry ID (obs-rust#1195) through IORegistryEntryIDMatching and IORegistryEntryCreateCFProperty, and gives its number entries to iokit::device_utilization. IOKit and CoreFoundation open at run time through libloading, as the rest of the macOS code does. The JSON source name is "iokit". The probe prints the label's sample. On an M1 Max (macOS 26.7.1) the render adapter is 0x100000b5b (AGXAcceleratorG13X); the sample is 13 % idle and 99 % under a Metal compute load, the same as ioreg, in about 0.6 ms. clippy -D warnings is clean for macOS and Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: GPU status label screenshot on macOS (Refs obs-rust#1026) The status bar of this branch's app on an M1 Max under a Metal compute load: GPU: 99% with a green dot (ioreg: Device Utilization % 98). 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.
Refs #1020 (macOS part; Linux was #1194, the Windows DXGI LUID part is #1198)
What and why
On macOS the key for the GPU that OBS renders on is its IORegistry entry ID.
MTLDevice.registryIDof the default Metal device equals the entry ID of the GPU'sIOAcceleratorservice, and that service holds thePerformanceStatisticsthat #1026 reads. Checked on two machines:MTLCreateSystemDefaultDevice().registryIDioreg -c IOAccelerator0x100000b5bAGXAcceleratorG13X, id0x100000b5b0x100000648AGXAcceleratorG13G_B0, id0x100000648Both renderers use Metal's default GPU: libobs-metal creates its device with
MTLCreateSystemDefaultDevice()(device_createignores the adapter number), and the Cocoa OpenGL context does not allow offline renderers. So no frontend plumbing is needed on macOS; the render node argument is unused there.This PR:
RenderAdapter::RegistryId(u64).render_adapter_from_registry(render, gpus)(pure): a Metal ID is the answer if IOKit lists it or lists nothing; a Metal ID that IOKit does not list isUnknown(the sources disagree, so nothing is picked). Without a Metal device, one GPU is the answer and two or more areAmbiguous.platform/macos.rs:MTLCreateSystemDefaultDevice+-registryID(throughobjc_msgSend, cast to the method's exact type) andIOServiceGetMatchingServices("IOAccelerator")+IORegistryEntryGetRegistryEntryID. Metal, IOKit and libobjc are opened withlibloading(macOS-only dependency, already in the workspace for obs-nvenc), so no framework is added to the link.platform::render_adapter()uses it on macOS. Other non-Linux, non-Windows hosts returnUnknown.Not tested on real hardware: a Mac with two GPUs (Intel MacBook Pro with integrated + discrete). The fixture covers that case.
RED → GREEN
tests/gpu_status/render_adapter.rswith a stub that returnsUnknown. 4 fail (Apple Silicon and the discrete GPU of a two-GPU MacBook Pro in one case, a Metal ID without an IOKit list, one GPU without a Metal device, two GPUs without one); the 2Unknowncases pass with the stub.-D warnings, rustfmt and dylint clean on macOS../lintpasses on Linux (Debian 13) with--with pyyaml(see note below).probeprintsRegistryId(4294970203)(=0x100000b5b) on the M1 Max andRegistryId(4294968904)(=0x100000648) on the M1, the IDs in the table above.Note: on master,
./lintfails on hosts without a system PyYAML:ci/test_ccache_launcher_installed.pydeclarespyyamlas an inline script dependency, but the gate runs it withpython -m unittest. Not part of this PR.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