webgpu

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 12 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 webgpu owns the framework's wgpu-native instance, adapter and device. It is the only new GPU API boundary: platform renderers select and size a target, while application graphics use WebGPU resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RuntimePath

func RuntimePath() (string, bool)

RuntimePath returns the wgpu-native library the process will load, if one can be located. WGPU_NATIVE_PATH wins, then lib/ next to the executable or in an ancestor of the working directory, then the platform loader's search path.

Types

type GPU

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

GPU owns a wgpu-native instance, its preferred hardware adapter, the logical device and the device's default queue.

func Open

func Open() (*GPU, error)

Open initializes wgpu-native and requests a high-performance adapter. The first call also locates a development lib/wgpu-native library when WGPU_NATIVE_PATH is unset.

func (*GPU) Adapter

func (g *GPU) Adapter() *wgpu.Adapter

Adapter returns the selected adapter.

func (*GPU) AdapterInfo

func (g *GPU) AdapterInfo() wgpu.AdapterInfoGo

AdapterInfo returns the selected adapter's descriptive information.

func (*GPU) Device

func (g *GPU) Device() *wgpu.Device

Device returns the logical WebGPU device.

func (*GPU) Instance

func (g *GPU) Instance() *wgpu.Instance

Instance returns the wgpu-native instance, for asynchronous error scopes.

func (*GPU) Queue

func (g *GPU) Queue() *wgpu.Queue

Queue returns the device's default queue.

func (*GPU) Release

func (g *GPU) Release()

Release frees the queue, device, adapter and instance. It is safe to call more than once.

type Renderer

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

Renderer draws WebGPU scenes. Shared pipeline resources are reused across the root frame and every nested native UI canvas; each target owns the instance buffer and atlas bindings its scene draws with.

func NewRenderer

func NewRenderer(g *GPU, format wgpu.TextureFormat) (*Renderer, error)

NewRenderer creates a scene renderer for targets of format.

func (*Renderer) FinishFrame

func (r *Renderer) FinishFrame()

FinishFrame releases transient effect resources after the command buffer that reads them has been submitted.

func (*Renderer) Release

func (r *Renderer) Release()

Release frees the renderer's WebGPU resources.

func (*Renderer) Render

func (r *Renderer) Render(s *scene.Scene, encoder *wgpu.CommandEncoder, view *wgpu.TextureView) error

Render encodes s into view. Clear is the scene background.

func (*Renderer) RenderTarget

func (r *Renderer) RenderTarget(s *scene.Scene, encoder *wgpu.CommandEncoder, target *wgpu.Texture, view *wgpu.TextureView) error

RenderTarget encodes s into target and view. A backdrop-reading effect needs the target handle so it can be copied into the backdrop grab.

func (*Renderer) RenderTargetPart

func (r *Renderer) RenderTargetPart(s *scene.Scene, encoder *wgpu.CommandEncoder, target *wgpu.Texture, view *wgpu.TextureView, part *gpu.Part) error

RenderTargetPart draws only batches meeting part into an existing target. The caller must have filled the target's untouched pixels with the same scene; part is normally the result of gpu.Part.Set.

Jump to

Keyboard shortcuts

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