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
- Variables
- func CPUAccess(fd int, flags uint64) error
- func CompileThrough(leaveRealtime func()) error
- func Compiling()
- func PinThread() (unpin func() error)
- func WithOwnVendorOnly(drivers []string, open func() error) error
- type Buffer
- type ChromaSiting
- type Coefficients
- type DMABUF
- type Device
- type Display
- func (d *Display) Close() error
- func (d *Display) DMABUFFormats() ([]fourcc.Format, error)
- func (d *Display) DMABUFModifiers(format fourcc.Format) ([]ModifierSupport, error)
- func (d *Display) Device() (Device, error)
- func (d *Display) Enter() error
- func (d *Display) Extensions() []string
- func (d *Display) Fence() (*Sync, error)
- func (d *Display) GL() *GL
- func (d *Display) Has(ext string) bool
- func (d *Display) ImportDMABUF(b DMABUF) (*Image, error)
- func (d *Display) ImportFence(fd int) (*Sync, error)
- func (d *Display) Leave() error
- func (d *Display) MakeCurrent() error
- func (d *Display) PlainFence() (*Sync, error)
- func (d *Display) Release() error
- func (d *Display) Renew() error
- func (d *Display) Robust() bool
- func (d *Display) Vendor() string
- type EGLError
- type FormatModifier
- type GBM
- type GBMLibrary
- type GL
- func (gl *GL) ActiveTexture(texture uint32)
- func (gl *GL) AllocateBuffer(target uint32, size int, usage uint32)
- func (gl *GL) BindBuffer(target, buffer uint32)
- func (gl *GL) BindFramebuffer(target, fb uint32)
- func (gl *GL) BindTexture(target, texture uint32)
- func (gl *GL) BlendFunc(src, dst uint32)
- func (gl *GL) BufferData(target uint32, values []float32, usage uint32)
- func (gl *GL) Check(op string) error
- func (gl *GL) Compile(typ uint32, source string) (uint32, error)
- func (gl *GL) Disable(capability uint32)
- func (gl *GL) DrawArrays(mode uint32, first, count int32)
- func (gl *GL) EGLImageTargetRenderbuffer(image *Image)
- func (gl *GL) EGLImageTargetTexture2D(target uint32, image *Image)
- func (gl *GL) Enable(capability uint32)
- func (gl *GL) EnableVertexAttribArray(index uint32)
- func (gl *GL) Extensions() string
- func (gl *GL) Flush()
- func (gl *GL) IsProgram(program uint32) bool
- func (gl *GL) Link(vertex, fragment string) (uint32, error)
- func (gl *GL) MapBufferForReading(target uint32, size int) []byte
- func (gl *GL) MapBufferRangeForWriting(target uint32, offset, size int, invalidate bool) []byte
- func (gl *GL) PrecisionBits(shaderType, precisionType uint32) int32
- func (gl *GL) ReadPixels(x, y, width, height int32, format uint32, pixels []byte)
- func (gl *GL) ReadPixelsIntoBuffer(x, y, width, height int32, format uint32)
- func (gl *GL) Renderer() string
- func (gl *GL) ResetStatus() error
- func (gl *GL) Scissor(x, y, width, height int32)
- func (gl *GL) TexImage2D(target uint32, internalFormat int32, width, height int32, format, typ uint32, ...)
- func (gl *GL) TexParameteri(target, pname uint32, param int32)
- func (gl *GL) TexSubImage2D(target uint32, x, y, width, height int32, format, typ uint32, pixels []byte)
- func (gl *GL) TexSubImage2DFromBuffer(target uint32, x, y, width, height int32, format, typ uint32, offset int)
- func (gl *GL) Uniform1f(location int32, v float32)
- func (gl *GL) Uniform2f(location int32, a, b float32)
- func (gl *GL) Uniform4f(location int32, a, b, c, d float32)
- func (gl *GL) UniformMatrix3(location int32, m *[9]float32)
- func (gl *GL) UnmapBuffer(target uint32) bool
- func (gl *GL) UseProgram(program uint32)
- func (gl *GL) Vendor() string
- func (gl *GL) Version() string
- func (gl *GL) VertexAttribPointer(index uint32, size int32, typ uint32, normalized uint8, stride int32, ...)
- func (gl *GL) Viewport(x, y, width, height int32)
- type GLError
- type Image
- type Library
- type ModifierSupport
- type Paths
- type Plane
- type Range
- type ScanoutTarget
- type Siting
- type Sync
- type Usage
- type YUVEncoding
Constants ¶
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 )
const ( EGLEnv = "LYS_WM_LIBEGL" GLESv2Env = "LYS_WM_LIBGLESV2" GBMEnv = "LYS_WM_LIBGBM" )
const ( SyncRead = 1 << 0 SyncWrite = 1 << 1 SyncEnd = 1 << 2 )
Variables ¶
var ( ErrUnsupported = errors.New("gpu: unsupported") ErrContextLost = errors.New("gpu: context lost") )
Functions ¶
func CompileThrough ¶
func CompileThrough(leaveRealtime func()) error
func WithOwnVendorOnly ¶
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 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 ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
func (Device) Extensions ¶
func (Device) RenderNode ¶
type Display ¶
type Display struct {
// contains filtered or unexported fields
}
func (*Display) DMABUFModifiers ¶
func (d *Display) DMABUFModifiers(format fourcc.Format) ([]ModifierSupport, error)
func (*Display) Extensions ¶
func (*Display) MakeCurrent ¶
func (*Display) PlainFence ¶
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
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) BindBuffer ¶
func (*GL) BindFramebuffer ¶
func (*GL) BindTexture ¶
func (*GL) DrawArrays ¶
func (*GL) EGLImageTargetRenderbuffer ¶
func (*GL) EGLImageTargetTexture2D ¶
func (*GL) EnableVertexAttribArray ¶
func (*GL) Extensions ¶
func (*GL) MapBufferRangeForWriting ¶
func (*GL) PrecisionBits ¶
func (*GL) ReadPixels ¶
func (*GL) ReadPixelsIntoBuffer ¶
func (*GL) ResetStatus ¶
func (*GL) TexImage2D ¶
func (*GL) TexParameteri ¶
func (*GL) TexSubImage2D ¶
func (*GL) TexSubImage2DFromBuffer ¶
func (*GL) UniformMatrix3 ¶
func (*GL) UnmapBuffer ¶
func (*GL) UseProgram ¶
func (*GL) VertexAttribPointer ¶
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
func (*Library) ContextSwitches ¶
func (*Library) Surfaceless ¶
type ModifierSupport ¶
type ScanoutTarget ¶
type ScanoutTarget struct {
Device uint64
Formats []FormatModifier
}
type Sync ¶
type Sync struct {
// contains filtered or unexported fields
}
func (*Sync) ClientWait ¶
type YUVEncoding ¶
type YUVEncoding struct {
Coefficients Coefficients
Range Range
Chroma ChromaSiting
}
func DefaultYUV ¶
func DefaultYUV(size image.Point) YUVEncoding