Backend and platform integration#

Low-level bindings and infrastructure that connect the Python API to browser and native WebGPU backends.

WebGPU API bindings#

class webgpu.webgpu_api.Adapter(handle)#

Bases: BaseWebGPUHandle

property features: list[FeatureName]#
property info: AdapterInfo#
property isFallbackAdapter: bool#
property limits: Limits#
async requestDevice(
requiredFeatures: list[FeatureName] | None = None,
requiredLimits: Limits | None = None,
defaultQueue: QueueDescriptor | None = None,
label: str = '',
) Device#
requestDeviceSync(
requiredFeatures: list[FeatureName] | None = None,
requiredLimits: Limits | None = None,
defaultQueue: QueueDescriptor | None = None,
label: str = '',
) Device#
class webgpu.webgpu_api.AdapterInfo(
vendor: str = '',
architecture: str = '',
device: str = '',
description: str = '',
)#

Bases: BaseWebGPUObject

architecture: str = ''#
description: str = ''#
device: str = ''#
vendor: str = ''#
class webgpu.webgpu_api.AdapterType(value)#

Bases: str, Enum

CPU = 'CPU'#
discrete_GPU = 'discrete_GPU'#
integrated_GPU = 'integrated_GPU'#
unknown = 'unknown'#
class webgpu.webgpu_api.AddressMode(value)#

Bases: str, Enum

clamp_to_edge = 'clamp-to-edge'#
mirror_repeat = 'mirror-repeat'#
repeat = 'repeat'#
undefined = 'undefined'#
class webgpu.webgpu_api.AutoLayoutMode(value)#

Bases: str, Enum

auto = 'auto'#
class webgpu.webgpu_api.BackendType(value)#

Bases: str, Enum

D3D11 = 'D3D11'#
D3D12 = 'D3D12'#
WebGPU = 'WebGPU'#
metal = 'metal'#
null = 'null'#
openGL = 'openGL'#
openGLES = 'openGLES'#
undefined = 'undefined'#
vulkan = 'vulkan'#
class webgpu.webgpu_api.BaseWebGPUHandle(handle)#

Bases: object

destroy()#
handle: Proxy#
class webgpu.webgpu_api.BaseWebGPUObject#

Bases: object

toJS()#
class webgpu.webgpu_api.BindGroup(handle)#

Bases: BaseWebGPUHandle

class webgpu.webgpu_api.BindGroupDescriptor(
layout: webgpu.webgpu_api.BindGroupLayout,
entries: list[webgpu.webgpu_api.BindGroupEntry] = <factory>,
label: str = '',
)#

Bases: BaseWebGPUObject

entries: list[BindGroupEntry]#
label: str = ''#
layout: BindGroupLayout#
class webgpu.webgpu_api.BindGroupEntry(binding: int, resource: 'Sampler | TextureView | Buffer')#

Bases: BaseWebGPUObject

binding: int#
resource: Sampler | TextureView | Buffer#
class webgpu.webgpu_api.BindGroupLayout(handle)#

Bases: BaseWebGPUHandle

class webgpu.webgpu_api.BindGroupLayoutDescriptor(
label: str = '',
entries: list['BindGroupLayoutEntry'] = <factory>,
)#

Bases: BaseWebGPUObject

entries: list[BindGroupLayoutEntry]#
label: str = ''#
class webgpu.webgpu_api.BindGroupLayoutEntry(
binding: int = 0,
visibility: webgpu.webgpu_api.ShaderStage = <ShaderStage.NONE: 0>,
buffer: 'BufferBindingLayout | None' = None,
sampler: 'SamplerBindingLayout | None' = None,
texture: 'TextureBindingLayout | None' = None,
storageTexture: 'StorageTextureBindingLayout | None' = None,
)#

Bases: BaseWebGPUObject

binding: int = 0#
buffer: BufferBindingLayout | None = None#
sampler: SamplerBindingLayout | None = None#
storageTexture: StorageTextureBindingLayout | None = None#
texture: TextureBindingLayout | None = None#
visibility: ShaderStage = 0#
class webgpu.webgpu_api.BlendComponent(
operation: webgpu.webgpu_api.BlendOperation = <BlendOperation.add: 'add'>,
srcFactor: webgpu.webgpu_api.BlendFactor = <BlendFactor.one: 'one'>,
dstFactor: webgpu.webgpu_api.BlendFactor = <BlendFactor.zero: 'zero'>,
)#

Bases: BaseWebGPUObject

dstFactor: BlendFactor = 'zero'#
operation: BlendOperation = 'add'#
srcFactor: BlendFactor = 'one'#
class webgpu.webgpu_api.BlendFactor(value)#

Bases: str, Enum

constant = 'constant'#
dst = 'dst'#
dst_alpha = 'dst-alpha'#
one = 'one'#
one_minus_constant = 'one-minus-constant'#
one_minus_dst = 'one-minus-dst'#
one_minus_dst_alpha = 'one-minus-dst-alpha'#
one_minus_src = 'one-minus-src'#
one_minus_src1 = 'one-minus-src1'#
one_minus_src1_alpha = 'one-minus-src1-alpha'#
one_minus_src_alpha = 'one-minus-src-alpha'#
src = 'src'#
src1 = 'src1'#
src1_alpha = 'src1-alpha'#
src_alpha = 'src-alpha'#
src_alpha_saturated = 'src-alpha-saturated'#
undefined = 'undefined'#
zero = 'zero'#
class webgpu.webgpu_api.BlendOperation(value)#

Bases: str, Enum

add = 'add'#
max = 'max'#
min = 'min'#
reverse_subtract = 'reverse-subtract'#
subtract = 'subtract'#
undefined = 'undefined'#
class webgpu.webgpu_api.BlendState(
color: webgpu.webgpu_api.BlendComponent,
alpha: webgpu.webgpu_api.BlendComponent,
)#

Bases: BaseWebGPUObject

alpha: BlendComponent#
color: BlendComponent#
class webgpu.webgpu_api.Buffer(handle)#

Bases: BaseWebGPUHandle

destroy() None#
getConstMappedRange(offset: int = 0, size: int = 0) int#
getMappedRange(offset: int = 0, size: int = 0) int#
async mapAsync(
mode: MapMode,
offset: int = 0,
size: int = 0,
) _DummyNone#
property mapState: BufferMapState#
property size: int#
unmap() None#
property usage: BufferUsage#
class webgpu.webgpu_api.BufferBindingLayout(
type: webgpu.webgpu_api.BufferBindingType = <BufferBindingType.uniform: 'uniform'>,
hasDynamicOffset: bool = False,
minBindingSize: int = 0,
)#

Bases: BaseWebGPUObject

hasDynamicOffset: bool = False#
minBindingSize: int = 0#
type: BufferBindingType = 'uniform'#
class webgpu.webgpu_api.BufferBindingType(value)#

Bases: str, Enum

binding_not_used = 'binding_not_used'#
read_only_storage = 'read_only_storage'#
storage = 'storage'#
undefined = 'undefined'#
uniform = 'uniform'#
class webgpu.webgpu_api.BufferDescriptor(
size: int,
usage: webgpu.webgpu_api.BufferUsage,
mappedAtCreation: bool = False,
label: str = '',
)#

Bases: BaseWebGPUObject

label: str = ''#
mappedAtCreation: bool = False#
size: int#
usage: BufferUsage#
class webgpu.webgpu_api.BufferMapState(value)#

Bases: str, Enum

mapped = 'mapped'#
pending = 'pending'#
unmapped = 'unmapped'#
class webgpu.webgpu_api.BufferUsage(value)#

Bases: IntFlag

COPY_DST = 8#
COPY_SRC = 4#
INDEX = 16#
INDIRECT = 256#
MAP_READ = 1#
MAP_WRITE = 2#
NONE = 0#
QUERY_RESOLVE = 512#
STORAGE = 128#
UNIFORM = 64#
VERTEX = 32#
class webgpu.webgpu_api.CallbackMode(value)#

Bases: str, Enum

allow_process_events = 'allow_process_events'#
allow_spontaneous = 'allow_spontaneous'#
wait_any_only = 'wait_any_only'#
class webgpu.webgpu_api.Color(r: float = 0.0, g: float = 0.0, b: float = 0.0, a: float = 0.0)#

Bases: BaseWebGPUObject

a: float = 0.0#
b: float = 0.0#
g: float = 0.0#
r: float = 0.0#
class webgpu.webgpu_api.ColorTargetState(
format: webgpu.webgpu_api.TextureFormat,
blend: webgpu.webgpu_api.BlendState | None = None,
writeMask: webgpu.webgpu_api.ColorWriteMask = <ColorWriteMask.ALL: 15>,
)#

Bases: BaseWebGPUObject

blend: BlendState | None = None#
format: TextureFormat#
writeMask: ColorWriteMask = 15#
class webgpu.webgpu_api.ColorWriteMask(value)#

Bases: IntFlag

ALL = 15#
ALPHA = 8#
BLUE = 4#
GREEN = 2#
NONE = 0#
RED = 1#
class webgpu.webgpu_api.CommandBuffer(handle)#

Bases: BaseWebGPUHandle

class webgpu.webgpu_api.CommandBufferDescriptor(label: str = '')#

Bases: BaseWebGPUObject

label: str = ''#
class webgpu.webgpu_api.CommandEncoder(handle)#

Bases: BaseWebGPUHandle

beginComputePass(
timestampWrites: PassTimestampWrites | None = None,
label: str = '',
) ComputePassEncoder#
beginRenderPass(
colorAttachments: list[RenderPassColorAttachment],
depthStencilAttachment: RenderPassDepthStencilAttachment,
occlusionQuerySet: QuerySet | None = None,
timestampWrites: PassTimestampWrites | None = None,
label: str = '',
) RenderPassEncoder#
clearBuffer(
buffer: Buffer,
offset: int = 0,
size: int = 0,
) None#
copyBufferToBuffer(
source: Buffer,
sourceOffset,
destination: Buffer,
destinationOffset,
size,
) None#
copyBufferToTexture(
source: TexelCopyBufferInfo,
destination: TexelCopyTextureInfo,
copySize: list,
) None#
copyTextureToBuffer(
source: TexelCopyTextureInfo,
destination: TexelCopyBufferInfo,
copySize: list,
) None#
copyTextureToTexture(
source: TexelCopyTextureInfo,
destination: TexelCopyTextureInfo,
copySize: list,
) None#
finish(label: str = '') CommandBuffer#
getLoadOp() LoadOp#
insertDebugMarker(markerLabel: str = '') None#
popDebugGroup() None#
pushDebugGroup(groupLabel: str = '') None#
resolveQuerySet(
querySet: QuerySet,
firstQuery: int,
queryCount: int,
destination: Buffer,
destinationOffset: int = 0,
) None#
class webgpu.webgpu_api.CommandEncoderDescriptor(label: str = '')#

Bases: BaseWebGPUObject

label: str = ''#
class webgpu.webgpu_api.CompareFunction(value)#

Bases: str, Enum

always = 'always'#
equal = 'equal'#
greater = 'greater'#
greater_equal = 'greater-equal'#
less = 'less'#
less_equal = 'less-equal'#
never = 'never'#
not_equal = 'not-equal'#
undefined = 'undefined'#
class webgpu.webgpu_api.CompilationInfo(
messages: list[webgpu.webgpu_api.CompilationMessage] = <factory>,
)#

Bases: BaseWebGPUObject

messages: list[CompilationMessage]#
class webgpu.webgpu_api.CompilationInfoRequestStatus(value)#

Bases: str, Enum

error = 'error'#
instance_dropped = 'instance_dropped'#
success = 'success'#
class webgpu.webgpu_api.CompilationMessage(
message: str,
type: webgpu.webgpu_api.CompilationMessageType,
lineNum: int,
linePos: int,
offset: int,
length: int,
)#

Bases: BaseWebGPUObject

length: int#
lineNum: int#
linePos: int#
message: str#
offset: int#
type: CompilationMessageType#
class webgpu.webgpu_api.CompilationMessageType(value)#

Bases: str, Enum

error = 'error'#
info = 'info'#
warning = 'warning'#
class webgpu.webgpu_api.CompositeAlphaMode(value)#

Bases: str, Enum

auto = 'auto'#
inherit = 'inherit'#
opaque = 'opaque'#
premultiplied = 'premultiplied'#
unpremultiplied = 'unpremultiplied'#
class webgpu.webgpu_api.ComputePassDescriptor(timestampWrites: 'PassTimestampWrites', label: str = '')#

Bases: BaseWebGPUObject

label: str = ''#
timestampWrites: PassTimestampWrites#
class webgpu.webgpu_api.ComputePassEncoder(handle)#

Bases: BaseWebGPUHandle

dispatchWorkgroups(
workgroupCountX: int,
workgroupCountY: int = 0,
workgroupCountZ: int = 0,
) None#
dispatchWorkgroupsIndirect(
indirectBuffer: Buffer,
indirectOffset: int = 0,
) None#
end() None#
insertDebugMarker(markerLabel: str = '') None#
popDebugGroup() None#
pushDebugGroup(groupLabel: str = '') None#
setBindGroup(
index: int,
bindGroup: BindGroup,
dynamicOffsets: list[int] = [],
) None#
setPipeline(
pipeline: ComputePipeline | None = None,
) None#
class webgpu.webgpu_api.ComputePipeline(handle)#

Bases: BaseWebGPUHandle

getBindGroupLayout(
groupIndex: int = 0,
) BindGroupLayout#
class webgpu.webgpu_api.ComputePipelineDescriptor(
layout: 'PipelineLayout',
compute: webgpu.webgpu_api.ComputeState,
label: str = '',
)#

Bases: BaseWebGPUObject

compute: ComputeState#
label: str = ''#
layout: PipelineLayout#
class webgpu.webgpu_api.ComputeState(module: 'ShaderModule', entryPoint: str = '')#

Bases: BaseWebGPUObject

entryPoint: str = ''#
module: ShaderModule#
class webgpu.webgpu_api.CullMode(value)#

Bases: str, Enum

back = 'back'#
front = 'front'#
none = 'none'#
class webgpu.webgpu_api.DepthStencilState(
format: webgpu.webgpu_api.TextureFormat,
depthWriteEnabled: bool,
depthCompare: webgpu.webgpu_api.CompareFunction,
stencilFront: webgpu.webgpu_api.StencilFaceState = <factory>,
stencilBack: webgpu.webgpu_api.StencilFaceState = <factory>,
stencilReadMask: int = 4294967295,
stencilWriteMask: int = 4294967295,
depthBias: int = 0,
depthBiasSlopeScale: float = 0.0,
depthBiasClamp: float = 0.0,
)#

Bases: BaseWebGPUObject

depthBias: int = 0#
depthBiasClamp: float = 0.0#
depthBiasSlopeScale: float = 0.0#
depthCompare: CompareFunction#
depthWriteEnabled: bool#
format: TextureFormat#
stencilBack: StencilFaceState#
stencilFront: StencilFaceState#
stencilReadMask: int = 4294967295#
stencilWriteMask: int = 4294967295#
class webgpu.webgpu_api.Device(handle)#

Bases: BaseWebGPUHandle

property adapterInfo: AdapterInfo#
createBindGroup(
layout: BindGroupLayout,
entries: list[BindGroupEntry] = Field(name=None,
type=None,
default=<dataclasses._MISSING_TYPE object>,
default_factory=<class 'list'>,
init=True,
repr=True,
hash=None,
compare=True,
metadata=mappingproxy({}),
kw_only=<dataclasses._MISSING_TYPE object>,
_field_type=None),
label: str = '',
) BindGroup#
createBindGroupLayout(
entries: list[BindGroupLayoutEntry] = Field(name=None,
type=None,
default=<dataclasses._MISSING_TYPE object>,
default_factory=<class 'list'>,
init=True,
repr=True,
hash=None,
compare=True,
metadata=mappingproxy({}),
kw_only=<dataclasses._MISSING_TYPE object>,
_field_type=None),
label: str = '',
) BindGroupLayout#
createBuffer(
size: int,
usage: BufferUsage,
mappedAtCreation: bool = False,
label: str = '',
) Buffer#
createCommandEncoder(
label: str = '',
) CommandEncoder#
createComputePipeline(
layout: PipelineLayout,
compute: ComputeState,
label: str = '',
) ComputePipeline#
async createComputePipelineAsync(
layout: PipelineLayout,
compute: ComputeState,
label: str = '',
) ComputePipeline#
createPipelineLayout(
bindGroupLayouts: list[BindGroupLayout] = [],
label: str = '',
) PipelineLayout#
createQuerySet(
count: int,
label: str = '',
) QuerySet#
createRenderBundleEncoder(
label: str = '',
) RenderBundleEncoder#
createRenderPipeline(
layout: PipelineLayout | AutoLayoutMode,
vertex: VertexState,
fragment: FragmentState,
depthStencil: DepthStencilState,
primitive: PrimitiveState = Field(name=None,
type=None,
default=<dataclasses._MISSING_TYPE object>,
default_factory=<class 'webgpu.webgpu_api.PrimitiveState'>,
init=True,
repr=True,
hash=None,
compare=True,
metadata=mappingproxy({}),
kw_only=<dataclasses._MISSING_TYPE object>,
_field_type=None),
multisample: MultisampleState = Field(name=None,
type=None,
default=<dataclasses._MISSING_TYPE object>,
default_factory=<class 'webgpu.webgpu_api.MultisampleState'>,
init=True,
repr=True,
hash=None,
compare=True,
metadata=mappingproxy({}),
kw_only=<dataclasses._MISSING_TYPE object>,
_field_type=None),
label: str = '',
)#
async createRenderPipelineAsync(
layout: PipelineLayout,
vertex: VertexState,
fragment: FragmentState,
depthStencil: DepthStencilState,
primitive: PrimitiveState = Field(name=None,
type=None,
default=<dataclasses._MISSING_TYPE object>,
default_factory=<class 'webgpu.webgpu_api.PrimitiveState'>,
init=True,
repr=True,
hash=None,
compare=True,
metadata=mappingproxy({}),
kw_only=<dataclasses._MISSING_TYPE object>,
_field_type=None),
multisample: MultisampleState = Field(name=None,
type=None,
default=<dataclasses._MISSING_TYPE object>,
default_factory=<class 'webgpu.webgpu_api.MultisampleState'>,
init=True,
repr=True,
hash=None,
compare=True,
metadata=mappingproxy({}),
kw_only=<dataclasses._MISSING_TYPE object>,
_field_type=None),
label: str = '',
) None#
createSampler(
addressModeU: AddressMode = AddressMode.clamp_to_edge,
addressModeV: AddressMode = AddressMode.clamp_to_edge,
addressModeW: AddressMode = AddressMode.clamp_to_edge,
magFilter: FilterMode = FilterMode.nearest,
minFilter: FilterMode = FilterMode.nearest,
mipmapFilter: MipmapFilterMode = MipmapFilterMode.nearest,
lodMinClamp: float = 0.0,
lodMaxClamp: float = 32,
compare: CompareFunction | None = None,
maxAnisotropy: int = 1,
label: str = '',
)#
createShaderModule(
code: str,
compilationHints: list[ShaderModuleCompilationHint] = [],
label: str = '',
) ShaderModule#
createTexture(
size: list,
usage: TextureUsage,
format: TextureFormat,
sampleCount: int = 1,
dimension: str = '2d',
mipLevelCount: int = 1,
viewFormats: list[TextureFormat] | None = None,
label: str = '',
) Texture#
destroy() None#
property features: list[FeatureName]#
property limits: Limits#
popErrorScope() None#
pushErrorScope(filter: ErrorFilter) None#
property queue: Queue#
class webgpu.webgpu_api.DeviceDescriptor(
requiredFeatures: list['FeatureName'] | None = None,
requiredLimits: webgpu.webgpu_api.Limits | None = None,
defaultQueue: webgpu.webgpu_api.QueueDescriptor | None = None,
label: str = '',
)#

Bases: BaseWebGPUObject

defaultQueue: QueueDescriptor | None = None#
label: str = ''#
requiredFeatures: list[FeatureName] | None = None#
requiredLimits: Limits | None = None#
class webgpu.webgpu_api.DeviceLostReason(value)#

Bases: str, Enum

destroyed = 'destroyed'#
failed_creation = 'failed_creation'#
instance_dropped = 'instance_dropped'#
unknown = 'unknown'#
class webgpu.webgpu_api.ErrorFilter(value)#

Bases: str, Enum

internal = 'internal'#
out_of_memory = 'out-of-memory'#
validation = 'validation'#
class webgpu.webgpu_api.Extent3d(width: int = 0, height: int = 0, depthOrArrayLayers: int = 0)#

Bases: BaseWebGPUObject

depthOrArrayLayers: int = 0#
height: int = 0#
width: int = 0#
class webgpu.webgpu_api.FeatureLevel(value)#

Bases: str, Enum

compatibility = 'compatibility'#
core = 'core'#
class webgpu.webgpu_api.FeatureName#

Bases: str

bgra8unorm_storage = 'bgra8unorm-storage'#
clip_distances = 'clip-distances'#
depth32_float_stencil8 = 'depth32float-stencil8'#
depth_clip_control = 'depth-clip-control'#
dual_source_blending = 'dual-source-blending'#
float32_blendable = 'float32-blendable'#
float32_filterable = 'float32-filterable'#
indirect_first_instance = 'indirect-first-instance'#
rg11b10ufloat_renderable = 'rg11b10ufloat-renderable'#
shader_f16 = 'shader-f16'#
texture_compression_ASTC = 'texture-compression-ASTC'#
texture_compression_ASTC_sliced_3D = 'texture-compression-ASTC-sliced-3D'#
texture_compression_BC = 'texture-compression-BC'#
texture_compression_BC_sliced_3D = 'texture-compression-BC-sliced-3D'#
texture_compression_ETC2 = 'texture-compression-ETC2'#
timestamp_query = 'timestamp-query'#
undefined = 'undefined'#
class webgpu.webgpu_api.FilterMode(value)#

Bases: str, Enum

linear = 'linear'#
nearest = 'nearest'#
class webgpu.webgpu_api.FragmentState(
module: 'ShaderModule | None' = None,
entryPoint: str = '',
targets: list[webgpu.webgpu_api.ColorTargetState] = <factory>,
)#

Bases: BaseWebGPUObject

entryPoint: str = ''#
module: ShaderModule | None = None#
targets: list[ColorTargetState]#
class webgpu.webgpu_api.FrontFace(value)#

Bases: str, Enum

CCW = 'ccw'#
CW = 'cw'#
class webgpu.webgpu_api.IndexFormat(value)#

Bases: str, Enum

uint16 = 'uint16'#
uint32 = 'uint32'#
class webgpu.webgpu_api.Limits(
maxTextureDimension1D: int | None = None,
maxTextureDimension2D: int | None = None,
maxTextureDimension3D: int | None = None,
maxTextureArrayLayers: int | None = None,
maxBindGroups: int | None = None,
maxBindGroupsPlusVertexBuffers: int | None = None,
maxBindingsPerBindGroup: int | None = None,
maxDynamicUniformBuffersPerPipelineLayout: int | None = None,
maxDynamicStorageBuffersPerPipelineLayout: int | None = None,
maxSampledTexturesPerShaderStage: int | None = None,
maxSamplersPerShaderStage: int | None = None,
maxStorageBuffersPerShaderStage: int | None = None,
maxStorageTexturesPerShaderStage: int | None = None,
maxUniformBuffersPerShaderStage: int | None = None,
maxUniformBufferBindingSize: int | None = None,
maxStorageBufferBindingSize: int | None = None,
minUniformBufferOffsetAlignment: int | None = None,
minStorageBufferOffsetAlignment: int | None = None,
maxVertexBuffers: int | None = None,
maxBufferSize: int | None = None,
maxVertexAttributes: int | None = None,
maxVertexBufferArrayStride: int | None = None,
maxInterStageShaderVariables: int | None = None,
maxColorAttachments: int | None = None,
maxColorAttachmentBytesPerSample: int | None = None,
maxComputeWorkgroupStorageSize: int | None = None,
maxComputeInvocationsPerWorkgroup: int | None = None,
maxComputeWorkgroupSizeX: int | None = None,
maxComputeWorkgroupSizeY: int | None = None,
maxComputeWorkgroupSizeZ: int | None = None,
maxComputeWorkgroupsPerDimension: int | None = None,
)#

Bases: BaseWebGPUObject

maxBindGroups: int | None = None#
maxBindGroupsPlusVertexBuffers: int | None = None#
maxBindingsPerBindGroup: int | None = None#
maxBufferSize: int | None = None#
maxColorAttachmentBytesPerSample: int | None = None#
maxColorAttachments: int | None = None#
maxComputeInvocationsPerWorkgroup: int | None = None#
maxComputeWorkgroupSizeX: int | None = None#
maxComputeWorkgroupSizeY: int | None = None#
maxComputeWorkgroupSizeZ: int | None = None#
maxComputeWorkgroupStorageSize: int | None = None#
maxComputeWorkgroupsPerDimension: int | None = None#
maxDynamicStorageBuffersPerPipelineLayout: int | None = None#
maxDynamicUniformBuffersPerPipelineLayout: int | None = None#
maxInterStageShaderVariables: int | None = None#
maxSampledTexturesPerShaderStage: int | None = None#
maxSamplersPerShaderStage: int | None = None#
maxStorageBufferBindingSize: int | None = None#
maxStorageBuffersPerShaderStage: int | None = None#
maxStorageTexturesPerShaderStage: int | None = None#
maxTextureArrayLayers: int | None = None#
maxTextureDimension1D: int | None = None#
maxTextureDimension2D: int | None = None#
maxTextureDimension3D: int | None = None#
maxUniformBufferBindingSize: int | None = None#
maxUniformBuffersPerShaderStage: int | None = None#
maxVertexAttributes: int | None = None#
maxVertexBufferArrayStride: int | None = None#
maxVertexBuffers: int | None = None#
minStorageBufferOffsetAlignment: int | None = None#
minUniformBufferOffsetAlignment: int | None = None#
class webgpu.webgpu_api.LoadOp(value)#

Bases: str, Enum

clear = 'clear'#
load = 'load'#
class webgpu.webgpu_api.MapMode(value)#

Bases: IntFlag

NONE = 0#
READ = 1#
WRITE = 2#
class webgpu.webgpu_api.MipmapFilterMode(value)#

Bases: str, Enum

linear = 'linear'#
nearest = 'nearest'#
class webgpu.webgpu_api.MultisampleState(
count: int = 1,
mask: int = 4294967295,
alphaToCoverageEnabled: bool = False,
)#

Bases: BaseWebGPUObject

alphaToCoverageEnabled: bool = False#
count: int = 1#
mask: int = 4294967295#
class webgpu.webgpu_api.Origin3d(x: int = 0, y: int = 0, z: int = 0)#

Bases: BaseWebGPUObject

x: int = 0#
y: int = 0#
z: int = 0#
class webgpu.webgpu_api.PassTimestampWrites(
querySet: 'QuerySet',
beginningOfPassWriteIndex: int,
endOfPassWriteIndex: int,
)#

Bases: BaseWebGPUObject

beginningOfPassWriteIndex: int#
endOfPassWriteIndex: int#
querySet: QuerySet#
class webgpu.webgpu_api.PipelineLayout(handle)#

Bases: BaseWebGPUHandle

class webgpu.webgpu_api.PipelineLayoutDescriptor(
bindGroupLayouts: list['BindGroupLayout'] = <factory>,
label: str = '',
)#

Bases: BaseWebGPUObject

bindGroupLayouts: list[BindGroupLayout]#
label: str = ''#
class webgpu.webgpu_api.PowerPreference(value)#

Bases: str, Enum

high_performance = 'high-performance'#
low_power = 'low-power'#
class webgpu.webgpu_api.PresentMode(value)#

Bases: str, Enum

fifo = 'fifo'#
fifo_relaxed = 'fifo_relaxed'#
immediate = 'immediate'#
mailbox = 'mailbox'#
undefined = 'undefined'#
class webgpu.webgpu_api.PrimitiveState(
topology: 'PrimitiveTopology | None' = None,
stripIndexFormat: webgpu.webgpu_api.IndexFormat | None = None,
frontFace: webgpu.webgpu_api.FrontFace = <FrontFace.CCW: 'ccw'>,
cullMode: webgpu.webgpu_api.CullMode = <CullMode.none: 'none'>,
unclippedDepth: bool = False,
)#

Bases: BaseWebGPUObject

cullMode: CullMode = 'none'#
frontFace: FrontFace = 'ccw'#
stripIndexFormat: IndexFormat | None = None#
topology: PrimitiveTopology | None = None#
unclippedDepth: bool = False#
class webgpu.webgpu_api.PrimitiveTopology(value)#

Bases: str, Enum

line_list = 'line-list'#
line_strip = 'line-strip'#
point_list = 'point-list'#
triangle_list = 'triangle-list'#
triangle_strip = 'triangle-strip'#
class webgpu.webgpu_api.QuerySet(handle)#

Bases: BaseWebGPUHandle

property count: int#
destroy() None#
property type: QueryType#
class webgpu.webgpu_api.QuerySetDescriptor(
type: webgpu.webgpu_api.QueryType,
count: int,
label: str = '',
)#

Bases: BaseWebGPUObject

count: int#
label: str = ''#
type: QueryType#
class webgpu.webgpu_api.QueryType(value)#

Bases: str, Enum

occlusion = 'occlusion'#
timestamp = 'timestamp'#
class webgpu.webgpu_api.Queue(handle)#

Bases: BaseWebGPUHandle

onSubmittedWorkDone() JsPromise#
submit(commands: list[CommandBuffer] = []) None#
writeBuffer(
buffer: Buffer,
bufferOffset: int,
data: bytes,
dataOffset: int = 0,
size: int | None = None,
) None#
writeTexture(
destination: TexelCopyTextureInfo,
data: bytes,
dataLayout: TexelCopyBufferLayout,
size: list,
) None#
class webgpu.webgpu_api.QueueDescriptor(label: str = '')#

Bases: BaseWebGPUObject

label: str = ''#
class webgpu.webgpu_api.RenderBundle(handle)#

Bases: BaseWebGPUHandle

class webgpu.webgpu_api.RenderBundleDescriptor(label: str = '')#

Bases: BaseWebGPUObject

label: str = ''#
class webgpu.webgpu_api.RenderBundleEncoder(handle)#

Bases: BaseWebGPUHandle

draw(
vertexCount: int = 0,
instanceCount: int = 0,
firstVertex: int = 0,
firstInstance: int = 0,
) None#
drawIndexed(
indexCount: int = 0,
instanceCount: int = 0,
firstIndex: int = 0,
baseVertex: int = 0,
firstInstance: int = 0,
) None#
drawIndexedIndirect(
indirectBuffer: Buffer,
indirectOffset: int = 0,
) None#
drawIndirect(
indirectBuffer: Buffer,
indirectOffset: int = 0,
) None#
finish(label: str = '') RenderBundle#
insertDebugMarker(markerLabel: str = '') None#
popDebugGroup() None#
pushDebugGroup(groupLabel: str = '') None#
setBindGroup(
groupIndex: int = 0,
group: BindGroup | None = None,
dynamicOffsets: list[int] = [],
) None#
setIndexBuffer(
buffer: Buffer | None = None,
format: IndexFormat | None = None,
offset: int = 0,
size: int = 0,
) None#
setPipeline(
pipeline: RenderPipeline | None = None,
) None#
setVertexBuffer(
slot: int = 0,
buffer: Buffer | None = None,
offset: int = 0,
size: int = 0,
) None#
class webgpu.webgpu_api.RenderBundleEncoderDescriptor(
colorFormats: list[webgpu.webgpu_api.TextureFormat],
depthStencilFormat: webgpu.webgpu_api.TextureFormat,
sampleCount: int = 1,
depthReadOnly: bool = False,
stencilReadOnly: bool = False,
label: str = '',
)#

Bases: BaseWebGPUObject

colorFormats: list[TextureFormat]#
depthReadOnly: bool = False#
depthStencilFormat: TextureFormat#
label: str = ''#
sampleCount: int = 1#
stencilReadOnly: bool = False#
class webgpu.webgpu_api.RenderPassColorAttachment(
view: webgpu.webgpu_api.TextureView,
resolveTarget: webgpu.webgpu_api.TextureView | None = None,
loadOp: webgpu.webgpu_api.LoadOp = <LoadOp.load: 'load'>,
storeOp: webgpu.webgpu_api.StoreOp = <StoreOp.store: 'store'>,
clearValue: webgpu.webgpu_api.Color = <factory>,
depthSlice: int | None = None,
)#

Bases: BaseWebGPUObject

clearValue: Color#
depthSlice: int | None = None#
loadOp: LoadOp = 'load'#
resolveTarget: TextureView | None = None#
storeOp: StoreOp = 'store'#
view: TextureView#
class webgpu.webgpu_api.RenderPassDepthStencilAttachment(
view: webgpu.webgpu_api.TextureView,
depthLoadOp: webgpu.webgpu_api.LoadOp = <LoadOp.load: 'load'>,
depthStoreOp: webgpu.webgpu_api.StoreOp = <StoreOp.store: 'store'>,
depthClearValue: float = 0.0,
depthReadOnly: bool = False,
stencilClearValue: int = 0,
stencilLoadOp: webgpu.webgpu_api.LoadOp | None = None,
stencilStoreOp: webgpu.webgpu_api.StoreOp | None = None,
stencilReadOnly: bool = False,
)#

Bases: BaseWebGPUObject

depthClearValue: float = 0.0#
depthLoadOp: LoadOp = 'load'#
depthReadOnly: bool = False#
depthStoreOp: StoreOp = 'store'#
stencilClearValue: int = 0#
stencilLoadOp: LoadOp | None = None#
stencilReadOnly: bool = False#
stencilStoreOp: StoreOp | None = None#
view: TextureView#
class webgpu.webgpu_api.RenderPassDescriptor(
colorAttachments: list[webgpu.webgpu_api.RenderPassColorAttachment],
depthStencilAttachment: webgpu.webgpu_api.RenderPassDepthStencilAttachment,
occlusionQuerySet: 'QuerySet | None' = None,
timestampWrites: webgpu.webgpu_api.PassTimestampWrites | None = None,
label: str = '',
)#

Bases: BaseWebGPUObject

colorAttachments: list[RenderPassColorAttachment]#
depthStencilAttachment: RenderPassDepthStencilAttachment#
label: str = ''#
occlusionQuerySet: QuerySet | None = None#
timestampWrites: PassTimestampWrites | None = None#
class webgpu.webgpu_api.RenderPassEncoder(handle)#

Bases: BaseWebGPUHandle

beginOcclusionQuery(queryIndex: int = 0) None#
draw(
vertexCount: int = 0,
instanceCount: int = 0,
firstVertex: int = 0,
firstInstance: int = 0,
) None#
drawIndexed(
indexCount: int = 0,
instanceCount: int = 0,
firstIndex: int = 0,
baseVertex: int = 0,
firstInstance: int = 0,
) None#
drawIndexedIndirect(
indirectBuffer: Buffer,
indirectOffset: int = 0,
) None#
drawIndirect(
indirectBuffer: Buffer,
indirectOffset: int = 0,
) None#
end() None#
endOcclusionQuery() None#
executeBundles(
bundles: list[RenderBundle] = [],
) None#
insertDebugMarker(markerLabel: str = '') None#
popDebugGroup() None#
pushDebugGroup(groupLabel: str = '') None#
setBindGroup(
groupIndex: int = 0,
group: BindGroup | None = None,
dynamicOffsets: list[int] = [],
) None#
setBlendConstant(
color: Color | None = None,
) None#
setIndexBuffer(
buffer: Buffer | None = None,
format: IndexFormat | None = None,
offset: int = 0,
size: int | None = None,
) None#
setPipeline(
pipeline: RenderPipeline | None = None,
) None#
setScissorRect(
x: int = 0,
y: int = 0,
width: int = 0,
height: int = 0,
) None#
setStencilReference(reference: int = 0) None#
setVertexBuffer(
slot: int = 0,
buffer: Buffer | None = None,
offset: int = 0,
size: int | None = None,
) None#
setViewport(
x: float = 0.0,
y: float = 0.0,
width: float = 0.0,
height: float = 0.0,
minDepth: float = 0.0,
maxDepth: float = 0.0,
) None#
class webgpu.webgpu_api.RenderPipeline(handle)#

Bases: BaseWebGPUHandle

getBindGroupLayout(
groupIndex: int = 0,
) BindGroupLayout#
class webgpu.webgpu_api.RenderPipelineDescriptor(
layout: webgpu.webgpu_api.PipelineLayout | webgpu.webgpu_api.AutoLayoutMode,
vertex: 'VertexState',
fragment: 'FragmentState',
depthStencil: 'DepthStencilState',
primitive: webgpu.webgpu_api.PrimitiveState = <factory>,
multisample: webgpu.webgpu_api.MultisampleState = <factory>,
label: str = '',
)#

Bases: BaseWebGPUObject

depthStencil: DepthStencilState#
fragment: FragmentState#
label: str = ''#
layout: PipelineLayout | AutoLayoutMode#
multisample: MultisampleState#
primitive: PrimitiveState#
vertex: VertexState#
class webgpu.webgpu_api.RequestAdapterOptions(
featureLevel: webgpu.webgpu_api.FeatureLevel | None = None,
powerPreference: 'PowerPreference | None' = None,
forceFallbackAdapter: bool = False,
xrCompatible: bool = False,
)#

Bases: BaseWebGPUObject

featureLevel: FeatureLevel | None = None#
forceFallbackAdapter: bool = False#
powerPreference: PowerPreference | None = None#
xrCompatible: bool = False#
class webgpu.webgpu_api.Sampler(handle)#

Bases: BaseWebGPUHandle

class webgpu.webgpu_api.SamplerBindingLayout(
type: webgpu.webgpu_api.SamplerBindingType = <SamplerBindingType.filtering: 'filtering'>,
)#

Bases: BaseWebGPUObject

type: SamplerBindingType = 'filtering'#
class webgpu.webgpu_api.SamplerBindingType(value)#

Bases: str, Enum

comparison = 'comparison'#
filtering = 'filtering'#
non_filtering = 'non-filtering'#
class webgpu.webgpu_api.SamplerDescriptor(
label: str = '',
addressModeU: webgpu.webgpu_api.AddressMode = <AddressMode.clamp_to_edge: 'clamp-to-edge'>,
addressModeV: webgpu.webgpu_api.AddressMode = <AddressMode.clamp_to_edge: 'clamp-to-edge'>,
addressModeW: webgpu.webgpu_api.AddressMode = <AddressMode.clamp_to_edge: 'clamp-to-edge'>,
magFilter: webgpu.webgpu_api.FilterMode = <FilterMode.nearest: 'nearest'>,
minFilter: webgpu.webgpu_api.FilterMode = <FilterMode.nearest: 'nearest'>,
mipmapFilter: webgpu.webgpu_api.MipmapFilterMode = <MipmapFilterMode.nearest: 'nearest'>,
lodMinClamp: float = 0.0,
lodMaxClamp: float = 32,
compare: 'CompareFunction | None' = None,
maxAnisotropy: int = 1,
)#

Bases: BaseWebGPUObject

addressModeU: AddressMode = 'clamp-to-edge'#
addressModeV: AddressMode = 'clamp-to-edge'#
addressModeW: AddressMode = 'clamp-to-edge'#
compare: CompareFunction | None = None#
label: str = ''#
lodMaxClamp: float = 32#
lodMinClamp: float = 0.0#
magFilter: FilterMode = 'nearest'#
maxAnisotropy: int = 1#
minFilter: FilterMode = 'nearest'#
mipmapFilter: MipmapFilterMode = 'nearest'#
class webgpu.webgpu_api.ShaderModule(handle)#

Bases: BaseWebGPUHandle

getCompilationInfo() None#
class webgpu.webgpu_api.ShaderModuleCompilationHint(
entryPoint: str,
layout: webgpu.webgpu_api.PipelineLayout | webgpu.webgpu_api.AutoLayoutMode,
)#

Bases: BaseWebGPUObject

entryPoint: str#
layout: PipelineLayout | AutoLayoutMode#
class webgpu.webgpu_api.ShaderModuleDescriptor(
code: str,
compilationHints: list['ShaderModuleCompilationHint'] = <factory>,
label: str = '',
)#

Bases: BaseWebGPUObject

code: str#
compilationHints: list[ShaderModuleCompilationHint]#
label: str = ''#
class webgpu.webgpu_api.ShaderStage(value)#

Bases: IntFlag

ALL = 7#
COMPUTE = 4#
FRAGMENT = 2#
NONE = 0#
VERTEX = 1#
class webgpu.webgpu_api.Status(value)#

Bases: str, Enum

error = 'error'#
success = 'success'#
class webgpu.webgpu_api.StencilFaceState(
compare: 'CompareFunction | None' = None,
failOp: 'StencilOperation | None' = None,
depthFailOp: 'StencilOperation | None' = None,
passOp: 'StencilOperation | None' = None,
)#

Bases: BaseWebGPUObject

compare: CompareFunction | None = None#
depthFailOp: StencilOperation | None = None#
failOp: StencilOperation | None = None#
passOp: StencilOperation | None = None#
class webgpu.webgpu_api.StencilOperation(value)#

Bases: str, Enum

decrement_clamp = 'decrement-clamp'#
decrement_wrap = 'decrement-wrap'#
increment_clamp = 'increment-clamp'#
increment_wrap = 'increment-wrap'#
invert = 'invert'#
keep = 'keep'#
replace = 'replace'#
undefined = 'undefined'#
zero = 'zero'#
class webgpu.webgpu_api.StorageTextureAccess(value)#

Bases: str, Enum

read_only = 'read-ony'#
read_write = 'read-write'#
write_only = 'write-only'#
class webgpu.webgpu_api.StorageTextureBindingLayout(
format: webgpu.webgpu_api.TextureFormat,
access: webgpu.webgpu_api.StorageTextureAccess = <StorageTextureAccess.write_only: 'write-only'>,
viewDimension: str = '2d',
)#

Bases: BaseWebGPUObject

access: StorageTextureAccess = 'write-only'#
format: TextureFormat#
viewDimension: str = '2d'#
class webgpu.webgpu_api.StoreOp(value)#

Bases: str, Enum

discard = 'discard'#
store = 'store'#
class webgpu.webgpu_api.TexelCopyBufferInfo(
buffer: 'Buffer',
offset: int = 0,
bytesPerRow: int | None = None,
rowsPerImage: int | None = None,
)#

Bases: BaseWebGPUObject

buffer: Buffer#
bytesPerRow: int | None = None#
offset: int = 0#
rowsPerImage: int | None = None#
class webgpu.webgpu_api.TexelCopyBufferLayout(
bytesPerRow: int,
offset: int = 0,
rowsPerImage: int | None = None,
)#

Bases: BaseWebGPUObject

bytesPerRow: int#
offset: int = 0#
rowsPerImage: int | None = None#
class webgpu.webgpu_api.TexelCopyTextureInfo(
texture: 'Texture',
mipLevel: int = 0,
origin: webgpu.webgpu_api.Origin3d = <factory>,
aspect: webgpu.webgpu_api.TextureAspect = <TextureAspect.all: 'all'>,
)#

Bases: BaseWebGPUObject

aspect: TextureAspect = 'all'#
mipLevel: int = 0#
origin: Origin3d#
texture: Texture#
class webgpu.webgpu_api.Texture(handle)#

Bases: BaseWebGPUHandle

createView(
descriptor: TextureViewDescriptor | None = None,
) TextureView#
property depthOrArrayLayers: int#
destroy() None#
property dimension: str#
property format: TextureFormat#
property height: int#
property mipLevelCount: int#
property sampleCount: int#
property usage: TextureUsage#
property width: int#
class webgpu.webgpu_api.TextureAspect(value)#

Bases: str, Enum

all = 'all'#
depth_only = 'depth-only'#
stencil_only = 'stencil-only'#
class webgpu.webgpu_api.TextureBindingLayout(
sampleType: webgpu.webgpu_api.TextureSampleType = <TextureSampleType.float: 'float'>,
viewDimension: str = '2d',
multisampled: bool = False,
)#

Bases: BaseWebGPUObject

multisampled: bool = False#
sampleType: TextureSampleType = 'float'#
viewDimension: str = '2d'#
class webgpu.webgpu_api.TextureDescriptor(
size: list,
usage: webgpu.webgpu_api.TextureUsage,
format: webgpu.webgpu_api.TextureFormat,
sampleCount: int = 1,
dimension: str = '2d',
mipLevelCount: int = 1,
viewFormats: list['TextureFormat'] | None = None,
label: str = '',
)#

Bases: BaseWebGPUObject

dimension: str = '2d'#
format: TextureFormat#
label: str = ''#
mipLevelCount: int = 1#
sampleCount: int = 1#
size: list#
usage: TextureUsage#
viewFormats: list[TextureFormat] | None = None#
webgpu.webgpu_api.TextureDimensionInt2Str(dim: int)#
class webgpu.webgpu_api.TextureFormat(value)#

Bases: str, Enum

astc_10x10_unorm = 'astc-10x10-unorm'#
astc_10x10_unorm_srgb = 'astc-10x10-unorm-srgb'#
astc_10x5_unorm = 'astc-10x5-unorm'#
astc_10x5_unorm_srgb = 'astc-10x5-unorm-srgb'#
astc_10x6_unorm = 'astc-10x6-unorm'#
astc_10x6_unorm_srgb = 'astc-10x6-unorm-srgb'#
astc_10x8_unorm = 'astc-10x8-unorm'#
astc_10x8_unorm_srgb = 'astc-10x8-unorm-srgb'#
astc_12x10_unorm = 'astc-12x10-unorm'#
astc_12x10_unorm_srgb = 'astc-12x10-unorm-srgb'#
astc_12x12_unorm = 'astc-12x12-unorm'#
astc_12x12_unorm_srgb = 'astc-12x12-unorm-srgb'#
astc_4x4_unorm = 'astc-4x4-unorm'#
astc_4x4_unorm_srgb = 'astc-4x4-unorm-srgb'#
astc_5x4_unorm = 'astc-5x4-unorm'#
astc_5x4_unorm_srgb = 'astc-5x4-unorm-srgb'#
astc_5x5_unorm = 'astc-5x5-unorm'#
astc_5x5_unorm_srgb = 'astc-5x5-unorm-srgb'#
astc_6x5_unorm = 'astc-6x5-unorm'#
astc_6x5_unorm_srgb = 'astc-6x5-unorm-srgb'#
astc_6x6_unorm = 'astc-6x6-unorm'#
astc_6x6_unorm_srgb = 'astc-6x6-unorm-srgb'#
astc_8x5_unorm = 'astc-8x5-unorm'#
astc_8x5_unorm_srgb = 'astc-8x5-unorm-srgb'#
astc_8x6_unorm = 'astc-8x6-unorm'#
astc_8x6_unorm_srgb = 'astc-8x6-unorm-srgb'#
astc_8x8_unorm = 'astc-8x8-unorm'#
astc_8x8_unorm_srgb = 'astc-8x8-unorm-srgb'#
bc1_rgba_unorm = 'bc1-rgba-unorm'#
bc1_rgba_unorm_srgb = 'bc1-rgba-unorm-srgb'#
bc2_rgba_unorm = 'bc2-rgba-unorm'#
bc2_rgba_unorm_srgb = 'bc2-rgba-unorm-srgb'#
bc3_rgba_unorm = 'bc3-rgba-unorm'#
bc3_rgba_unorm_srgb = 'bc3-rgba-unorm-srgb'#
bc4_r_snorm = 'bc4-r-snorm'#
bc4_r_unorm = 'bc4-r-unorm'#
bc5_rg_snorm = 'bc5-rg-snorm'#
bc5_rg_unorm = 'bc5-rg-unorm'#
bc6h_rgb_float = 'bc6h-rgb-float'#
bc6h_rgb_ufloat = 'bc6h-rgb-ufloat'#
bc7_rgba_unorm = 'bc7-rgba-unorm'#
bc7_rgba_unorm_srgb = 'bc7-rgba-unorm-srgb'#
bgra8unorm = 'bgra8unorm'#
bgra8unorm_srgb = 'bgra8unorm-srgb'#
depth16unorm = 'depth16unorm'#
depth24plus = 'depth24plus'#
depth24plus_stencil8 = 'depth24plus-stencil8'#
depth32float = 'depth32float'#
depth32float_stencil8 = 'depth32float-stencil8'#
eac_r11snorm = 'eac-r11snorm'#
eac_r11unorm = 'eac-r11unorm'#
eac_rg11snorm = 'eac-rg11snorm'#
eac_rg11unorm = 'eac-rg11unorm'#
etc2_rgb8a1unorm = 'etc2-rgb8a1unorm'#
etc2_rgb8a1unorm_srgb = 'etc2-rgb8a1unorm-srgb'#
etc2_rgb8unorm = 'etc2-rgb8unorm'#
etc2_rgb8unorm_srgb = 'etc2-rgb8unorm-srgb'#
etc2_rgba8unorm = 'etc2-rgba8unorm'#
etc2_rgba8unorm_srgb = 'etc2-rgba8unorm-srgb'#
r16float = 'r16float'#
r16sint = 'r16sint'#
r16uint = 'r16uint'#
r32float = 'r32float'#
r32sint = 'r32sint'#
r32uint = 'r32uint'#
r8sint = 'r8sint'#
r8snorm = 'r8snorm'#
r8uint = 'r8uint'#
r8unorm = 'r8unorm'#
rg11b10ufloat = 'rg11b10ufloat'#
rg16float = 'rg16float'#
rg16sint = 'rg16sint'#
rg16uint = 'rg16uint'#
rg32float = 'rg32float'#
rg32sint = 'rg32sint'#
rg32uint = 'rg32uint'#
rg8sint = 'rg8sint'#
rg8snorm = 'rg8snorm'#
rg8uint = 'rg8uint'#
rg8unorm = 'rg8unorm'#
rgb10a2uint = 'rgb10a2uint'#
rgb10a2unorm = 'rgb10a2unorm'#
rgb9e5ufloat = 'rgb9e5ufloat'#
rgba16float = 'rgba16float'#
rgba16sint = 'rgba16sint'#
rgba16uint = 'rgba16uint'#
rgba32float = 'rgba32float'#
rgba32sint = 'rgba32sint'#
rgba32uint = 'rgba32uint'#
rgba8sint = 'rgba8sint'#
rgba8snorm = 'rgba8snorm'#
rgba8uint = 'rgba8uint'#
rgba8unorm = 'rgba8unorm'#
rgba8unorm_srgb = 'rgba8unorm-srgb'#
stencil8 = 'stencil8'#
class webgpu.webgpu_api.TextureSampleType(value)#

Bases: str, Enum

depth = 'depth'#
float = 'float'#
sint = 'sint'#
uint = 'uint'#
unfilterable_float = 'unfilterable_float'#
class webgpu.webgpu_api.TextureUsage(value)#

Bases: IntFlag

COPY_DST = 2#
COPY_SRC = 1#
NONE = 0#
RENDER_ATTACHMENT = 16#
STORAGE_BINDING = 8#
TEXTURE_BINDING = 4#
class webgpu.webgpu_api.TextureView(handle)#

Bases: BaseWebGPUHandle

class webgpu.webgpu_api.TextureViewDescriptor(
format: webgpu.webgpu_api.TextureFormat,
dimension: str,
baseMipLevel: int = 0,
mipLevelCount: int = 1,
baseArrayLayer: int = 0,
arrayLayerCount: int = 0,
aspect: webgpu.webgpu_api.TextureAspect = <TextureAspect.all: 'all'>,
usage: webgpu.webgpu_api.TextureUsage = <TextureUsage.NONE: 0>,
label: str = '',
)#

Bases: BaseWebGPUObject

arrayLayerCount: int = 0#
aspect: TextureAspect = 'all'#
baseArrayLayer: int = 0#
baseMipLevel: int = 0#
dimension: str#
format: TextureFormat#
label: str = ''#
mipLevelCount: int = 1#
usage: TextureUsage = 0#
class webgpu.webgpu_api.VertexAttribute(
format: webgpu.webgpu_api.VertexFormat,
offset: int,
shaderLocation: int,
)#

Bases: BaseWebGPUObject

format: VertexFormat#
offset: int#
shaderLocation: int#
class webgpu.webgpu_api.VertexBufferLayout(
arrayStride: int,
stepMode: webgpu.webgpu_api.VertexStepMode = <VertexStepMode.vertex: 'vertex'>,
attributes: list['VertexAttribute'] = <factory>,
)#

Bases: BaseWebGPUObject

arrayStride: int#
attributes: list[VertexAttribute]#
stepMode: VertexStepMode = 'vertex'#
class webgpu.webgpu_api.VertexFormat(value)#

Bases: str, Enum

float16 = 'float16'#
float16x2 = 'float16x2'#
float16x4 = 'float16x4'#
float32 = 'float32'#
float32x2 = 'float32x2'#
float32x3 = 'float32x3'#
float32x4 = 'float32x4'#
sint16 = 'sint16'#
sint16x2 = 'sint16x2'#
sint16x4 = 'sint16x4'#
sint32 = 'sint32'#
sint32x2 = 'sint32x2'#
sint32x3 = 'sint32x3'#
sint32x4 = 'sint32x4'#
sint8 = 'sint8'#
sint8x2 = 'sint8x2'#
sint8x4 = 'sint8x4'#
snorm16 = 'snorm16'#
snorm16x2 = 'snorm16x2'#
snorm16x4 = 'snorm16x4'#
snorm8 = 'snorm8'#
snorm8x2 = 'snorm8x2'#
snorm8x4 = 'snorm8x4'#
uint16 = 'uint16'#
uint16x2 = 'uint16x2'#
uint16x4 = 'uint16x4'#
uint32 = 'uint32'#
uint32x2 = 'uint32x2'#
uint32x3 = 'uint32x3'#
uint32x4 = 'uint32x4'#
uint8 = 'uint8'#
uint8x2 = 'uint8x2'#
uint8x4 = 'uint8x4'#
unorm10__10__10__2 = 'unorm10__10__10__2'#
unorm16 = 'unorm16'#
unorm16x2 = 'unorm16x2'#
unorm16x4 = 'unorm16x4'#
unorm8 = 'unorm8'#
unorm8x2 = 'unorm8x2'#
unorm8x4 = 'unorm8x4'#
unorm8x4_B_G_R_A = 'unorm8x4_B_G_R_A'#
class webgpu.webgpu_api.VertexState(
module: 'ShaderModule',
entryPoint: str = '',
buffers: list['VertexBufferLayout'] = <factory>,
)#

Bases: BaseWebGPUObject

buffers: list[VertexBufferLayout]#
entryPoint: str = ''#
module: ShaderModule#
class webgpu.webgpu_api.VertexStepMode(value)#

Bases: str, Enum

instance = 'instance'#
vertex = 'vertex'#
webgpu.webgpu_api.fromJS(obj)#
webgpu.webgpu_api.print_communications(func)#
webgpu.webgpu_api.print_time(func)#
async webgpu.webgpu_api.requestAdapter(
featureLevel: FeatureLevel | None = None,
powerPreference: PowerPreference | None = None,
forceFallbackAdapter: bool = False,
xrCompatible: bool = False,
) Adapter#

Platform and linking#

Platform specific code, currenty there are two possibilities:

  1. Running in a browser with Pyodide Webgpu calls are done directly in the browser using the Pyodide interface provided by the “js” module.

  2. Running in a Python environment with a websocket connection to a browser Webgpu calls are transferred via a websocket connection to the browser environment (using the webgpu.link.websocket module)

class webgpu.platform.JsPromise#

Bases: object

webgpu.platform.create_event_handler(
func,
prevent_default=True,
stop_propagation=False,
stop_immediate_propagation=False,
return_value=None,
)#
webgpu.platform.execute_when_init(func)#

Register a callback to run once the JS side is ready.

If the platform has already been initialized, the callback is executed immediately. Otherwise it is queued and executed from init once the websocket connection has been established and js is set.

webgpu.platform.init(before_wait_for_connection=None, block_on_connection: bool = True)#

Initialize the websocket link to the browser.

In the default (classic Jupyter) mode, this blocks until the browser has connected via websocket so that js is ready to use.

In environments like VS Code notebooks, outputs are typically only processed once the cell has finished executing. In that situation calling init with block_on_connection=False avoids a deadlock by moving the blocking wait_for_connection part to a background thread. Code that depends on js should use execute_when_init() so it runs once the connection is ready.

webgpu.platform.init_pyodide(link_)#
webgpu.platform.toJS(x)#
class webgpu.link.base.AttrDict(*args, **kwargs)#

Bases: dict

class webgpu.link.base.LinkBase#

Bases: object

call(id, args=[], parent_id=None, ignore_result=False, prop=None)#
call_method(id=None, prop=None, args=[], ignore_result=False)#
call_method_ignore_return(id=None, prop=None, args=[])#
call_new(id=None, prop=None, args=[], ignore_result=False)#
create_handle(obj)#
create_proxy(func, ignore_return_value=False)#
destroy_proxy(proxy)#
expose(name: str, obj)#
get(id, prop: str | None = None)#
get_item(id, key)#
get_keys(id)#
static register_serializer(type_, serializer)#
set(id, prop, value)#
set_item(id, key, value)#
class webgpu.link.base.LinkBaseAsync#

Bases: LinkBase

create_proxy(func, ignore_return_value=False)#
wait_for_connection()#

Bases: LinkBase

create_proxy(func, ignore_return_value=False)#
class webgpu.link.proxy.Proxy(link, parent_id=None, id=None)#

Bases: object

class webgpu.link.websocket.WebsocketLinkBase#

Bases: LinkBaseAsync

wait_for_connection()#
wait_for_server_running()#
class webgpu.link.websocket.WebsocketLinkClient(url)#

Bases: WebsocketLinkBase

class webgpu.link.websocket.WebsocketLinkServer#

Bases: WebsocketLinkBase

property port#
stop()#