This repo contains a MoonBit port of the `wgpu-native` C API (WebGPU)
Dependencies
| Platform | Backend | Surface API |
|---|---|---|
| macOS | Metal | Instance::create_surface_metal_layer() |
| Linux (experimental) | Vulkan | Instance::create_surface_wayland() / create_surface_xcb() / create_surface_xlib() |
| Windows (experimental) | DX12 / Vulkan (via wgpu-native) | Instance::create_surface_windows_hwnd() / create_surface_swap_chain_panel() |
| Android (experimental) | Vulkan/OpenGLES (depends on native build) | Instance::create_surface_android_native_window() |
{
"import": [
{ "path": "Milky2018/wgpu_mbt", "alias": "wgpu" }
]
}fn main {
try {
let instance = @wgpu.Instance::create()
let adapter = instance.request_adapter_sync()
let device = adapter.request_device_sync(instance)
let queue = device.queue()
let buf = device.create_buffer(
size=4UL,
usage=@wgpu.BufferUsage::from_u64(@wgpu.BUFFER_USAGE_COPY_DST),
)
ignore(buf.size())
let shader = device.create_shader_module_wgsl(
#|@compute @workgroup_size(1)
#|fn main() {}
#|,
)
let pipeline = device.create_compute_pipeline(shader)
let encoder = device.create_command_encoder()
let pass = encoder.begin_compute_pass()
pass.set_pipeline(pipeline)
pass.dispatch_workgroups(1U, 1U, 1U)
pass.end()
pass.release()
let cmd = encoder.finish()
queue.submit_one(cmd)
cmd.release()
encoder.release()
pipeline.release()
shader.release()
buf.release()
queue.release()
device.release()
adapter.release()
instance.release()
} catch {
e => println(e.message())
}
}let config = @wgpu.SurfaceConfiguration::new(
width,
height,
usage,
format,
@wgpu.PresentMode::from_u32(present_mode_u32),
@wgpu.CompositeAlphaMode::from_u32(alpha_mode_u32),
)
.with_view_formats([format])
.with_desired_maximum_frame_latency(2U)
surface.configure_with_or_raise(adapter, device, config)type BufferSyncErrortype ComputePipelineDescErrortype OptionalSymbolErrortype QueueWorkDoneErrortype QueueWorkDoneWaitErrortype RenderPipelineDescErrortype SurfaceConfigureErrortype SurfacePresentErrortype SurfaceTextureErrortype WaitAnyErrorpub suberror WgpuError {
WgpuNativeUnavailable(String)
WgpuNativeUnsupported(String)
WgpuNativeMissingSymbol(String, String)
WgpuRequestAdapterFailed(UInt)
WgpuRequestDeviceFailed(UInt)
}fn Adapter::request_device_future_id_u64(self : Adapter, descriptor? : WGPUDeviceDescriptorPtr) -> UInt64fn Adapter::request_device_sync_with_features_and_limits(self : Adapter, instance : Instance, required_features_u32 : Array[UInt], max_bind_groups_u32? : UInt, max_dynamic_uniform_buffers_u32? : UInt, max_uniform_buffer_binding_size? : UInt64, max_storage_buffer_binding_size? : UInt64, max_push_constant_size_u32? : UInt, max_non_sampler_bindings_u32? : UInt, label? : String, queue_label? : String, trace_path? : String) -> Device raise WgpuErrorfn BindGroupBuilder::add_buffer(self : BindGroupBuilder, binding : UInt, buffer : Buffer, offset? : UInt64, size? : UInt64) -> Boolfn BindGroupBuilder::add_buffer_array(self : BindGroupBuilder, binding : UInt, buffers : Array[Buffer], offset? : UInt64, size? : UInt64) -> Boolfn BindGroupBuilder::add_sampler(self : BindGroupBuilder, binding : UInt, sampler : Sampler) -> Boolfn BindGroupBuilder::add_sampler_array(self : BindGroupBuilder, binding : UInt, samplers : Array[Sampler]) -> Boolfn BindGroupBuilder::add_texture_view(self : BindGroupBuilder, binding : UInt, view : TextureView) -> Boolfn BindGroupBuilder::add_texture_view_array(self : BindGroupBuilder, binding : UInt, views : Array[TextureView]) -> Boolfn BindGroupBuilder::finish(self : BindGroupBuilder, device : Device, layout : BindGroupLayout, label? : String) -> BindGroupfn BindGroupLayoutBuilder::add_buffer(self : BindGroupLayoutBuilder, binding : UInt, visibility : ShaderStage, type_u32 : UInt, has_dynamic_offset? : Bool, min_binding_size? : UInt64, count? : UInt) -> Boolfn BindGroupLayoutBuilder::add_sampler(self : BindGroupLayoutBuilder, binding : UInt, visibility : ShaderStage, type_u32 : UInt, count? : UInt) -> Boolfn BindGroupLayoutBuilder::add_storage_texture(self : BindGroupLayoutBuilder, binding : UInt, visibility : ShaderStage, access_u32 : UInt, format : TextureFormat, view_dimension_u32 : UInt, count? : UInt) -> Boolfn BindGroupLayoutBuilder::add_texture(self : BindGroupLayoutBuilder, binding : UInt, visibility : ShaderStage, sample_type_u32 : UInt, view_dimension_u32 : UInt, multisampled? : Bool, count? : UInt) -> Boolfn BindGroupLayoutBuilder::finish(self : BindGroupLayoutBuilder, device : Device, label? : String) -> BindGroupLayoutfn Buffer::map_read_sync_or_raise(self : Buffer, instance : Instance, offset : UInt64, size : UInt64) -> Bytes raise BufferSyncErrorfn Buffer::map_write_sync_or_raise(self : Buffer, instance : Instance, offset : UInt64, data : Bytes) -> Unit raise BufferSyncErrorfn Buffer::readback_or_raise(self : Buffer, instance : Instance, offset : UInt64, size : UInt64) -> Bytes raise BufferSyncErrorfn CommandEncoder::begin_compute_pass_ptr(self : CommandEncoder, descriptor : WGPUComputePassDescriptorPtr) -> ComputePassfn CommandEncoder::begin_compute_pass_raw(self : CommandEncoder, descriptor : WGPUComputePassDescriptorPtr) -> ComputePassfn CommandEncoder::begin_render_pass(self : CommandEncoder, descriptor : WGPURenderPassDescriptorPtr) -> RenderPassfn CommandEncoder::begin_render_pass_color2(self : CommandEncoder, view0 : TextureView, view1 : TextureView) -> RenderPassfn CommandEncoder::begin_render_pass_color2_depth(self : CommandEncoder, color0_view : TextureView, color1_view : TextureView, depth_view : TextureView) -> RenderPassfn CommandEncoder::begin_render_pass_color2_depth_u32(self : CommandEncoder, color0_view : TextureView, color1_view : TextureView, depth_view : TextureView, color0_load_op_u32? : UInt, color0_store_op_u32? : UInt, color0_clear_r_f32? : Float, color0_clear_g_f32? : Float, color0_clear_b_f32? : Float, color0_clear_a_f32? : Float, color1_load_op_u32? : UInt, color1_store_op_u32? : UInt, color1_clear_r_f32? : Float, color1_clear_g_f32? : Float, color1_clear_b_f32? : Float, color1_clear_a_f32? : Float, depth_load_op_u32? : UInt, depth_store_op_u32? : UInt, depth_clear_value_f32? : Float, depth_read_only? : Bool, stencil_load_op_u32? : UInt, stencil_store_op_u32? : UInt, stencil_clear_value_u32? : UInt, stencil_read_only? : Bool) -> RenderPassfn CommandEncoder::begin_render_pass_color_clear(self : CommandEncoder, view : TextureView, r : Float, g : Float, b : Float, a : Float) -> RenderPassfn CommandEncoder::begin_render_pass_color_depth(self : CommandEncoder, color_view : TextureView, depth_view : TextureView) -> RenderPassfn CommandEncoder::begin_render_pass_color_depth_u32(self : CommandEncoder, color_view : TextureView, depth_view : TextureView, color_load_op_u32? : UInt, color_store_op_u32? : UInt, color_clear_r_f32? : Float, color_clear_g_f32? : Float, color_clear_b_f32? : Float, color_clear_a_f32? : Float, depth_load_op_u32? : UInt, depth_store_op_u32? : UInt, depth_clear_value_f32? : Float, depth_read_only? : Bool, stencil_load_op_u32? : UInt, stencil_store_op_u32? : UInt, stencil_clear_value_u32? : UInt, stencil_read_only? : Bool) -> RenderPassfn CommandEncoder::begin_render_pass_color_load(self : CommandEncoder, view : TextureView) -> RenderPassfn CommandEncoder::begin_render_pass_color_occlusion(self : CommandEncoder, view : TextureView, query_set : QuerySet) -> RenderPassfn CommandEncoder::begin_render_pass_ptr(self : CommandEncoder, descriptor : WGPURenderPassDescriptorPtr) -> RenderPassfn CommandEncoder::clear_buffer(self : CommandEncoder, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn CommandEncoder::clear_buffer_raw(self : CommandEncoder, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn CommandEncoder::copy_buffer_to_buffer(self : CommandEncoder, source : Buffer, source_offset : UInt64, destination : Buffer, destination_offset : UInt64, size : UInt64) -> Unitfn CommandEncoder::copy_buffer_to_buffer_raw(self : CommandEncoder, source : Buffer, source_offset : UInt64, destination : Buffer, destination_offset : UInt64, size : UInt64) -> Unitfn CommandEncoder::copy_buffer_to_texture(self : CommandEncoder, source : WGPUTexelCopyBufferInfoPtr, destination : WGPUTexelCopyTextureInfoPtr, copy_size : WGPUExtent3DPtr) -> Unitfn CommandEncoder::copy_buffer_to_texture_ptr(self : CommandEncoder, source : WGPUTexelCopyBufferInfoPtr, destination : WGPUTexelCopyTextureInfoPtr, copy_size : WGPUExtent3DPtr) -> Unitfn CommandEncoder::copy_buffer_to_texture_rgba8(self : CommandEncoder, buffer : Buffer, texture : Texture, width : UInt, height : UInt) -> Unitfn CommandEncoder::copy_buffer_to_texture_rgba8_mip_layer(self : CommandEncoder, buffer : Buffer, texture : Texture, mip_level : UInt, array_layer : UInt, width : UInt, height : UInt) -> Unitfn CommandEncoder::copy_texture_to_buffer(self : CommandEncoder, source : WGPUTexelCopyTextureInfoPtr, destination : WGPUTexelCopyBufferInfoPtr, copy_size : WGPUExtent3DPtr) -> Unitfn CommandEncoder::copy_texture_to_buffer_bytes_per_pixel(self : CommandEncoder, texture : Texture, buffer : Buffer, width : UInt, height : UInt, bytes_per_pixel : UInt) -> Unitfn CommandEncoder::copy_texture_to_buffer_bytes_per_pixel_mip_layer(self : CommandEncoder, texture : Texture, mip_level : UInt, array_layer : UInt, buffer : Buffer, width : UInt, height : UInt, bytes_per_pixel : UInt) -> Unitfn CommandEncoder::copy_texture_to_buffer_ptr(self : CommandEncoder, source : WGPUTexelCopyTextureInfoPtr, destination : WGPUTexelCopyBufferInfoPtr, copy_size : WGPUExtent3DPtr) -> Unitfn CommandEncoder::copy_texture_to_buffer_rgba8(self : CommandEncoder, texture : Texture, buffer : Buffer, width : UInt, height : UInt) -> Unitfn CommandEncoder::copy_texture_to_buffer_rgba8_mip_layer(self : CommandEncoder, texture : Texture, mip_level : UInt, array_layer : UInt, buffer : Buffer, width : UInt, height : UInt) -> Unitfn CommandEncoder::copy_texture_to_texture(self : CommandEncoder, source : WGPUTexelCopyTextureInfoPtr, destination : WGPUTexelCopyTextureInfoPtr, copy_size : WGPUExtent3DPtr) -> Unitfn CommandEncoder::copy_texture_to_texture_ptr(self : CommandEncoder, source : WGPUTexelCopyTextureInfoPtr, destination : WGPUTexelCopyTextureInfoPtr, copy_size : WGPUExtent3DPtr) -> Unitfn CommandEncoder::copy_texture_to_texture_rgba8(self : CommandEncoder, src : Texture, dst : Texture, width : UInt, height : UInt) -> Unitfn CommandEncoder::copy_texture_to_texture_rgba8_mip_layer(self : CommandEncoder, src : Texture, src_mip_level : UInt, src_array_layer : UInt, dst : Texture, dst_mip_level : UInt, dst_array_layer : UInt, width : UInt, height : UInt) -> Unitfn CommandEncoder::finish_ptr(self : CommandEncoder, descriptor : WGPUCommandBufferDescriptorPtr) -> CommandBufferfn CommandEncoder::finish_raw(self : CommandEncoder, descriptor : WGPUCommandBufferDescriptorPtr) -> CommandBufferfn CommandEncoder::resolve_query_set(self : CommandEncoder, query_set : QuerySet, first_query : UInt, query_count : UInt, destination : Buffer, destination_offset : UInt64) -> Unitfn CommandEncoder::resolve_query_set_raw(self : CommandEncoder, query_set : QuerySet, first_query : UInt, query_count : UInt, destination : Buffer, destination_offset : UInt64) -> Unitfn CommandEncoder::write_timestamp(self : CommandEncoder, query_set : QuerySet, query_index : UInt) -> Unitfn CommandEncoder::write_timestamp_raw(self : CommandEncoder, query_set : QuerySet, query_index : UInt) -> Unitpub struct CompilationMessage {
type_u32 : UInt
line_num_u64 : UInt64
line_pos_u64 : UInt64
offset_u64 : UInt64
length_u64 : UInt64
text : String
}pub struct CompositeAlphaMode {
raw : UInt
}fn ComputePass::begin_pipeline_statistics_query(self : ComputePass, query_set : QuerySet, query_index : UInt) -> Unitfn ComputePass::begin_pipeline_statistics_query_raw(self : ComputePass, query_set : QuerySet, query_index : UInt) -> Unitfn ComputePass::dispatch_workgroups_indirect(self : ComputePass, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn ComputePass::dispatch_workgroups_indirect_raw(self : ComputePass, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn ComputePass::dispatch_workgroups_raw(self : ComputePass, workgroup_count_x : UInt, workgroup_count_y : UInt, workgroup_count_z : UInt) -> Unitfn ComputePass::set_bind_group(self : ComputePass, index : UInt, group : BindGroup, dynamic_offsets : Array[UInt]) -> Unitfn ComputePass::write_timestamp(self : ComputePass, query_set : QuerySet, query_index : UInt) -> Unitfn ComputePass::write_timestamp_raw(self : ComputePass, query_set : QuerySet, query_index : UInt) -> Unitfn ComputePipeline::get_bind_group_layout_raw(self : ComputePipeline, group_index : UInt) -> BindGroupLayoutfn ComputePipelineDescBuilder::create_pipeline(self : ComputePipelineDescBuilder, device : Device) -> ComputePipeline raise ComputePipelineDescErrorfn ComputePipelineDescBuilder::finish_descriptor_ptr(self : ComputePipelineDescBuilder) -> WGPUComputePipelineDescriptorPtr raise ComputePipelineDescErrorfn ComputePipelineDescBuilder::last_error(self : ComputePipelineDescBuilder) -> ComputePipelineDescErrorfn ComputePipelineDescBuilder::new(shader_module : ShaderModule, layout? : PipelineLayout) -> ComputePipelineDescBuilder raise ComputePipelineDescErrorfn ComputePipelineDescBuilder::set_entry_point(self : ComputePipelineDescBuilder, entry_point : String) -> Unit raise ComputePipelineDescErrorfn Device::create_bind_group_layout(self : Device, descriptor : WGPUBindGroupLayoutDescriptorPtr) -> BindGroupLayoutfn Device::create_bind_group_layout_ptr(self : Device, descriptor : WGPUBindGroupLayoutDescriptorPtr) -> BindGroupLayoutfn Device::create_bind_group_layout_storage_texture_rgba8_writeonly(self : Device) -> BindGroupLayoutfn Device::create_bind_group_ptr(self : Device, descriptor : WGPUBindGroupDescriptorPtr) -> BindGroupfn Device::create_bind_group_sampler(self : Device, bind_group_layout : BindGroupLayout, sampler : Sampler) -> BindGroupfn Device::create_bind_group_sampler_texture_2d(self : Device, bind_group_layout : BindGroupLayout, sampler : Sampler, view : TextureView) -> BindGroupfn Device::create_bind_group_storage_buffer(self : Device, bind_group_layout : BindGroupLayout, buffer : Buffer) -> BindGroupfn Device::create_bind_group_storage_texture_2d(self : Device, bind_group_layout : BindGroupLayout, view : TextureView) -> BindGroupfn Device::create_bind_group_texture_2d(self : Device, bind_group_layout : BindGroupLayout, view : TextureView) -> BindGroupfn Device::create_bind_group_uniform_buffer(self : Device, bind_group_layout : BindGroupLayout, buffer : Buffer) -> BindGroupfn Device::create_bind_group_uniform_buffer_16(self : Device, bind_group_layout : BindGroupLayout, buffer : Buffer) -> BindGroupfn Device::create_buffer(self : Device, size~ : UInt64, usage~ : BufferUsage, mapped_at_creation? : Bool) -> Bufferfn Device::create_command_encoder_ptr(self : Device, descriptor : WGPUCommandEncoderDescriptorPtr) -> CommandEncoderfn Device::create_command_encoder_raw(self : Device, descriptor : WGPUCommandEncoderDescriptorPtr) -> CommandEncoderfn Device::create_compute_pipeline_async_sync_ptr(self : Device, instance : Instance, descriptor : WGPUComputePipelineDescriptorPtr) -> ComputePipelinefn Device::create_compute_pipeline_async_sync_ptr_or_raise(self : Device, instance : Instance, descriptor : WGPUComputePipelineDescriptorPtr) -> ComputePipeline raise OptionalSymbolErrorfn Device::create_compute_pipeline_entry(self : Device, shader_module : ShaderModule, entry_point : String) -> ComputePipeline raise ComputePipelineDescErrorfn Device::create_compute_pipeline_ptr(self : Device, descriptor : WGPUComputePipelineDescriptorPtr) -> ComputePipelinefn Device::create_compute_pipeline_raw(self : Device, descriptor : WGPUComputePipelineDescriptorPtr) -> ComputePipelinefn Device::create_compute_pipeline_with_layout(self : Device, layout : PipelineLayout, shader_module : ShaderModule) -> ComputePipelinefn Device::create_compute_pipeline_with_layout_entry(self : Device, layout : PipelineLayout, shader_module : ShaderModule, entry_point : String) -> ComputePipeline raise ComputePipelineDescErrorfn Device::create_pipeline_layout(self : Device, descriptor : WGPUPipelineLayoutDescriptorPtr) -> PipelineLayoutfn Device::create_pipeline_layout_1(self : Device, bind_group_layout : BindGroupLayout) -> PipelineLayoutfn Device::create_pipeline_layout_2(self : Device, bind_group_layout0 : BindGroupLayout, bind_group_layout1 : BindGroupLayout) -> PipelineLayoutfn Device::create_pipeline_layout_ptr(self : Device, descriptor : WGPUPipelineLayoutDescriptorPtr) -> PipelineLayoutfn Device::create_pipeline_layout_push_constants(self : Device, stages : ShaderStage, start : UInt, end : UInt) -> PipelineLayoutfn Device::create_pipeline_layout_push_constants_many(self : Device, first_stages : ShaderStage, first_start : UInt, first_end : UInt, other_ranges : Array[(ShaderStage, UInt, UInt)]) -> PipelineLayoutfn Device::create_render_bundle_encoder(self : Device, descriptor : WGPURenderBundleEncoderDescriptorPtr) -> RenderBundleEncoderfn Device::create_render_bundle_encoder_ptr(self : Device, descriptor : WGPURenderBundleEncoderDescriptorPtr) -> RenderBundleEncoderfn Device::create_render_pipeline(self : Device, descriptor : WGPURenderPipelineDescriptorPtr) -> RenderPipelinefn Device::create_render_pipeline_async_sync_ptr(self : Device, instance : Instance, descriptor : WGPURenderPipelineDescriptorPtr) -> RenderPipelinefn Device::create_render_pipeline_async_sync_ptr_or_raise(self : Device, instance : Instance, descriptor : WGPURenderPipelineDescriptorPtr) -> RenderPipeline raise OptionalSymbolErrorfn Device::create_render_pipeline_color_format(self : Device, shader_module : ShaderModule, format : TextureFormat) -> RenderPipelinefn Device::create_render_pipeline_color_format_alpha_blend(self : Device, shader_module : ShaderModule, format : TextureFormat) -> RenderPipelinefn Device::create_render_pipeline_color_format_entries(self : Device, shader_module : ShaderModule, format : TextureFormat, vs_entry? : String, fs_entry? : String, alpha_blend? : Bool, depth? : Bool, color_write_mask? : UInt64) -> RenderPipelinefn Device::create_render_pipeline_ptr(self : Device, descriptor : WGPURenderPipelineDescriptorPtr) -> RenderPipelinefn Device::create_render_pipeline_rgba8(self : Device, shader_module : ShaderModule) -> RenderPipelinefn Device::create_render_pipeline_rgba8_alpha_blend(self : Device, shader_module : ShaderModule) -> RenderPipelinefn Device::create_render_pipeline_rgba8_depth(self : Device, shader_module : ShaderModule) -> RenderPipelinefn Device::create_render_pipeline_rgba8_mrt2(self : Device, shader_module : ShaderModule) -> RenderPipelinefn Device::create_render_pipeline_rgba8_pos2(self : Device, shader_module : ShaderModule) -> RenderPipelinefn Device::create_render_pipeline_rgba8_pos2_with_layout(self : Device, layout : PipelineLayout, shader_module : ShaderModule) -> RenderPipelinefn Device::create_render_pipeline_rgba8_with_layout(self : Device, layout : PipelineLayout, shader_module : ShaderModule) -> RenderPipelinefn Device::create_sampler_u32(self : Device, address_mode_u_u32 : UInt, address_mode_v_u32 : UInt, address_mode_w_u32 : UInt, mag_filter_u32 : UInt, min_filter_u32 : UInt, mipmap_filter_u32 : UInt, lod_min_clamp_f32? : Float, lod_max_clamp_f32? : Float, compare_u32? : UInt, max_anisotropy_u32? : UInt) -> Samplerfn Device::create_shader_module(self : Device, descriptor : WGPUShaderModuleDescriptorPtr) -> ShaderModulefn Device::create_shader_module_glsl(self : Device, stage_u64 : UInt64, code : String) -> ShaderModulefn Device::create_shader_module_ptr(self : Device, descriptor : WGPUShaderModuleDescriptorPtr) -> ShaderModulefn Device::create_shader_module_spir_v(self : Device, descriptor : WGPUShaderModuleDescriptorSpirVPtr) -> ShaderModulefn Device::create_texture_rgba8_2d_array_with_usage(self : Device, width : UInt, height : UInt, layers : UInt, mip_level_count : UInt, usage : TextureUsage) -> Texturefn Device::create_texture_rgba8_2d_with_usage(self : Device, width : UInt, height : UInt, usage : TextureUsage) -> Texturefn Device::create_texture_u32(self : Device, width : UInt, height : UInt, depth_or_array_layers : UInt, usage : TextureUsage, dimension : TextureDimension, format : TextureFormat, mip_level_count? : UInt, sample_count? : UInt, view_formats? : Array[TextureFormat]) -> Texturefn Instance::enumerate_adapters(self : Instance, options : WGPUInstanceEnumerateAdapterOptionsPtr, adapters : WGPUAdapterPtr) -> UInt64fn Instance::get_wgsl_language_features(self : Instance, features : WGPUSupportedWGSLLanguageFeaturesPtr) -> WGPUStatusfn Instance::has_wgsl_language_feature(self : Instance, feature : WGPUWGSLLanguageFeatureName) -> Boolfn Instance::request_adapter_future_id_u64(self : Instance, options? : WGPURequestAdapterOptionsPtr) -> UInt64fn Instance::request_adapter_sync_ptr(self : Instance, options : WGPURequestAdapterOptionsPtr) -> Adapter raise WgpuErrorfn Instance::wait_any(self : Instance, future_count : UInt64, futures : WGPUFutureWaitInfoPtr, timeout_ns : UInt64) -> WGPUWaitStatusfn Instance::wait_any_one(self : Instance, future_id : UInt64, timeout_ns? : UInt64) -> WaitAnyResultfn Instance::wait_any_one_or_raise(self : Instance, future_id : UInt64, timeout_ns? : UInt64) -> WaitAnyResult raise WaitAnyErrorpub struct InstanceCapabilities {
timed_wait_any_enable : Bool
timed_wait_any_max_count : UInt64
}pub struct MapMode {
raw : UInt64
}fn Queue::on_submitted_work_done_async_take_or_raise(self : Queue, future_id : UInt64) -> Unit raise QueueWorkDoneErrorfn Queue::on_submitted_work_done_sync_or_raise(self : Queue, instance : Instance) -> Unit raise QueueWorkDoneErrorfn Queue::on_submitted_work_done_wait_or_raise(self : Queue, instance : Instance, timeout_ns? : UInt64) -> Unit raise QueueWorkDoneWaitErrorfn Queue::submit_for_index_raw(self : Queue, command_count : UInt64, commands : WGPUCommandBufferPtr) -> UInt64fn Queue::write_texture_ptr(self : Queue, destination : WGPUTexelCopyTextureInfoPtr, data : Bytes, data_layout : WGPUTexelCopyBufferLayoutPtr, write_size : WGPUExtent3DPtr, data_size? : UInt64) -> Unitfn RenderBundleEncoder::draw(self : RenderBundleEncoder, vertex_count : UInt, instance_count : UInt, first_vertex : UInt, first_instance : UInt) -> Unitfn RenderBundleEncoder::draw_indexed(self : RenderBundleEncoder, index_count : UInt, instance_count : UInt, first_index : UInt, base_vertex : Int, first_instance : UInt) -> Unitfn RenderBundleEncoder::draw_indexed_indirect(self : RenderBundleEncoder, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderBundleEncoder::draw_indexed_indirect_raw(self : RenderBundleEncoder, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderBundleEncoder::draw_indexed_raw(self : RenderBundleEncoder, index_count : UInt, instance_count : UInt, first_index : UInt, base_vertex : Int, first_instance : UInt) -> Unitfn RenderBundleEncoder::draw_indirect(self : RenderBundleEncoder, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderBundleEncoder::draw_indirect_raw(self : RenderBundleEncoder, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderBundleEncoder::draw_raw(self : RenderBundleEncoder, vertex_count : UInt, instance_count : UInt, first_vertex : UInt, first_instance : UInt) -> Unitfn RenderBundleEncoder::finish_ptr(self : RenderBundleEncoder, descriptor : WGPURenderBundleDescriptorPtr) -> RenderBundlefn RenderBundleEncoder::finish_raw(self : RenderBundleEncoder, descriptor : WGPURenderBundleDescriptorPtr) -> RenderBundlefn RenderBundleEncoder::set_bind_group(self : RenderBundleEncoder, index : UInt, group : BindGroup, dynamic_offsets : Array[UInt]) -> Unitfn RenderBundleEncoder::set_index_buffer(self : RenderBundleEncoder, buffer : Buffer, format : WGPUIndexFormat, offset : UInt64, size : UInt64) -> Unitfn RenderBundleEncoder::set_index_buffer_u16(self : RenderBundleEncoder, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderBundleEncoder::set_index_buffer_u32(self : RenderBundleEncoder, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderBundleEncoder::set_pipeline_raw(self : RenderBundleEncoder, pipeline : RenderPipeline) -> Unitfn RenderBundleEncoder::set_push_constants(self : RenderBundleEncoder, stages : ShaderStage, offset : UInt, data : Bytes) -> Unitfn RenderBundleEncoder::set_vertex_buffer(self : RenderBundleEncoder, slot : UInt, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderBundleEncoder::set_vertex_buffer_raw(self : RenderBundleEncoder, slot : UInt, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderPass::begin_pipeline_statistics_query(self : RenderPass, query_set : QuerySet, query_index : UInt) -> Unitfn RenderPass::begin_pipeline_statistics_query_raw(self : RenderPass, query_set : QuerySet, query_index : UInt) -> Unitfn RenderPass::draw(self : RenderPass, vertex_count : UInt, instance_count : UInt, first_vertex : UInt, first_instance : UInt) -> Unitfn RenderPass::draw_indexed(self : RenderPass, index_count : UInt, instance_count : UInt, first_index : UInt, base_vertex : Int, first_instance : UInt) -> Unitfn RenderPass::draw_indexed_indirect(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderPass::draw_indexed_indirect_raw(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderPass::draw_indexed_raw(self : RenderPass, index_count : UInt, instance_count : UInt, first_index : UInt, base_vertex : Int, first_instance : UInt) -> Unitfn RenderPass::draw_indirect(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderPass::draw_indirect_raw(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64) -> Unitfn RenderPass::draw_raw(self : RenderPass, vertex_count : UInt, instance_count : UInt, first_vertex : UInt, first_instance : UInt) -> Unitfn RenderPass::execute_bundles_raw(self : RenderPass, bundle_count : UInt64, bundles : WGPURenderBundlePtr) -> Unitfn RenderPass::multi_draw_indexed_indirect(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64, count : UInt) -> Unitfn RenderPass::multi_draw_indexed_indirect_count(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64, count_buffer : Buffer, count_buffer_offset : UInt64, max_count : UInt) -> Unitfn RenderPass::multi_draw_indexed_indirect_count_raw(self : RenderPass, buffer : Buffer, offset : UInt64, count_buffer : Buffer, count_buffer_offset : UInt64, max_count : UInt) -> Unitfn RenderPass::multi_draw_indexed_indirect_raw(self : RenderPass, buffer : Buffer, offset : UInt64, count : UInt) -> Unitfn RenderPass::multi_draw_indirect(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64, count : UInt) -> Unitfn RenderPass::multi_draw_indirect_count(self : RenderPass, indirect_buffer : Buffer, indirect_offset : UInt64, count_buffer : Buffer, count_buffer_offset : UInt64, max_count : UInt) -> Unitfn RenderPass::multi_draw_indirect_count_raw(self : RenderPass, buffer : Buffer, offset : UInt64, count_buffer : Buffer, count_buffer_offset : UInt64, max_count : UInt) -> Unitfn RenderPass::multi_draw_indirect_raw(self : RenderPass, buffer : Buffer, offset : UInt64, count : UInt) -> Unitfn RenderPass::set_bind_group(self : RenderPass, index : UInt, group : BindGroup, dynamic_offsets : Array[UInt]) -> Unitfn RenderPass::set_blend_constant_rgba(self : RenderPass, r : Double, g : Double, b : Double, a : Double) -> Unitfn RenderPass::set_index_buffer(self : RenderPass, buffer : Buffer, format : WGPUIndexFormat, offset : UInt64, size : UInt64) -> Unitfn RenderPass::set_index_buffer_u16(self : RenderPass, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderPass::set_index_buffer_u32(self : RenderPass, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderPass::set_push_constants(self : RenderPass, stages : ShaderStage, offset : UInt, data : Bytes) -> Unitfn RenderPass::set_scissor_rect(self : RenderPass, x : UInt, y : UInt, width : UInt, height : UInt) -> Unitfn RenderPass::set_scissor_rect_raw(self : RenderPass, x : UInt, y : UInt, width : UInt, height : UInt) -> Unitfn RenderPass::set_vertex_buffer(self : RenderPass, slot : UInt, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderPass::set_vertex_buffer_raw(self : RenderPass, slot : UInt, buffer : Buffer, offset : UInt64, size : UInt64) -> Unitfn RenderPass::set_viewport(self : RenderPass, x : Float, y : Float, width : Float, height : Float, min_depth : Float, max_depth : Float) -> Unitfn RenderPass::set_viewport_raw(self : RenderPass, x : Float, y : Float, width : Float, height : Float, min_depth : Float, max_depth : Float) -> Unitfn RenderPass::write_timestamp_raw(self : RenderPass, query_set : QuerySet, query_index : UInt) -> Unitfn RenderPipeline::get_bind_group_layout_raw(self : RenderPipeline, group_index : UInt) -> BindGroupLayoutfn RenderPipelineDescBuilder::add_vertex_attribute(self : RenderPipelineDescBuilder, format_u32 : UInt, offset : UInt64, shader_location : UInt) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::add_vertex_buffer_layout(self : RenderPipelineDescBuilder, array_stride : UInt64, step_mode_u32 : UInt) -> UInt raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::clear_primitive_extras(self : RenderPipelineDescBuilder) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::create_pipeline(self : RenderPipelineDescBuilder, device : Device) -> RenderPipeline raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::disable_blend(self : RenderPipelineDescBuilder) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::enable_alpha_blend(self : RenderPipelineDescBuilder) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::finish_descriptor_ptr(self : RenderPipelineDescBuilder) -> WGPURenderPipelineDescriptorPtr raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::last_error(self : RenderPipelineDescBuilder) -> RenderPipelineDescErrorfn RenderPipelineDescBuilder::new(shader_module : ShaderModule, layout? : PipelineLayout) -> RenderPipelineDescBuilder raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_blend_components(self : RenderPipelineDescBuilder, color_src_factor_u32 : UInt, color_dst_factor_u32 : UInt, color_operation_u32 : UInt, alpha_src_factor_u32 : UInt, alpha_dst_factor_u32 : UInt, alpha_operation_u32 : UInt) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_color_target_count(self : RenderPipelineDescBuilder, count_u32 : UInt) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_color_target_format(self : RenderPipelineDescBuilder, format : TextureFormat) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_color_target_format_at(self : RenderPipelineDescBuilder, index_u32 : UInt, format : TextureFormat) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_color_target_write_mask(self : RenderPipelineDescBuilder, write_mask_u64 : UInt64) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_color_target_write_mask_at(self : RenderPipelineDescBuilder, index_u32 : UInt, write_mask_u64 : UInt64) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_conservative_rasterization(self : RenderPipelineDescBuilder, conservative : Bool) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_depth_stencil(self : RenderPipelineDescBuilder, depth_format : TextureFormat, depth_write_enabled? : Bool, depth_compare_u32? : UInt) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_entry_points(self : RenderPipelineDescBuilder, vs_entry : String, fs_entry : String) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_polygon_mode_u32(self : RenderPipelineDescBuilder, polygon_mode_u32 : UInt) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_topology_u32(self : RenderPipelineDescBuilder, topology_u32 : UInt) -> Unit raise RenderPipelineDescErrorfn RenderPipelineDescBuilder::set_vertex_buffer_layout(self : RenderPipelineDescBuilder, array_stride : UInt64, step_mode_u32 : UInt) -> Unit raise RenderPipelineDescErrorfn ShaderModule::get_compilation_info_sync(self : ShaderModule, instance : Instance) -> CompilationInfofn ShaderModule::get_compilation_info_sync_or_raise(self : ShaderModule, instance : Instance) -> CompilationInfo raise OptionalSymbolErrorfn ShaderModule::get_compilation_info_sync_status_u32(self : ShaderModule, instance : Instance) -> UIntfn Surface::capabilities_format_u32_at(self : Surface, adapter : Adapter, index : UInt64) -> TextureFormatfn Surface::configure_best_effort(self : Surface, adapter : Adapter, device : Device, width : UInt, height : UInt, usage : TextureUsage, prefer_srgb? : Bool, vsync? : Bool, desired_maximum_frame_latency? : UInt) -> Boolfn Surface::configure_default(self : Surface, adapter : Adapter, device : Device, width : UInt, height : UInt, usage : TextureUsage, desired_maximum_frame_latency? : UInt) -> TextureFormatfn Surface::configure_u32(self : Surface, adapter : Adapter, device : Device, width : UInt, height : UInt, usage : TextureUsage, format : TextureFormat, present_mode_u32 : UInt, alpha_mode_u32 : UInt, desired_maximum_frame_latency? : UInt) -> Boolfn Surface::configure_u32_or_raise(self : Surface, adapter : Adapter, device : Device, width : UInt, height : UInt, usage : TextureUsage, format : TextureFormat, present_mode_u32 : UInt, alpha_mode_u32 : UInt, desired_maximum_frame_latency? : UInt) -> Unit raise SurfaceConfigureErrorfn Surface::configure_view_formats_u32(self : Surface, adapter : Adapter, device : Device, width : UInt, height : UInt, usage : TextureUsage, format : TextureFormat, present_mode_u32 : UInt, alpha_mode_u32 : UInt, view_formats : Array[TextureFormat], desired_maximum_frame_latency? : UInt) -> Boolfn Surface::configure_view_formats_u32_or_raise(self : Surface, adapter : Adapter, device : Device, width : UInt, height : UInt, usage : TextureUsage, format : TextureFormat, present_mode_u32 : UInt, alpha_mode_u32 : UInt, view_formats : Array[TextureFormat], desired_maximum_frame_latency? : UInt) -> Unit raise SurfaceConfigureErrorfn Surface::configure_with(self : Surface, adapter : Adapter, device : Device, config : SurfaceConfiguration) -> Boolfn Surface::configure_with_or_raise(self : Surface, adapter : Adapter, device : Device, config : SurfaceConfiguration) -> Unit raise SurfaceConfigureErrorfn Surface::get_capabilities(self : Surface, adapter : Adapter, capabilities : WGPUSurfaceCapabilitiesPtr) -> WGPUStatusfn Surface::get_current_texture_or_raise(self : Surface) -> SurfaceTexture raise SurfaceTextureErrorfn Surface::get_current_texture_raw(self : Surface, surface_texture : WGPUSurfaceTexturePtr) -> Unitpub struct SurfaceConfiguration {
width : UInt
height : UInt
usage : TextureUsage
format : TextureFormat
present_mode_u32 : UInt
alpha_mode_u32 : UInt
view_formats : Array[TextureFormat]
desired_maximum_frame_latency : UInt
}fn SurfaceConfiguration::new(width : UInt, height : UInt, usage : TextureUsage, format : TextureFormat, present_mode : PresentMode, alpha_mode : CompositeAlphaMode) -> SurfaceConfigurationfn SurfaceConfiguration::with_desired_maximum_frame_latency(self : SurfaceConfiguration, desired_maximum_frame_latency : UInt) -> SurfaceConfigurationfn SurfaceConfiguration::with_view_formats(self : SurfaceConfiguration, view_formats : Array[TextureFormat]) -> SurfaceConfigurationfn SurfaceTexture::take_texture_or_raise(self : SurfaceTexture) -> Texture raise SurfaceTextureErrorfn Texture::create_view_2d(self : Texture, base_mip_level : UInt, mip_level_count : UInt) -> TextureViewfn Texture::create_view_2d_array(self : Texture, base_array_layer : UInt, array_layer_count : UInt, base_mip_level : UInt, mip_level_count : UInt) -> TextureViewfn Texture::create_view_ptr(self : Texture, descriptor : WGPUTextureViewDescriptorPtr) -> TextureViewfn Texture::create_view_raw(self : Texture, descriptor : WGPUTextureViewDescriptorPtr) -> TextureViewfn Texture::create_view_u32(self : Texture, format : TextureFormat, view_dimension_u32 : UInt, aspect_u32 : UInt, base_array_layer : UInt, array_layer_count : UInt, base_mip_level : UInt, mip_level_count : UInt) -> TextureViewpub struct TextureFormat {
raw : UInt
}impl Eq for TextureFormatlet COMPILATION_INFO_REQUEST_STATUS_INSTANCE_DROPPED : UIntlet COMPUTE_PIPELINE_DESC_ERR_NULL_DESCRIPTOR : UIntlet CREATE_PIPELINE_ASYNC_STATUS_INSTANCE_DROPPED : UIntlet CREATE_PIPELINE_ASYNC_STATUS_INTERNAL_ERROR : UIntlet CREATE_PIPELINE_ASYNC_STATUS_VALIDATION_ERROR : UIntlet FEATURE_NAME_TEXTURE_COMPRESSION_ASTC_SLICED3D : UIntlet FEATURE_NAME_TEXTURE_COMPRESSION_BC_SLICED3D : UIntlet NATIVE_FEATURE_CONSERVATIVE_RASTERIZATION : UIntlet NATIVE_FEATURE_PARTIALLY_BOUND_BINDING_ARRAY : UIntlet NATIVE_FEATURE_SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING : UIntlet NATIVE_FEATURE_STORAGE_RESOURCE_BINDING_ARRAY : UIntlet NATIVE_FEATURE_TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES : UIntlet NATIVE_FEATURE_TEXTURE_COMPRESSION_ASTC_HDR : UIntlet NATIVE_FEATURE_TIMESTAMP_QUERY_INSIDE_ENCODERS : UIntlet NATIVE_FEATURE_TIMESTAMP_QUERY_INSIDE_PASSES : UIntlet NATIVE_FEATURE_UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING : UIntlet OPTIONAL_SYMBOL_AVAILABILITY_MISSING_SYMBOL : UIntlet OPTIONAL_SYMBOL_AVAILABILITY_NATIVE_UNAVAILABLE : UIntlet OPTIONAL_SYMBOL_ERROR_KIND_MISSING_SYMBOL : UIntlet OPTIONAL_SYMBOL_ERROR_KIND_NATIVE_UNAVAILABLE : UIntlet OPTIONAL_SYMBOL_ERROR_KIND_RUNTIME_FAILED : UIntlet PIPELINE_STATISTIC_NAME_CLIPPER_INVOCATIONS : UIntlet PIPELINE_STATISTIC_NAME_CLIPPER_PRIMITIVES_OUT : UIntlet PIPELINE_STATISTIC_NAME_COMPUTE_SHADER_INVOCATIONS : UIntlet PIPELINE_STATISTIC_NAME_FRAGMENT_SHADER_INVOCATIONS : UIntlet PIPELINE_STATISTIC_NAME_VERTEX_SHADER_INVOCATIONS : UIntlet RENDER_PIPELINE_DESC_ERR_COLOR_TARGET_COUNT_EXCEEDS_MAX : UIntlet RENDER_PIPELINE_DESC_ERR_COLOR_TARGET_COUNT_ZERO : UIntlet RENDER_PIPELINE_DESC_ERR_COLOR_TARGET_INDEX_OOB : UIntlet RENDER_PIPELINE_DESC_ERR_NO_VERTEX_BUFFER_LAYOUT : UIntlet RENDER_PIPELINE_DESC_ERR_VERTEX_ATTRIBUTE_EXCEEDS_MAX : UIntlet RENDER_PIPELINE_DESC_ERR_VERTEX_BUFFER_LAYOUT_EXCEEDS_MAX : UIntlet SURFACE_DEFAULT_DESIRED_MAXIMUM_FRAME_LATENCY : UIntlet SURFACE_GET_CURRENT_TEXTURE_STATUS_DEVICE_LOST : UIntlet SURFACE_GET_CURRENT_TEXTURE_STATUS_FORCE32 : UIntlet SURFACE_GET_CURRENT_TEXTURE_STATUS_OUTDATED : UIntlet SURFACE_GET_CURRENT_TEXTURE_STATUS_OUT_OF_MEMORY : UIntlet SURFACE_GET_CURRENT_TEXTURE_STATUS_SUCCESS_OPTIMAL : UIntlet SURFACE_GET_CURRENT_TEXTURE_STATUS_SUCCESS_SUBOPTIMAL : UIntlet SURFACE_GET_CURRENT_TEXTURE_STATUS_TIMEOUT : UIntlet S_TYPE_SURFACE_SOURCE_ANDROID_NATIVE_WINDOW : UIntlet WGSL_LANGUAGE_FEATURE_NAME_PACKED4X8_INTEGER_DOT_PRODUCT : UIntlet WGSL_LANGUAGE_FEATURE_NAME_POINTER_COMPOSITE_ACCESS : UIntlet WGSL_LANGUAGE_FEATURE_NAME_READONLY_AND_READWRITE_STORAGE_TEXTURES : UIntlet WGSL_LANGUAGE_FEATURE_NAME_UNRESTRICTED_POINTER_PARAMETERS : UIntfn set_uncaptured_error_stderr_enabled(enabled : Bool) -> Unitfn surface_configuration_ptr_new(device : Device, config : SurfaceConfiguration) -> WGPUSurfaceConfigurationPtrfn surface_descriptor_wayland_new(display : OpaquePtr, surface : OpaquePtr) -> WGPUSurfaceDescriptorPtrfn surface_descriptor_windows_hwnd_new(hinstance : OpaquePtr, hwnd : OpaquePtr) -> WGPUSurfaceDescriptorPtrThis repo contains a MoonBit port of the `wgpu-native` C API (WebGPU)
Dependencies