Documentation
¶
Overview ¶
Package win holds the minimal COM, DXGI, and Direct3D 11 bindings Planck needs, called through syscall with no cgo.
Index ¶
- Constants
- Variables
- func Animate(x, y, size int32, stop <-chan struct{}) error
- func BoostThread(task string) (revert func(), err error)
- func CreateDevice(a Adapter) (Device, Context, error)
- func DisablePowerThrottling() error
- func Ptr(p uintptr) unsafe.Pointer
- type Adapter
- type AdapterDesc1
- type Box
- type Context
- func (c Context) Begin(q Query)
- func (c Context) CopyResource(dst, src *Object)
- func (c Context) CopySubresourceRegion(dst *Object, x, y uint32, src *Object, box *Box)
- func (c Context) End(q Query)
- func (c Context) Flush()
- func (c Context) GetData(q Query, out unsafe.Pointer, size uint32) uintptr
- func (c Context) Map(res *Object, mapType uint32, out *MappedSubresource) error
- func (c Context) Unmap(res *Object)
- func (c Context) WaitIdle(q Query)
- type Device
- func (d Device) CreateQuery(kind uint32) (Query, error)
- func (d Device) CreateTexture2D(desc *Texture2DDesc) (Texture, error)
- func (d Device) CreateTexture2DInit(desc *Texture2DDesc, data []byte, rowPitch uint32) (Texture, error)
- func (d Device) OpenSharedResource(handle uintptr) (Texture, error)
- func (d Device) OpenSharedResource1(handle uintptr) (Texture, error)
- func (d Device) RaiseGPUThreadPriority() int
- type Duplication
- type Factory
- type GUID
- type HRESULT
- type LUIDPair
- type MappedSubresource
- type Object
- type OutduplDesc
- type OutduplFrameInfo
- type Output
- type OutputDesc
- type OutputDesc1
- type Query
- type Rect32
- type Texture
- type Texture2DDesc
Constants ¶
const ( DXGI_FORMAT_R10G10B10A2_UNORM = 24 DXGI_FORMAT_R16G16B16A16_FLOAT = 10 DXGI_FORMAT_B8G8R8A8_UNORM = 87 DXGI_FORMAT_AYUV = 100 DXGI_FORMAT_NV12 = 103 DXGI_FORMAT_P010 = 104 DXGI_FORMAT_Y410 = 108 D3D11_USAGE_DEFAULT = 0 D3D11_USAGE_STAGING = 3 D3D11_BIND_SHADER_RESOURCE = 0x8 D3D11_BIND_RENDER_TARGET = 0x20 D3D11_CPU_ACCESS_WRITE = 0x10000 D3D11_CPU_ACCESS_READ = 0x20000 D3D11_RESOURCE_MISC_SHARED = 0x2 D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x100 D3D11_RESOURCE_MISC_SHARED_NTHANDLE = 0x800 D3D11_MAP_READ = 1 D3D11_MAP_WRITE = 2 D3D11_CREATE_DEVICE_BGRA_SUPPORT = 0x20 D3D11_CREATE_DEVICE_VIDEO_SUPPORT = 0x800 D3D11_QUERY_EVENT = 0 D3D11_QUERY_TIMESTAMP = 2 D3D11_QUERY_TIMESTAMP_DISJOINT = 3 DXGI_SHARED_RESOURCE_READ = 0x80000000 DXGI_SHARED_RESOURCE_WRITE = 1 )
Variables ¶
var ( IID_IDXGIFactory1 = NewGUID(0x770aae78, 0xf26f, 0x4dba, [8]byte{0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87}) IID_IDXGIOutput1 = NewGUID(0x00cddea8, 0x939b, 0x4b83, [8]byte{0xa3, 0x40, 0xa6, 0x85, 0x22, 0x66, 0x66, 0xcc}) IID_IDXGIOutput5 = NewGUID(0x80a07424, 0xab52, 0x42eb, [8]byte{0x83, 0x3c, 0x0c, 0x42, 0xfd, 0x28, 0x2d, 0x98}) IID_IDXGIOutput6 = NewGUID(0x068346e8, 0xaaec, 0x4b84, [8]byte{0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1}) IID_IDXGIResource = NewGUID(0x035f3ab4, 0x482e, 0x4e50, [8]byte{0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b}) IID_IDXGIResource1 = NewGUID(0x30961379, 0x4609, 0x4a41, [8]byte{0x99, 0x8e, 0x54, 0xfe, 0x56, 0x7e, 0xe0, 0xc1}) IID_IDXGIKeyedMutex = NewGUID(0x9d8e1289, 0xd7b3, 0x465f, [8]byte{0x81, 0x26, 0x25, 0x0e, 0x34, 0x9a, 0xf8, 0x5d}) IID_ID3D11Texture2D = NewGUID(0x6f15aaf2, 0xd208, 0x4e89, [8]byte{0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c}) )
var IID_ID3D11Device1 = NewGUID(0xa04bfb29, 0x08ef, 0x43d6, [8]byte{0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86})
var IID_IDXGIDevice = NewGUID(0x54ec77fa, 0x1377, 0x44e6, [8]byte{0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c})
Functions ¶
func Animate ¶
Animate shows a small non-activating window at (x, y) that changes color once per desktop composition until stop is closed, so Desktop Duplication has a new image every refresh. It never takes focus or moves the cursor.
func BoostThread ¶
BoostThread registers the calling OS thread with the Multimedia Class Scheduler Service as task ("Games", "Pro Audio"), falling back to THREAD_PRIORITY_HIGHEST when MMCSS is unavailable. At normal priority a paced encode thread wakes late often enough to add 5-30 ms tails. The caller must hold runtime.LockOSThread until it calls revert.
func CreateDevice ¶
CreateDevice makes a hardware D3D11 device on the given adapter.
func DisablePowerThrottling ¶ added in v0.2.0
func DisablePowerThrottling() error
DisablePowerThrottling opts the process out of EcoQoS: Windows 11 runs a background process, which the host is whenever a game is in front, on efficiency cores with coalesced timers, and stalls every thread in it for 20-140 ms every few seconds, MMCSS or not.
Types ¶
type Adapter ¶
type Adapter struct{ *Object }
func (Adapter) Desc ¶
func (a Adapter) Desc() (AdapterDesc1, error)
type AdapterDesc1 ¶
type Context ¶
type Context struct{ *Object }
func (Context) CopyResource ¶
func (Context) CopySubresourceRegion ¶
type Device ¶
type Device struct{ *Object }
func (Device) CreateTexture2D ¶
func (d Device) CreateTexture2D(desc *Texture2DDesc) (Texture, error)
func (Device) CreateTexture2DInit ¶
func (d Device) CreateTexture2DInit(desc *Texture2DDesc, data []byte, rowPitch uint32) (Texture, error)
CreateTexture2DInit creates a texture with initial pixel data for mip 0.
func (Device) OpenSharedResource ¶
OpenSharedResource opens a legacy (non-NT) shared handle.
func (Device) OpenSharedResource1 ¶
OpenSharedResource1 opens an NT handle made by IDXGIResource1::CreateSharedHandle.
func (Device) RaiseGPUThreadPriority ¶
RaiseGPUThreadPriority asks the GPU scheduler to run the device's work ahead of other processes' (IDXGIDevice::SetGPUThreadPriority, +7) and returns the priority in effect. Without the privilege to raise it the device keeps the default, 0.
type Duplication ¶
type Duplication struct{ *Object }
Duplication wraps IDXGIOutputDuplication.
func (Duplication) AcquireNextFrame ¶
func (d Duplication) AcquireNextFrame(timeoutMs uint32, info *OutduplFrameInfo, res **Object) error
AcquireNextFrame returns the desktop image as an IDXGIResource. Callers must pass heap pointers for info and res (they are written by the call).
func (Duplication) Desc ¶
func (d Duplication) Desc() OutduplDesc
func (Duplication) ReleaseFrame ¶
func (d Duplication) ReleaseFrame() error
type MappedSubresource ¶
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is any COM interface pointer. Its first word is the vtable.
type OutduplDesc ¶
type OutduplFrameInfo ¶
type Output ¶
type Output struct{ *Object }
func (Output) Desc ¶
func (o Output) Desc() (OutputDesc, error)
func (Output) Desc1 ¶
func (o Output) Desc1() (OutputDesc1, error)
Desc1 reports HDR color space and bits per color (IDXGIOutput6).
func (Output) Duplicate ¶
func (o Output) Duplicate(device *Object, formats []uint32) (Duplication, error)
Duplicate opens Desktop Duplication on this output. formats non-empty uses IDXGIOutput5::DuplicateOutput1 so HDR desktops can be captured as 10-bit or FP16; otherwise IDXGIOutput1::DuplicateOutput (BGRA8 only).
type OutputDesc ¶
type OutputDesc struct {
DeviceName [32]uint16
DesktopCoordinates Rect32
AttachedToDesktop int32
Rotation uint32
Monitor uintptr
}
func (OutputDesc) Name ¶
func (d OutputDesc) Name() string
type OutputDesc1 ¶
type OutputDesc1 struct {
DeviceName [32]uint16
DesktopCoordinates Rect32
AttachedToDesktop int32
Rotation uint32
Monitor uintptr
BitsPerColor uint32
ColorSpace uint32
RedPrimary [2]float32
GreenPrimary [2]float32
BluePrimary [2]float32
WhitePoint [2]float32
MinLuminance float32
MaxLuminance float32
MaxFullFrameLuminance float32
}
type Texture ¶
type Texture struct{ *Object }
func (Texture) CreateSharedHandle ¶
CreateSharedHandle exports the texture as an NT handle (needs MISC_SHARED_NTHANDLE).
func (Texture) Desc ¶
func (t Texture) Desc() Texture2DDesc
func (Texture) SharedHandle ¶
SharedHandle returns the legacy shared handle (needs MISC_SHARED).