Documentation
¶
Overview ¶
Package webgl runs KindGPU views over WebGL 2 for the web backend and mini games (docs/architecture/gpu.md): the view's lifecycle (Controller), plain Go and testable anywhere, and the backend that plays its frames on a context it is given (Backend, js/wasm), with no DOM, so a host that has canvases but no document can use it.
Index ¶
- func ClampLimits(l driver.GPULimits) driver.GPULimits
- func MipDim(base, mip uint32) uint32
- type BackendKind
- type Controller
- func (c *Controller) AcceptFrame(frame driver.GPUFrame) bool
- func (c *Controller) BeginInit() bool
- func (c *Controller) Configure(cfg driver.GPUViewConfig)
- func (c *Controller) Destroy()
- func (c *Controller) MakeError(code driver.GPUErrorCode, message string) *driver.GPUEvent
- func (c *Controller) MarkLost(reason driver.GPUDeviceLostReason, message string) *driver.GPUEvent
- func (c *Controller) MarkReady(backend BackendKind, surfaceFmt driver.GPUTextureFormat, ...) *driver.GPUEvent
- func (c *Controller) Resize(cssW, cssH driver.Points, pixelRatio float32) (w, h int, changed bool, ev *driver.GPUEvent)
- func (c *Controller) ResourceCounts() ResourceCounts
- type ResourceCounts
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClampLimits ¶
ClampLimits fills zero fields with conservative Stage 1 defaults.
Types ¶
type BackendKind ¶
type BackendKind uint8
BackendKind identifies which browser GPU API backs a KindGPU view.
const ( BackendNone BackendKind = iota BackendWebGPU BackendWebGL2 )
func (BackendKind) String ¶
func (k BackendKind) String() string
type Controller ¶
type Controller struct {
Config driver.GPUViewConfig
State State
Backend BackendKind
Generation uint32
Width int
Height int
// contains filtered or unexported fields
}
Controller manages the portable lifecycle, pixel sizing, generation tracking, and resource accounting for one mounted KindGPU view.
func NewController ¶
func NewController(id driver.NodeID) *Controller
NewController returns the controller of KindGPU view id, uninitialized.
func (*Controller) AcceptFrame ¶
func (c *Controller) AcceptFrame(frame driver.GPUFrame) bool
AcceptFrame checks whether frame targets the live generation and records resource create/destroy ops for leak accounting.
func (*Controller) BeginInit ¶
func (c *Controller) BeginInit() bool
BeginInit starts initializing the view, reporting false when it is initializing, ready or destroyed.
func (*Controller) Configure ¶
func (c *Controller) Configure(cfg driver.GPUViewConfig)
Configure sets the view's formats and sample count (ItemGPU).
func (*Controller) MakeError ¶
func (c *Controller) MakeError(code driver.GPUErrorCode, message string) *driver.GPUEvent
MakeError returns an error event of the live generation, nil once the view is destroyed.
func (*Controller) MarkLost ¶
func (c *Controller) MarkLost(reason driver.GPUDeviceLostReason, message string) *driver.GPUEvent
MarkLost transitions to Lost, clears tracked live resources, and returns the GPUEventDeviceLost payload (nil if not currently Ready or already Destroyed).
func (*Controller) MarkReady ¶
func (c *Controller) MarkReady(backend BackendKind, surfaceFmt driver.GPUTextureFormat, limits driver.GPULimits, features driver.GPUFeatures) *driver.GPUEvent
MarkReady transitions to Ready, bumps the device generation, and returns the GPUEventDeviceReady payload (nil if already destroyed).
func (*Controller) Resize ¶
func (c *Controller) Resize(cssW, cssH driver.Points, pixelRatio float32) (w, h int, changed bool, ev *driver.GPUEvent)
Resize updates the controller's physical pixel dimensions and returns a GPUEventResize when the view is already ready and the size changed.
func (*Controller) ResourceCounts ¶
func (c *Controller) ResourceCounts() ResourceCounts
ResourceCounts are how many of each resource the app's frames left alive.