gpu

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 15 Imported by: 0 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

Overview

Package gpu binds libEGL, libGLESv2 and libgbm through purego: displays on the GBM, device and surfaceless platforms, GLES2 contexts, dmabuf images, native fences and buffer allocation.

Index

Constants

View Source
const (
	NoError               = 0
	Texture2D             = 0x0DE1
	TextureExternalOES    = 0x8D65
	Texture0              = 0x84C0
	Texture1              = 0x84C1
	TextureMinFilter      = 0x2801
	TextureMagFilter      = 0x2800
	TextureWrapS          = 0x2802
	TextureWrapT          = 0x2803
	Linear                = 0x2601
	Nearest               = 0x2600
	ClampToEdge           = 0x812F
	RGBA                  = 0x1908
	BGRAExt               = 0x80E1
	RGBA8OES              = 0x8058
	RGB10A2               = 0x8059
	RGBA16F               = 0x881A
	HalfFloat             = 0x140B
	Red                   = 0x1903
	Blue                  = 0x1905
	TextureSwizzleR       = 0x8E42
	TextureSwizzleB       = 0x8E44
	UnsignedByte          = 0x1401
	UnsignedInt2101010Rev = 0x8368
	Float                 = 0x1406
	UnpackAlignment       = 0x0CF5
	PackRowLengthNV       = 0x0D02
	UnpackSkipPixelsExt   = 0x0CF4
	UnpackSkipRowsExt     = 0x0CF3
	Framebuffer           = 0x8D40
	Renderbuffer          = 0x8D41
	ColorAttachment0      = 0x8CE0
	FramebufferComplete   = 0x8CD5
	Blend                 = 0x0BE2
	ScissorTest           = 0x0C11
	Zero                  = 0
	One                   = 1
	OneMinusSrcAlpha      = 0x0303
	ColorBufferBit        = 0x4000
	VertexShader          = 0x8B31
	FragmentShader        = 0x8B30
	HighFloat             = 0x8DF2
	CompileStatus         = 0x8B81
	LinkStatus            = 0x8B82
	InfoLogLength         = 0x8B84
	TriangleStrip         = 0x0005
	ArrayBuffer           = 0x8892
	StaticDraw            = 0x88E4
	StreamDraw            = 0x88E0
	StreamRead            = 0x88E1
	PixelPackBuffer       = 0x88EB
	PixelUnpackBuffer     = 0x88EC
	MapReadBit            = 0x0001
)
View Source
const (
	EGLEnv    = "LYS_WM_LIBEGL"
	GLESv2Env = "LYS_WM_LIBGLESV2"
	GBMEnv    = "LYS_WM_LIBGBM"
)
View Source
const (
	SyncRead  = 1 << 0
	SyncWrite = 1 << 1
	SyncEnd   = 1 << 2
)

Variables

View Source
var (
	ErrUnsupported = errors.New("gpu: unsupported")
	ErrContextLost = errors.New("gpu: context lost")
)

Functions

func CPUAccess

func CPUAccess(fd int, flags uint64) error

func CompileThrough

func CompileThrough(leaveRealtime func()) error

func Compiling

func Compiling()

func PinThread

func PinThread() (unpin func() error)

func WithOwnVendorOnly

func WithOwnVendorOnly(drivers []string, open func() error) error

WithOwnVendorOnly runs open, which loads EGL for the first time in this process, with libglvnd limited to the vendor of drivers, the kernel drivers of every card on the seat.

Types

type Buffer

type Buffer struct {
	DMABUF
	// contains filtered or unexported fields
}

func NewBuffer

func NewBuffer(d DMABUF, destroy func()) *Buffer

func (*Buffer) Close

func (b *Buffer) Close() error

type ChromaSiting

type ChromaSiting struct {
	Horizontal, Vertical Siting
}

type Coefficients

type Coefficients uint8
const (
	CoefficientsUnspecified Coefficients = iota
	BT601
	BT709
	BT2020
)

type DMABUF

type DMABUF struct {
	Size     image.Point
	Format   fourcc.Format
	Modifier fourcc.Modifier
	Planes   []Plane
	YUV      YUVEncoding
}

func FromDmabuf

func FromDmabuf(b dmabuf.Buffer) DMABUF

func (DMABUF) Dmabuf

func (d DMABUF) Dmabuf() dmabuf.Buffer

func (DMABUF) Dup

func (d DMABUF) Dup() (*Buffer, error)

type Device

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

func (Device) Extensions

func (d Device) Extensions() []string

func (Device) RenderNode

func (d Device) RenderNode() string

func (Device) Software

func (d Device) Software() bool

type Display

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

func (*Display) Close

func (d *Display) Close() error

func (*Display) DMABUFFormats

func (d *Display) DMABUFFormats() ([]fourcc.Format, error)

func (*Display) DMABUFModifiers

func (d *Display) DMABUFModifiers(format fourcc.Format) ([]ModifierSupport, error)

func (*Display) Device

func (d *Display) Device() (Device, error)

func (*Display) Enter

func (d *Display) Enter() error

func (*Display) Extensions

func (d *Display) Extensions() []string

func (*Display) Fence

func (d *Display) Fence() (*Sync, error)

func (*Display) GL

func (d *Display) GL() *GL

func (*Display) Has

func (d *Display) Has(ext string) bool

func (*Display) ImportDMABUF

func (d *Display) ImportDMABUF(b DMABUF) (*Image, error)

func (*Display) ImportFence

func (d *Display) ImportFence(fd int) (*Sync, error)

func (*Display) Leave

func (d *Display) Leave() error

func (*Display) MakeCurrent

func (d *Display) MakeCurrent() error

func (*Display) PlainFence

func (d *Display) PlainFence() (*Sync, error)

func (*Display) Release

func (d *Display) Release() error

func (*Display) Renew

func (d *Display) Renew() error

func (*Display) Robust

func (d *Display) Robust() bool

func (*Display) Vendor

func (d *Display) Vendor() string

type EGLError

type EGLError struct {
	Op   string
	Code int32
}

func (*EGLError) Error

func (e *EGLError) Error() string

func (*EGLError) Is

func (e *EGLError) Is(target error) bool

type FormatModifier

type FormatModifier struct {
	Format   fourcc.Format
	Modifier fourcc.Modifier
}

type GBM

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

func (*GBM) Allocate

func (d *GBM) Allocate(size image.Point, format fourcc.Format, modifiers []fourcc.Modifier, usage Usage) (*Buffer, error)

func (*GBM) Backend

func (d *GBM) Backend() string

func (*GBM) Close

func (d *GBM) Close()

type GBMLibrary

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

func LoadGBM

func LoadGBM(paths Paths) (*GBMLibrary, error)

func (*GBMLibrary) Close

func (g *GBMLibrary) Close() error

func (*GBMLibrary) Open

func (g *GBMLibrary) Open(fd int) (*GBM, error)

type GL

type GL struct {
	GenTextures    func(n int32, textures *uint32)
	DeleteTextures func(n int32, textures *uint32)

	PixelStorei        func(pname uint32, param int32)
	GenFramebuffers    func(n int32, fbs *uint32)
	DeleteFramebuffers func(n int32, fbs *uint32)

	FramebufferTexture2D    func(target, attachment, texTarget, texture uint32, level int32)
	FramebufferRenderbuffer func(target, attachment, rbTarget, rb uint32)
	CheckFramebufferStatus  func(target uint32) uint32
	GenRenderbuffers        func(n int32, rbs *uint32)
	DeleteRenderbuffers     func(n int32, rbs *uint32)
	BindRenderbuffer        func(target, rb uint32)
	RenderbufferStorage     func(target, internalFormat uint32, width, height int32)
	GenBuffers              func(n int32, buffers *uint32)
	DeleteBuffers           func(n int32, buffers *uint32)

	ColorMask    func(r, g, b, a uint8)
	ClearColor   func(r, g, b, a float32)
	Clear        func(mask uint32)
	CreateShader func(typ uint32) uint32

	CompileShader func(shader uint32)
	GetShaderiv   func(shader, pname uint32, params *int32)

	DeleteShader  func(shader uint32)
	CreateProgram func() uint32
	AttachShader  func(program, shader uint32)
	LinkProgram   func(program uint32)
	GetProgramiv  func(program, pname uint32, params *int32)

	DeleteProgram func(program uint32)

	GetUniformLocation func(program uint32, name string) int32
	GetAttribLocation  func(program uint32, name string) int32
	Uniform1i          func(location, v int32)

	DisableVertexAttribArray func(index uint32)

	Finish func()
	// contains filtered or unexported fields
}

func (*GL) ActiveTexture

func (gl *GL) ActiveTexture(texture uint32)

func (*GL) AllocateBuffer

func (gl *GL) AllocateBuffer(target uint32, size int, usage uint32)

func (*GL) BindBuffer

func (gl *GL) BindBuffer(target, buffer uint32)

func (*GL) BindFramebuffer

func (gl *GL) BindFramebuffer(target, fb uint32)

func (*GL) BindTexture

func (gl *GL) BindTexture(target, texture uint32)

func (*GL) BlendFunc

func (gl *GL) BlendFunc(src, dst uint32)

func (*GL) BufferData

func (gl *GL) BufferData(target uint32, values []float32, usage uint32)

func (*GL) Check

func (gl *GL) Check(op string) error

func (*GL) Compile

func (gl *GL) Compile(typ uint32, source string) (uint32, error)

func (*GL) Disable

func (gl *GL) Disable(capability uint32)

func (*GL) DrawArrays

func (gl *GL) DrawArrays(mode uint32, first, count int32)

func (*GL) EGLImageTargetRenderbuffer

func (gl *GL) EGLImageTargetRenderbuffer(image *Image)

func (*GL) EGLImageTargetTexture2D

func (gl *GL) EGLImageTargetTexture2D(target uint32, image *Image)

func (*GL) Enable

func (gl *GL) Enable(capability uint32)

func (*GL) EnableVertexAttribArray

func (gl *GL) EnableVertexAttribArray(index uint32)

func (*GL) Extensions

func (gl *GL) Extensions() string

func (*GL) Flush

func (gl *GL) Flush()

func (*GL) IsProgram

func (gl *GL) IsProgram(program uint32) bool
func (gl *GL) Link(vertex, fragment string) (uint32, error)

func (*GL) MapBufferForReading

func (gl *GL) MapBufferForReading(target uint32, size int) []byte

func (*GL) MapBufferRangeForWriting

func (gl *GL) MapBufferRangeForWriting(target uint32, offset, size int, invalidate bool) []byte

func (*GL) PrecisionBits

func (gl *GL) PrecisionBits(shaderType, precisionType uint32) int32

func (*GL) ReadPixels

func (gl *GL) ReadPixels(x, y, width, height int32, format uint32, pixels []byte)

func (*GL) ReadPixelsIntoBuffer

func (gl *GL) ReadPixelsIntoBuffer(x, y, width, height int32, format uint32)

func (*GL) Renderer

func (gl *GL) Renderer() string

func (*GL) ResetStatus

func (gl *GL) ResetStatus() error

func (*GL) Scissor

func (gl *GL) Scissor(x, y, width, height int32)

func (*GL) TexImage2D

func (gl *GL) TexImage2D(target uint32, internalFormat int32, width, height int32, format, typ uint32, pixels []byte)

func (*GL) TexParameteri

func (gl *GL) TexParameteri(target, pname uint32, param int32)

func (*GL) TexSubImage2D

func (gl *GL) TexSubImage2D(target uint32, x, y, width, height int32, format, typ uint32, pixels []byte)

func (*GL) TexSubImage2DFromBuffer

func (gl *GL) TexSubImage2DFromBuffer(target uint32, x, y, width, height int32, format, typ uint32, offset int)

func (*GL) Uniform1f

func (gl *GL) Uniform1f(location int32, v float32)

func (*GL) Uniform2f

func (gl *GL) Uniform2f(location int32, a, b float32)

func (*GL) Uniform4f

func (gl *GL) Uniform4f(location int32, a, b, c, d float32)

func (*GL) UniformMatrix3

func (gl *GL) UniformMatrix3(location int32, m *[9]float32)

func (*GL) UnmapBuffer

func (gl *GL) UnmapBuffer(target uint32) bool

func (*GL) UseProgram

func (gl *GL) UseProgram(program uint32)

func (*GL) Vendor

func (gl *GL) Vendor() string

func (*GL) Version

func (gl *GL) Version() string

func (*GL) VertexAttribPointer

func (gl *GL) VertexAttribPointer(index uint32, size int32, typ uint32, normalized uint8, stride int32, offset uintptr)

func (*GL) Viewport

func (gl *GL) Viewport(x, y, width, height int32)

type GLError

type GLError struct {
	Op   string
	Code uint32
}

func (*GLError) Error

func (e *GLError) Error() string

func (*GLError) Is

func (e *GLError) Is(target error) bool

type Image

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

func (*Image) Destroy

func (i *Image) Destroy() error

type Library

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

func Load

func Load(paths Paths) (*Library, error)

func (*Library) ContextSwitches

func (l *Library) ContextSwitches() uint64

func (*Library) Devices

func (l *Library) Devices() ([]Device, error)

func (*Library) OnDevice

func (l *Library) OnDevice(d Device) (*Display, error)

func (*Library) OnGBM

func (l *Library) OnGBM(g *GBM) (*Display, error)

func (*Library) Surfaceless

func (l *Library) Surfaceless() (*Display, error)

type ModifierSupport

type ModifierSupport struct {
	Modifier     fourcc.Modifier
	ExternalOnly bool
}

type Paths

type Paths struct {
	EGL, GLESv2, GBM string
}

func PathsFromEnv

func PathsFromEnv(getenv func(string) string) Paths

type Plane

type Plane struct {
	FD     int
	Offset uint32
	Stride uint32
}

type Range

type Range uint8
const (
	RangeUnspecified Range = iota
	LimitedRange
	FullRange
)

type ScanoutTarget

type ScanoutTarget struct {
	Device  uint64
	Formats []FormatModifier
}

type Siting

type Siting uint8
const (
	SitingUnspecified Siting = iota
	SitedAt0
	SitedAtHalf
	SitedAt1
)

type Sync

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

func (*Sync) ClientWait

func (s *Sync) ClientWait() error

func (*Sync) Destroy

func (s *Sync) Destroy() error

func (*Sync) FD

func (s *Sync) FD() (int, error)

func (*Sync) Wait

func (s *Sync) Wait() error

type Usage

type Usage uint32
const (
	UseScanout   Usage = 1 << 0
	UseRendering Usage = 1 << 2
	UseLinear    Usage = 1 << 4
)

type YUVEncoding

type YUVEncoding struct {
	Coefficients Coefficients
	Range        Range
	Chroma       ChromaSiting
}

func DefaultYUV

func DefaultYUV(size image.Point) YUVEncoding

Jump to

Keyboard shortcuts

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