moonwgpu

    The WebGPU API for MoonBit.

    webgpu
    wgpu
    gpu
    graphics
    compute
    shader
    wgsl
    rendering
    moonbit
    Download zip
    Version
    0.0.1
    License
    Apache-2.0
    Last updated
    2 hours ago
    Downloads
    1

    No dependencies

    #moonwgpu

    The WebGPU API for MoonBit: one surface, any host.

    Every object the WebGPU specification defines is here under its own name — Instance, Adapter, Device, Queue, the resources, the encoders, the passes, the bundles — together with the validation the specification puts in front of each of them. A caller writes one program; a backend decides whether it runs on a graphics API or in memory.

    let backend = @memory.Backend::new()
    let device = @moonwgpu.Instance::new(backend~).request_adapter().request_device()

    The library is layered so that each question has one home:

    PackageWhat it holds
    moonbitstack/moonwgpuThe objects: instance, adapter, device, queue, buffers, textures, samplers, shader modules, layouts, pipelines, encoders, passes, bundles, query sets, canvas contexts
    moonbitstack/moonwgpu/typesThe vocabulary: descriptors, enumerations, flag sets, the texture and vertex format tables, limits and features, surface configurations
    moonbitstack/moonwgpu/coreThe rules: descriptor validation, usage tracking, command recording, error scopes
    moonbitstack/moonwgpu/halThe contract a host implements: create, write, read, submit, and the Surface a window system fills
    moonbitstack/moonwgpu/hal/memoryA host that keeps everything in memory and executes every copy and clear for real
    moonbitstack/moonwgpu/hal/vulkan, hal/metal, hal/dx12, hal/gles, webOne package per graphics API: the name of the backend, the seam it will sit on, and a refusal until its C stub or host bridge exists

    #Install

    moon add moonbitstack/moonwgpu

    #The first device

    An instance takes a backend; everything above it is the same whatever the backend is.

    test {
    let backend = @memory.Backend::new()
    let instance = @moonwgpu.Instance::new(backend~)
    let adapter = instance.request_adapter()
    let device = adapter.request_device()
    assert_eq(instance.backend_name(), "memory")
    assert_eq(device.limits().max_bind_groups, 4)
    }

    #Bytes in, bytes out

    A buffer that can be written and mapped is the shortest way to see the library work: the queue writes, the command buffer copies, the mapping reads.

    test {
    let backend = @memory.Backend::new()
    let device = @moonwgpu.Instance::new(backend~).request_adapter().request_device()
    let source = device.create_buffer(
    descriptor=@types.BufferDescriptor::new(
    size=16,
    usage=@types.BufferUsages::copy_src() | @types.BufferUsages::copy_dst(),
    ),
    )
    let destination = device.create_buffer(
    descriptor=@types.BufferDescriptor::new(
    size=16,
    usage=@types.BufferUsages::copy_dst() | @types.BufferUsages::map_read(),
    ),
    )
    device.queue().write_buffer(buffer=source, offset=0, data=b"\x01\x02\x03\x04")
    let encoder = device.create_command_encoder()
    encoder.copy_buffer_to_buffer(
    source=source,
    source_offset=0,
    destination=destination,
    destination_offset=4,
    size=4,
    )
    device.queue().submit(command_buffers=[encoder.finish()])
    destination.map_read()
    let bytes = destination.get_mapped_range()
    assert_eq(bytes[4], b'\x01')
    assert_eq(bytes[7], b'\x04')
    }

    #A frame from the host

    Where a browser imports a video element, a native host hands over the frame it already decoded. The frame is copied when it is imported, so the host may reuse its buffer as soon as the call returns, and the texture lives until the host says the frame has moved on.

    test {
    let backend = @memory.Backend::new()
    let device = @moonwgpu.Instance::new(backend~).request_adapter().request_device()
    let image = @types.ExternalImage::new(
    size=@types.Extent3d::new(width=2, height=1),
    format=@types.TextureFormat::Rgba8unorm,
    data=b"\xff\x00\x00\xff\x00\xff\x00\xff",
    )
    let frame = device.import_external_texture(
    descriptor=@types.ExternalTextureDescriptor::new(image~),
    )
    let target = device.create_texture(
    descriptor=@types.TextureDescriptor::new(
    size=@types.Extent3d::new(width=2, height=1),
    format=@types.TextureFormat::Rgba8unorm,
    usage=@types.TextureUsages::copy_dst(),
    ),
    )
    device.queue().copy_external_image_to_texture(
    source=@types.CopyExternalImageSourceInfo::new(image~),
    destination=@types.CopyExternalImageDestInfo::new(texture=target.id()),
    copy_size=@types.Extent3d::new(width=2, height=1),
    )
    assert_false(frame.is_expired())
    frame.expire()
    assert_true(frame.is_expired())
    }

    #A shader you compiled yourself

    The device takes WGSL, and it also takes SPIR-V that a front end already produced, which is what a native backend wants and what a caller with a build step already has. The second form is checked for the magic number and for whole words, and nothing else: parsing SPIR-V is not this library's question.

    test {
    let backend = @memory.Backend::new()
    let device = @moonwgpu.Instance::new(backend~).request_adapter().request_device()
    let words = b"\x03\x02\x23\x07\x00\x00\x01\x00"
    let shader = device.create_shader_module(
    descriptor=@types.ShaderModuleDescriptor::spirv(words~),
    )
    assert_eq(shader.get_compilation_info().messages.length(), 0)
    }

    #A canvas

    A canvas is the one object that cannot exist without a window system, so it is split in two: CanvasContext holds a @hal.Surface, which a host implements over its own window or view, and turns the frames that surface hands out into ordinary Texture objects. Configure it with a device and a format, take a frame with get_current_texture, render into it like any other texture, and give it back with present.

    let canvas = @moonwgpu.CanvasContext::new(surface~=window)
    canvas.configure(
    device~,
    configuration=@types.SurfaceConfiguration::new(
    format=instance.get_preferred_canvas_format(),
    ),
    )
    let frame = canvas.get_current_texture()
    // ... record a pass into `frame` ...
    device.queue().submit(command_buffers=[encoder.finish()])
    canvas.present(texture=frame)

    #What the device refuses

    Validation is not a mode: every call that the specification validates raises a Refused carrying the class of the error, the place in the descriptor, the value the rule wanted and the value it got.

    test {
    let backend = @memory.Backend::new()
    let device = @moonwgpu.Instance::new(backend~).request_adapter().request_device()
    try {
    device.create_buffer(
    descriptor=@types.BufferDescriptor::new(
    size=16,
    usage=@types.BufferUsages::map_read() | @types.BufferUsages::vertex(),
    ),
    ) |> ignore
    fail("MAP_READ may only be combined with COPY_DST")
    } catch {
    @core.Refused::Validation(kind~, at~, ..) => {
    assert_eq(kind, @types.InvalidBufferUsage)
    assert_eq(at, "descriptor.usage")
    }
    _ => fail("the refusal should be a validation error")
    }
    }

    #Objects

    ObjectWhat it is for
    InstanceThe entry point, over one backend
    AdapterWhat a host offers: limits, features, and a device
    DeviceMakes resources, encoders, pipelines and query sets; error scopes
    QueueWrites bytes, submits command buffers, waits for work
    BufferBytes the device reads and writes; mapping for read-back
    Texture, TextureViewTexels, mip levels, array layers, and the views over them
    SamplerHow a shader reads a texture
    ShaderModuleWGSL source, kept for the pipelines that name its entry points
    BindGroupLayout, BindGroupWhat a shader sees, and the resources bound to it
    PipelineLayout, RenderPipeline, ComputePipelineThe whole fixed-function state of a draw or a dispatch
    CommandEncoder, CommandBufferRecording, then submitting
    RenderPassEncoder, ComputePassEncoderOne pass: pipeline, bindings, draws, dispatches
    RenderBundleEncoder, RenderBundleA recorded run of draws any pass can execute
    QuerySetTimestamps and occlusion results
    ExternalTextureA decoded frame a host handed over, bindable until it expires
    CanvasContextA surface a host provides, configured with a device and a format

    #The specification

    Three documents describe what this library is supposed to be, and this repository names all three rather than paraphrasing them:

    DocumentWhat it isWhat it decides here
    WebGPUthe W3C text, on the Recommendation trackthe normative one: every validation rule in core follows a step in it, and a rule that exists here and there is implemented as written there
    WebGPU draftthe editor's copy, the text the TR is built fromthe source the rules were read out of, and the place a change appears before it is published; where the two differ, the TR is what is implemented
    WGSLthe shading languagenot here: parsing and executing WGSL belong to moonnaga, and this library keeps only the seam a compiled module arrives through

    The draft is checked out as a submodule at spec/, pinned to gpuweb/gpuweb@d178d91 — the revision whose paragraphs the rules were transcribed from — so a comment like "the row pitch is a multiple of 256" can be traced to the sentence that says so. The draft and the TR carry the same text; what the pin adds is a date, so a reader a year from now reads the paragraph the code was written against rather than whatever the editor has added since:

    git submodule update --init --depth 1 spec # about 4 MB, working tree only

    The source is Bikeshed, and it is one file per document: spec/spec/index.bs holds the whole WebGPU text — eighteen thousand lines, the IDL inline with the prose around it — and spec/wgsl/index.bs the WGSL one. Update the pin deliberately: a new revision may add a rule that the validators have not learned yet.

    The reference implementations are read, not vendored: wgpu for the layering this library follows (types below the API, hal below that) and Dawn for what a conformance run actually asserts. Local checkouts of either belong in .ref/, which git ignores.

    The conformance suite is imported the same way. It is TypeScript driving navigator.gpu, so the part of it that can run against this library is the part that asks questions rather than draws pictures: conformance/ holds a generated index of every case the suite declares and a ledger of the rules this library mirrors, file by file, with the tests that assert them. Both directions are checked, so a case renamed upstream and a claim whose test disappeared are both build failures. The js backend can be driven from JavaScript as well, through a small WebGPU-shaped facade — see Backends. Details in conformance/README.md.

    Both pins move on the first and the fifteenth of the month: .github/workflows/refresh.yml walks spec and cts to upstream head, regenerates the index, and opens a pull request with whatever moved.

    #What runs today

    The memory backend executes every command that moves bytes — the four copies, buffer and texture clears, and queue writes — byte for byte. Passes, draws and dispatches are validated and recorded in full, and executed by a host that has a shader compiler; running WGSL is a separate library's question, and this one keeps the seam (hal's contract) rather than pretending.

    CapabilityState
    Creating every resource, with the specification's validationdone
    Bind groups, pipeline layouts, render and compute pipelinesdone
    Command recording: passes, bundles, indirect draws and dispatchesdone
    Copies and clears, executed byte exactly on the memory backenddone
    Mapping a buffer, whole or by range (mapAsync), for reading and for writingdone
    Query sets, timestamps, occlusion queriesrecorded and validated
    Shader compilation info (getCompilationInfo)reported by a backend that compiles; empty without one
    Shader modules from WGSL or from SPIR-V a front end producedaccepted, with the magic number and word alignment checked
    Immediate constants (setImmediates)recorded and validated in passes and bundles
    External frames (importExternalTexture, copyExternalImageToTexture)copied texel by texel, with row flipping and alpha premultiplication
    Limits, features and their dependenciesthe specification's full tables
    Texture and vertex format tablesevery format the specification defines
    Canvases (CanvasContext, configure, getCurrentTexture)a frame is an ordinary texture over the host's Surface
    The same suite on wasm, wasm-gc, js and native187 tests on each, recorded in conformance/targets.json
    Driving the js backend from JavaScriptsrc/bindings/js plus a WebGPU-shaped facade in conformance/js
    Executing a shaderneeds a WGSL front end, which is its own library (moonnaga); a module that arrives as SPIR-V runs today
    Vulkanreal: instance, device, buffers, textures, pipelines, descriptor sets, dynamic render passes, compute, read-back
    Metal, D3D12 and GLESpackaged and named; each refuses with its reason until its stub exists

    #Vulkan

    hal/vulkan is the first backend that runs on a device. It is a MoonBit implementation of the same contract the memory backend implements, with one C file underneath it: src/hal/vulkan/stub.c is the only place a Vulkan call is made, it opens the loader at run time, and it links against nothing. Where the Vulkan headers are absent the file still compiles, and the backend reports that the loader cannot be reached instead of failing to build.

    moon run src/examples/05-device --target native

    device: llvmpipe (LLVM 21.1.8, 256 bits) clear: 4x4 read back as 51,102,153,255 triangle: 512 of 4096 pixels in the triangle's colour compute: 1024 of 1024 words read back as 2n+1

    To build it you need the Vulkan development headers and a driver: on Debian and Ubuntu, libvulkan-dev and mesa-vulkan-drivers. The loader is opened with dlopen/LoadLibrary, so nothing is linked at build time and no SDK is needed to check the package.

    PieceHow it is here
    Instance, device, queueone VkInstance and one VkDevice per backend, the first device the loader reports
    Buffershost-visible and coherent, mapped once at creation
    Textures, views, samplersVK_IMAGE_TILING_OPTIMAL, with the usage bits the descriptor asks for
    Pipelinesbuilt for dynamic rendering (VkPipelineRenderingCreateInfo), so a pass is a vkCmdBeginRendering and the pipeline needs no render pass object
    Bind groupsone descriptor set per group, at the set index the bind names
    Subresource layoutstracked by the backend, one per mip level, and every use is a barrier from what it was to what it now is
    Read-backa staging buffer and a copy on the same queue, for read_texture, write_texture and the examples
    ImmediatesVulkan push constants, in one 128-byte range on every pipeline layout
    ShadersSPIR-V, which is what ShaderModuleDescriptor::spirv takes; a WGSL module is created with an error a caller can read, and a pipeline built on it refuses

    The shaders the examples and the tests use are compiled from the GLSL in scripts/shaders by scripts/build_shaders.py, which writes the words into src/shaders/modules.mbt. That is where the wrapper's shader compiler will plug in: the same words, from WGSL instead of GLSL.

    A surface needs a window system, so Surface is still the windowing layer's job and a native canvas arrives with it; hal/gles also stays pending until the windowing layer lands.

    #Backends

    One source tree, four backends, one suite. conformance/targets.json is the record of what each backend actually ran, and scripts/targets.py --check keeps it honest in CI:

    python3 scripts/targets.py # run the suite on all four, write the file python3 scripts/targets.py --check # fail if a backend lost a test

    BackendHow the suite runs thereWhat can call into it
    nativemoon test --target native, in the caller's thread over the memory backendMoonBit
    wasmmoon test --target wasm, under a wasm runtimeMoonBit
    wasm-gcmoon test --target wasm-gc, likewiseMoonBit
    jsmoon test --target js, and from JavaScript: src/bindings/jsJavaScript

    The last row is the one a conformance suite needs. src/bindings/js is built for --target js only and publishes three functions on globalThis — ask(op, …) -> Int, text(op, …) -> String, take(op, …) -> Bytes — and conformance/js/webgpu.mjs wraps them in the objects, promises and error classes the specification defines:

    moon build --target js node conformance/js/run.mjs # a dozen cases, in the shape the suite writes them

    What that buys is the error model a suite is written against: a call that the library refuses returns an invalid object, and the error arrives later from popErrorScope. The bridge is Device::report_error, which records a raised refusal in the innermost scope that accepts its filter.

    What it does not buy, and no facade could: a case that compares pixels needs a rasterizer, and a case that runs a shader needs a WGSL compiler. The memory backend moves bytes and keeps no framebuffer; moonnaga is the shader question. Encoding also stays on the MoonBit side for now — the facade creates, writes, maps and destroys, and hands submit only the empty array it can prove.

    The other two backends cannot be called from JavaScript at all, and that is a property of the toolchain rather than of this library: a wasm or wasm-gc artifact exports _start and nothing else — no functions, no memory — and neither backend accepts extern "js", so a host has no way in. What they can be driven by is the suite itself running inside them, which is what the ledger above asserts; native is in the same position from JavaScript's side, since it has no stable ABI to reach through.

    #Licence

    Apache-2.0. See LICENSE.

    Adapter

    What a caller holds between asking for an adapter and asking for a device.

    Adapter::features

    The optional features this adapter offers.

    Adapter::info

    fn Adapter::info(self : Adapter) -> AdapterInfo

    What the adapter says about itself.

    Adapter::is_fallback_adapter

    fn Adapter::is_fallback_adapter(self : Adapter) -> Bool

    Whether this is a fallback adapter, one that prefers to be correct over being fast. https://www.w3.org/TR/webgpu/#dom-gpuadapter-isfallbackadapter

    Adapter::limits

    The limits this adapter offers.

    Adapter::request_device

    fn Adapter::request_device(self : Adapter, descriptor? : DeviceDescriptor) -> Device raise
    Refused

    Create a device, checking that everything asked for is offered. https://www.w3.org/TR/webgpu/#dom-gpuadapter-requestdevice

    AdapterInfo

    pub(all) struct AdapterInfo {
    vendor : String
    architecture : String
    device : String
    description : String
    is_fallback_adapter : Bool
    subgroup_min_size : Int
    subgroup_max_size : Int
    } derive(Eq,
    Debug
    )

    An GPUAdapterInfo: what an adapter says about itself.

    AdapterInfo::new

    fn AdapterInfo::new(vendor? : String, architecture? : String, device? : String, description? : String, is_fallback_adapter? : Bool, subgroup_min_size? : Int, subgroup_max_size? : Int) -> AdapterInfo

    BindGroup

    A bind group: resources bound together, ready to be set on a pass.

    BindGroup::id

    The group's identity inside its device.

    BindGroup::layout

    The layout the group was made against.

    BindGroupLayout

    A bind group layout: the shape of a set of resources a shader sees.

    BindGroupLayout::descriptor

    The descriptor the layout was created from.

    BindGroupLayout::id

    The layout's identity inside its device.

    Buffer

    pub struct Buffer {
    device : Device
    id :
    BufferId

    size : Int
    usage :
    BufferUsages

    mapped : Bytes?
    mapped_offset : Int
    mapped_size : Int
    mapped_for_write : Bool
    destroyed : Bool
    }

    A buffer: a block of bytes the device can read from and write into.

    Buffer::destroy

    fn Buffer::destroy(self : Buffer) -> Unit

    Destroy the buffer. Later uses are refused; the bytes are kept by the backend until the device itself goes away, which is what a driver does. https://www.w3.org/TR/webgpu/#dom-gpubuffer-destroy

    Buffer::get_mapped_range

    fn Buffer::get_mapped_range(self : Buffer, offset? : Int, size? : Int) -> Bytes raise
    Refused

    The bytes of the mapped range, or of a range inside it.

    offset is relative to the mapping and a multiple of 8, as in the specification; both bounds default to the whole mapped range. https://www.w3.org/TR/webgpu/#dom-gpubuffer-getmappedrange

    Buffer::id

    The buffer's identity inside its device, for a bind group entry.

    Buffer::is_mapped

    fn Buffer::is_mapped(self : Buffer) -> Bool

    Whether the buffer is currently mapped.

    Buffer::map_async

    fn Buffer::map_async(self : Buffer, mode~ :
    MapMode
    , offset? : Int, size? : Int) -> Unit raise
    Refused

    mapAsync: map a range of the buffer, for reading or for writing.

    The specification's form is a promise because a real device may still be writing the range. On a device whose timeline this library runs in the caller's thread the wait is the call itself, so this returns when the range is ready; map_read and map_write are the whole-buffer shorthands.

    The alignment rules are the specification's: offset is a multiple of 8, the range is a non-zero multiple of 4, and it lies inside the buffer. https://www.w3.org/TR/webgpu/#dom-gpubuffer-mapasync

    Buffer::map_read

    fn Buffer::map_read(self : Buffer) -> Unit raise
    Refused

    Map the whole buffer for reading, so that get_mapped_range returns its bytes.

    The specification's mapAsync is asynchronous because a real device may still be writing. On a device whose timeline this library runs in the caller's thread, the wait is the call itself: this is the native form of that promise. https://www.w3.org/TR/webgpu/#dom-gpubuffer-mapasync

    Buffer::map_state

    Whether the buffer is unmapped, waiting to be mapped, or mapped. https://www.w3.org/TR/webgpu/#dom-gpubuffer-mapstate

    Buffer::map_write

    fn Buffer::map_write(self : Buffer, data~ : Bytes) -> Unit raise
    Refused

    Fill the range a write mapping holds. Outside a mapping this is the whole-buffer shorthand: the bytes reach the device at once.

    A write mapping is filled by this call rather than by mutating the bytes get_mapped_range returned, because those bytes are a read-only view in this library. The range is the one map_async took, and unmap hands it back to the device. https://www.w3.org/TR/webgpu/#dom-gpubuffer-getmappedrange

    Buffer::size

    fn Buffer::size(self : Buffer) -> Int

    The size in bytes this buffer was created with.

    Buffer::unmap

    fn Buffer::unmap(self : Buffer) -> Unit

    Drop the mapping, writing back what a write mapping was given.

    A write-back the device refuses is dropped: the only ways it can fail are a destroyed or lost device, and in both cases the bytes have no destination left to reach.

    Buffer::usage

    The usages this buffer was created with.

    CanvasContext

    A canvas: the surface a device renders into and something else presents.

    GPUCanvasContext, with the window system factored out. The context owns no pixels and no swap chain; it holds a @hal.Surface, which a windowing layer implements, and turns the frames that surface hands out into ordinary Texture objects, so that recording into a canvas is recording into a texture and nothing more.

    https://www.w3.org/TR/webgpu/#canvas-context

    CanvasContext::canvas

    fn CanvasContext::canvas(self : CanvasContext) -> String

    The host's own name for the surface, which is what canvas names in the specification: the element belongs to the host.

    CanvasContext::capabilities

    What this surface accepts, before anything is configured.

    CanvasContext::configure

    configure: bind the canvas to a device and a format.

    CanvasContext::get_current_texture

    getCurrentTexture: the frame to render into.

    The texture carries the configuration's format and usage and the surface's current size, so a render pass opens on it exactly as on a texture the device created. The frame is recycled when it is presented.

    CanvasContext::is_configured

    fn CanvasContext::is_configured(self : CanvasContext) -> Bool

    Whether a configuration is in force.

    CanvasContext::new

    A context over a host surface, unconfigured.

    CanvasContext::present

    Hand a frame back for display.

    CanvasContext::unconfigure

    fn CanvasContext::unconfigure(self : CanvasContext) -> Unit

    unconfigure: drop the configuration and the frames held for it.

    CommandBuffer

    pub(all) struct CommandBuffer {
    label : String
    commands : Array[
    Command
    ]
    } derive(
    Debug
    )

    A finished command buffer: the commands one encoder recorded, ready for queue.submit.

    CommandEncoder

    pub struct CommandEncoder {
    device : Device
    frame :
    Frame

    label : String
    }

    Records commands into a command buffer.

    The encoder validates what it can while recording - that a pass has ended before the next command, that the encoder is not finished - and leaves the rules about resources to the queue, which sees the whole batch at once. The specification makes the same split: encoding is per command, validation of what a command names is per submit.

    CommandEncoder::begin_compute_pass

    Start a compute pass.

    CommandEncoder::begin_render_pass

    Start a render pass. Only one pass may be open at a time. https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-beginrenderpass

    CommandEncoder::clear_buffer

    fn CommandEncoder::clear_buffer(self : CommandEncoder, buffer~ : Buffer, offset? : Int, size? : Int) -> Unit raise
    Refused

    clearBuffer: every byte of the range becomes zero.

    CommandEncoder::clear_texture

    clearTexture: every texel of the region becomes zero.

    CommandEncoder::copy_buffer_to_buffer

    fn CommandEncoder::copy_buffer_to_buffer(self : CommandEncoder, source~ : Buffer, source_offset~ : Int, destination~ : Buffer, destination_offset~ : Int, size~ : Int) -> Unit raise
    Refused

    copyBufferToBuffer. https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-copybuffertobuffer

    CommandEncoder::finish

    Finish the encoder and hand over the commands. https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-finish

    CommandEncoder::insert_debug_marker

    fn CommandEncoder::insert_debug_marker(self : CommandEncoder, marker~ : String) -> Unit raise
    Refused

    insertDebugMarker. https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-insertdebugmarker

    CommandEncoder::label

    fn CommandEncoder::label(self : CommandEncoder) -> String

    The encoder's label.

    CommandEncoder::pop_debug_group

    popDebugGroup.

    CommandEncoder::push_debug_group

    fn CommandEncoder::push_debug_group(self : CommandEncoder, group_label~ : String) -> Unit raise
    Refused

    pushDebugGroup.

    CommandEncoder::resolve_query_set

    fn CommandEncoder::resolve_query_set(self : CommandEncoder, query_set~ : QuerySet, first_query~ : Int, query_count~ : Int, destination~ : Buffer, destination_offset? : Int) -> Unit raise
    Refused

    resolveQuerySet: write the results of a query set into a buffer. https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-resolvequeryset

    ComputePassEncoder

    Records the commands of one compute pass.

    ComputePassEncoder::dispatch_workgroups

    dispatchWorkgroups.

    ComputePassEncoder::dispatch_workgroups_indirect

    fn ComputePassEncoder::dispatch_workgroups_indirect(self : ComputePassEncoder, buffer~ : Buffer, offset? : Int) -> Unit raise
    Refused

    dispatchWorkgroupsIndirect: the workgroup counts come from a buffer. https://www.w3.org/TR/webgpu/#dom-gpucomputepassencoder-dispatchworkgroupsindirect

    ComputePassEncoder::end

    End the pass and keep what it recorded.

    ComputePassEncoder::insert_debug_marker

    fn ComputePassEncoder::insert_debug_marker(self : ComputePassEncoder, marker~ : String) -> Unit raise
    Refused

    insertDebugMarker.

    ComputePassEncoder::label

    fn ComputePassEncoder::label(self : ComputePassEncoder) -> String

    The pass's label.

    ComputePassEncoder::pop_debug_group

    popDebugGroup.

    ComputePassEncoder::push_debug_group

    fn ComputePassEncoder::push_debug_group(self : ComputePassEncoder, group_label~ : String) -> Unit raise
    Refused

    pushDebugGroup.

    ComputePassEncoder::set_bind_group

    fn ComputePassEncoder::set_bind_group(self : ComputePassEncoder, index~ : Int, bind_group~ : BindGroup, dynamic_offsets? : Array[Int]) -> Unit raise
    Refused

    setBindGroup.

    ComputePassEncoder::set_immediates

    fn ComputePassEncoder::set_immediates(self : ComputePassEncoder, range_offset~ : Int, data~ : Bytes, data_offset? : Int, data_size? : Int) -> Unit raise
    Refused

    setImmediates, for a compute pass.

    ComputePassEncoder::set_pipeline

    setPipeline.

    ComputePassEncoder::write_timestamp

    fn ComputePassEncoder::write_timestamp(self : ComputePassEncoder, query_set~ : QuerySet, query_index~ : Int) -> Unit raise
    Refused

    writeTimestamp.

    ComputePipeline

    pub struct ComputePipeline {
    device : Device
    id :
    ComputePipelineId

    label : String
    }

    A compute pipeline: one compute entry point and its layout.

    ComputePipeline::get_bind_group_layout

    fn ComputePipeline::get_bind_group_layout(self : ComputePipeline, index~ : Int) -> BindGroupLayout raise
    Refused

    One of the bind group layouts a pipeline was built with.

    ComputePipeline::id

    The pipeline's identity inside its device.

    ComputePipeline::label

    fn ComputePipeline::label(self : ComputePipeline) -> String

    The pipeline's label.

    Device

    pub struct Device {
    hub :
    Hub

    label : String
    default_queue_label : String
    }

    A device: the object that makes resources and records work.

    The state lives in a @core.Hub, so copying a Device copies a handle and not a device. That is the same arrangement the specification has, where every object carries a reference to its device.

    Device::backend_name

    fn Device::backend_name(self : Device) -> String

    The backend's name, for diagnostics.

    Device::clear_uncaptured_errors

    fn Device::clear_uncaptured_errors(self : Device) -> Unit

    Forget the uncaptured errors kept so far.

    Device::create_bind_group

    A GPUBindGroupDescriptor to a bind group.

    Device::create_bind_group_layout

    A GPUBindGroupLayoutDescriptor to a bind group layout.

    Device::create_buffer

    A GPUBufferDescriptor to a buffer. https://www.w3.org/TR/webgpu/#dom-gpudevice-createbuffer

    Device::create_command_encoder

    fn Device::create_command_encoder(self : Device, label? : String) -> CommandEncoder

    An encoder with nothing recorded.

    Device::create_compute_pipeline

    A GPUComputePipelineDescriptor to a compute pipeline.

    Device::create_compute_pipeline_async

    createComputePipelineAsync, for the same reason as the render form. https://www.w3.org/TR/webgpu/#dom-gpudevice-createcomputepipelineasync

    Device::create_pipeline_layout

    A GPUPipelineLayoutDescriptor to a pipeline layout.

    Device::create_query_set

    A GPUQuerySetDescriptor to a query set.

    Device::create_render_bundle_encoder

    fn Device::create_render_bundle_encoder(self : Device, descriptor~ : RenderBundleEncoderDescriptor) -> RenderBundleEncoder raise
    Refused

    An encoder for a render bundle over the given attachment formats.

    Device::create_render_pipeline

    A GPURenderPipelineDescriptor to a render pipeline.

    Device::create_render_pipeline_async

    createRenderPipelineAsync.

    The specification's asynchronous form lets a compiler work off the device timeline. Nothing here compiles on another thread - the device timeline runs in the caller's - so this is the same call, kept so that a caller written against the specification compiles unchanged. https://www.w3.org/TR/webgpu/#dom-gpudevice-createrenderpipelineasync

    Device::create_sampler

    A GPUSamplerDescriptor to a sampler.

    Device::create_shader_module

    A GPUShaderModuleDescriptor to a shader module.

    Device::create_texture

    A GPUTextureDescriptor to a texture.

    Device::destroy

    fn Device::destroy(self : Device) -> Unit

    Lose the device: every later call is refused, as after a real device loss.

    Device::destroyed

    fn Device::destroyed(self : Device) -> Bool

    Whether the device has been destroyed, GPUBufferMapState's neighbour in the specification's device object. A destroyed device is a lost one. https://www.w3.org/TR/webgpu/#dom-gpudevice-destroyed

    Device::features

    The features the device was created with.

    Device::import_external_texture

    importExternalTexture: take a frame a host decoded and hold it as a texture a bind group can name.

    The frame is copied when it is imported, so the host may reuse its buffer as soon as this returns. https://www.w3.org/TR/webgpu/#dom-gpudevice-importexternaltexture

    Device::label

    fn Device::label(self : Device) -> String

    The device's label.

    Device::limits

    The limits the device was created with.

    Device::lost

    fn Device::lost(self : Device) -> Bool

    Whether the device has been lost.

    Device::lost_info

    GPUDevice.lost: why the device is gone, or None while it is alive.

    The specification resolves a promise with this object; a device whose timeline runs in the caller's thread can answer it at once. https://www.w3.org/TR/webgpu/#dom-gpudevice-lost

    Device::pop_error_scope

    Pop the innermost error scope and hand back what it collected. https://www.w3.org/TR/webgpu/#dom-gpudevice-poperrorscope

    Device::push_error_scope

    fn Device::push_error_scope(self : Device, filter? :
    ErrorFilter
    ) -> Unit

    Push an error scope: the errors the device itself generates while it is on top are collected for pop_error_scope instead of being lost. https://www.w3.org/TR/webgpu/#dom-gpudevice-pusherrorscope

    Device::queue

    fn Device::queue(self : Device) -> Queue

    The queue work is submitted to. One device has one queue.

    Device::report_error

    Hand a refusal to the device's error scopes.

    The two error models this library serves are not the same one. A MoonBit caller gets its refusals raised, at the call that made them, and never has to ask. A caller written against the specification never sees a raise: the failing call returns an invalid object and the error arrives later, from pop_error_scope. This is the bridge - it records an error in the innermost scope whose filter accepts it, or among the device's uncaptured errors when no scope is open - and hands the error back so that a host can both record it and report it.

    Device::set_uncapturederror_handler

    fn Device::set_uncapturederror_handler(self : Device, handler : (
    Refused
    ) -> Unit?) -> Unit

    Set, or with None clear, the handler an uncaptured error is handed to. It stands where the specification's onuncapturederror event listener does, and runs on the thread that caused the error.

    Device::uncaptured_errors

    The errors no error scope collected, oldest first. The specification delivers these to onuncapturederror; this library keeps them and hands them over. https://www.w3.org/TR/webgpu/#dom-gpudevice-onuncapturederror

    Device::uncapturederror_handler

    fn Device::uncapturederror_handler(self : Device) -> (
    Refused
    ) -> Unit?

    The handler set by set_uncapturederror_handler, if any.

    DeviceDescriptor

    pub(all) struct DeviceDescriptor {
    label : String
    required_features :
    Features

    required_limits :
    Limits
    ?
    default_queue_label : String
    } derive(
    Debug
    )

    A GPUDeviceDescriptor.

    DeviceDescriptor::new

    fn DeviceDescriptor::new(label? : String, required_features? :
    Features
    , required_limits? :
    Limits
    , default_queue_label? : String) -> DeviceDescriptor

    A device with no optional feature and the adapter's own limits.

    ExternalTexture

    A frame a host decoded, held as a texture a bind group can name.

    The specification calls the same object a GPUExternalTexture, and gives it a lifetime as short as the frame it came from: after the frame is gone the texture is expired, and using it is refused. A host that knows its frame has moved on says so with expire. https://www.w3.org/TR/webgpu/#gpuexternaltexture

    ExternalTexture::color_space

    The colour space the pixels are in, as recorded at import.

    ExternalTexture::descriptor

    The frame and colour space the texture was imported with.

    ExternalTexture::expire

    fn ExternalTexture::expire(self : ExternalTexture) -> Unit

    Mark the texture expired, as the specification's automatic expiry does when the frame it came from is replaced.

    ExternalTexture::id

    The texture's identity inside its device.

    ExternalTexture::is_expired

    fn ExternalTexture::is_expired(self : ExternalTexture) -> Bool

    Whether the frame behind this texture has moved on.

    ExternalTexture::label

    fn ExternalTexture::label(self : ExternalTexture) -> String

    The texture's label.

    Instance

    pub struct Instance {
    backend : &
    Hal

    label : String
    }

    The entry point: what a caller has to build before anything else.

    A Instance owns a backend, a handle to one way of talking to a device: the memory backend of this repository, a native graphics API, or the browser's own WebGPU. The handle is injected rather than chosen here, so that this package never depends on a particular one.

    Instance::backend_name

    fn Instance::backend_name(self : Instance) -> String

    The name of the backend behind this instance, as in "memory".

    Instance::get_preferred_canvas_format

    getPreferredCanvasFormat: the format a canvas of this host wants its textures in.

    Where a browser answers with the format its compositor accepts - bgra8unorm on every platform whose surfaces are 32-bit BGRA - a native host answers for itself, and this library keeps the same layout so that a canvas written here travels without a channel swap. https://www.w3.org/TR/webgpu/#dom-gpu-getpreferredcanvasformat

    Instance::new

    fn Instance::new(backend~ : &
    Hal
    , label? : String) -> Instance

    An instance over backend.

    Instance::request_adapter

    fn Instance::request_adapter(self : Instance, options? : RequestAdapterOptions) -> Adapter

    Ask for an adapter. A backend that offers exactly one adapter hands it over whatever the options say; the options exist so that a host with several can pick. https://www.w3.org/TR/webgpu/#dom-gpu-requestadapter

    PipelineLayout

    A pipeline layout: the bind group layouts a pipeline draws on.

    PipelineLayout::descriptor

    The descriptor the layout was created from.

    PipelineLayout::id

    The layout's identity inside its device.

    QuerySet

    A query set: the timestamps or occlusion results a pass writes.

    QuerySet::count

    fn QuerySet::count(self : QuerySet) -> Int

    How many queries the set holds.

    QuerySet::destroy

    fn QuerySet::destroy(self : QuerySet) -> Unit

    Destroy the set. Later uses are refused. https://www.w3.org/TR/webgpu/#dom-gpuqueryset-destroy

    QuerySet::id

    The set's identity inside its device.

    QuerySet::kind

    What the set records.

    Queue

    pub struct Queue {
    device : Device
    label : String
    }

    The queue work is submitted to.

    Writes through the queue happen before the next submission, which is why write_buffer and write_texture take effect without a command buffer. https://www.w3.org/TR/webgpu/#gpiqueue

    Queue::copy_external_image_to_texture

    copyExternalImageToTexture: move the pixels of a decoded frame into a texture, before the next submission.

    The rows need no alignment of their own: the frame is copied texel by texel, which is why the specification allows it on a queue rather than through a buffer. https://www.w3.org/TR/webgpu/#dom-gpuqueue-copyexternalimagetotexture

    Queue::label

    fn Queue::label(self : Queue) -> String

    The queue's label.

    Queue::on_submitted_work_done

    fn Queue::on_submitted_work_done(self : Queue) -> Unit

    Wait until everything submitted so far has finished.

    The specification returns a promise here because a real device works later. The device timeline of this library runs in the caller's thread, so every submission is already complete when submit returns, and this call only reports that. https://www.w3.org/TR/webgpu/#dom-gpuqueue-onsubmittedworkdone

    Queue::submit

    fn Queue::submit(self : Queue, command_buffers~ : Array[CommandBuffer]) -> Unit raise
    Refused

    Submit command buffers in order. Nothing reaches the host until every command of every buffer has passed validation. https://www.w3.org/TR/webgpu/#dom-gpuqueue-submit

    Queue::write_buffer

    fn Queue::write_buffer(self : Queue, buffer~ : Buffer, offset~ : Int, data~ : Bytes) -> Unit raise
    Refused

    Write bytes into a buffer before the next submission. https://www.w3.org/TR/webgpu/#dom-gpuqueue-writebuffer

    Queue::write_texture

    Write texels into a texture before the next submission. Unlike a copy through a buffer, these rows need no 256-byte stride. https://www.w3.org/TR/webgpu/#dom-gpuqueue-writetexture

    RenderBundleEncoder

    pub struct RenderBundleEncoder {
    device : Device
    descriptor : RenderBundleEncoderDescriptor
    commands : Array[
    RenderCommand
    ]
    ended : Bool
    }

    Records a render bundle: a run of draw commands that any number of passes can execute again.

    A bundle records the same commands a render pass does, minus the ones that depend on the pass's own attachment views. It is validated when it is executed, in the pass it lands in, which is where the specification puts that check. https://www.w3.org/TR/webgpu/#render-bundles

    RenderBundleEncoder::draw_indexed_indirect

    fn RenderBundleEncoder::draw_indexed_indirect(self : RenderBundleEncoder, buffer~ : Buffer, offset? : Int) -> Unit raise
    Refused

    drawIndexedIndirect.

    RenderBundleEncoder::draw_indirect

    fn RenderBundleEncoder::draw_indirect(self : RenderBundleEncoder, buffer~ : Buffer, offset? : Int) -> Unit raise
    Refused

    drawIndirect.

    RenderBundleEncoder::finish

    Finish the bundle. https://www.w3.org/TR/webgpu/#dom-gpurenderbundleencoder-finish

    RenderBundleEncoder::insert_debug_marker

    fn RenderBundleEncoder::insert_debug_marker(self : RenderBundleEncoder, marker~ : String) -> Unit raise
    Refused

    insertDebugMarker.

    RenderBundleEncoder::label

    fn RenderBundleEncoder::label(self : RenderBundleEncoder) -> String

    The bundle encoder's label.

    RenderBundleEncoder::pop_debug_group

    popDebugGroup.

    RenderBundleEncoder::push_debug_group

    fn RenderBundleEncoder::push_debug_group(self : RenderBundleEncoder, group_label~ : String) -> Unit raise
    Refused

    pushDebugGroup.

    RenderBundleEncoder::set_bind_group

    fn RenderBundleEncoder::set_bind_group(self : RenderBundleEncoder, index~ : Int, bind_group~ : BindGroup, dynamic_offsets? : Array[Int]) -> Unit raise
    Refused

    setBindGroup.

    RenderBundleEncoder::set_immediates

    fn RenderBundleEncoder::set_immediates(self : RenderBundleEncoder, range_offset~ : Int, data~ : Bytes, data_offset? : Int, data_size? : Int) -> Unit raise
    Refused

    setImmediates, recorded into the bundle.

    RenderBundleEncoder::set_index_buffer

    fn RenderBundleEncoder::set_index_buffer(self : RenderBundleEncoder, buffer~ : Buffer, format~ :
    IndexFormat
    , offset? : Int, size? : Int) -> Unit raise
    Refused

    setIndexBuffer.

    RenderBundleEncoder::set_pipeline

    setPipeline.

    RenderBundleEncoder::set_vertex_buffer

    fn RenderBundleEncoder::set_vertex_buffer(self : RenderBundleEncoder, slot~ : Int, buffer~ : Buffer, offset? : Int, size? : Int) -> Unit raise
    Refused

    setVertexBuffer.

    RenderBundleEncoderDescriptor

    pub(all) struct RenderBundleEncoderDescriptor {
    label : String
    color_formats : Array[
    TextureFormat
    ]
    depth_stencil_format :
    TextureFormat
    ?
    sample_count : Int
    depth_read_only : Bool
    stencil_read_only : Bool
    } derive(
    Debug
    )

    A GPURenderBundleEncoderDescriptor: the attachment formats a bundle is recorded against, so that its commands can be validated without a pass.

    RenderBundleEncoderDescriptor::new

    fn RenderBundleEncoderDescriptor::new(color_formats~ : Array[
    TextureFormat
    ], label? : String, depth_stencil_format? :
    TextureFormat
    , sample_count? : Int, depth_read_only? : Bool, stencil_read_only? : Bool) -> RenderBundleEncoderDescriptor

    RenderPassEncoder

    Records the commands of one render pass.

    RenderPassEncoder::begin_occlusion_query

    fn RenderPassEncoder::begin_occlusion_query(self : RenderPassEncoder, query_index~ : Int) -> Unit raise
    Refused

    beginOcclusionQuery.

    RenderPassEncoder::draw_indexed_indirect

    fn RenderPassEncoder::draw_indexed_indirect(self : RenderPassEncoder, buffer~ : Buffer, offset? : Int) -> Unit raise
    Refused

    drawIndexedIndirect.

    RenderPassEncoder::draw_indirect

    fn RenderPassEncoder::draw_indirect(self : RenderPassEncoder, buffer~ : Buffer, offset? : Int) -> Unit raise
    Refused

    drawIndirect: the four arguments come from a buffer. https://www.w3.org/TR/webgpu/#dom-gpurenderpassencoder-drawindirect

    RenderPassEncoder::end

    End the pass and keep what it recorded. https://www.w3.org/TR/webgpu/#dom-gpurenderpassencoder-end

    RenderPassEncoder::end_occlusion_query

    endOcclusionQuery.

    RenderPassEncoder::execute_bundles

    executeBundles: run the recorded bundles in this pass, in order. https://www.w3.org/TR/webgpu/#dom-gpurenderpassencoder-executebundles

    RenderPassEncoder::insert_debug_marker

    fn RenderPassEncoder::insert_debug_marker(self : RenderPassEncoder, marker~ : String) -> Unit raise
    Refused

    insertDebugMarker.

    RenderPassEncoder::label

    fn RenderPassEncoder::label(self : RenderPassEncoder) -> String

    The pass's label.

    RenderPassEncoder::pop_debug_group

    popDebugGroup.

    RenderPassEncoder::push_debug_group

    fn RenderPassEncoder::push_debug_group(self : RenderPassEncoder, group_label~ : String) -> Unit raise
    Refused

    pushDebugGroup.

    RenderPassEncoder::set_bind_group

    fn RenderPassEncoder::set_bind_group(self : RenderPassEncoder, index~ : Int, bind_group~ : BindGroup, dynamic_offsets? : Array[Int]) -> Unit raise
    Refused

    setBindGroup.

    RenderPassEncoder::set_blend_constant

    setBlendConstant.

    RenderPassEncoder::set_immediates

    fn RenderPassEncoder::set_immediates(self : RenderPassEncoder, range_offset~ : Int, data~ : Bytes, data_offset? : Int, data_size? : Int) -> Unit raise
    Refused

    setImmediates: load bytes into the immediate constants of the bind group that was bound last.

    RenderPassEncoder::set_index_buffer

    fn RenderPassEncoder::set_index_buffer(self : RenderPassEncoder, buffer~ : Buffer, format~ :
    IndexFormat
    , offset? : Int, size? : Int) -> Unit raise
    Refused

    setIndexBuffer.

    RenderPassEncoder::set_pipeline

    setPipeline. https://www.w3.org/TR/webgpu/#dom-gpurenderpassencoder-setpipeline

    RenderPassEncoder::set_scissor_rect

    fn RenderPassEncoder::set_scissor_rect(self : RenderPassEncoder, x~ : Int, y~ : Int, width~ : Int, height~ : Int) -> Unit raise
    Refused

    setScissorRect.

    RenderPassEncoder::set_stencil_reference

    fn RenderPassEncoder::set_stencil_reference(self : RenderPassEncoder, reference~ : Int) -> Unit raise
    Refused

    setStencilReference.

    RenderPassEncoder::set_vertex_buffer

    fn RenderPassEncoder::set_vertex_buffer(self : RenderPassEncoder, slot~ : Int, buffer~ : Buffer, offset? : Int, size? : Int) -> Unit raise
    Refused

    setVertexBuffer.

    RenderPassEncoder::set_viewport

    fn RenderPassEncoder::set_viewport(self : RenderPassEncoder, x~ : Double, y~ : Double, width~ : Double, height~ : Double, min_depth? : Double, max_depth? : Double) -> Unit raise
    Refused

    setViewport.

    RenderPassEncoder::write_timestamp

    fn RenderPassEncoder::write_timestamp(self : RenderPassEncoder, query_set~ : QuerySet, query_index~ : Int) -> Unit raise
    Refused

    writeTimestamp.

    RenderPipeline

    pub struct RenderPipeline {
    device : Device
    id :
    RenderPipelineId

    label : String
    }

    A render pipeline: the whole fixed function state of a draw.

    RenderPipeline::get_bind_group_layout

    fn RenderPipeline::get_bind_group_layout(self : RenderPipeline, index~ : Int) -> BindGroupLayout raise
    Refused

    One of the bind group layouts a pipeline was built with.

    A pipeline created without an explicit layout has an automatic one, which this layer does not model: reflection needs the shader's own declarations. https://www.w3.org/TR/webgpu/#dom-gpupipelinebase-getbindgrouplayout

    RenderPipeline::id

    The pipeline's identity inside its device.

    RenderPipeline::label

    fn RenderPipeline::label(self : RenderPipeline) -> String

    The pipeline's label.

    RequestAdapterOptions

    pub(all) struct RequestAdapterOptions {
    power_preference :
    PowerPreference

    force_fallback_adapter : Bool
    } derive(Eq,
    Debug
    )

    A GPURequestAdapterOptions.

    RequestAdapterOptions::new

    Sampler

    A sampler: how a shader reads a texture, and how it reads between texels.

    Sampler::descriptor

    The descriptor the sampler was created from.

    Sampler::id

    The sampler's identity inside its device.

    Sampler::is_comparison

    fn Sampler::is_comparison(self : Sampler) -> Bool

    Whether the sampler compares against a reference value instead of returning texels.

    Sampler::is_filtering

    fn Sampler::is_filtering(self : Sampler) -> Bool

    Whether any of the filters interpolates, which decides whether the sampler may fill a filtering slot of a bind group layout.

    ShaderModule

    pub struct ShaderModule {
    device : Device
    id :
    ShaderModuleId

    label : String
    }

    A shader module: source code the device can build entry points from.

    ShaderModule::get_compilation_info

    getCompilationInfo: what the backend's compiler said about this module.

    A module with an error in it is still created, as in the specification; the messages are how a caller learns that a pipeline built from it will fail. https://www.w3.org/TR/webgpu/#dom-gpushadermodule-getcompilationinfo

    ShaderModule::id

    The module's identity inside its device.

    ShaderModule::label

    fn ShaderModule::label(self : ShaderModule) -> String

    The module's label.

    Texture

    A texture: texels in a format, with mip levels and array layers.

    Texture::create_view

    A view of the texture. https://www.w3.org/TR/webgpu/#dom-gputexture-createview

    Texture::depth_or_array_layers

    fn Texture::depth_or_array_layers(self : Texture) -> Int

    How many array layers, or depth slices, the texture has. GPUTexture.depthOrArrayLayers.

    Texture::destroy

    fn Texture::destroy(self : Texture) -> Unit

    Destroy the texture. Later uses are refused.

    Texture::dimension

    The texture's dimension.

    Texture::format

    The texel format.

    Texture::height

    fn Texture::height(self : Texture) -> Int

    The texture's height, GPUTexture.height.

    Texture::id

    The texture's identity inside its device.

    Texture::mip_level_count

    fn Texture::mip_level_count(self : Texture) -> Int

    How many mip levels the texture has.

    Texture::sample_count

    fn Texture::sample_count(self : Texture) -> Int

    How many samples each texel has.

    Texture::size

    The size the texture was created with, in texels.

    Texture::usage

    The usages the texture was created with.

    Texture::width

    fn Texture::width(self : Texture) -> Int

    The texture's width, GPUTexture.width.

    TextureView

    A view of a texture: what a bind group entry or an attachment names.

    TextureView::dimension

    The dimension the view reads the texture as.

    TextureView::format

    The format the view reads the texture as.

    TextureView::id

    The view's identity inside its device.

    TextureView::texture

    The texture the view stands on.