Shared GPU infrastructure for the gogpu ecosystem (DeviceProvider, EventSource, Registry)
Repo gogpu/gpucontext, read from GitHub 3 d ago. gogpu has not joined Take My Repo.
gogpu/gpucontext is a public repo on GitHub by gogpu. Shared GPU infrastructure for the gogpu ecosystem (DeviceProvider, EventSource, Registry). It declares the MIT license on GitHub. It is written mainly in Go, has 5 stars and last changed on 2026-11-19. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-20.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
Shared GPU infrastructure for the gogpu ecosystem.
gpucontext provides interfaces and utilities for sharing GPU resources across multiple packages without circular dependencies.
| Package | Purpose | Dependencies |
|---|---|---|
| gputypes | WebGPU types (enums, structs, constants) | ZERO |
| gpucontext | Interfaces (DeviceProvider, EventSource, WindowChrome, Texture) | imports gputypes |
gpucontext imports gputypes to use shared types in interface signatures, ensuring type compatibility across the ecosystem.
go get github.com/gogpu/gpucontext
Requires: Go 1.25+
any)The DeviceProvider interface enables dependency injection of GPU capabilities:
// In gogpu/gogpu - implements DeviceProvider
type App struct {
device gpucontext.Device
queue gpucontext.Queue
}
func (app *App) Device() gpucontext.Device { return app.device }
func (app *App) Queue() gpucontext.Queue { return app.queue }
func (app *App) SurfaceFormat() gpucontext.TextureFormat { return app.format }
func (app *App) Adapter() gpucontext.Adapter { return app.adapter }
// In gogpu/gg - uses DeviceProvider
func NewGPUCanvas(provider gpucontext.DeviceProvider) *Canvas {
return &Canvas{
device: provider.Device(),
queue: provider.Queue(),
}
}
any)GPU accelerators (like gg's SDF pipeline) share the host device via typed interfaces:
// Consumer gets typed device from provider
func (a *SDFAccelerator) SetDeviceProvider(dp gpucontext.DeviceProvider) {
dev := dp.Device() // gpucontext.Device (minimal interface)
wgpuDev, ok := dev.(*wgpu.Device) // type assert for full wgpu API
if ok {
a.initWithSharedDevice(wgpuDev)
}
}
The pattern follows Go's "accept interfaces, return structs":
gpucontext.Device — minimal interface (type token)*wgpu.Device — concrete type, satisfies gpucontext.Device implicitlyThe WindowProvider interface enables UI frameworks and rendering libraries to query
window dimensions (logical points) and DPI scale factor:
// In gogpu/ui - uses WindowProvider for layout
func (ui *UI) Layout(wp gpucontext.WindowProvider) {
w, h := wp.Size() // logical points (DIP)
scale := wp.ScaleFactor() // 2.0 on Retina
ui.root.Layout(w, h, scale)
}
// In gg/ggcanvas - auto-detects HiDPI from provider
func New(provider gpucontext.DeviceProvider, w, h int) (*Canvas, error) {
scale := 1.0
if wp, ok := provider.(gpucontext.WindowProvider); ok {
scale = wp.ScaleFactor()
}
// allocate pixmap at physical resolution: w*scale x h*scale
}
PlatformProvider exposes clipboard, cursor, and system preferences.
Not all hosts support it — use type assertion to check:
// In gogpu/ui - cursor management
func (ui *UI) UpdateCursor(provider gpucontext.WindowProvider) {
if pp, ok := provider.(gpucontext.PlatformProvider); ok {
pp.SetCursor(gpucontext.CursorPointer) // hand cursor
}
}
// In gogpu/ui - clipboard
func (ui *UI) Paste(provider gpucontext.WindowProvider) {
if pp, ok := provider.(gpucontext.PlatformProvider); ok {
text, err := pp.ClipboardRead()
if err == nil {
ui.focused.InsertText(text)
}
}
}
// In gogpu/ui - theme detection
func (ui *UI) DetectTheme(provider gpucontext.WindowProvider) {
if pp, ok := provider.(gpucontext.PlatformProvider); ok {
if pp.DarkMode() {
ui.SetTheme(DarkTheme)
}
}
}
EventSource enables UI frameworks to receive input events from host applications:
// In gogpu/ui - uses EventSource
func (ui *UI) AttachEvents(source gpucontext.EventSource) {
source.OnKeyPress(func(key gpucontext.Key, mods gpucontext.Modifiers) {
ui.focused.HandleKeyDown(key, mods)
})
source.OnMousePress(func(button gpucontext.MouseButton, x, y float64) {
widget := ui.hitTest(x, y)
widget.HandleMouseDown(button, x, y)
})
}
// In gogpu/gogpu - implements EventSource
type App struct {
keyHandlers []func(gpucontext.Key, gpucontext.Modifiers)
}
func (app *App) OnKeyPress(fn func(gpucontext.Key, gpucontext.Modifiers)) {
app.keyHandlers = append(app.keyHandlers, fn)
}
IMEState, IMEController and the optional IMEEventSource enable Input Method Editor support for Chinese,
Japanese, Korean and other complex input. All text positions are UTF-8 byte offsets (IMETextRange), as in
Wayland text-input, GTK4 and winit:
// In gogpu/ui - handle IME composition
func (input *TextInput) AttachIME(source gpucontext.EventSource) {
source.OnIMECompositionStart(func() {
input.showCompositionWindow()
})
source.OnIMECompositionUpdate(func(state gpucontext.IMEState) {
// Composition text with its cursor (UTF-8 byte range; hidden when the IME asks)
input.setCompositionText(state.CompositionText, state.Cursor, state.HasCursor())
})
source.OnIMECompositionEnd(func(committed string) {
// Insert final text
input.insertText(committed)
input.hideCompositionWindow()
})
// Optional events, found by type assertion
if ime, ok := source.(gpucontext.IMEEventSource); ok {
ime.OnIMECanceled(input.clearComposition)
ime.OnIMEDeleteSurrounding(input.deleteAroundCursor)
}
}
// Enable IME and tell it where the caret is and what the field expects
func (input *TextInput) Focus(controller gpucontext.IMEController) {
controller.SetIMEEnabled(true)
controller.SetIMECursorArea(gpucontext.IMECursorArea{X: input.caretX, Y: input.caretY, Height: input.lineHeight})
if controller.IMECapabilities().Has(gpucontext.IMECapabilityContentType) {
controller.SetIMEContentType(gpucontext.ContentPurposeEmail, gpucontext.ContentHintCompletion)
}
}
Texture provides a minimal interface for GPU textures, enabling sharing between packages:
// Texture is a minimal interface for GPU textures
type Texture interface {
Width() int
Height() int
}
// TextureDrawer can draw textures (implemented by renderers)
type TextureDrawer interface {
DrawTexture(tex Texture, x, y float32) error
DrawTextureEx(tex Texture, opts TextureDrawOptions) error
}
// TextureCreator can create textures from pixel data
type TextureCreator interface {
CreateTexture(width, height int, pixels []byte) (Texture, error)
}
TextureUpdater enables efficient texture updates without recreating textures:
// TextureUpdater updates existing texture pixel data (full upload)
type TextureUpdater interface {
UpdateData(data []byte) error
}
// ImageDataLayout describes the memory layout of pixel data for region uploads.
// Mirrors W3C GPUTexelCopyBufferLayout at the application level.
type ImageDataLayout struct {
BytesPerRow int // 0 = tight packed (w * bytesPerPixel)
RowsPerImage int // 0 = height (for 3D/array textures)
Offset int // byte offset into data
}
// TextureRegionUpdater uploads only a sub-rectangle (partial upload)
type TextureRegionUpdater interface {
UpdateRegion(region image.Rectangle, data []byte, layout ImageDataLayout) error
}
TextureRegionUpdater enables incremental rendering — only dirty regions are uploaded to GPU instead of the full texture. For a 1080p@2x window, this reduces upload from ~33MB to a few KB per frame when only a small widget changes.
Usage in integration packages:
// In gg/integration/ggcanvas - creates textures from CPU canvas
func (c *Canvas) Flush() (gpucontext.Texture, error) {
pixels := c.pixmap.Pix()
return c.creator.CreateTexture(c.width, c.height, pixels)
}
// In gogpu - implements TextureDrawer
func (ctx *Context) DrawTexture(tex gpucontext.Texture, x, y float32) error {
return ctx.renderer.DrawTexture(tex, x, y)
}
WindowChrome enables custom window chrome for frameless windows and runtime fullscreen toggle:
// In gogpu/ui - custom title bar with hit testing
func (ui *UI) SetupFramelessWindow(provider gpucontext.WindowProvider) {
if wc, ok := provider.(gpucontext.WindowChrome); ok {
wc.SetFrameless(true)
wc.SetHitTestCallback(func(x, y float64) gpucontext.HitTestResult {
if y < 40 { // title bar height
return gpucontext.HitTestCaption // enables window dragging
}
return gpucontext.HitTestClient
})
}
}
// Window controls
wc.Minimize()
wc.Maximize() // toggles maximized/restored
wc.IsMaximized() // for button icon state
wc.SetFullscreen(true) // enter fullscreen (borderless on Win, native on macOS)
wc.IsFullscreen() // query fullscreen state
wc.Close()
The Registry[T] provides thread-safe registration with priority-based selection:
import "github.com/gogpu/gpucontext"
// Create registry with priority order
var backends = gpucontext.NewRegistry[Backend](
gpucontext.WithPriority("vulkan", "dx12", "metal", "gles", "software"),
)
// Register backends (typically in init())
func init() {
backends.Register("vulkan", NewVulkanBackend)
backends.Register("software", NewSoftwareBackend)
}
// Get best available backend
backend := backends.Best()
// Or get specific backend
vulkan := backends.Get("vulkan")
// Check availability
if backends.Has("vulkan") {
// Vulkan is available
}
// List all available
names := backends.Available() // ["vulkan", "software"]
gputypes (ZERO deps)
All WebGPU types (100+)
│
▼
gpucontext
(imports gputypes)
DeviceProvider, WindowChrome,
WindowProvider, PlatformProvider,
EventSource, Texture, Registry
│
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
gogpu gg ui
(implements) (uses) (uses)
│
▼
wgpu/hal
| Package | Description |
|---|---|
| gogpu/gogpu | Graphics framework, implements DeviceProvider |
| gogpu/gg | 2D graphics, uses DeviceProvider |
| gogpu/wgpu | Pure Go WebGPU implementation |
| born-ml/born | ML framework, implements & uses |
MIT License — see LICENSE for details.
gogpu/gpucontext is a public repo on GitHub by gogpu. Shared GPU infrastructure for the gogpu ecosystem (DeviceProvider, EventSource, Registry).
It declares the MIT license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-19. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.

Tensors and Dynamic neural networks in Python with strong GPU acceleration
Official electron build of draw.io

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
Pure Go GPU Application Framework — windowing, input, lifecycle, platform abstraction. Part of the GoGPU ecosystem.

Enterprise-grade 2D graphics library for Go. Pure Go, zero CGO. Part of GoGPU ecosystem.
Pure Go system tray library for Windows, macOS, and Linux. Zero CGO.
Pure Go Shader Compiler — WGSL to SPIR-V, MSL, GLSL, HLSL, DXIL. Zero CGO.
This page is also available as structured data, with the same sources and dates.
/api/v1/resources/gh/gogpu/gpucontextTake My Repo has not tested this on your machine. Requirements come from the project's own documentation.