From c36698aff4dd137ca3284bbbfdf47490c7db3cdf Mon Sep 17 00:00:00 2001 From: Fabio Krapohl Date: Sat, 10 Aug 2019 22:05:32 +0200 Subject: [PATCH] rename methods for command buffer to methods for command encoder --- ffi/wgpu-remote.h | 72 ----------------- ffi/wgpu.h | 120 +++++++++++++++------------- wgpu-native/src/command/transfer.rs | 18 ++--- 3 files changed, 75 insertions(+), 135 deletions(-) delete mode 100644 ffi/wgpu-remote.h diff --git a/ffi/wgpu-remote.h b/ffi/wgpu-remote.h deleted file mode 100644 index 643aaea25b5..00000000000 --- a/ffi/wgpu-remote.h +++ /dev/null @@ -1,72 +0,0 @@ - - -/* Generated with cbindgen:0.8.7 */ - -#include -#include -#include -#include - -typedef enum { - WGPUPowerPreference_Default = 0, - WGPUPowerPreference_LowPower = 1, - WGPUPowerPreference_HighPerformance = 2, -} WGPUPowerPreference; - -typedef struct WGPUClient WGPUClient; - -typedef struct WGPUClientFactory WGPUClientFactory; - -typedef struct WGPUServer WGPUServer; - -typedef uint32_t WGPUIndex; - -typedef uint32_t WGPUEpoch; - -typedef struct { - WGPUIndex _0; - WGPUEpoch _1; -} WGPUId; - -typedef WGPUId WGPUDeviceId; - -typedef WGPUId WGPUAdapterId; - -typedef struct { - bool anisotropic_filtering; -} WGPUExtensions; - -typedef struct { - uint32_t max_bind_groups; -} WGPULimits; - -typedef struct { - WGPUExtensions extensions; - WGPULimits limits; -} WGPUDeviceDescriptor; - -typedef struct { - WGPUPowerPreference power_preference; -} WGPUAdapterDescriptor; - -typedef struct { - WGPUClientFactory *factory; - WGPUServer *server; - const uint8_t *error; -} WGPUInfrastructure; - -WGPUDeviceId wgpu_client_adapter_create_device(const WGPUClient *client, - WGPUAdapterId adapter_id, - const WGPUDeviceDescriptor *desc); - -WGPUClient *wgpu_client_create(const WGPUClientFactory *factory); - -void wgpu_client_destroy(const WGPUClientFactory *factory, WGPUClient *client); - -WGPUAdapterId wgpu_client_get_adapter(const WGPUClient *client, const WGPUAdapterDescriptor *desc); - -WGPUInfrastructure wgpu_initialize(void); - -void wgpu_server_process(const WGPUServer *server); - -void wgpu_terminate(WGPUClientFactory *factory); diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 9208a109e09..ce2da754c6f 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -1,6 +1,6 @@ #define WGPU_LOCAL -/* Generated with cbindgen:0.9.0 */ +/* Generated with cbindgen:0.8.7 */ #include #include @@ -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 08a6d68fef0..ae3cfb09ec4 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,