Crate dawn_sys

Source
Expand description

dawn-sys provides unsafe Rust bindings for Dawn, the open-source and cross-platform implementation of the WebGPU standard that powers Google Chrome, Microsoft Edge, and other Chromium-based browsers. More precisely, it provides:

  • Unsafe bindings to webgpu.h, which is a one-to-one mapping of the WebGPU IDL. This crate mainly exposes bindings generated using rust-bindgen but also revamps some details for a more handy API.
  • Pre-built Dawn binaries (webgpu_dawn.dll), kindly provided by Mārtiņš Možeiko’s build-dawn automation on GitHub Actions that rebuilds the Dawn binaries once per week. This crate contains a build script that handles chores like copying necessary binaries to the output directory, making everything ready out of the box.

If you are looking for safe and idiomatic Rust wrappers for Dawn or webgpu.h, you should consider dawn-rs instead of this crate, which provides higher-level and more “Rust-style” abstractions based on this crate. If you are just looking for a higher-level graphics API wrapper and guarenteed consistent behavior and performance with mainstream browsers (Google Chrome, Microsoft Edge, …) isn’t one your major concerns, please also try wgpu before reaching for dawn-rs or dawn-sys. wgpu is another open source and cross-platform implementation of the WebGPU specification that is fully written in Rust and is used in Mozilla Firefox, Servo and Deno for WebGPU support. It also serves as the de-facto standard of high-level, cross-platform graphics development in the Rust ecosystem.

This crate is still a work in progress. USE AT YOUR OWN RISK. It should serve in most common cases but may lack certain APIs or fail on corner cases. The aforementioned wgpu crate is way more mature and should always be considered ahead of this crate.

This crate is currently Windows-only. Given the cross-platform capabilities of Dawn, it is planned to eventually support macOS, Linux and web in the long term, but it is not currently a key focus of the maintainer of this crate. If you’d like to help, you are welcome to open an issue for further discussion.

This crate assumes your familiarity with GPU development using webgpu.h, the WebGPU C API. Because of this (and also considering that currently a large part of webgpu.h APIs have still not been documented yet :(), this crate is not providing rustdoc for a large part of its exported items except for those that have been well documented in webgpu.h and those that are re-exported in dawn-rs. Completing the missing docs in webgpu.h is not currently a key focus of the maintainer of this crate. If you’d like to help, please contribute to WebGPU-Headers and this crate will follow upstream updates.

This crate is licensed under the BSD-3-Clause license, aligning to Dawn and WebGPU-Headers. This whole repository is also licensed under the GNU General Public License, Version 3.0, see README.md at the repository root.

This crate welcomes all kind of contributions. Open an issue or PR at any time for bugfixes or feature requests.

Structs§

WGPUAdapterInfo
WGPUAdapterTypeIter
An iterator over the variants of WGPUAdapterType
WGPUAddressModeIter
An iterator over the variants of WGPUAddressMode
WGPUBackendTypeIter
An iterator over the variants of WGPUBackendType
WGPUBindGroupDescriptor
WGPUBindGroupEntry
WGPUBindGroupLayoutDescriptor
WGPUBindGroupLayoutEntry
WGPUBlendComponent
WGPUBlendFactorIter
An iterator over the variants of WGPUBlendFactor
WGPUBlendOperationIter
An iterator over the variants of WGPUBlendOperation
WGPUBlendState
WGPUBufferBindingLayout
WGPUBufferBindingTypeIter
An iterator over the variants of WGPUBufferBindingType
WGPUBufferDescriptor
WGPUBufferMapCallbackInfo
WGPUBufferMapStateIter
An iterator over the variants of WGPUBufferMapState
WGPUBufferUsage
WGPUCallbackModeIter
An iterator over the variants of WGPUCallbackMode
WGPUChainedStruct
WGPUColor
WGPUColorTargetState
WGPUColorWriteMask
WGPUCommandBufferDescriptor
WGPUCommandEncoderDescriptor
WGPUCompareFunctionIter
An iterator over the variants of WGPUCompareFunction
WGPUCompilationInfo
WGPUCompilationInfoCallbackInfo
WGPUCompilationInfoRequestStatusIter
An iterator over the variants of WGPUCompilationInfoRequestStatus
WGPUCompilationMessage
WGPUCompilationMessageTypeIter
An iterator over the variants of WGPUCompilationMessageType
WGPUCompositeAlphaModeIter
An iterator over the variants of WGPUCompositeAlphaMode
WGPUComputePassDescriptor
WGPUComputePipelineDescriptor
WGPUComputeState
WGPUConstantEntry
WGPUCreateComputePipelineAsyncCallbackInfo
WGPUCreatePipelineAsyncStatusIter
An iterator over the variants of WGPUCreatePipelineAsyncStatus
WGPUCreateRenderPipelineAsyncCallbackInfo
WGPUCullModeIter
An iterator over the variants of WGPUCullMode
WGPUDepthStencilState
WGPUDeviceDescriptor
WGPUDeviceLostCallbackInfo
WGPUDeviceLostReasonIter
An iterator over the variants of WGPUDeviceLostReason
WGPUErrorFilterIter
An iterator over the variants of WGPUErrorFilter
WGPUErrorTypeIter
An iterator over the variants of WGPUErrorType
WGPUExtent3D
WGPUFeatureLevelIter
An iterator over the variants of WGPUFeatureLevel
WGPUFeatureNameIter
An iterator over the variants of WGPUFeatureName
WGPUFilterModeIter
An iterator over the variants of WGPUFilterMode
WGPUFragmentState
WGPUFrontFaceIter
An iterator over the variants of WGPUFrontFace
WGPUFuture
WGPUFutureWaitInfo
WGPUIndexFormatIter
An iterator over the variants of WGPUIndexFormat
WGPUInstanceDescriptor
WGPUInstanceFeatureNameIter
An iterator over the variants of WGPUInstanceFeatureName
WGPUInstanceLimits
WGPULimits
WGPULoadOpIter
An iterator over the variants of WGPULoadOp
WGPUMapAsyncStatusIter
An iterator over the variants of WGPUMapAsyncStatus
WGPUMapMode
WGPUMipmapFilterModeIter
An iterator over the variants of WGPUMipmapFilterMode
WGPUMultisampleState
WGPUOptionalBoolIter
An iterator over the variants of WGPUOptionalBool
WGPUOrigin3D
WGPUPassTimestampWrites
WGPUPipelineLayoutDescriptor
WGPUPopErrorScopeCallbackInfo
WGPUPopErrorScopeStatusIter
An iterator over the variants of WGPUPopErrorScopeStatus
WGPUPowerPreferenceIter
An iterator over the variants of WGPUPowerPreference
WGPUPredefinedColorSpaceIter
An iterator over the variants of WGPUPredefinedColorSpace
WGPUPresentModeIter
An iterator over the variants of WGPUPresentMode
WGPUPrimitiveState
WGPUPrimitiveTopologyIter
An iterator over the variants of WGPUPrimitiveTopology
WGPUQuerySetDescriptor
WGPUQueryTypeIter
An iterator over the variants of WGPUQueryType
WGPUQueueDescriptor
WGPUQueueWorkDoneCallbackInfo
WGPUQueueWorkDoneStatusIter
An iterator over the variants of WGPUQueueWorkDoneStatus
WGPURenderBundleDescriptor
WGPURenderBundleEncoderDescriptor
WGPURenderPassColorAttachment
WGPURenderPassDepthStencilAttachment
WGPURenderPassDescriptor
WGPURenderPassMaxDrawCount
WGPURenderPipelineDescriptor
WGPURequestAdapterCallbackInfo
WGPURequestAdapterOptions
WGPURequestAdapterStatusIter
An iterator over the variants of WGPURequestAdapterStatus
WGPURequestAdapterWebXROptions
WGPURequestDeviceCallbackInfo
WGPURequestDeviceStatusIter
An iterator over the variants of WGPURequestDeviceStatus
WGPUSTypeIter
An iterator over the variants of WGPUSType
WGPUSamplerBindingLayout
WGPUSamplerBindingTypeIter
An iterator over the variants of WGPUSamplerBindingType
WGPUSamplerDescriptor
WGPUShaderModuleDescriptor
WGPUShaderSourceSPIRV
WGPUShaderSourceWGSL
WGPUShaderStage
WGPUStatusIter
An iterator over the variants of WGPUStatus
WGPUStencilFaceState
WGPUStencilOperationIter
An iterator over the variants of WGPUStencilOperation
WGPUStorageTextureAccessIter
An iterator over the variants of WGPUStorageTextureAccess
WGPUStorageTextureBindingLayout
WGPUStoreOpIter
An iterator over the variants of WGPUStoreOp
WGPUStringView
WGPUSupportedFeatures
WGPUSupportedInstanceFeatures
WGPUSupportedWGSLLanguageFeatures
WGPUSurfaceCapabilities
WGPUSurfaceColorManagement
WGPUSurfaceConfiguration
WGPUSurfaceDescriptor
WGPUSurfaceGetCurrentTextureStatusIter
An iterator over the variants of WGPUSurfaceGetCurrentTextureStatus
WGPUSurfaceSourceAndroidNativeWindow
WGPUSurfaceSourceMetalLayer
WGPUSurfaceSourceWaylandSurface
WGPUSurfaceSourceWindowsHWND
WGPUSurfaceSourceXCBWindow
WGPUSurfaceSourceXlibWindow
WGPUSurfaceTexture
WGPUTexelCopyBufferInfo
WGPUTexelCopyBufferLayout
WGPUTexelCopyTextureInfo
WGPUTextureAspectIter
An iterator over the variants of WGPUTextureAspect
WGPUTextureBindingLayout
WGPUTextureDescriptor
WGPUTextureDimensionIter
An iterator over the variants of WGPUTextureDimension
WGPUTextureFormatIter
An iterator over the variants of WGPUTextureFormat
WGPUTextureSampleTypeIter
An iterator over the variants of WGPUTextureSampleType
WGPUTextureUsage
WGPUTextureViewDescriptor
WGPUTextureViewDimensionIter
An iterator over the variants of WGPUTextureViewDimension
WGPUToneMappingModeIter
An iterator over the variants of WGPUToneMappingMode
WGPUUncapturedErrorCallbackInfo
WGPUVertexAttribute
WGPUVertexBufferLayout
WGPUVertexFormatIter
An iterator over the variants of WGPUVertexFormat
WGPUVertexState
WGPUVertexStepModeIter
An iterator over the variants of WGPUVertexStepMode
WGPUWGSLLanguageFeatureNameIter
An iterator over the variants of WGPUWGSLLanguageFeatureName
WGPUWaitStatusIter
An iterator over the variants of WGPUWaitStatus

Enums§

WGPUAdapterType
WGPUAddressMode
WGPUBackendType
WGPUBlendFactor
WGPUBlendOperation
WGPUBufferBindingType
WGPUBufferMapState
WGPUCallbackMode
WGPUCompareFunction
WGPUCompilationInfoRequestStatus
WGPUCompilationMessageType
WGPUCompositeAlphaMode
WGPUCreatePipelineAsyncStatus
WGPUCullMode
WGPUDeviceLostReason
WGPUErrorFilter
WGPUErrorType
WGPUFeatureLevel
WGPUFeatureName
WGPUFilterMode
WGPUFrontFace
WGPUIndexFormat
WGPUInstanceFeatureName
WGPULoadOp
WGPUMapAsyncStatus
WGPUMipmapFilterMode
WGPUOptionalBool
WGPUPopErrorScopeStatus
WGPUPowerPreference
WGPUPredefinedColorSpace
WGPUPresentMode
WGPUPrimitiveTopology
WGPUQueryType
WGPUQueueWorkDoneStatus
WGPURequestAdapterStatus
WGPURequestDeviceStatus
WGPUSType
WGPUSamplerBindingType
WGPUStatus
WGPUStencilOperation
WGPUStorageTextureAccess
WGPUStoreOp
WGPUSurfaceGetCurrentTextureStatus
WGPUTextureAspect
WGPUTextureDimension
WGPUTextureFormat
WGPUTextureSampleType
WGPUTextureViewDimension
WGPUToneMappingMode
WGPUVertexFormat
WGPUVertexStepMode
WGPUWGSLLanguageFeatureName
WGPUWaitStatus

Constants§

WGPU_ARRAY_LAYER_COUNT_UNDEFINED
Indicates no array layer count is specified.
WGPU_COPY_STRIDE_UNDEFINED
Indicates no copy stride is specified.
WGPU_DEPTH_CLEAR_VALUE_UNDEFINED
Indicates no depth clear value is specified.
WGPU_DEPTH_SLICE_UNDEFINED
Indicates no depth slice is specified.
WGPU_FALSE
false value of WGPUBool.
WGPU_LIMIT_U32_UNDEFINED
For u32 limits, indicates no limit value is specified.
WGPU_LIMIT_U64_UNDEFINED
For u64 limits, indicates no limit value is specified.
WGPU_MIP_LEVEL_COUNT_UNDEFINED
Indicates no mip level count is specified.
WGPU_QUERY_SET_INDEX_UNDEFINED
Indicates no query set index is specified.
WGPU_STRLEN
Sentinel value used in WGPUStringView.
WGPU_TRUE
true value of WGPUBool.
WGPU_WHOLE_MAP_SIZE
Indicates a size extending to the end of the buffer.
WGPU_WHOLE_SIZE
Indicates a size extending to the end of the buffer.

Functions§

wgpuAdapterAddRef
wgpuAdapterGetFeatures
wgpuAdapterGetInfo
wgpuAdapterGetLimits
wgpuAdapterHasFeature
wgpuAdapterRelease
wgpuAdapterRequestDevice
wgpuBindGroupAddRef
wgpuBindGroupLayoutAddRef
wgpuBindGroupLayoutRelease
wgpuBindGroupLayoutSetLabel
wgpuBindGroupRelease
wgpuBindGroupSetLabel
wgpuBufferAddRef
wgpuBufferDestroy
wgpuBufferGetConstMappedRange
wgpuBufferGetMapState
wgpuBufferGetMappedRange
wgpuBufferGetSize
wgpuBufferGetUsage
wgpuBufferMapAsync
wgpuBufferReadMappedRange
wgpuBufferRelease
wgpuBufferSetLabel
wgpuBufferUnmap
wgpuBufferWriteMappedRange
wgpuCommandBufferAddRef
wgpuCommandBufferRelease
wgpuCommandBufferSetLabel
wgpuCommandEncoderAddRef
wgpuCommandEncoderBeginComputePass
wgpuCommandEncoderBeginRenderPass
wgpuCommandEncoderClearBuffer
wgpuCommandEncoderCopyBufferToBuffer
wgpuCommandEncoderCopyBufferToTexture
wgpuCommandEncoderCopyTextureToBuffer
wgpuCommandEncoderCopyTextureToTexture
wgpuCommandEncoderFinish
wgpuCommandEncoderInsertDebugMarker
wgpuCommandEncoderPopDebugGroup
wgpuCommandEncoderPushDebugGroup
wgpuCommandEncoderRelease
wgpuCommandEncoderResolveQuerySet
wgpuCommandEncoderSetLabel
wgpuCommandEncoderWriteTimestamp
wgpuComputePassEncoderAddRef
wgpuComputePassEncoderDispatchWorkgroups
wgpuComputePassEncoderDispatchWorkgroupsIndirect
wgpuComputePassEncoderEnd
wgpuComputePassEncoderInsertDebugMarker
wgpuComputePassEncoderPopDebugGroup
wgpuComputePassEncoderPushDebugGroup
wgpuComputePassEncoderRelease
wgpuComputePassEncoderSetBindGroup
wgpuComputePassEncoderSetLabel
wgpuComputePassEncoderSetPipeline
wgpuComputePipelineAddRef
wgpuComputePipelineGetBindGroupLayout
wgpuComputePipelineRelease
wgpuComputePipelineSetLabel
wgpuCreateInstance
wgpuDeviceAddRef
wgpuDeviceCreateBindGroup
wgpuDeviceCreateBindGroupLayout
wgpuDeviceCreateBuffer
wgpuDeviceCreateCommandEncoder
wgpuDeviceCreateComputePipeline
wgpuDeviceCreateComputePipelineAsync
wgpuDeviceCreatePipelineLayout
wgpuDeviceCreateQuerySet
wgpuDeviceCreateRenderBundleEncoder
wgpuDeviceCreateRenderPipeline
wgpuDeviceCreateRenderPipelineAsync
wgpuDeviceCreateSampler
wgpuDeviceCreateShaderModule
wgpuDeviceCreateTexture
wgpuDeviceDestroy
wgpuDeviceGetAdapterInfo
wgpuDeviceGetFeatures
wgpuDeviceGetLimits
wgpuDeviceGetLostFuture
wgpuDeviceGetQueue
wgpuDeviceHasFeature
wgpuDevicePopErrorScope
wgpuDevicePushErrorScope
wgpuDeviceRelease
wgpuDeviceSetLabel
wgpuGetInstanceFeatures
wgpuGetInstanceLimits
wgpuHasInstanceFeature
wgpuInstanceAddRef
wgpuInstanceCreateSurface
wgpuInstanceGetWGSLLanguageFeatures
wgpuInstanceHasWGSLLanguageFeature
wgpuInstanceProcessEvents
wgpuInstanceRelease
wgpuInstanceRequestAdapter
wgpuInstanceWaitAny
wgpuPipelineLayoutAddRef
wgpuPipelineLayoutRelease
wgpuPipelineLayoutSetLabel
wgpuQuerySetAddRef
wgpuQuerySetDestroy
wgpuQuerySetGetCount
wgpuQuerySetGetType
wgpuQuerySetRelease
wgpuQuerySetSetLabel
wgpuQueueAddRef
wgpuQueueOnSubmittedWorkDone
wgpuQueueRelease
wgpuQueueSetLabel
wgpuQueueSubmit
wgpuQueueWriteBuffer
wgpuQueueWriteTexture
wgpuRenderBundleAddRef
wgpuRenderBundleEncoderAddRef
wgpuRenderBundleEncoderDraw
wgpuRenderBundleEncoderDrawIndexed
wgpuRenderBundleEncoderDrawIndexedIndirect
wgpuRenderBundleEncoderDrawIndirect
wgpuRenderBundleEncoderFinish
wgpuRenderBundleEncoderInsertDebugMarker
wgpuRenderBundleEncoderPopDebugGroup
wgpuRenderBundleEncoderPushDebugGroup
wgpuRenderBundleEncoderRelease
wgpuRenderBundleEncoderSetBindGroup
wgpuRenderBundleEncoderSetIndexBuffer
wgpuRenderBundleEncoderSetLabel
wgpuRenderBundleEncoderSetPipeline
wgpuRenderBundleEncoderSetVertexBuffer
wgpuRenderBundleRelease
wgpuRenderBundleSetLabel
wgpuRenderPassEncoderAddRef
wgpuRenderPassEncoderBeginOcclusionQuery
wgpuRenderPassEncoderDraw
wgpuRenderPassEncoderDrawIndexed
wgpuRenderPassEncoderDrawIndexedIndirect
wgpuRenderPassEncoderDrawIndirect
wgpuRenderPassEncoderEnd
wgpuRenderPassEncoderEndOcclusionQuery
wgpuRenderPassEncoderExecuteBundles
wgpuRenderPassEncoderInsertDebugMarker
wgpuRenderPassEncoderPopDebugGroup
wgpuRenderPassEncoderPushDebugGroup
wgpuRenderPassEncoderRelease
wgpuRenderPassEncoderSetBindGroup
wgpuRenderPassEncoderSetBlendConstant
wgpuRenderPassEncoderSetIndexBuffer
wgpuRenderPassEncoderSetLabel
wgpuRenderPassEncoderSetPipeline
wgpuRenderPassEncoderSetScissorRect
wgpuRenderPassEncoderSetStencilReference
wgpuRenderPassEncoderSetVertexBuffer
wgpuRenderPassEncoderSetViewport
wgpuRenderPipelineAddRef
wgpuRenderPipelineGetBindGroupLayout
wgpuRenderPipelineRelease
wgpuRenderPipelineSetLabel
wgpuSamplerAddRef
wgpuSamplerRelease
wgpuSamplerSetLabel
wgpuShaderModuleAddRef
wgpuShaderModuleGetCompilationInfo
wgpuShaderModuleRelease
wgpuShaderModuleSetLabel
wgpuSurfaceAddRef
wgpuSurfaceConfigure
wgpuSurfaceGetCapabilities
wgpuSurfaceGetCurrentTexture
wgpuSurfacePresent
wgpuSurfaceRelease
wgpuSurfaceSetLabel
wgpuSurfaceUnconfigure
wgpuTextureAddRef
wgpuTextureCreateView
wgpuTextureDestroy
wgpuTextureGetDepthOrArrayLayers
wgpuTextureGetDimension
wgpuTextureGetFormat
wgpuTextureGetHeight
wgpuTextureGetMipLevelCount
wgpuTextureGetSampleCount
wgpuTextureGetUsage
wgpuTextureGetWidth
wgpuTextureRelease
wgpuTextureSetLabel
wgpuTextureViewAddRef
wgpuTextureViewRelease
wgpuTextureViewSetLabel

Type Aliases§

WGPUAdapter
WGPUBindGroup
WGPUBindGroupLayout
WGPUBool
WGPUBuffer
WGPUBufferMapCallback
WGPUCommandBuffer
WGPUCommandEncoder
WGPUCompilationInfoCallback
WGPUComputePassEncoder
WGPUComputePipeline
WGPUCreateComputePipelineAsyncCallback
WGPUCreateRenderPipelineAsyncCallback
WGPUDevice
WGPUDeviceLostCallback
WGPUFlags
WGPUInstance
WGPUPipelineLayout
WGPUPopErrorScopeCallback
WGPUQuerySet
WGPUQueue
WGPUQueueWorkDoneCallback
WGPURenderBundle
WGPURenderBundleEncoder
WGPURenderPassEncoder
WGPURenderPipeline
WGPURequestAdapterCallback
WGPURequestDeviceCallback
WGPUSampler
WGPUShaderModule
WGPUSurface
WGPUTexture
WGPUTextureView
WGPUUncapturedErrorCallback