Skip to content

Commit

Permalink
rename methods for command buffer to methods for command encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
porky11 committed Aug 10, 2019
1 parent 186fbee commit 231bfeb
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 138 deletions.
6 changes: 3 additions & 3 deletions examples/compute/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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);
Expand All @@ -135,4 +135,4 @@ int main(
wgpu_device_poll(device, true);

return 0;
}
}
72 changes: 0 additions & 72 deletions ffi/wgpu-remote.h

This file was deleted.

120 changes: 66 additions & 54 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define WGPU_LOCAL

/* Generated with cbindgen:0.9.0 */
/* Generated with cbindgen:0.8.7 */

#include <stdarg.h>
#include <stdbool.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions wgpu-native/src/command/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
BufferAddress,
BufferId,
BufferUsage,
CommandBufferId,
CommandEncoderId,
Extent3d,
Origin3d,
TextureId,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 231bfeb

Please sign in to comment.