gpu

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: BSD-3-Clause Imports: 14 Imported by: 1 module, 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 is the public GPU API of Glutter (SPEC §27.2): buffers, textures, samplers, WGSL shaders, render and compute pipelines, command encoders and readback over the device of the explicit renderer.

The names follow WebGPU, in Go form. SDL 3's GPU API is the other design reference (D32).

An app gets the device of the renderer that draws its windows with DeviceOf, or with OnDevice, which also tells when the renderer makes a new device after a loss. Everything made from a device is used on the UI thread (SPEC §13). Commands are recorded with a CommandEncoder, finished into a CommandBuffer and sent with Queue.Submit. The shaders are made by glutter-gen gpushaders (SPEC §27.3).

Flutter: no counterpart

Index

Constants

View Source
const (
	// TagGPUUnavailable is the tag of the error of DeviceOf when the renderer of the app has no GPU device to
	// give: the app runs on the OpenGL ES, WebGL or software renderer, or has no engine behind it. The
	// metadata "renderer" says why.
	//
	// Flutter: no counterpart
	TagGPUUnavailable = "GPUUnavailable"
	// TagGPUDeviceNotReady is the tag of the error of DeviceOf before the renderer has opened its device,
	// which it does when it draws its first frame (the choice of a device depends on the window), and
	// between the loss of a device and the frame that opens the next one. OnDevice calls its function when
	// there is one.
	//
	// Flutter: no counterpart
	TagGPUDeviceNotReady = "GPUDeviceNotReady"
	// TagGPUDeviceLost is the tag of the error of a call on a device that was lost, and of the error that
	// OnLost functions get. The device and everything made with it stay unusable: DeviceOf gives the new device
	// when the renderer has made it.
	//
	// Flutter: no counterpart
	TagGPUDeviceLost = "GPUDeviceLost"
	// TagGPUInvalidDescriptor is the tag of the error of a constructor whose description cannot be made: a size
	// of 0, a format that a usage does not allow, an entry point that the shader lacks. The metadata "field" names
	// the field of the description and "value" the value it had.
	//
	// Flutter: no counterpart
	TagGPUInvalidDescriptor = "GPUInvalidDescriptor"
	// TagGPULimitExceeded is the tag of the error of a constructor whose description is larger than a limit
	// (Device.Limits). The metadata "field", "value" and "max" say which.
	//
	// Flutter: no counterpart
	TagGPULimitExceeded = "GPULimitExceeded"
	// TagGPUShaderCompileFailed is the tag of the error of a pipeline whose shader the driver refuses (the
	// backends make it; the messages are in its metadata).
	//
	// Flutter: no counterpart
	TagGPUShaderCompileFailed = "GPUShaderCompileFailed"
	// TagGPUOutOfMemory is the tag of the error of a call that needs more memory than the GPU or the system has
	// (the backends make it).
	//
	// Flutter: no counterpart
	TagGPUOutOfMemory = "GPUOutOfMemory"
	// TagGPUReadFailed is the tag of the error that Buffer.Read gives to its function when the bytes could not be
	// read back; the error of the backend is its cause.
	//
	// Flutter: no counterpart
	TagGPUReadFailed = "GPUReadFailed"
	// TagGPUWrongThread is the tag of the programmer error of a call from a goroutine that is not the UI thread.
	// Debug builds panic with it (SPEC §13).
	//
	// Flutter: no counterpart
	TagGPUWrongThread = "GPUWrongThread"
	// TagGPUEncodingInvalid is the tag of the programmer error of a misuse while encoding: a pass that was not
	// ended, a draw without a pipeline, a bind group of another layout, a draw past the end of a buffer, a command
	// buffer submitted twice. Debug builds panic with it; release builds skip the checks. The metadata "call" and
	// "what" say which call and which rule.
	//
	// Flutter: no counterpart
	TagGPUEncodingInvalid = "GPUEncodingInvalid"
	// TagGPUResourceReleased is the programmer error of using a resource after Release. Debug builds panic with
	// it; the metadata "kind" and "label" say which resource.
	//
	// Flutter: no counterpart
	TagGPUResourceReleased = "GPUResourceReleased"
	// TagGPUResourceLeaked is the tag of the warning that debug builds log, for each resource that was not
	// released, when the app ends. The attributes "kind", "label" and "created" say what it was and which call made
	// it.
	//
	// Flutter: no counterpart
	TagGPUResourceLeaked = "GPUResourceLeaked"
)

The tags of the errors of package gpu (SPEC §27.11). Each has a route test. An error that a backend makes (GPUOutOfMemory, VulkanDeviceLost, GPUShaderCompileFailed, ...) comes back untouched; IsDeviceLost says whether an error is a loss of the device, whatever backend it came from.

View Source
const (
	// TagGPUViewInvalid is the tag of the programmer error of a NewView call with a configuration that cannot be
	// made: a nil paint function, a format that is not one of the view's, a sample count that is not 1 or 4, or
	// more than one ViewOpts. Debug builds panic with it; the metadata "field" names the option.
	//
	// Flutter: no counterpart
	TagGPUViewInvalid = "GPUViewInvalid"
)

The tags of the errors of package gpu that the view makes.

Variables

This section is empty.

Functions

func IsDeviceLost

func IsDeviceLost(err error) bool

IsDeviceLost says whether err is the loss of a GPU device: GPUDeviceLost, or the loss as a backend reports it (VulkanDeviceLost).

Flutter: no counterpart

func OnDevice

func OnDevice(b *widgets.WidgetsBinding, fn func(*Device)) (cancel func())

OnDevice calls fn with the device of the app each time there is a new one: when the renderer opens its device at its first frame, and again after each device that was lost. fn runs on the UI thread, from the event loop, never inside the call to OnDevice or inside a frame, so it may make resources and submit. If a device exists when OnDevice is called, fn is called for it from the event loop too. It returns the function that stops the calls. A GPU view (step 30.5) makes its resources in such a function.

Flutter: no counterpart

Types

type AddressMode

type AddressMode int

AddressMode is what a sampler does outside the texture.

Flutter: no counterpart

const (
	// AddressModeUnspecified is the zero value: the default (clamp to the edge).
	//
	// Flutter: no counterpart
	AddressModeUnspecified AddressMode = iota
	// AddressModeClampToEdge repeats the edge texel.
	//
	// Flutter: no counterpart
	AddressModeClampToEdge
	// AddressModeRepeat tiles the texture.
	//
	// Flutter: no counterpart
	AddressModeRepeat
	// AddressModeMirrorRepeat tiles the texture, mirrored at each edge.
	//
	// Flutter: no counterpart
	AddressModeMirrorRepeat
)

The values of AddressMode.

type BindGroup

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

BindGroup is the resources a pipeline's shaders read in one group: buffers, texture views and samplers, one for each binding of the group's layout (WebGPU's GPUBindGroup). A pass binds one with SetBindGroup. The uniform buffers of a group have a dynamic offset: SetBindGroup gives one for each, so that one buffer holds the uniforms of many draws.

Flutter: no counterpart

func (*BindGroup) Label

func (r *BindGroup) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*BindGroup) Layout

func (g *BindGroup) Layout() *BindGroupLayout

Layout returns the layout the group was made for.

Flutter: no counterpart

func (*BindGroup) Release

func (g *BindGroup) Release()

Release forgets the group. The commands that were recorded with it keep working. It may be called twice.

Flutter: no counterpart

type BindGroupDesc

type BindGroupDesc struct {
	// Label names the bind group in the messages of errors and in the log of a leak.
	Label string
	// Layout is the layout of the group, from RenderPipeline.BindGroupLayout or
	// ComputePipeline.BindGroupLayout.
	Layout *BindGroupLayout
	// Entries are the resources, one for each binding that the pipeline's functions read from the group.
	Entries []BindGroupEntry
}

BindGroupDesc describes a bind group (WebGPU's GPUBindGroupDescriptor).

Flutter: no counterpart

type BindGroupEntry

type BindGroupEntry struct {
	// Binding is the number in @binding.
	Binding int
	// Buffer is a uniform or storage buffer, from Offset, Size bytes (0 means to the end). A uniform buffer's
	// Offset is a multiple of Limits.MinUniformBufferOffsetAlignment and a storage buffer's of
	// Limits.MinStorageBufferOffsetAlignment.
	Buffer       *Buffer
	Offset, Size int
	// TextureView is a sampled texture, or the storage texture of a storage binding.
	TextureView *TextureView
	// Sampler is a sampler.
	Sampler *Sampler
}

BindGroupEntry is one resource of a bind group (WebGPU's GPUBindGroupEntry): the one for @binding(Binding) of the group. Exactly one of Buffer, TextureView and Sampler is set, the one the binding is.

Flutter: no counterpart

type BindGroupLayout

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

BindGroupLayout says which resources a bind group of a pipeline holds: the bindings that the shaders of the pipeline declare in one group (WebGPU's GPUBindGroupLayout). A pipeline makes its layouts, from the WGSL: RenderPipeline.BindGroupLayout and ComputePipeline.BindGroupLayout. A layout belongs to its pipeline and goes with it.

Flutter: no counterpart

func (*BindGroupLayout) Bindings

func (l *BindGroupLayout) Bindings() []ShaderBinding

Bindings returns the bindings of the group, by binding number. Each is what the WGSL declares.

Flutter: no counterpart

func (*BindGroupLayout) Group

func (l *BindGroupLayout) Group() int

Group returns the number of the group in the shader.

Flutter: no counterpart

type BindingKind

type BindingKind int

BindingKind is what a shader binding is.

Flutter: no counterpart

const (
	// BindingUnspecified is the zero value: no binding.
	//
	// Flutter: no counterpart
	BindingUnspecified BindingKind = iota
	// BindingUniformBuffer is a `var<uniform>`.
	//
	// Flutter: no counterpart
	BindingUniformBuffer
	// BindingSampledTexture is a `texture_2d<f32>`, or a texture_2d_array, texture_cube or texture_3d of f32
	// or u32 (ShaderBinding.Dimension and Sample).
	//
	// Flutter: no counterpart
	BindingSampledTexture
	// BindingSampler is a `sampler`.
	//
	// Flutter: no counterpart
	BindingSampler
	// BindingStorageBufferReadOnly is a `var<storage, read>`.
	//
	// Flutter: no counterpart
	BindingStorageBufferReadOnly
	// BindingStorageBuffer is a `var<storage, read_write>`: a compute entry point only.
	//
	// Flutter: no counterpart
	BindingStorageBuffer
	// BindingStorageTexture is a `texture_storage_2d<format, write>` (or _2d_array or _3d, with
	// ShaderBinding.StorageFormat): a compute entry point only.
	//
	// Flutter: no counterpart
	BindingStorageTexture
)

The kinds of binding a shader may have (SPEC §27.3).

func (BindingKind) String

func (k BindingKind) String() string

String returns "uniform", "texture", "sampler", "storage-read", "storage", "storage-texture" or "unspecified".

type BlendFactor

type BlendFactor int

BlendFactor is a factor of the blend equation: the source times its factor plus the destination times its factor.

Flutter: no counterpart

const (
	// BlendFactorUnspecified is the zero value: One for the source and Zero for the destination.
	//
	// Flutter: no counterpart
	BlendFactorUnspecified BlendFactor = iota
	// BlendFactorZero is 0.
	//
	// Flutter: no counterpart
	BlendFactorZero
	// BlendFactorOne is 1.
	//
	// Flutter: no counterpart
	BlendFactorOne
	// BlendFactorSrcAlpha is the alpha of the source.
	//
	// Flutter: no counterpart
	BlendFactorSrcAlpha
	// BlendFactorOneMinusSrcAlpha is 1 minus the alpha of the source.
	//
	// Flutter: no counterpart
	BlendFactorOneMinusSrcAlpha
	// BlendFactorDstAlpha is the alpha of the destination.
	//
	// Flutter: no counterpart
	BlendFactorDstAlpha
	// BlendFactorOneMinusDstAlpha is 1 minus the alpha of the destination.
	//
	// Flutter: no counterpart
	BlendFactorOneMinusDstAlpha
)

The values of BlendFactor.

type BlendState

type BlendState struct {
	// Enabled turns blending on; off, the new color replaces the old.
	Enabled bool
	// SrcFactor and DstFactor weigh the new color and the old.
	SrcFactor, DstFactor BlendFactor
}

BlendState is the blending of one color target: the new color times SrcFactor plus the one in the target times DstFactor, for the color and the alpha alike (the blend of the explicit device, SPEC §9.3; WebGPU's GPUBlendState has more).

Flutter: no counterpart

type Buffer

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

Buffer is a block of GPU memory (WebGPU's GPUBuffer). Its bytes are written with Queue.WriteBuffer or a copy and read with Read. Release it when it is not needed; the memory is freed when the work that uses it is done.

Flutter: no counterpart

func (*Buffer) Label

func (r *Buffer) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*Buffer) Read

func (b *Buffer) Read(offset, size int, done func(data []byte, err error))

Read reads size bytes from offset (WebGPU's GPUBuffer.mapAsync and getMappedRange, in one call). The buffer has BufferUsageCopySrc, and the offset and the size are multiples of 4. done runs on the UI thread, from the event loop, once the GPU has finished the work submitted before the call; it is never called inside the call or inside the frame that asked. data is a copy that done keeps. A read that failed gives err with the tag GPUReadFailed (the backend's error is its cause), and a lost device GPUDeviceLost.

Flutter: no counterpart

func (*Buffer) Release

func (b *Buffer) Release()

Release frees the buffer, when the work that uses it is done. It may be called twice. After the device is lost it only forgets the buffer.

Flutter: no counterpart

func (*Buffer) Size

func (b *Buffer) Size() int

Size returns the size in bytes.

Flutter: no counterpart

func (*Buffer) Usage

func (b *Buffer) Usage() BufferUsage

Usage returns the uses the buffer was made for.

Flutter: no counterpart

type BufferCopy

type BufferCopy struct {
	Buffer *Buffer
	Layout DataLayout
}

BufferCopy is a buffer and the layout of the texels in it (WebGPU's GPUImageCopyBuffer).

Flutter: no counterpart

type BufferDesc

type BufferDesc struct {
	// Label names the buffer in the messages of errors and in the log of a leak.
	Label string
	// Size is in bytes, at least 1 and at most Limits.MaxBufferSize.
	Size int
	// Usage says what the buffer is for; at least one use.
	Usage BufferUsage
}

BufferDesc describes a buffer (WebGPU's GPUBufferDescriptor).

Flutter: no counterpart

type BufferUsage

type BufferUsage int

BufferUsage says what a buffer is used for; the values are combined with |.

Flutter: no counterpart

const (
	// BufferUsageVertex is a buffer that holds vertices (SetVertexBuffer).
	//
	// Flutter: no counterpart
	BufferUsageVertex BufferUsage = 1 << iota
	// BufferUsageIndex is a buffer that holds indices (SetIndexBuffer).
	//
	// Flutter: no counterpart
	BufferUsageIndex
	// BufferUsageUniform is a buffer that a uniform binding reads.
	//
	// Flutter: no counterpart
	BufferUsageUniform
	// BufferUsageStorage is a buffer that a storage binding reads or, in a compute pass, writes.
	//
	// Flutter: no counterpart
	BufferUsageStorage
	// BufferUsageIndirect is a buffer of the arguments of DrawIndirect, DrawIndexedIndirect and DispatchIndirect.
	//
	// Flutter: no counterpart
	BufferUsageIndirect
	// BufferUsageCopySrc is a buffer that the copies and Read take from.
	//
	// Flutter: no counterpart
	BufferUsageCopySrc
	// BufferUsageCopyDst is a buffer that the copies write to.
	//
	// Flutter: no counterpart
	BufferUsageCopyDst
	// BufferUsageQueryResolve is a buffer that ResolveQuerySet writes to.
	//
	// Flutter: no counterpart
	BufferUsageQueryResolve
)

The values of BufferUsage.

type Color

type Color struct {
	R, G, B, A float64
}

Color is a clear value: four floats, red first. For a texture of unsigned integers they are the integer values (WebGPU's GPUColor).

Flutter: no counterpart

type ColorTargetState

type ColorTargetState struct {
	// Format is the format of the attachment that the pipeline draws into.
	Format TextureFormat
	// Blend is how the colors blend with what the target holds.
	Blend BlendState
	// WriteMask says which channels are written; the zero value writes all of them.
	WriteMask ColorWriteMask
}

ColorTargetState is a color target of a render pipeline (WebGPU's GPUColorTargetState).

Flutter: no counterpart

type ColorWriteMask

type ColorWriteMask int

ColorWriteMask says which channels of a color target a pipeline writes; the values are combined with |. The zero value writes all of them.

Flutter: no counterpart

const (
	// ColorWriteMaskAll writes all four channels.
	//
	// Flutter: no counterpart
	ColorWriteMaskAll ColorWriteMask = 0
	// ColorWriteMaskRed writes red.
	//
	// Flutter: no counterpart
	ColorWriteMaskRed ColorWriteMask = 1 << (iota - 1)
	// ColorWriteMaskGreen writes green.
	//
	// Flutter: no counterpart
	ColorWriteMaskGreen
	// ColorWriteMaskBlue writes blue.
	//
	// Flutter: no counterpart
	ColorWriteMaskBlue
	// ColorWriteMaskAlpha writes alpha.
	//
	// Flutter: no counterpart
	ColorWriteMaskAlpha
	// ColorWriteMaskNone writes nothing.
	//
	// Flutter: no counterpart
	ColorWriteMaskNone
)

The values of ColorWriteMask.

type CommandBuffer

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

CommandBuffer is the finished commands of an encoder (WebGPU's GPUCommandBuffer). It is submitted once.

Flutter: no counterpart

type CommandEncoder

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

CommandEncoder records commands (WebGPU's GPUCommandEncoder): passes, and copies between buffers and textures. Finish makes a CommandBuffer of them and Queue.Submit sends it to the GPU. Nothing runs before the submission. The encoder is used on the UI thread and is not released: it goes when it is finished.

A misuse while encoding (a pass not ended, a copy outside a buffer, a draw without a pipeline) is a programmer error: in debug builds it panics with GPUEncodingInvalid (SPEC §27.2).

Flutter: no counterpart

func (*CommandEncoder) BeginComputePass

func (e *CommandEncoder) BeginComputePass(desc ComputePassDesc) *ComputePass

BeginComputePass starts a compute pass (WebGPU's GPUCommandEncoder.beginComputePass). Compute passes need no attachments. The timestamps, when given, need Features.TimestampQuery.

Flutter: no counterpart

func (*CommandEncoder) BeginRenderPass

func (e *CommandEncoder) BeginRenderPass(desc RenderPassDesc) *RenderPass

BeginRenderPass starts a pass that draws into the attachments (WebGPU's GPUCommandEncoder.beginRenderPass). There is at least one attachment, at most Limits.MaxColorAttachments colors and one depth-stencil. They are views of 2D textures (a LayerView for a layer of an array or a cube, a LevelView for a mip level) with TextureUsageRenderAttachment, of one size and one sample count. A multisampled color view has a resolve view of one sample, of its size and format.

Flutter: no counterpart

func (*CommandEncoder) CopyBufferToBuffer

func (e *CommandEncoder) CopyBufferToBuffer(src *Buffer, srcOffset int, dst *Buffer, dstOffset, size int)

CopyBufferToBuffer copies size bytes (WebGPU's GPUCommandEncoder.copyBufferToBuffer). The source has BufferUsageCopySrc and the destination BufferUsageCopyDst; the offsets and the size are multiples of 4, the ranges are inside the buffers, and the buffers are two.

Flutter: no counterpart

func (*CommandEncoder) CopyBufferToTexture

func (e *CommandEncoder) CopyBufferToTexture(src BufferCopy, dst TextureCopy, size Extent3D)

CopyBufferToTexture copies rows of texels from a buffer into a box of a texture (WebGPU's GPUCommandEncoder.copyBufferToTexture). size is the box: its width and height, and the layers of an array or a cube or the depth of a volume. The layout of the buffer: BytesPerRow is a multiple of Limits.BytesPerRowAlignment (0 is the width of the box rounded up to it), RowsPerImage is the distance in rows between two layers (0 is the height of the box). A depth texture and a multisampled texture are not copied into.

Flutter: no counterpart

func (*CommandEncoder) CopyTextureToBuffer

func (e *CommandEncoder) CopyTextureToBuffer(src TextureCopy, dst BufferCopy, size Extent3D)

CopyTextureToBuffer copies a box of a texture into rows in a buffer (WebGPU's GPUCommandEncoder.copyTextureToBuffer), with the layout rules of CopyBufferToTexture. The texture has TextureUsageCopySrc (or RenderAttachment), is not multisampled, and has a format that can be copied (not Depth24PlusStencil8).

Flutter: no counterpart

func (*CommandEncoder) CopyTextureToTexture

func (e *CommandEncoder) CopyTextureToTexture(src, dst TextureCopy, size Extent3D)

CopyTextureToTexture copies a box between two textures of one format (WebGPU's GPUCommandEncoder.copyTextureToTexture). Both are 2D, 2D arrays or cubes (a volume is not copied: copy it through a buffer), not multisampled and not depth textures; size.DepthOrArrayLayers is the number of layers. The boxes are inside their mip levels, and the source has TextureUsageCopySrc or RenderAttachment.

Flutter: no counterpart

func (*CommandEncoder) Finish

func (e *CommandEncoder) Finish() *CommandBuffer

Finish ends the recording and returns the commands (WebGPU's GPUCommandEncoder.finish). No pass is open.

Flutter: no counterpart

func (*CommandEncoder) ResolveQuerySet

func (e *CommandEncoder) ResolveQuerySet(q *QuerySet, first, count int, dst *Buffer, offset int)

ResolveQuerySet writes count timestamps of the set from first, as 64 bit unsigned integers in ticks (Features.TimestampPeriod), into dst at offset (WebGPU's GPUCommandEncoder.resolveQuerySet). dst has BufferUsageQueryResolve and the offset is a multiple of Limits.MinStorageBufferOffsetAlignment. Read the bytes with Buffer.Read after a copy into a buffer with BufferUsageCopySrc.

Flutter: no counterpart

type CompareFunction

type CompareFunction int

CompareFunction is how a depth or stencil test compares the new value to the stored one.

Flutter: no counterpart

const (
	// CompareFunctionUnspecified is the zero value: Always (Less for the depth test).
	//
	// Flutter: no counterpart
	CompareFunctionUnspecified CompareFunction = iota
	// CompareFunctionNever never passes.
	//
	// Flutter: no counterpart
	CompareFunctionNever
	// CompareFunctionLess passes when the new value is less.
	//
	// Flutter: no counterpart
	CompareFunctionLess
	// CompareFunctionEqual passes when the values are equal.
	//
	// Flutter: no counterpart
	CompareFunctionEqual
	// CompareFunctionLessEqual passes when the new value is less or equal.
	//
	// Flutter: no counterpart
	CompareFunctionLessEqual
	// CompareFunctionGreater passes when the new value is greater.
	//
	// Flutter: no counterpart
	CompareFunctionGreater
	// CompareFunctionNotEqual passes when the values differ.
	//
	// Flutter: no counterpart
	CompareFunctionNotEqual
	// CompareFunctionGreaterEqual passes when the new value is greater or equal.
	//
	// Flutter: no counterpart
	CompareFunctionGreaterEqual
	// CompareFunctionAlways always passes.
	//
	// Flutter: no counterpart
	CompareFunctionAlways
)

The values of CompareFunction.

type ComputePass

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

ComputePass records the dispatches of a compute pass (WebGPU's GPUComputePassEncoder). End it before anything else is recorded in its encoder. A pass is kept by the queue for the next one once its encoder is submitted.

Flutter: no counterpart

func (*ComputePass) DispatchWorkgroups

func (p *ComputePass) DispatchWorkgroups(x, y, z int)

DispatchWorkgroups runs x by y by z workgroups (WebGPU's GPUComputePassEncoder.dispatchWorkgroups). Each count is from 0 to Limits.MaxComputeWorkgroupsPerDimension.

Flutter: no counterpart

func (*ComputePass) DispatchWorkgroupsIndirect

func (p *ComputePass) DispatchWorkgroupsIndirect(b *Buffer, offset int)

DispatchWorkgroupsIndirect runs the workgroups whose counts are in a buffer: three 32 bit unsigned integers at offset (WebGPU's GPUComputePassEncoder.dispatchWorkgroupsIndirect). The buffer has BufferUsageIndirect and the offset is a multiple of 4.

Flutter: no counterpart

func (*ComputePass) End

func (p *ComputePass) End()

End finishes the pass (WebGPU's GPUComputePassEncoder.end). The encoder can record other commands then.

Flutter: no counterpart

func (*ComputePass) SetBindGroup

func (p *ComputePass) SetBindGroup(index int, bg *BindGroup, dynamicOffsets ...uint32)

SetBindGroup binds the group of index to the bind group, with the rules of RenderPass.SetBindGroup (WebGPU's GPUComputePassEncoder.setBindGroup). A storage buffer has no dynamic offset: its range is the entry's.

Flutter: no counterpart

func (*ComputePass) SetPipeline

func (p *ComputePass) SetPipeline(pipe *ComputePipeline)

SetPipeline chooses the pipeline of the next dispatches (WebGPU's GPUComputePassEncoder.setPipeline). The bind groups that were set stay, when they fit the pipeline.

Flutter: no counterpart

type ComputePassDesc

type ComputePassDesc struct {
	// Label names the pass in the messages of errors.
	Label string
	// TimestampWrites, when set, writes the time of the start and the end of the pass.
	TimestampWrites *PassTimestampWrites
}

ComputePassDesc describes a compute pass (WebGPU's GPUComputePassDescriptor).

Flutter: no counterpart

type ComputePipeline

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

ComputePipeline is a compute function of a shader (WebGPU's GPUComputePipeline). A compute pass runs one set by SetPipeline.

Flutter: no counterpart

func (*ComputePipeline) BindGroupLayout

func (p *ComputePipeline) BindGroupLayout(i int) *BindGroupLayout

BindGroupLayout returns the layout of bind group i of the pipeline, as RenderPipeline.BindGroupLayout does.

Flutter: no counterpart

func (*ComputePipeline) Label

func (r *ComputePipeline) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*ComputePipeline) Release

func (p *ComputePipeline) Release()

Release frees the pipeline, when the work that uses it is done. It may be called twice.

Flutter: no counterpart

func (*ComputePipeline) WorkgroupSize

func (p *ComputePipeline) WorkgroupSize() [3]int

WorkgroupSize returns the @workgroup_size of the compute function.

Flutter: no counterpart

type ComputePipelineDesc

type ComputePipelineDesc struct {
	// Label names the pipeline in the messages of errors and in the log of a leak.
	Label string
	// Module is the shader and EntryPoint the name of its @compute function.
	Module     *ShaderModule
	EntryPoint string
}

ComputePipelineDesc describes a compute pipeline (WebGPU's GPUComputePipelineDescriptor).

Flutter: no counterpart

type CullMode

type CullMode int

CullMode is which triangles a pipeline leaves out. The zero value is CullModeNone.

Flutter: no counterpart

const (
	// CullModeNone leaves out none.
	//
	// Flutter: no counterpart
	CullModeNone CullMode = iota
	// CullModeFront leaves out the triangles that face the viewer.
	//
	// Flutter: no counterpart
	CullModeFront
	// CullModeBack leaves out the triangles that face away.
	//
	// Flutter: no counterpart
	CullModeBack
)

The values of CullMode.

type DataLayout

type DataLayout struct {
	// Offset is where the first texel is, in bytes; a multiple of 4 and of the bytes of a texel.
	Offset int
	// BytesPerRow is the distance between two rows: a multiple of Limits.BytesPerRowAlignment, and at least a
	// row. A queue write has no such alignment (Queue.WriteTexture).
	BytesPerRow int
	// RowsPerImage is the distance between two images, in rows; at least the height of the copy. 0 means the
	// height of the copy.
	RowsPerImage int
}

DataLayout is how the texels of a copy are laid out in the bytes of a buffer or of a slice (WebGPU's GPUImageDataLayout): the first texel is at Offset, the rows are BytesPerRow apart, and the images (layers or slices) RowsPerImage rows apart.

Flutter: no counterpart

type DepthStencilState

type DepthStencilState struct {
	// Format is the format of the depth attachment: a depth format.
	Format TextureFormat
	// DepthWriteEnabled lets the pipeline write depth.
	DepthWriteEnabled bool
	// DepthCompare is the depth test; the zero value is Less.
	DepthCompare CompareFunction
	// StencilFront and StencilBack are the stencil tests of the front and back faces.
	StencilFront, StencilBack StencilFaceState
	// StencilReadMask and StencilWriteMask select the bits that the test reads and writes; 0 stands for all of
	// them.
	StencilReadMask, StencilWriteMask uint32
	// DepthBias, DepthBiasSlopeScale and DepthBiasClamp offset the depth of triangles.
	DepthBias           int32
	DepthBiasSlopeScale float32
	DepthBiasClamp      float32
}

DepthStencilState is the depth and stencil state of a render pipeline (WebGPU's GPUDepthStencilState).

Flutter: no counterpart

type Device

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

Device is a GPU device: the one of the renderer of the app, shared with it (DeviceOf). Everything made from it is used on the UI thread only; in debug builds a call from another goroutine panics with GPUWrongThread. When the device is lost, every resource made with it stops working and OnLost functions run (SPEC §27.2).

Flutter: no counterpart

func DeviceOf

func DeviceOf(bc widgets.BuildContext) (*Device, error)

DeviceOf returns the GPU device of the app: the device of the renderer that draws its windows (Vulkan, Direct3D 12 or WebGPU), which package gpu shares with it (SPEC §27.2). It fails with GPUUnavailable when the app runs on the OpenGL ES, WebGL or software renderer, and with GPUDeviceNotReady before the first frame, when the renderer has not opened its device yet: use OnDevice to be called when there is one. Call it on the UI thread.

Flutter: no counterpart

func DeviceOfBinding

func DeviceOfBinding(b *widgets.WidgetsBinding) (*Device, error)

DeviceOfBinding is DeviceOf for code that has the binding and no BuildContext.

Flutter: no counterpart

func (*Device) Description

func (d *Device) Description() string

Description names the adapter, such as "AMD Radeon RX 6800M (RADV NAVI22)", when the backend can tell; "" when it cannot.

Flutter: no counterpart

func (*Device) Features

func (d *Device) Features() Features

Features returns the optional features of the device.

Flutter: no counterpart

func (*Device) IsLost

func (d *Device) IsLost() bool

IsLost says whether the device was lost. A lost device does nothing, and its calls that return an error return GPUDeviceLost.

Flutter: no counterpart

func (*Device) Limits

func (d *Device) Limits() Limits

Limits returns the limits of the device.

Flutter: no counterpart

func (*Device) MarkTextureFrameAvailable

func (d *Device) MarkTextureFrameAvailable(id int64)

MarkTextureFrameAvailable says that the app wrote the texture with the id since the last frame: it schedules a frame, and the layers that show the texture are damaged, so that the compositor redraws their rectangles. Call it after the commands that wrote the texture were submitted. An id that is not registered is ignored.

Flutter: no counterpart (FlutterEngineMarkExternalTextureFrameAvailable)

func (*Device) NewBindGroup

func (d *Device) NewBindGroup(desc BindGroupDesc) (*BindGroup, error)

NewBindGroup makes a bind group for a layout (WebGPU's GPUDevice.createBindGroup). Every binding of the layout has exactly one entry. It fails with GPUInvalidDescriptor for an entry that does not fit its binding (the wrong resource, a buffer without the use, a range outside the buffer or smaller than what the shader reads, a texture view of another dimension or sample type, a storage texture of another format, a resource of another device) and with GPULimitExceeded for a binding range over the limits or an offset that is not aligned.

A uniform entry's Offset is a multiple of Limits.MinUniformBufferOffsetAlignment, a storage entry's of Limits.MinStorageBufferOffsetAlignment. A Size of 0 is up to the end of the buffer.

Flutter: no counterpart

func (*Device) NewBuffer

func (d *Device) NewBuffer(desc BufferDesc) (*Buffer, error)

NewBuffer makes a buffer (WebGPU's GPUDevice.createBuffer). It fails with GPUInvalidDescriptor and GPULimitExceeded for a description that cannot be made (the metadata "field" and "value" say which part), with GPUDeviceLost on a lost device, and with the error of the backend (GPUOutOfMemory) untouched.

Flutter: no counterpart

func (*Device) NewCommandEncoder

func (d *Device) NewCommandEncoder() *CommandEncoder

NewCommandEncoder starts a list of commands (WebGPU's GPUDevice.createCommandEncoder). The encoder, its command buffer and its passes are kept by the queue for the next encoder once the buffer is submitted, so a frame that records the same commands each time allocates nothing: do not use an encoder, a pass or a command buffer after it was submitted.

Flutter: no counterpart

func (*Device) NewComputePipeline

func (d *Device) NewComputePipeline(desc ComputePipelineDesc) (*ComputePipeline, error)

NewComputePipeline makes a compute pipeline (WebGPU's GPUDevice.createComputePipeline). It fails with GPUInvalidDescriptor for an entry point the shader lacks or that is not a compute function, and with GPULimitExceeded for a @workgroup_size or a count of resources over the limits; the other failures are those of NewRenderPipeline.

Flutter: no counterpart

func (*Device) NewQuerySet

func (d *Device) NewQuerySet(desc QuerySetDesc) (*QuerySet, error)

NewQuerySet makes a set of timestamps (WebGPU's GPUDevice.createQuerySet). It fails with GPUInvalidDescriptor when Features.TimestampQuery is false or the count is not from 1 to 4096.

Flutter: no counterpart

func (*Device) NewRenderPipeline

func (d *Device) NewRenderPipeline(desc RenderPipelineDesc) (*RenderPipeline, error)

NewRenderPipeline makes a pipeline (WebGPU's GPUDevice.createRenderPipeline). It fails with GPUInvalidDescriptor and GPULimitExceeded for a description that cannot be made (the metadata "field", "value" and the reason in the message say which part: an entry point the shader lacks, a vertex input with no attribute or of another type, a target that cannot be drawn into, a binding that the two functions declare differently), with GPUShaderCompileFailed when the backend cannot compile the shader (its error is the cause), with GPUDeviceLost on a lost device, and with GPUOutOfMemory.

Flutter: no counterpart

func (*Device) NewSampler

func (d *Device) NewSampler(desc SamplerDesc) (*Sampler, error)

NewSampler makes a sampler (WebGPU's GPUDevice.createSampler). The zero value of a filter is nearest and of an address mode is clamp to edge; no mip filter reads level 0 only. It fails with GPUInvalidDescriptor for a value that is not one of the constants, with GPUDeviceLost on a lost device, and with the error of the backend untouched.

Flutter: no counterpart

func (*Device) NewShaderModule

func (d *Device) NewShaderModule(s *Shader) (*ShaderModule, error)

NewShaderModule makes a module from a shader that glutter-gen gpushaders made (WebGPU's GPUDevice.createShaderModule). It fails with GPUInvalidDescriptor for a shader that is not whole (nil, no entry point, an entry point twice, a binding of a kind or a storage format that does not exist, a binding twice in one group) and with GPULimitExceeded for an entry point that has more resources than a stage may. The backend compiles the shader later, at the first pipeline: a failure there is GPUShaderCompileFailed.

Flutter: no counterpart

func (*Device) NewTexture

func (d *Device) NewTexture(desc TextureDesc) (*Texture, error)

NewTexture makes a texture (WebGPU's GPUDevice.createTexture). It fails with GPUInvalidDescriptor and GPULimitExceeded for a description that cannot be made (the metadata "field" and "value" say which part), with GPUDeviceLost on a lost device, and with the error of the backend (GPUOutOfMemory) untouched.

Flutter: no counterpart

func (*Device) OnLost

func (d *Device) OnLost(fn func(err error)) (remove func())

OnLost calls fn once when the device is lost (a driver reset, a lost WebGPU device), on the UI thread from the event loop, with the GPUDeviceLost error. It returns the function that removes fn. A function added to a device that is lost already is called at once from the event loop.

Flutter: no counterpart

func (*Device) Queue

func (d *Device) Queue() *Queue

Queue returns the queue of the device.

Flutter: no counterpart

func (*Device) RegisterTexture

func (d *Device) RegisterTexture(t *Texture) int64

RegisterTexture lets the windows show the texture: it returns the id that a Texture widget, a TextureBox or SceneBuilder.AddTexture names (SPEC §27.4; Flutter's embedder registers textures the same way). The renderer samples the texture where the widget is, scaled to its rectangle and premultiplied, with the commands that wrote it submitted before the frame's composite; nothing is copied. The texture is 2D with one sample and TextureUsageTextureBinding, and its format is RGBA8Unorm or BGRA8Unorm (sRGB-encoded values) or RGBA16Float (linear values, which the composite encodes to sRGB). A lost device registers nothing and returns 0; so does a texture that the renderer cannot show, in debug builds after a panic with GPUEncodingInvalid.

Flutter: no counterpart (FlutterEngineRegisterExternalTexture)

func (*Device) Resources

func (d *Device) Resources() ResourceCounts

Resources returns how many resources of each kind are alive. The memory tests check that it goes back to 0.

Flutter: no counterpart

func (*Device) UnregisterTexture

func (d *Device) UnregisterTexture(id int64)

UnregisterTexture stops the windows from showing the texture with the id; a layer that names it draws nothing then. An id that is not registered is ignored. Releasing the texture unregisters it too.

Flutter: no counterpart (FlutterEngineUnregisterExternalTexture)

type EntryPoint

type EntryPoint struct {
	// Name is the name of the function.
	Name string
	// Stage is the stage the function runs in.
	Stage ShaderStage
	// Bindings are the resources the function reads, directly or through the functions it calls, sorted by
	// group and binding.
	Bindings []ShaderBinding
	// Inputs are the @location inputs of a vertex entry point, in the order of the parameters.
	Inputs []VertexInput
	// WorkgroupSize is the @workgroup_size of a compute entry point (the missing dimensions are 1).
	WorkgroupSize [3]int
	// ReadsInstanceIndex and ReadsVertexIndex say that a vertex entry point reads
	// @builtin(instance_index) or @builtin(vertex_index). Such a shader is drawn with a first instance, a
	// first vertex and a base vertex of 0 only: Direct3D 12's SV_InstanceID and SV_VertexID leave out the
	// first instance and the first vertex of a draw (SPEC §27.1).
	ReadsInstanceIndex, ReadsVertexIndex bool
}

EntryPoint is a function of a shader that a pipeline stage runs.

Flutter: no counterpart

type Extent3D

type Extent3D struct {
	Width, Height, DepthOrArrayLayers int
}

Extent3D is the size of a texture or of a copy: the width and height in texels, and the number of layers of an array, the six faces of a cube, or the depth of a volume (WebGPU's GPUExtent3D).

Flutter: no counterpart

type Features

type Features struct {
	// Float32Filterable says that RGBA32Float and R32Float textures can be sampled with a filter.
	Float32Filterable bool
	// TimestampQuery says that query sets can be made and passes can write timestamps into them.
	TimestampQuery bool
	// TimestampPeriod is the time of one tick of a timestamp, in nanoseconds; 0 when TimestampQuery is false.
	TimestampPeriod float64
}

Features are the optional features of a device (WebGPU's GPUSupportedFeatures).

Flutter: no counterpart

type FilterMode

type FilterMode int

FilterMode is how a sampler reads between texels.

Flutter: no counterpart

const (
	// FilterModeUnspecified is the zero value: the default (nearest).
	//
	// Flutter: no counterpart
	FilterModeUnspecified FilterMode = iota
	// FilterModeNearest reads the nearest texel.
	//
	// Flutter: no counterpart
	FilterModeNearest
	// FilterModeLinear blends the nearest texels.
	//
	// Flutter: no counterpart
	FilterModeLinear
)

The values of FilterMode.

type FragmentState

type FragmentState struct {
	// Module is the shader and EntryPoint the name of its @fragment function. The module is the vertex
	// stage's: both functions are in one WGSL file.
	Module     *ShaderModule
	EntryPoint string
	// Targets are the color targets, by attachment index; at least one.
	Targets []ColorTargetState
}

FragmentState is the fragment stage of a render pipeline (WebGPU's GPUFragmentState).

Flutter: no counterpart

type FrontFace

type FrontFace int

FrontFace is which winding of a triangle faces the viewer. The zero value is FrontFaceCCW.

Flutter: no counterpart

const (
	// FrontFaceCCW is counter-clockwise on the screen.
	//
	// Flutter: no counterpart
	FrontFaceCCW FrontFace = iota
	// FrontFaceCW is clockwise on the screen.
	//
	// Flutter: no counterpart
	FrontFaceCW
)

The values of FrontFace.

type Limits

type Limits struct {
	// MaxTextureDimension2D is the largest width or height of a 2D texture, and MaxTextureDimension3D the largest
	// side of a 3D texture.
	MaxTextureDimension2D, MaxTextureDimension3D int
	// MaxTextureArrayLayers is the most layers of a texture array.
	MaxTextureArrayLayers int
	// MaxBindGroups is the number of bind groups a pipeline may use.
	MaxBindGroups int
	// MaxSampledTexturesPerShaderStage, MaxSamplersPerShaderStage, MaxUniformBuffersPerShaderStage,
	// MaxStorageBuffersPerShaderStage and MaxStorageTexturesPerShaderStage are the most resources of a kind that
	// the functions of one stage read.
	MaxSampledTexturesPerShaderStage, MaxSamplersPerShaderStage, MaxUniformBuffersPerShaderStage int
	MaxStorageBuffersPerShaderStage, MaxStorageTexturesPerShaderStage                            int
	// MaxUniformBufferBindingSize and MaxStorageBufferBindingSize are the largest range of a buffer that a
	// binding reads.
	MaxUniformBufferBindingSize, MaxStorageBufferBindingSize int
	// MinUniformBufferOffsetAlignment and MinStorageBufferOffsetAlignment are what the offsets of a binding are a
	// multiple of.
	MinUniformBufferOffsetAlignment, MinStorageBufferOffsetAlignment int
	// BytesPerRowAlignment is what DataLayout.BytesPerRow of a copy between a buffer and a texture is a multiple of.
	BytesPerRowAlignment int
	// MaxBufferSize is the largest buffer.
	MaxBufferSize int
	// MaxVertexBuffers and MaxVertexAttributes are the most vertex buffers and vertex attributes of a pipeline.
	MaxVertexBuffers, MaxVertexAttributes int
	// MaxColorAttachments is the most color attachments of a pass or targets of a pipeline, and
	// MaxColorAttachmentBytesPerSample the most bytes that their texels take together.
	MaxColorAttachments, MaxColorAttachmentBytesPerSample int
	// MaxComputeInvocationsPerWorkgroup, MaxComputeWorkgroupSize and MaxComputeWorkgroupsPerDimension limit the
	// @workgroup_size of a compute function and the numbers of a dispatch.
	MaxComputeInvocationsPerWorkgroup int
	MaxComputeWorkgroupSize           [3]int
	MaxComputeWorkgroupsPerDimension  int
}

Limits are the limits of a device (WebGPU's GPUSupportedLimits). They are the design limits of Glutter's explicit renderer (SPEC §9.3, §27.1): every backend honours them, so that a program that stays inside them runs the same on each. The constructors return GPULimitExceeded for a description that is over one.

Flutter: no counterpart

type LoadOp

type LoadOp int

LoadOp is what a pass does with an attachment before it draws. The zero value is LoadOpClear.

Flutter: no counterpart

const (
	// LoadOpClear fills the attachment with the clear value.
	//
	// Flutter: no counterpart
	LoadOpClear LoadOp = iota
	// LoadOpLoad keeps what the attachment holds.
	//
	// Flutter: no counterpart
	LoadOpLoad
	// LoadOpDontCare leaves the contents undefined, for a pass that draws every texel.
	//
	// Flutter: no counterpart
	LoadOpDontCare
)

The values of LoadOp.

type MultisampleState

type MultisampleState struct {
	// Count is 1 or 4; 0 means 1.
	Count int
}

MultisampleState is the sample count of a render pipeline (WebGPU's GPUMultisampleState).

Flutter: no counterpart

type Origin3D

type Origin3D struct {
	X, Y, Z int
}

Origin3D is the first texel of a copy: x and y in the texture, and z, the layer or the slice (WebGPU's GPUOrigin3D).

Flutter: no counterpart

type PassTimestampWrites

type PassTimestampWrites struct {
	QuerySet *QuerySet
	// BeginIndex and EndIndex are the queries that get the time at the start and at the end of the pass.
	BeginIndex, EndIndex int
}

PassTimestampWrites tells a pass to write its start and its end to a query set (WebGPU's GPURenderPassTimestampWrites). Features.TimestampQuery must be true.

Flutter: no counterpart

type PrimitiveState

type PrimitiveState struct {
	Topology  PrimitiveTopology
	CullMode  CullMode
	FrontFace FrontFace
}

PrimitiveState is how a render pipeline assembles primitives (WebGPU's GPUPrimitiveState).

Flutter: no counterpart

type PrimitiveTopology

type PrimitiveTopology int

PrimitiveTopology is how the vertices of a draw make primitives. The zero value is TriangleList.

Flutter: no counterpart

const (
	// PrimitiveTopologyTriangleList makes a triangle of each three vertices.
	//
	// Flutter: no counterpart
	PrimitiveTopologyTriangleList PrimitiveTopology = iota
	// PrimitiveTopologyTriangleStrip makes a triangle of each vertex and the two before it.
	//
	// Flutter: no counterpart
	PrimitiveTopologyTriangleStrip
	// PrimitiveTopologyLineList makes a line of each two vertices.
	//
	// Flutter: no counterpart
	PrimitiveTopologyLineList
	// PrimitiveTopologyLineStrip makes a line of each vertex and the one before it.
	//
	// Flutter: no counterpart
	PrimitiveTopologyLineStrip
	// PrimitiveTopologyPointList makes a point of each vertex.
	//
	// Flutter: no counterpart
	PrimitiveTopologyPointList
)

The values of PrimitiveTopology.

type QuerySet

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

QuerySet is a set of timestamps that passes write (PassTimestampWrites) and CommandEncoder.ResolveQuerySet reads (WebGPU's GPUQuerySet). It needs Features.TimestampQuery.

Flutter: no counterpart

func (*QuerySet) Count

func (q *QuerySet) Count() int

Count returns the number of timestamps.

Flutter: no counterpart

func (*QuerySet) Label

func (r *QuerySet) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*QuerySet) Release

func (q *QuerySet) Release()

Release frees the set. It may be called twice.

Flutter: no counterpart

type QuerySetDesc

type QuerySetDesc struct {
	// Label names the set in the messages of errors and in the log of a leak.
	Label string
	// Count is the number of timestamps; at least 1.
	Count int
}

QuerySetDesc describes a set of timestamp queries (WebGPU's GPUQuerySetDescriptor).

Flutter: no counterpart

type Queue

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

Queue is the queue of a device (WebGPU's GPUQueue): the commands of the command buffers that are submitted run on the GPU in the order they were submitted, and the writes take effect in that order too.

Each call to Submit is one submission of the explicit device (one Begin and one Submit, SPEC §9.3), and the device has FramesInFlight (2) of them in flight with the frame of the renderer: submit once for each frame, with all the command buffers of the frame, rather than once for each of them.

Flutter: no counterpart

func (*Queue) OnSubmittedWorkDone

func (q *Queue) OnSubmittedWorkDone(fn func())

OnSubmittedWorkDone calls fn, on the UI thread from the event loop, once the GPU has finished everything that was submitted before this call (WebGPU's GPUQueue.onSubmittedWorkDone). It is never called inside the call.

Flutter: no counterpart

func (*Queue) Submit

func (q *Queue) Submit(buffers ...*CommandBuffer) error

Submit sends the command buffers to the GPU, in order, as one submission (WebGPU's GPUQueue.submit). A command buffer is submitted once. It fails with GPUDeviceLost for a lost device, and with the errors of the backend (such as GPUOutOfMemory) untouched.

Flutter: no counterpart

func (*Queue) WriteBuffer

func (q *Queue) WriteBuffer(b *Buffer, offset int, data []byte)

WriteBuffer writes data into the buffer at offset (WebGPU's GPUQueue.writeBuffer). The data is copied before the call returns; the write happens, for the GPU, between the submissions before it and the ones after. The buffer has BufferUsageCopyDst, and the offset and the length are multiples of 4.

Flutter: no counterpart

func (*Queue) WriteTexture

func (q *Queue) WriteTexture(dst TextureCopy, data []byte, layout DataLayout, size Extent3D)

WriteTexture writes data into a box of a texture (WebGPU's GPUQueue.writeTexture). The data is copied before the call returns, and the write happens in the order of the submissions. layout says how the texels are laid out in data; unlike a copy from a buffer, its BytesPerRow has no alignment. The texture is not a depth texture or multisampled.

Flutter: no counterpart

type RenderPass

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

RenderPass records the draws into the attachments of a render pass (WebGPU's GPURenderPassEncoder). End it before anything else is recorded in its encoder. A pass is kept by the queue for the next one once its encoder is submitted.

Flutter: no counterpart

func (*RenderPass) Draw

func (p *RenderPass) Draw(vertices, instances, firstVertex, firstInstance int)

Draw draws vertices, instances times (WebGPU's GPURenderPassEncoder.draw). A shader that reads vertex_index is drawn with firstVertex 0, one that reads instance_index with firstInstance 0.

Flutter: no counterpart

func (*RenderPass) DrawIndexed

func (p *RenderPass) DrawIndexed(indices, instances, firstIndex, baseVertex, firstInstance int)

DrawIndexed draws indices, instances times (WebGPU's GPURenderPassEncoder.drawIndexed). The indices are inside the index buffer.

Flutter: no counterpart

func (*RenderPass) DrawIndexedIndirect

func (p *RenderPass) DrawIndexedIndirect(b *Buffer, offset int)

DrawIndexedIndirect draws with the arguments in a buffer: five 32 bit integers at offset, the index count, the instance count, the first index, the base vertex (signed) and the first instance (WebGPU's GPURenderPassEncoder.drawIndexedIndirect). The rules of DrawIndirect hold.

Flutter: no counterpart

func (*RenderPass) DrawIndirect

func (p *RenderPass) DrawIndirect(b *Buffer, offset int)

DrawIndirect draws with the arguments in a buffer: four 32 bit unsigned integers at offset, the vertex count, the instance count, the first vertex and the first instance (WebGPU's GPURenderPassEncoder.drawIndirect). The buffer has BufferUsageIndirect and the offset is a multiple of 4. The first vertex and the first instance are 0 for a shader that reads vertex_index or instance_index: the CPU cannot check them.

Flutter: no counterpart

func (*RenderPass) End

func (p *RenderPass) End()

End finishes the pass (WebGPU's GPURenderPassEncoder.end). The encoder can record other commands then.

Flutter: no counterpart

func (*RenderPass) SetBindGroup

func (p *RenderPass) SetBindGroup(index int, bg *BindGroup, dynamicOffsets ...uint32)

SetBindGroup binds the group of index to the bind group (WebGPU's GPURenderPassEncoder.setBindGroup). dynamicOffsets has one offset for each uniform buffer of the group, in binding order, each a multiple of Limits.MinUniformBufferOffsetAlignment; the range of the binding, moved by the offset, is inside the buffer. The group was made for the layout of group index of the pipeline.

Flutter: no counterpart

func (*RenderPass) SetIndexBuffer

func (p *RenderPass) SetIndexBuffer(b *Buffer, offset int)

SetIndexBuffer binds a buffer of 16 bit indices, from offset (WebGPU's GPURenderPassEncoder.setIndexBuffer with the format uint16). The buffer has BufferUsageIndex and the offset is a multiple of 2.

Flutter: no counterpart

func (*RenderPass) SetIndexBuffer32

func (p *RenderPass) SetIndexBuffer32(b *Buffer, offset int)

SetIndexBuffer32 binds a buffer of 32 bit indices, from offset (WebGPU's GPURenderPassEncoder.setIndexBuffer with the format uint32). The buffer has BufferUsageIndex and the offset is a multiple of 4.

Flutter: no counterpart

func (*RenderPass) SetPipeline

func (p *RenderPass) SetPipeline(pipe *RenderPipeline)

SetPipeline chooses the pipeline of the next draws (WebGPU's GPURenderPassEncoder.setPipeline). Its targets are the attachments of the pass: the same formats in the same order, the same depth-stencil format and the same sample count. The bind groups that were set stay, when they fit the pipeline.

Flutter: no counterpart

func (*RenderPass) SetScissorRect

func (p *RenderPass) SetScissorRect(x, y, width, height int)

SetScissorRect limits the draws to a rectangle of the attachments, in pixels (WebGPU's GPURenderPassEncoder.setScissorRect). The rectangle is inside the attachments.

Flutter: no counterpart

func (*RenderPass) SetStencilReference

func (p *RenderPass) SetStencilReference(ref uint32)

SetStencilReference sets the reference value of the stencil tests (WebGPU's GPURenderPassEncoder.setStencilReference). It is 0 at the start of a pass.

Flutter: no counterpart

func (*RenderPass) SetVertexBuffer

func (p *RenderPass) SetVertexBuffer(slot int, b *Buffer, offset int)

SetVertexBuffer binds a vertex buffer to a slot, from offset (WebGPU's GPURenderPassEncoder.setVertexBuffer). The buffer has BufferUsageVertex and the offset is a multiple of 4.

Flutter: no counterpart

type RenderPassColorAttachment

type RenderPassColorAttachment struct {
	// View is the texture that is drawn into: a render attachment.
	View *TextureView
	// ResolveTarget, when set, gets the resolved pixels of a multisampled View.
	ResolveTarget *TextureView
	// LoadOp is what the pass does with View before it draws, and ClearValue the color of LoadOpClear.
	LoadOp     LoadOp
	ClearValue Color
	// StoreOp is what the pass does with View after.
	StoreOp StoreOp
}

RenderPassColorAttachment is a color attachment of a render pass (WebGPU's GPURenderPassColorAttachment).

Flutter: no counterpart

type RenderPassDepthStencilAttachment

type RenderPassDepthStencilAttachment struct {
	// View is the depth texture.
	View *TextureView
	// DepthLoadOp, DepthStoreOp and DepthClearValue are for the depth, StencilLoadOp, StencilStoreOp and
	// StencilClearValue for the stencil of a format that has one.
	DepthLoadOp       LoadOp
	DepthStoreOp      StoreOp
	DepthClearValue   float64
	StencilLoadOp     LoadOp
	StencilStoreOp    StoreOp
	StencilClearValue uint32
}

RenderPassDepthStencilAttachment is the depth and stencil attachment of a render pass (WebGPU's GPURenderPassDepthStencilAttachment).

Flutter: no counterpart

type RenderPassDesc

type RenderPassDesc struct {
	// Label names the pass in the messages of errors.
	Label string
	// ColorAttachments are up to Limits.MaxColorAttachments, by attachment index.
	ColorAttachments []RenderPassColorAttachment
	// DepthStencilAttachment is the depth attachment, or nil.
	DepthStencilAttachment *RenderPassDepthStencilAttachment
	// TimestampWrites, when set, writes the time of the start and the end of the pass.
	TimestampWrites *PassTimestampWrites
}

RenderPassDesc describes a render pass (WebGPU's GPURenderPassDescriptor).

Flutter: no counterpart

type RenderPipeline

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

RenderPipeline is the state of a draw: the vertex and fragment functions of a shader, the layout of the vertex buffers, the targets with their blending, the primitives and the depth and stencil tests (WebGPU's GPURenderPipeline). A pass draws with one set by SetPipeline.

Flutter: no counterpart

func (*RenderPipeline) BindGroupLayout

func (p *RenderPipeline) BindGroupLayout(i int) *BindGroupLayout

BindGroupLayout returns the layout of bind group i of the pipeline: the bindings the vertex and fragment functions declare in `@group(i)`. A group the shader does not use has a layout with no bindings. i is from 0 to Limits.MaxBindGroups - 1.

Flutter: no counterpart

func (*RenderPipeline) Label

func (r *RenderPipeline) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*RenderPipeline) Release

func (p *RenderPipeline) Release()

Release frees the pipeline, when the work that uses it is done. It may be called twice.

Flutter: no counterpart

type RenderPipelineDesc

type RenderPipelineDesc struct {
	// Label names the pipeline in the messages of errors and in the log of a leak.
	Label        string
	Vertex       VertexState
	Fragment     FragmentState
	Primitive    PrimitiveState
	DepthStencil *DepthStencilState
	Multisample  MultisampleState
}

RenderPipelineDesc describes a render pipeline (WebGPU's GPURenderPipelineDescriptor). The layout comes from the shader (WebGPU's layout "auto"): RenderPipeline.BindGroupLayout gives it.

Flutter: no counterpart

type ResourceCounts

type ResourceCounts struct {
	Buffers, Textures, Samplers, ShaderModules, RenderPipelines, ComputePipelines, BindGroups, QuerySets int
}

ResourceCounts is how many resources of each kind a device made that were not released.

Flutter: no counterpart

func (ResourceCounts) Total

func (c ResourceCounts) Total() int

Total is the number of resources that are alive.

Flutter: no counterpart

type SampleType

type SampleType int

SampleType is how a shader reads the texels of a texture (WebGPU's GPUTextureSampleType). The zero value is SampleTypeFloat.

Flutter: no counterpart

const (
	// SampleTypeFloat is a floating point texture that a filtering sampler can read.
	//
	// Flutter: no counterpart
	SampleTypeFloat SampleType = iota
	// SampleTypeUnfilterableFloat is a floating point texture that only textureLoad and the like read:
	// any float texture can be bound to it, a float32 texture too.
	//
	// Flutter: no counterpart
	SampleTypeUnfilterableFloat
	// SampleTypeUint is an unsigned integer texture.
	//
	// Flutter: no counterpart
	SampleTypeUint
)

The sample types of a texture binding.

type Sampler

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

Sampler says how a shader reads between the texels of a texture (WebGPU's GPUSampler).

Flutter: no counterpart

func (*Sampler) Label

func (r *Sampler) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*Sampler) Release

func (s *Sampler) Release()

Release frees the sampler. It may be called twice.

Flutter: no counterpart

type SamplerDesc

type SamplerDesc struct {
	// Label names the sampler in the messages of errors and in the log of a leak.
	Label string
	// AddressModeU, AddressModeV and AddressModeW say what the sampler does outside the texture.
	AddressModeU, AddressModeV, AddressModeW AddressMode
	// MagFilter and MinFilter are the filters when the texture is enlarged and when it is reduced, and
	// MipmapFilter the one between two mip levels.
	MagFilter, MinFilter, MipmapFilter FilterMode
}

SamplerDesc describes a sampler (WebGPU's GPUSamplerDescriptor).

Flutter: no counterpart

type Shader

type Shader struct {
	// Name is the name of the .wgsl file without its extension.
	Name string
	// WGSL is the source text, with the `//#include` lines expanded.
	WGSL string
	// SPIRV is what naga made from the WGSL: one module with every entry point.
	SPIRV []byte
	// HLSL is what naga made from the WGSL for shader model 5.1, with every binding at the register of
	// ShaderBinding.Register: one file with every entry point.
	HLSL string
	// MSL is what naga made from the WGSL for Metal Shading Language 2.4, with every resource at the index of
	// ShaderBinding.MetalIndex: one file with every entry point.
	MSL string
	// Entries are the entry points of the module.
	Entries []EntryPoint
}

Shader is one WGSL module with its SPIR-V, its HLSL, its MSL and its reflection. glutter-gen gpushaders makes the values of this type in shaders_gen.go (D31, SPEC §27.3): WebGPU takes the WGSL, Vulkan the SPIR-V and Direct3D 12 the HLSL and Metal the MSL. An app does not make one by hand.

Flutter: no counterpart

func (*Shader) Entry

func (s *Shader) Entry(name string) (e EntryPoint, ok bool)

Entry returns the entry point with the name; ok is false when there is none.

Flutter: no counterpart

type ShaderBinding

type ShaderBinding struct {
	// Name is the name of the variable in the WGSL.
	Name string
	// Group and Binding are the numbers of the declaration.
	Group, Binding int
	// Kind says what the resource is.
	Kind BindingKind
	// Dimension is the dimension of a texture binding; the zero value is a 2D texture.
	Dimension TextureDimension
	// Sample is the sample type of a sampled texture binding.
	Sample SampleType
	// StorageFormat is the texel format of a storage texture binding, as WGSL names it ("rgba8unorm",
	// "rgba16float", "r32float" or "r32uint").
	StorageFormat string
	// Size is the size in bytes of the type of a uniform or storage buffer binding, by the layout rules of
	// WGSL. For a storage buffer that ends in an array without a length it counts one element of the
	// array, which is the smallest buffer range that WebGPU accepts for the binding.
	Size int
	// Register is where the HLSL binds the resource.
	Register ShaderRegister
	// MetalIndex is where the MSL binds the resource: the index in the argument table of its class
	// (buffer, texture or sampler), the place of the binding among those of the module of its class in
	// the order of group and binding (SPEC §29.5).
	MetalIndex int
}

ShaderBinding is one resource a shader reads, from its declaration in the WGSL: `@group(g) @binding(b) var ...`.

Flutter: no counterpart

type ShaderModule

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

ShaderModule is a shader that glutter-gen gpushaders made, ready for the pipelines of a device (WebGPU's GPUShaderModule). The backend compiles it when a pipeline that uses one of its entry points is made.

Flutter: no counterpart

func (*ShaderModule) Label

func (r *ShaderModule) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*ShaderModule) Release

func (m *ShaderModule) Release()

Release forgets the module. The pipelines made from it keep working. It may be called twice.

Flutter: no counterpart

type ShaderRegister

type ShaderRegister struct {
	// Class is the register class: "b" for a uniform buffer, "t" for a texture or a read-only storage
	// buffer, "s" for a sampler and "u" for a writable storage buffer or a storage texture.
	Class string
	// Space is the register space, the group of the binding.
	Space int
	// Index is the register number, the binding number.
	Index int
}

ShaderRegister is where the HLSL of a shader binds a resource (Direct3D 12 only; SPEC §9.8, §27.3): for the binding B of the group G, `register(<Class>B, spaceG)`.

Flutter: no counterpart

type ShaderStage

type ShaderStage int

ShaderStage is the stage of a shader entry point.

Flutter: no counterpart

const (
	// ShaderStageUnspecified is the zero value: no stage.
	//
	// Flutter: no counterpart
	ShaderStageUnspecified ShaderStage = iota
	// ShaderStageVertex is an entry point marked @vertex.
	//
	// Flutter: no counterpart
	ShaderStageVertex
	// ShaderStageFragment is an entry point marked @fragment.
	//
	// Flutter: no counterpart
	ShaderStageFragment
	// ShaderStageCompute is an entry point marked @compute.
	//
	// Flutter: no counterpart
	ShaderStageCompute
)

The stages of an entry point.

func (ShaderStage) String

func (s ShaderStage) String() string

String returns "vertex", "fragment", "compute" or "unspecified".

type ShaderType

type ShaderType int

ShaderType is the type of an input of a vertex entry point: a scalar or a vector of 32 bit values.

Flutter: no counterpart

const (
	// ShaderTypeUnspecified is the zero value: no type.
	//
	// Flutter: no counterpart
	ShaderTypeUnspecified ShaderType = iota
	// ShaderTypeFloat32 is an f32.
	//
	// Flutter: no counterpart
	ShaderTypeFloat32
	// ShaderTypeFloat32x2 is a vec2<f32>.
	//
	// Flutter: no counterpart
	ShaderTypeFloat32x2
	// ShaderTypeFloat32x3 is a vec3<f32>.
	//
	// Flutter: no counterpart
	ShaderTypeFloat32x3
	// ShaderTypeFloat32x4 is a vec4<f32>.
	//
	// Flutter: no counterpart
	ShaderTypeFloat32x4
	// ShaderTypeSint32 is an i32.
	//
	// Flutter: no counterpart
	ShaderTypeSint32
	// ShaderTypeSint32x2 is a vec2<i32>.
	//
	// Flutter: no counterpart
	ShaderTypeSint32x2
	// ShaderTypeSint32x3 is a vec3<i32>.
	//
	// Flutter: no counterpart
	ShaderTypeSint32x3
	// ShaderTypeSint32x4 is a vec4<i32>.
	//
	// Flutter: no counterpart
	ShaderTypeSint32x4
	// ShaderTypeUint32 is a u32.
	//
	// Flutter: no counterpart
	ShaderTypeUint32
	// ShaderTypeUint32x2 is a vec2<u32>.
	//
	// Flutter: no counterpart
	ShaderTypeUint32x2
	// ShaderTypeUint32x3 is a vec3<u32>.
	//
	// Flutter: no counterpart
	ShaderTypeUint32x3
	// ShaderTypeUint32x4 is a vec4<u32>.
	//
	// Flutter: no counterpart
	ShaderTypeUint32x4
)

The types of the inputs of a vertex entry point.

type StencilFaceState

type StencilFaceState struct {
	// Compare compares the stencil reference to the stored value.
	Compare CompareFunction
	// FailOp, DepthFailOp and PassOp say what happens to the stored value when the stencil test fails, when
	// it passes and the depth test fails, and when both pass.
	FailOp, DepthFailOp, PassOp StencilOperation
}

StencilFaceState is the stencil test of one face of a triangle (WebGPU's GPUStencilFaceState).

Flutter: no counterpart

type StencilOperation

type StencilOperation int

StencilOperation is what the stencil test does to the stored value. The zero value is StencilOperationKeep.

Flutter: no counterpart

const (
	// StencilOperationKeep keeps the value.
	//
	// Flutter: no counterpart
	StencilOperationKeep StencilOperation = iota
	// StencilOperationZero sets it to 0.
	//
	// Flutter: no counterpart
	StencilOperationZero
	// StencilOperationReplace sets it to the stencil reference.
	//
	// Flutter: no counterpart
	StencilOperationReplace
	// StencilOperationInvert inverts its bits.
	//
	// Flutter: no counterpart
	StencilOperationInvert
	// StencilOperationIncrementClamp adds 1 up to the maximum.
	//
	// Flutter: no counterpart
	StencilOperationIncrementClamp
	// StencilOperationDecrementClamp subtracts 1 down to 0.
	//
	// Flutter: no counterpart
	StencilOperationDecrementClamp
	// StencilOperationIncrementWrap adds 1 and wraps.
	//
	// Flutter: no counterpart
	StencilOperationIncrementWrap
	// StencilOperationDecrementWrap subtracts 1 and wraps.
	//
	// Flutter: no counterpart
	StencilOperationDecrementWrap
)

The values of StencilOperation.

type StoreOp

type StoreOp int

StoreOp is what a pass does with an attachment after it drew. The zero value is StoreOpStore.

Flutter: no counterpart

const (
	// StoreOpStore keeps the result.
	//
	// Flutter: no counterpart
	StoreOpStore StoreOp = iota
	// StoreOpDiscard throws the result away.
	//
	// Flutter: no counterpart
	StoreOpDiscard
)

The values of StoreOp.

type Texture

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

Texture is an image, an array of images, a cube or a volume in GPU memory (WebGPU's GPUTexture), with mip levels and, for a render attachment, samples. A shader samples it or a pass draws into it through a TextureView. Release it when it is not needed; the memory is freed when the work that uses it is done.

Flutter: no counterpart

func (*Texture) Format

func (t *Texture) Format() TextureFormat

Format returns the format of the texels.

Flutter: no counterpart

func (*Texture) Kind

func (t *Texture) Kind() TextureKind

Kind returns the shape of the texture.

Flutter: no counterpart

func (*Texture) Label

func (r *Texture) Label() string

Label is the name that the resource was given in its description.

Flutter: no counterpart

func (*Texture) LayerView

func (t *Texture) LayerView(level, layer int) *TextureView

LayerView returns the 2D view of one layer of one mip level of an array or a cube. A pass can draw into it and a copy can read it; on Direct3D 12 a shader cannot sample or write it (SPEC §12.10): sample the texture, or a LevelView.

Flutter: no counterpart

func (*Texture) LevelView

func (t *Texture) LevelView(level int) *TextureView

LevelView returns the view of one mip level, with all its layers. A sampled view of it reads that level alone; a storage binding takes level 0 of a texture.

Flutter: no counterpart

func (*Texture) MipLevelCount

func (t *Texture) MipLevelCount() int

MipLevelCount returns the number of mip levels.

Flutter: no counterpart

func (*Texture) Release

func (t *Texture) Release()

Release frees the texture, and the views of it, when the work that uses them is done. It may be called twice. After the device is lost it only forgets the texture.

Flutter: no counterpart

func (*Texture) SampleCount

func (t *Texture) SampleCount() int

SampleCount returns the number of samples of each texel, 1 or 4.

Flutter: no counterpart

func (*Texture) Size

func (t *Texture) Size() Extent3D

Size returns the width and height, and the layers of an array, 6 for a cube, or the depth of a volume (1 for a 2D texture).

Flutter: no counterpart

func (*Texture) Usage

func (t *Texture) Usage() TextureUsage

Usage returns the uses the texture was made for.

Flutter: no counterpart

func (*Texture) View

func (t *Texture) View() *TextureView

View returns the view of the whole texture, with all its mip levels and layers.

Flutter: no counterpart

type TextureCopy

type TextureCopy struct {
	Texture  *Texture
	MipLevel int
	Origin   Origin3D
}

TextureCopy is a texture, a mip level of it and the first texel (WebGPU's GPUImageCopyTexture).

Flutter: no counterpart

type TextureDesc

type TextureDesc struct {
	// Label names the texture in the messages of errors and in the log of a leak.
	Label string
	// Size is the width and height, and the layers of an array (Kind TextureKind2DArray), the depth of a volume
	// (TextureKind3D) or 6 for a cube; 0 stands for 1 (6 for a cube).
	Size Extent3D
	// Kind is the shape; the zero value is a 2D texture.
	Kind TextureKind
	// Format is the format of the texels.
	Format TextureFormat
	// MipLevelCount is the number of levels; 0 means 1.
	MipLevelCount int
	// SampleCount is 1 or 4; 0 means 1. A multisampled texture is a render attachment that a pass resolves into
	// another texture.
	SampleCount int
	// Usage says what the texture is for; at least one use, and only those that Format allows.
	Usage TextureUsage
}

TextureDesc describes a texture (WebGPU's GPUTextureDescriptor).

Flutter: no counterpart

type TextureDimension

type TextureDimension int

TextureDimension is the dimension of a texture binding of a shader. The zero value is TextureDim2D.

Flutter: no counterpart

const (
	// TextureDim2D is a texture_2d.
	//
	// Flutter: no counterpart
	TextureDim2D TextureDimension = iota
	// TextureDim2DArray is a texture_2d_array.
	//
	// Flutter: no counterpart
	TextureDim2DArray
	// TextureDimCube is a texture_cube.
	//
	// Flutter: no counterpart
	TextureDimCube
	// TextureDim3D is a texture_3d.
	//
	// Flutter: no counterpart
	TextureDim3D
)

The dimensions of a texture binding.

type TextureFormat

type TextureFormat int

TextureFormat is the format of the texels of a texture.

Flutter: no counterpart

const (
	// TextureFormatUnspecified is the zero value: no format.
	//
	// Flutter: no counterpart
	TextureFormatUnspecified TextureFormat = iota
	// TextureFormatRGBA8Unorm is 4 bytes per texel, red first.
	//
	// Flutter: no counterpart
	TextureFormatRGBA8Unorm
	// TextureFormatBGRA8Unorm is 4 bytes per texel, blue first.
	//
	// Flutter: no counterpart
	TextureFormatBGRA8Unorm
	// TextureFormatR8Unorm is 1 byte per texel: coverage masks.
	//
	// Flutter: no counterpart
	TextureFormatR8Unorm
	// TextureFormatRGBA16Float is 8 bytes per texel, four half floats.
	//
	// Flutter: no counterpart
	TextureFormatRGBA16Float
	// TextureFormatRGBA32Float is 16 bytes per texel, four floats; a shader filters it only when Features.Float32Filterable.
	//
	// Flutter: no counterpart
	TextureFormatRGBA32Float
	// TextureFormatR32Float is 4 bytes per texel, one float.
	//
	// Flutter: no counterpart
	TextureFormatR32Float
	// TextureFormatR32Uint is 4 bytes per texel, one unsigned integer.
	//
	// Flutter: no counterpart
	TextureFormatR32Uint
	// TextureFormatRG32Uint is 8 bytes per texel, two unsigned integers.
	//
	// Flutter: no counterpart
	TextureFormatRG32Uint
	// TextureFormatDepth32Float is a depth buffer of one float per texel.
	//
	// Flutter: no counterpart
	TextureFormatDepth32Float
	// TextureFormatDepth24PlusStencil8 is a depth buffer of at least 24 bits with an 8 bit stencil; it cannot be copied.
	//
	// Flutter: no counterpart
	TextureFormatDepth24PlusStencil8
)

The values of TextureFormat.

type TextureKind

type TextureKind int

TextureKind is what a texture is: one image, an array of them, a cube or a volume.

Flutter: no counterpart

const (
	// TextureKindUnspecified is the zero value: a 2D texture.
	//
	// Flutter: no counterpart
	TextureKindUnspecified TextureKind = iota
	// TextureKind2D is one image.
	//
	// Flutter: no counterpart
	TextureKind2D
	// TextureKind2DArray is an array of images (Size.DepthOrArrayLayers of them).
	//
	// Flutter: no counterpart
	TextureKind2DArray
	// TextureKindCube is a cube: six square faces.
	//
	// Flutter: no counterpart
	TextureKindCube
	// TextureKind3D is a volume (Size.DepthOrArrayLayers deep).
	//
	// Flutter: no counterpart
	TextureKind3D
)

The values of TextureKind.

type TextureUsage

type TextureUsage int

TextureUsage says what a texture is used for; the values are combined with |.

Flutter: no counterpart

const (
	// TextureUsageTextureBinding is a texture that a shader samples.
	//
	// Flutter: no counterpart
	TextureUsageTextureBinding TextureUsage = 1 << iota
	// TextureUsageRenderAttachment is a texture that a render pass draws into.
	//
	// Flutter: no counterpart
	TextureUsageRenderAttachment
	// TextureUsageCopySrc is a texture that the copies and readbacks take from (a render attachment can be read too).
	//
	// Flutter: no counterpart
	TextureUsageCopySrc
	// TextureUsageStorageBinding is a texture that a compute shader writes through a storage binding.
	//
	// Flutter: no counterpart
	TextureUsageStorageBinding
)

The values of TextureUsage.

type TextureView

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

TextureView is a view of a texture (WebGPU's GPUTextureView): the whole texture, one mip level of it, or one layer of a level. A view is not released: it goes with its texture. A pass draws into a view and a bind group gives a shader one.

Flutter: no counterpart

func (*TextureView) Format

func (v *TextureView) Format() TextureFormat

Format returns the format of the texels.

Flutter: no counterpart

func (*TextureView) Size

func (v *TextureView) Size() Extent3D

Size returns the size of the view: of its mip level, with one layer for a LayerView.

Flutter: no counterpart

func (*TextureView) Texture

func (v *TextureView) Texture() *Texture

Texture returns the texture that the view is of.

Flutter: no counterpart

type VertexAttribute

type VertexAttribute struct {
	// ShaderLocation is the @location of the input.
	ShaderLocation int
	// Format is how the attribute is stored in the buffer.
	Format VertexFormat
	// Offset is where it starts in a vertex, in bytes.
	Offset int
}

VertexAttribute is one input of a vertex shader that a vertex buffer feeds (WebGPU's GPUVertexAttribute).

Flutter: no counterpart

type VertexBufferLayout

type VertexBufferLayout struct {
	// ArrayStride is the distance between two vertices (or two instances), in bytes.
	ArrayStride int
	// PerInstance makes the buffer advance once for each instance instead of once for each vertex.
	PerInstance bool
	// Attributes are the inputs it feeds.
	Attributes []VertexAttribute
}

VertexBufferLayout is how a vertex buffer is read (WebGPU's GPUVertexBufferLayout).

Flutter: no counterpart

type VertexFormat

type VertexFormat int

VertexFormat is how a vertex attribute is stored in a vertex buffer. The name has the type and the number of components.

Flutter: no counterpart

const (
	// VertexFormatUnspecified is the zero value: no format.
	//
	// Flutter: no counterpart
	VertexFormatUnspecified VertexFormat = iota
	// VertexFormatFloat32 is Float32.
	//
	// Flutter: no counterpart
	VertexFormatFloat32
	// VertexFormatFloat32x2 is Float32x2.
	//
	// Flutter: no counterpart
	VertexFormatFloat32x2
	// VertexFormatFloat32x3 is Float32x3.
	//
	// Flutter: no counterpart
	VertexFormatFloat32x3
	// VertexFormatFloat32x4 is Float32x4.
	//
	// Flutter: no counterpart
	VertexFormatFloat32x4
	// VertexFormatUnorm8x4 is Unorm8x4.
	//
	// Flutter: no counterpart
	VertexFormatUnorm8x4
	// VertexFormatUint32 is Uint32.
	//
	// Flutter: no counterpart
	VertexFormatUint32
	// VertexFormatUint32x2 is Uint32x2.
	//
	// Flutter: no counterpart
	VertexFormatUint32x2
	// VertexFormatUint32x3 is Uint32x3.
	//
	// Flutter: no counterpart
	VertexFormatUint32x3
	// VertexFormatUint32x4 is Uint32x4.
	//
	// Flutter: no counterpart
	VertexFormatUint32x4
	// VertexFormatSint32 is Sint32.
	//
	// Flutter: no counterpart
	VertexFormatSint32
	// VertexFormatSint32x2 is Sint32x2.
	//
	// Flutter: no counterpart
	VertexFormatSint32x2
	// VertexFormatSint32x3 is Sint32x3.
	//
	// Flutter: no counterpart
	VertexFormatSint32x3
	// VertexFormatSint32x4 is Sint32x4.
	//
	// Flutter: no counterpart
	VertexFormatSint32x4
	// VertexFormatUint8x2 is Uint8x2.
	//
	// Flutter: no counterpart
	VertexFormatUint8x2
	// VertexFormatUint8x4 is Uint8x4.
	//
	// Flutter: no counterpart
	VertexFormatUint8x4
	// VertexFormatSint8x2 is Sint8x2.
	//
	// Flutter: no counterpart
	VertexFormatSint8x2
	// VertexFormatSint8x4 is Sint8x4.
	//
	// Flutter: no counterpart
	VertexFormatSint8x4
	// VertexFormatUnorm8x2 is Unorm8x2.
	//
	// Flutter: no counterpart
	VertexFormatUnorm8x2
	// VertexFormatSnorm8x2 is Snorm8x2.
	//
	// Flutter: no counterpart
	VertexFormatSnorm8x2
	// VertexFormatSnorm8x4 is Snorm8x4.
	//
	// Flutter: no counterpart
	VertexFormatSnorm8x4
	// VertexFormatUint16x2 is Uint16x2.
	//
	// Flutter: no counterpart
	VertexFormatUint16x2
	// VertexFormatUint16x4 is Uint16x4.
	//
	// Flutter: no counterpart
	VertexFormatUint16x4
	// VertexFormatSint16x2 is Sint16x2.
	//
	// Flutter: no counterpart
	VertexFormatSint16x2
	// VertexFormatSint16x4 is Sint16x4.
	//
	// Flutter: no counterpart
	VertexFormatSint16x4
	// VertexFormatUnorm16x2 is Unorm16x2.
	//
	// Flutter: no counterpart
	VertexFormatUnorm16x2
	// VertexFormatUnorm16x4 is Unorm16x4.
	//
	// Flutter: no counterpart
	VertexFormatUnorm16x4
	// VertexFormatSnorm16x2 is Snorm16x2.
	//
	// Flutter: no counterpart
	VertexFormatSnorm16x2
	// VertexFormatSnorm16x4 is Snorm16x4.
	//
	// Flutter: no counterpart
	VertexFormatSnorm16x4
	// VertexFormatFloat16x2 is Float16x2.
	//
	// Flutter: no counterpart
	VertexFormatFloat16x2
	// VertexFormatFloat16x4 is Float16x4.
	//
	// Flutter: no counterpart
	VertexFormatFloat16x4
)

The values of VertexFormat.

type VertexInput

type VertexInput struct {
	// Name is the name of the parameter or of the member of the struct.
	Name string
	// Location is the number in @location.
	Location int
	// Type is the type the shader reads the input as.
	Type ShaderType
}

VertexInput is an `@location(n)` input of a vertex entry point.

Flutter: no counterpart

type VertexState

type VertexState struct {
	// Module is the shader and EntryPoint the name of its @vertex function.
	Module     *ShaderModule
	EntryPoint string
	// Buffers describe the vertex buffers, by slot.
	Buffers []VertexBufferLayout
}

VertexState is the vertex stage of a render pipeline (WebGPU's GPUVertexState).

Flutter: no counterpart

type View

type View struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

View is a widget that owns a render target the size of its box in device pixels, with an optional depth target and multisampling, and calls a function to draw into it when it must (SPEC §27.5). The window shows the target with no copy. The function runs on the UI thread after the paint phase and before the frame is composited, in paint order; a view that is not Continuous and not marked draws nothing, so an idle view costs no CPU. A panic in the function is reported as a paint error, and the view keeps its last picture.

Flutter: no counterpart

func NewView

func NewView(onPaint func(f *ViewFrame), opts ...ViewOpts) *View

NewView creates a view that draws with onPaint.

Flutter: no counterpart

func (*View) CreateState

func (w *View) CreateState() widgets.State

CreateState creates the state.

Flutter: no counterpart

type ViewController

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

ViewController asks a View to draw (SPEC §27.5).

Flutter: no counterpart

func NewViewController

func NewViewController() *ViewController

NewViewController creates a controller. Pass it as ViewOpts.Controller.

Flutter: no counterpart

func (*ViewController) MarkNeedsPaint

func (c *ViewController) MarkNeedsPaint()

MarkNeedsPaint asks the view to draw once more: its paint function runs in the next frame, which is scheduled if there is none. It does nothing while the controller has no view, or the view has no device.

Flutter: no counterpart

type ViewFrame

type ViewFrame struct {
	// Device is the device of the app.
	Device *Device
	// Encoder is the encoder of the frame. Record the passes into it; the view finishes and submits it.
	Encoder *CommandEncoder
	// Color is the color target: ViewOpts.Format, the size of the view in pixels, and multisampled when
	// ViewOpts.SampleCount is 4. Draw into Color.View().
	Color *Texture
	// Resolve is the texture that a multisampled Color is resolved into, which the window shows (set it as the
	// ResolveTarget of the color attachment); nil when the view is not multisampled.
	Resolve *Texture
	// Depth is the depth target, of ViewOpts.DepthFormat and the same sample count as Color; nil when the view
	// has no depth format.
	Depth *Texture
	// Width and Height are the size of the targets in pixels: the box of the view times the device pixel ratio,
	// rounded.
	Width, Height int
	// DevicePixelRatio is the number of pixels per logical pixel.
	DevicePixelRatio float64
	// Time is the time of the frame: the elapsed time of the view's Ticker when ViewOpts.Continuous is set, else
	// the time of the frame that draws the view.
	Time time.Duration
	// contains filtered or unexported fields
}

ViewFrame is what a View gives its paint function: the device, an encoder to record into, the targets and the numbers of the frame (SPEC §27.5). The view submits the encoder when the function returns.

Flutter: no counterpart

func (*ViewFrame) AfterSubmit

func (f *ViewFrame) AfterSubmit(fn func())

AfterSubmit asks for fn to be called on the UI thread right after the view submitted the frame's commands: the place to call Buffer.Read for what the frame wrote (a read asked for earlier would see the work before the frame), or Queue.OnSubmittedWorkDone. The functions run in the order they were asked for, in the same frame, and not at all when the submission failed.

Flutter: no counterpart

func (*ViewFrame) Submit

func (f *ViewFrame) Submit() error

Submit finishes the frame's encoder, submits it and runs the functions of AfterSubmit. The view does this when its paint function returns; only a program that makes a ViewFrame of its own (to draw into a texture with code written for a view) calls it. It returns the error of the submission.

Flutter: no counterpart

type ViewOpts

type ViewOpts struct {
	// Key is the key of the widget.
	Key foundation.Key
	// Format is the format of the color target: RGBA8Unorm (sRGB-encoded values; the default) or RGBA16Float
	// (linear values, which the window encodes to sRGB).
	Format TextureFormat
	// DepthFormat is the format of the depth target: Depth32Float or Depth24PlusStencil8. The default is none.
	DepthFormat TextureFormat
	// SampleCount is 1 (the default) or 4.
	SampleCount int
	// Continuous draws at every frame, at the display's rate, through a Ticker that follows TickerMode. Without it
	// the view draws when it is created, resized, or marked by Controller.
	Continuous bool
	// Controller asks the view to draw.
	Controller *ViewController
	// OnInit is called with the device when the view has one: at the first frame, and again after a device was
	// lost and replaced. Make the resources of the view in it.
	OnInit func(d *Device)
	// OnDispose is called for each OnInit: when the view leaves the tree, and when its device is lost (the
	// resources of that device are gone). Release the resources in it.
	OnDispose func()
	// Fallback is the widget shown when the app has no GPU (GPUUnavailable), and until a lost device is replaced.
	// The default is an empty box of the view's size.
	Fallback widgets.Widget
	// SemanticsLabel describes the view to assistive technology; the default is none.
	SemanticsLabel string
}

ViewOpts are the optional parameters of NewView.

Flutter: no counterpart

Jump to

Keyboard shortcuts

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