diff --git a/examples/compute/main.c b/examples/compute/main.c index 09740c47b7..4f0dd5674f 100644 --- a/examples/compute/main.c +++ b/examples/compute/main.c @@ -110,7 +110,7 @@ int main( .todo = 0 }); - wgpu_command_buffer_copy_buffer_to_buffer( + wgpu_command_encoder_copy_buffer_to_buffer( encoder, staging_buffer, 0, storage_buffer, 0, size); WGPUComputePassId command_pass = @@ -121,7 +121,7 @@ int main( wgpu_compute_pass_dispatch(command_pass, numbers_length, 1, 1); wgpu_compute_pass_end_pass(command_pass); - wgpu_command_buffer_copy_buffer_to_buffer( + wgpu_command_encoder_copy_buffer_to_buffer( encoder, storage_buffer, 0, staging_buffer, 0, size); WGPUQueueId queue = wgpu_device_get_queue(device); @@ -135,4 +135,4 @@ int main( wgpu_device_poll(device, true); return 0; -} \ No newline at end of file +} diff --git a/ffi/wgpu-remote.h b/ffi/wgpu-remote.h index 643aaea25b..e273e66dc6 100644 --- a/ffi/wgpu-remote.h +++ b/ffi/wgpu-remote.h @@ -1,6 +1,6 @@ -/* Generated with cbindgen:0.8.7 */ +/* Generated with cbindgen:0.9.0 */ #include #include diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 9208a109e0..ecf23f1745 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -273,39 +273,10 @@ typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, const typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, uint8_t *data, uint8_t *userdata); -typedef WGPUId WGPUCommandBufferId; - -typedef struct { - WGPUBufferId buffer; - WGPUBufferAddress offset; - uint32_t row_pitch; - uint32_t image_height; -} WGPUBufferCopyView; - -typedef WGPUId WGPUTextureId; - -typedef struct { - float x; - float y; - float z; -} WGPUOrigin3d; -#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0, .y = 0, .z = 0 } - -typedef struct { - WGPUTextureId texture; - uint32_t mip_level; - uint32_t array_layer; - WGPUOrigin3d origin; -} WGPUTextureCopyView; - -typedef struct { - uint32_t width; - uint32_t height; - uint32_t depth; -} WGPUExtent3d; - typedef WGPUId WGPUComputePassId; +typedef WGPUId WGPUCommandBufferId; + typedef WGPUCommandBufferId WGPUCommandEncoderId; typedef WGPUId WGPURenderPassId; @@ -349,6 +320,35 @@ typedef struct { const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId *depth_stencil_attachment; } WGPURenderPassDescriptor; +typedef struct { + WGPUBufferId buffer; + WGPUBufferAddress offset; + uint32_t row_pitch; + uint32_t image_height; +} WGPUBufferCopyView; + +typedef WGPUId WGPUTextureId; + +typedef struct { + float x; + float y; + float z; +} WGPUOrigin3d; +#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0, .y = 0, .z = 0 } + +typedef struct { + WGPUTextureId texture; + uint32_t mip_level; + uint32_t array_layer; + WGPUOrigin3d origin; +} WGPUTextureCopyView; + +typedef struct { + uint32_t width; + uint32_t height; + uint32_t depth; +} WGPUExtent3d; + typedef const char *WGPURawString; typedef WGPUId WGPUComputePipelineId; @@ -645,28 +645,6 @@ void wgpu_buffer_map_write_async(WGPUBufferId buffer_id, void wgpu_buffer_unmap(WGPUBufferId buffer_id); -void wgpu_command_buffer_copy_buffer_to_buffer(WGPUCommandBufferId command_buffer_id, - WGPUBufferId src, - WGPUBufferAddress src_offset, - WGPUBufferId dst, - WGPUBufferAddress dst_offset, - WGPUBufferAddress size); - -void wgpu_command_buffer_copy_buffer_to_texture(WGPUCommandBufferId command_buffer_id, - const WGPUBufferCopyView *source, - const WGPUTextureCopyView *destination, - WGPUExtent3d copy_size); - -void wgpu_command_buffer_copy_texture_to_buffer(WGPUCommandBufferId command_buffer_id, - const WGPUTextureCopyView *source, - const WGPUBufferCopyView *destination, - WGPUExtent3d copy_size); - -void wgpu_command_buffer_copy_texture_to_texture(WGPUCommandBufferId command_buffer_id, - const WGPUTextureCopyView *source, - const WGPUTextureCopyView *destination, - WGPUExtent3d copy_size); - #if defined(WGPU_LOCAL) WGPUComputePassId wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId command_encoder_id); #endif @@ -676,10 +654,36 @@ WGPURenderPassId wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId com const WGPURenderPassDescriptor *desc); #endif +void wgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoderId command_buffer_id, + WGPUBufferId src, + WGPUBufferAddress src_offset, + WGPUBufferId dst, + WGPUBufferAddress dst_offset, + WGPUBufferAddress size); + +void wgpu_command_encoder_copy_buffer_to_texture(WGPUCommandEncoderId command_buffer_id, + const WGPUBufferCopyView *source, + const WGPUTextureCopyView *destination, + WGPUExtent3d copy_size); + +void wgpu_command_encoder_copy_texture_to_buffer(WGPUCommandEncoderId command_buffer_id, + const WGPUTextureCopyView *source, + const WGPUBufferCopyView *destination, + WGPUExtent3d copy_size); + +void wgpu_command_encoder_copy_texture_to_texture(WGPUCommandEncoderId command_buffer_id, + const WGPUTextureCopyView *source, + const WGPUTextureCopyView *destination, + WGPUExtent3d copy_size); + WGPUCommandBufferId wgpu_command_encoder_finish(WGPUCommandEncoderId command_encoder_id); void wgpu_compute_pass_dispatch(WGPUComputePassId pass_id, uint32_t x, uint32_t y, uint32_t z); +void wgpu_compute_pass_dispatch_indirect(WGPUComputePassId pass_id, + WGPUBufferId indirect_buffer_id, + WGPUBufferAddress indirect_offset); + WGPUCommandBufferId wgpu_compute_pass_end_pass(WGPUComputePassId pass_id); void wgpu_compute_pass_insert_debug_marker(WGPUComputePassId _pass_id, WGPURawString _label); @@ -804,6 +808,14 @@ void wgpu_render_pass_draw_indexed(WGPURenderPassId pass_id, int32_t base_vertex, uint32_t first_instance); +void wgpu_render_pass_draw_indexed_indirect(WGPURenderPassId pass_id, + WGPUBufferId indirect_buffer_id, + WGPUBufferAddress indirect_offset); + +void wgpu_render_pass_draw_indirect(WGPURenderPassId pass_id, + WGPUBufferId indirect_buffer_id, + WGPUBufferAddress indirect_offset); + WGPUCommandBufferId wgpu_render_pass_end_pass(WGPURenderPassId pass_id); void wgpu_render_pass_insert_debug_marker(WGPURenderPassId _pass_id, WGPURawString _label); diff --git a/wgpu-native/src/command/transfer.rs b/wgpu-native/src/command/transfer.rs index 08a6d68fef..ae3cfb09ec 100644 --- a/wgpu-native/src/command/transfer.rs +++ b/wgpu-native/src/command/transfer.rs @@ -7,7 +7,7 @@ use crate::{ BufferAddress, BufferId, BufferUsage, - CommandBufferId, + CommandEncoderId, Extent3d, Origin3d, TextureId, @@ -65,8 +65,8 @@ impl TextureCopyView { } #[no_mangle] -pub extern "C" fn wgpu_command_buffer_copy_buffer_to_buffer( - command_buffer_id: CommandBufferId, +pub extern "C" fn wgpu_command_encoder_copy_buffer_to_buffer( + command_buffer_id: CommandEncoderId, src: BufferId, src_offset: BufferAddress, dst: BufferId, @@ -120,8 +120,8 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_buffer( } #[no_mangle] -pub extern "C" fn wgpu_command_buffer_copy_buffer_to_texture( - command_buffer_id: CommandBufferId, +pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture( + command_buffer_id: CommandEncoderId, source: &BufferCopyView, destination: &TextureCopyView, copy_size: Extent3d, @@ -198,8 +198,8 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_texture( } #[no_mangle] -pub extern "C" fn wgpu_command_buffer_copy_texture_to_buffer( - command_buffer_id: CommandBufferId, +pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer( + command_buffer_id: CommandEncoderId, source: &TextureCopyView, destination: &BufferCopyView, copy_size: Extent3d, @@ -275,8 +275,8 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_buffer( } #[no_mangle] -pub extern "C" fn wgpu_command_buffer_copy_texture_to_texture( - command_buffer_id: CommandBufferId, +pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture( + command_buffer_id: CommandEncoderId, source: &TextureCopyView, destination: &TextureCopyView, copy_size: Extent3d,