Documentation
¶
Overview ¶
Package gpu names graphics adapters across platforms so that capture and encode backends can agree on which device owns a frame.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
Adapter Adapter
// Handle is the ID3D11Device* on Windows. It is 0 on macOS, where
// IOSurfaces move between Metal, VideoToolbox and ScreenCaptureKit on
// their own, and on Linux, where frames are DMA-BUFs or memory and
// each encoder opens its own context on the adapter.
Handle uintptr
}
Device is a GPU device that frames live on, shared by capture, encode, decode and presentation so a frame never leaves its GPU.
type LUID ¶
type LUID uint64
LUID identifies an adapter for the lifetime of a boot on Windows (DXGI adapter LUID). On macOS it is the Metal registry ID; on Linux the device number of its DRM render node (see RenderNodes).
type PowerGuard ¶
type PowerGuard struct {
Adapter Adapter
Mode PowerMode
Reason error
// Executable is the program name the policy is bound to.
Executable string
// contains filtered or unexported fields
}
PowerGuard holds a GPU power policy until Close. It never fails to acquire: when the policy cannot be applied (no NVIDIA driver, no rights to write driver settings) Mode is PowerUnchanged and Reason holds the cause, and the encoder runs at the driver's default clocks.
func AcquireHighPerf ¶
func AcquireHighPerf(adapter Adapter) *PowerGuard
AcquireHighPerf keeps an AMD GPU at its highest clocks while the process runs, through amdgpu's power_dpm_force_performance_level, where this user may write it (root, or a udev rule granting it). Elsewhere it changes nothing: NVIDIA's Linux driver has no per-application power policy (locking clocks with nvidia-smi needs root and holds for every process), and Intel's has none to set.
func (*PowerGuard) Close ¶
func (g *PowerGuard) Close() error
Close restores what AcquireHighPerf changed. It is safe to call twice.
type PowerMode ¶
type PowerMode uint8
PowerMode is what AcquireHighPerf achieved on an adapter.
const ( // PowerUnchanged: no policy was applied; Reason says why. PowerUnchanged PowerMode = iota // PowerNotNeeded: the vendor's encoder does not drop to an idle clock // under a paced load, so there is nothing to change. PowerNotNeeded // PowerMaxPerformance: the driver keeps the adapter at its highest // performance state while this process runs. PowerMaxPerformance )
type RenderNode ¶ added in v0.2.0
RenderNode is a DRM render node, /dev/dri/renderD*, which decoders, encoders and presenting surfaces open without a display's master rights.
func RenderNodeFor ¶ added in v0.2.0
func RenderNodeFor(vendor Vendor) (RenderNode, error)
RenderNodeFor is the first render node of vendor, or of any vendor for VendorUnknown.
func RenderNodes ¶ added in v0.2.0
func RenderNodes() ([]RenderNode, error)
RenderNodes lists the system's render nodes in number order. On Linux an Adapter's LUID is its render node's device number (st_rdev), the same for every process during a boot; its vendor and device come from sysfs.