std1.0.0-beta-7 SafeC docs

Module ml::webgpu_api

#include <std/ml/webgpu_api.h> source

the part of the WebGPU C API (webgpu.h, as wgpu-native and Dawn ship it) that device_webgpu.sc and gpu_webgpu.sc call, declared for SafeC. Layouts follow webgpu.h's current revision (the one with WGPUStringView labels, callback-info structs and WGPUFuture returns: wgpu-native v24 on, Dawn from 2024 on); tests/stdlib/webgpu checks them against the real header with a C compiler (layout_check.c).

Handles (WGPUInstance, WGPUDevice, WGPUBuffer, ...) are pointers to opaque marker structs here, one per kind. Enums are 32-bit, flags (WGPUBufferUsage, WGPUMapMode, WGPUShaderStage) 64-bit, WGPUBool 32-bit. Callbacks receive WGPUStringView by value; SafeC passes and receives structs by value with the platform's C ABI, so the callback types below take it as one.

The two wgpu-native extensions used (wgpu.h's wgpuDevicePoll and wgpuDeviceCreateShaderModuleTrusted) are declared at the end; see device_webgpu.sc's header comment for Dawn.

Structs

WGPUStringView
WGPUChainedStruct
WGPUFuture
WGPURequestAdapterCallbackInfo
WGPURequestDeviceCallbackInfo
WGPUBufferMapCallbackInfo
WGPUQueueWorkDoneCallbackInfo
WGPUDeviceLostCallbackInfo
WGPUUncapturedErrorCallbackInfo
WGPUInstanceLimits
WGPUInstanceDescriptor
WGPURequestAdapterOptions
WGPULimits
WGPUQueueDescriptor
WGPUDeviceDescriptor
WGPUAdapterInfo
WGPUBufferDescriptor
WGPUShaderSourceWGSL
WGPUShaderModuleDescriptor
WGPUBufferBindingLayout
WGPUBindGroupLayoutEntryA layout entry for a buffer binding; the sampler / texture / storage texture members (64 bytes) stay zero (BindingNotUsed).
WGPUBindGroupLayoutDescriptor
WGPUPipelineLayoutDescriptor
WGPUBindGroupEntry
WGPUBindGroupDescriptor
WGPUConstantEntry
WGPUComputeState
WGPUComputePipelineDescriptor

Type aliases

WGPURequestAdapterCallbackstatus, adapter
WGPURequestDeviceCallbackstatus, device
WGPUBufferMapCallbackstatus
WGPUQueueWorkDoneCallbackstatus
WGPUUncapturedErrorCallback&device, type
WGPUDeviceLostCallback&device, reason

Functions

wgpuDevicePollRuns the device's maintenance (finished work, mapped buffers) so the instance's callbacks can fire; with wait, first blocks until submission *index (every submission when null) is done. 1 when the queue is empty.

Macros

WGPU_STYPE_SHADER_SOURCE_WGSL
WGPU_CALLBACK_MODE_WAIT_ANY_ONLY
WGPU_CALLBACK_MODE_ALLOW_PROCESS_EVENTS
WGPU_POWER_HIGH_PERFORMANCE
WGPU_REQUEST_STATUS_SUCCESSadapter, device, map, work done
WGPU_STATUS_SUCCESS
WGPU_FEATURE_SHADER_F16
WGPU_FEATURE_SUBGROUPS
WGPU_BUFFER_BINDING_UNIFORM
WGPU_BUFFER_BINDING_STORAGE
WGPU_BUFFER_BINDING_READ_ONLY_STORAGE
WGPU_BUFFER_USAGE_MAP_READ
WGPU_BUFFER_USAGE_MAP_WRITE
WGPU_BUFFER_USAGE_COPY_SRC
WGPU_BUFFER_USAGE_COPY_DST
WGPU_BUFFER_USAGE_UNIFORM
WGPU_BUFFER_USAGE_STORAGE
WGPU_MAP_MODE_READ
WGPU_SHADER_STAGE_COMPUTE
WGPU_RUNTIME_CHECKS_BOUNDSA shader module without the runtime checks wgpu adds to every shader (bounds checks on each buffer access, a counter in each loop); checks is a WGPUShaderRuntimeChecks mask, 0 for none.
WGPU_RUNTIME_CHECKS_LOOP_BOUNDING