WebGPU module

webgpu_map_buffer

procedureextensionexperimentalSource

Maps size bytes of buffer at offset for reading (.Read) or writing (.Write) and waits until they are mapped. wgpuBufferGetConstMappedRange or wgpuBufferGetMappedRange then give the bytes, and wgpuBufferUnmap ends the mapping. Returns false, and logs why, when mapping failed.

Example↗
instance := wgpuCreateInstance(null);
buffer: WGPUBuffer;
if webgpu_map_buffer(instance, buffer, .Read) {
    bytes := wgpuBufferGetConstMappedRange(buffer, 0, 64);
    // ... read from bytes ...
    wgpuBufferUnmap(buffer);
}

This one is only checked to compile, not run.

webgpu_map_buffer :: (
    instance: WGPUInstance,
    buffer: WGPUBuffer,
    mode: WGPUMapMode,
    offset: u64 = 0,
    size: u64 = WGPU_WHOLE_MAP_SIZE
) -> bool

Parameters

instance: WGPUInstance
buffer: WGPUBuffer
offset: u64 = 0

Returns

bool

See also