flutter3d_webgpu_web library
The half of this backend that needs a browser: the device, the pass encoder and the bindings under both.
Separate from flutter3d_webgpu.dart because dart:js_interop is not a
library the Dart VM has, and a barrel that re-exports one importing it
cannot be imported on the VM at all. The translation tables and the pipeline
signature are worth asserting whether or not there is a GPU in the room —
they are what catch a typo in "less-equal" in a second — so they stay in
the barrel that loads everywhere, and this one carries what only a browser
can run.
An application opens a device through openWebGpu and never touches
anything else here. The rest is exported because a backend is a package
somebody may have to debug from outside: the encoder's signature, the frame
arenas' counts and WebGpuDevice.debugDrainErrors are how a wrong picture
is turned into a sentence.
Classes
- GpuBufferUsage
- What a buffer may be used for, declared when it is made and never after.
- GpuColorWrite
-
The channels a colour target writes, for
GPUColorTargetState.writeMask. - GpuErrorFilter
- The three kinds of error a scope can be pushed for.
- GpuFeature
- The optional features worth asking an adapter about.
- GpuMapMode
-
Which way a mapped buffer may be read, for
GPUBuffer.mapAsync. - GpuShaderStage
-
Which stages a binding is visible to, for
GPUBindGroupLayoutEntry. - GpuTextureUsage
- What a texture may be used for.
- WebGpuBindingLayouts
- The bind group layouts one stage pair needs, and the pipeline layout over them.
- WebGpuDevice
-
WebGPU as a
GraphicsDevice, and as the compiler its shader libraries reach a browser through. - WebGpuEncoder
- One pass, recorded and submitted.
- WebGpuFrameArena
-
A bump allocator over one
GPUBuffer, reset every frame. See the library comment, which is where the argument for this shape is. - WebGpuGeometry
- A buffer this device owns.
- WebGpuTexture
- A texture this device owns, and the views it has been asked for.
Extension Types
- GPU
- GPUAdapter
- GPUAdapterInfo
- GPUBindGroup
- GPUBindGroupDescriptor
- GPUBindGroupEntry
- GPUBindGroupLayout
- GPUBindGroupLayoutDescriptor
- GPUBindGroupLayoutEntry
- GPUBlendComponent
- GPUBlendState
- GPUBuffer
- GPUBufferBinding
- GPUBufferBindingLayout
- GPUBufferDescriptor
- GpuCanvas
- A canvas, reduced to the one call a backend makes on it.
- GPUCanvasConfiguration
- GPUCanvasContext
- GPUColorDict
- GPUColorTargetState
- GPUCommandBuffer
- GPUCommandEncoder
- GPUCompilationInfo
- GPUCompilationMessage
- GPUDepthStencilState
- GPUDevice
- GPUDeviceDescriptor
- GPUDeviceLostInfo
- GPUError
- What a popped error scope hands back.
- GPUExtent3DDict
- GPUFragmentState
- GPUMultisampleState
- GPUOrigin3DDict
- GPUPipelineLayout
- GPUPipelineLayoutDescriptor
- GPUPrimitiveState
- GPUQueue
- GPURenderPassColorAttachment
- GPURenderPassDepthStencilAttachment
- GPURenderPassDescriptor
- GPURenderPassEncoder
- GPURenderPipeline
- GPURenderPipelineDescriptor
- GPURequestAdapterOptions
- GPUSampler
- GPUSamplerBindingLayout
- GPUSamplerDescriptor
- GPUShaderModule
- GPUShaderModuleDescriptor
- GPUStencilFaceState
- GPUSupportedFeatures
- The set of feature names an adapter or a device carries.
- GPUSupportedLimits
- The numbers a device will not go past.
- GPUTexelCopyBufferInfo
- GPUTexelCopyBufferLayout
- GPUTexelCopyTextureInfo
- GPUTexture
- GPUTextureBindingLayout
- GPUTextureDescriptor
- GPUTextureView
- GPUTextureViewDescriptor
- GPUVertexAttribute
- GPUVertexBufferLayout
- GPUVertexState
Properties
-
navigator, for the one property that says whether this browser has WebGPU at all.no setter
Functions
-
gpuChecked<
T> (GPUDevice device, String what, T body()) → Future< T> -
Runs
bodywith a validation scope open, and throws where the browser complained. -
gpuRequiredLimits(
Map< String, int> limits) → JSObject -
limitsasGPUDeviceDescriptor.requiredLimitstakes them. -
gpuShaderStageOf(
WebGpuVisibility visibility) → int - Which stages a binding is visible to, as this API's flag word.
-
gpuStrings(
Iterable< String> names) → JSArray<JSString> -
namesas this API takes a list of strings. -
openWebGpu(
{required int width, required int height}) → Future< GraphicsDevice> - Opens this backend with the engine's own shaders, or throws with something worth putting on screen.
-
webgpuCreateCubeRenderTarget(
GPUDevice gpu, List< WebGpuTexture> tracked, {required int size, required TextureFormat format, int mipLevels = 1}) → TextureHandle? -
An empty cube a pass may draw into, one face and one level at a time. See
GraphicsDevice.createCubeRenderTarget. -
webgpuCreateCubeTextureFromPixels(
GPUDevice gpu, List< WebGpuTexture> tracked, {required int size, required TextureFormat format, required List<ByteData> faces, List<List< ? mipLevels}) → TextureHandle?ByteData> > -
facesin+X, −X, +Y, −Y, +Z, −Zorder as one cube texture. SeeGraphicsDevice.createCubeTextureFromPixels. -
webgpuCreateTexture(
GPUDevice gpu, List< WebGpuTexture> tracked, RenderTargetSpec spec, {int levels = 1}) → TextureHandle -
A texture matching
spec, with a chainlevelsdeep. SeeGraphicsDevice.createTexture. -
webgpuCreateTextureFromPixels(
GPUDevice gpu, List< WebGpuTexture> tracked, {required int width, required int height, required TextureFormat format, required ByteData pixels, List<ByteData> ? mipLevels}) → TextureHandle? -
A texture already holding
pixels, andmipLevelsbelow it. SeeGraphicsDevice.createTextureFromPixels. -
webgpuDisposePersistentResources(
List< WebGpuTexture> textures, List<GPUBuffer> buffers) → void -
Destroys every tracked texture and buffer and empties both lists. See
GraphicsDevice.dispose. -
webgpuIsDepthStencil(
TextureFormat format) → bool -
Whether
formatis a depth or stencil layout, which decides what a texture in it may be used for. -
webgpuReleaseGeometry(
Object buffer, List< GPUBuffer> tracked) → bool - Destroys one geometry buffer and stops tracking it. See webgpuReleaseTexture.
-
webgpuReleaseTexture(
WebGpuTexture backend, List< WebGpuTexture> tracked) → bool - Destroys one texture and stops tracking it, or answers false for a handle this device does not hold — a double release, or one from another device.
-
webgpuTexelBytes(
TextureFormat format) → int? -
How many bytes one texel of
formattakes, for the uploads that state a row stride. -
webgpuUploadGeometry(
GPUDevice gpu, List< GPUBuffer> tracked, ByteData bytes, GeometryUsage usage) → GeometryBuffer -
Geometry uploaded once and bound many times, until the device that made it
is disposed. See
GraphicsDevice.uploadGeometry.
Typedefs
- WebGpuSlice = ({GPUBuffer buffer, int length, int offset})
- Where an arena put some bytes: the buffer they landed in, and how far into it.
Exceptions / Errors
- GpuDeviceError
- A WebGPU error that reached Dart, which without gpuChecked none of them do.