dxgi

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for windows/amd64

Overview

Package dxgi captures a Windows display with DXGI Desktop Duplication. The frame stays on the GPU that owns the output; nothing is copied to memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapters

func Adapters() ([]gpu.Adapter, error)

Adapters lists the hardware adapters in DXGI order: the first is the system's default. An adapter can appear under more than one LUID (one per display path); each is listed.

func Displays

func Displays() ([]capture.Display, error)

Displays lists the outputs attached to the desktop. ID is the GDI device name (`\\.\DISPLAY1`), stable while the display layout does not change.

func FindAdapter

func FindAdapter(match string) (gpu.Adapter, error)

FindAdapter returns the first hardware adapter whose name contains match, ignoring case ("4080", "Radeon", "UHD").

Types

type Device

type Device struct {
	Info    gpu.Adapter
	Adapter win.Adapter
	D3D     win.Device
	Context win.Context
}

Device is a D3D11 device on one adapter. Capture, encode, decode and presentation share it to keep frames on that GPU.

func OpenDevice

func OpenDevice(luid gpu.LUID) (*Device, error)

OpenDevice makes a hardware D3D11 device (BGRA and video support) on the adapter with this LUID.

func (*Device) Close

func (d *Device) Close()

type Options

type Options struct {
	// HDR asks for 10-bit or FP16 surfaces through
	// IDXGIOutput5::DuplicateOutput1 when the desktop is in HDR.
	HDR bool
}

Options configure OpenDisplay.

type Source

type Source struct {
	// contains filtered or unexported fields
}

func Open

func Open(device win.Device, adapter gpu.Adapter, output win.Output, hdr bool) (*Source, error)

Open duplicates output on device, which must be a D3D11 device of the adapter that owns the output. hdr asks for 10-bit or FP16 surfaces through IDXGIOutput5::DuplicateOutput1.

func OpenDisplay

func OpenDisplay(id string, opts Options) (*Source, error)

OpenDisplay duplicates the display with this ID (`\\.\DISPLAY1`; empty for the primary display) on a new D3D11 device of the adapter that drives it. The source owns the device; encoders take it from Device.

func (*Source) AccumulatedFrames

func (s *Source) AccumulatedFrames() int

AccumulatedFrames is how many desktop presents the last frame folded in.

func (*Source) Adapter

func (s *Source) Adapter() gpu.Adapter

func (*Source) Close

func (s *Source) Close() error

func (*Source) Device

func (s *Source) Device() *Device

Device is the device OpenDisplay made, or nil for a source made by Open.

func (*Source) Format

func (s *Source) Format() capture.Format

func (*Source) Next

func (s *Source) Next(timeout time.Duration) (capture.Frame, error)

Next waits up to timeout for the compositor's next desktop image. Updates that move only the cursor are skipped. Presented is the compositor's present time and Acquired the time Next got the frame, both on the QPC clock (internal/clock).

func (*Source) Recover

func (s *Source) Recover(timeout, interval time.Duration) error

Recover reopens duplication after Next returned capture.ErrAccessLost: a mode change, a full-screen switch, or the secure desktop (UAC, lock screen), during which duplication fails until the user returns. It retries every interval until it succeeds or timeout passes. Size, Format and Refresh reflect the new mode afterwards.

func (*Source) Refresh

func (s *Source) Refresh() float64

func (*Source) Release

func (s *Source) Release() error

func (*Source) Size

func (s *Source) Size() (int, int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL