Skip to content

Stand-alone passes #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 94 additions & 50 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
#include <stdint.h>
#include <stdlib.h>

#define WGPUDEFAULT_BIND_GROUPS 4

#define WGPUDESIRED_NUM_FRAMES 3

#define WGPUMAX_BIND_GROUPS 4

#define WGPUMAX_COLOR_TARGETS 4

#define WGPUMAX_MIP_LEVELS 16

#define WGPUMAX_VERTEX_BUFFERS 8

typedef enum {
WGPUAddressMode_ClampToEdge = 0,
WGPUAddressMode_Repeat = 1,
Expand Down Expand Up @@ -282,20 +294,19 @@ typedef uint64_t WGPUId_CommandBuffer_Dummy;

typedef WGPUId_CommandBuffer_Dummy WGPUCommandBufferId;

typedef uint64_t WGPUId_ComputePass_Dummy;

typedef WGPUId_ComputePass_Dummy WGPUComputePassId;

typedef WGPUCommandBufferId WGPUCommandEncoderId;

typedef struct {
uint8_t *data;
uint8_t *base;
uintptr_t capacity;
WGPUCommandEncoderId parent;
} WGPURawPass;

typedef struct {
uint32_t todo;
} WGPUComputePassDescriptor;

typedef uint64_t WGPUId_RenderPass_Dummy;

typedef WGPUId_RenderPass_Dummy WGPURenderPassId;

typedef uint64_t WGPUId_TextureView_Dummy;

typedef WGPUId_TextureView_Dummy WGPUTextureViewId;
Expand All @@ -315,11 +326,13 @@ typedef struct {

typedef struct {
WGPUTextureViewId attachment;
const WGPUTextureViewId *resolve_target;
WGPUTextureViewId resolve_target;
WGPULoadOp load_op;
WGPUStoreOp store_op;
WGPUColor clear_color;
} WGPURenderPassColorAttachmentDescriptor;
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId;

typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId WGPURawRenderPassColorAttachmentDescriptor;

typedef struct {
WGPUTextureViewId attachment;
Expand All @@ -329,12 +342,36 @@ typedef struct {
WGPULoadOp stencil_load_op;
WGPUStoreOp stencil_store_op;
uint32_t clear_stencil;
} WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId;
} WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId;

typedef WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId WGPURenderPassDepthStencilAttachmentDescriptor;

typedef struct {
WGPURawRenderPassColorAttachmentDescriptor colors[WGPUMAX_COLOR_TARGETS];
WGPURenderPassDepthStencilAttachmentDescriptor depth_stencil;
} WGPURawRenderTargets;

typedef struct {
WGPURawPass raw;
WGPURawRenderTargets targets;
} WGPURawRenderPass;

typedef const WGPUTextureViewId *WGPUOptionRef_TextureViewId;

typedef struct {
WGPUTextureViewId attachment;
WGPUOptionRef_TextureViewId resolve_target;
WGPULoadOp load_op;
WGPUStoreOp store_op;
WGPUColor clear_color;
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId;

typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId WGPURenderPassColorAttachmentDescriptor;

typedef struct {
const WGPURenderPassColorAttachmentDescriptor *color_attachments;
uintptr_t color_attachments_length;
const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId *depth_stencil_attachment;
const WGPURenderPassDepthStencilAttachmentDescriptor *depth_stencil_attachment;
} WGPURenderPassDescriptor;

typedef struct {
Expand Down Expand Up @@ -372,6 +409,8 @@ typedef struct {
uint32_t todo;
} WGPUCommandBufferDescriptor;

typedef WGPURawPass *WGPUComputePassId;

typedef const char *WGPURawString;

typedef uint64_t WGPUId_ComputePipeline_Dummy;
Expand Down Expand Up @@ -639,6 +678,8 @@ typedef struct {

typedef WGPUDeviceId WGPUQueueId;

typedef WGPURawRenderPass *WGPURenderPassId;

typedef uint64_t WGPUId_RenderBundle_Dummy;

typedef WGPUId_RenderBundle_Dummy WGPURenderBundleId;
Expand Down Expand Up @@ -688,11 +729,11 @@ void wgpu_buffer_unmap(WGPUBufferId buffer_id);

void wgpu_command_buffer_destroy(WGPUCommandBufferId command_buffer_id);

WGPUComputePassId wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encoder_id,
const WGPUComputePassDescriptor *desc);
WGPURawPass *wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encoder_id,
const WGPUComputePassDescriptor *_desc);

WGPURenderPassId wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id,
const WGPURenderPassDescriptor *desc);
WGPURawRenderPass *wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id,
const WGPURenderPassDescriptor *desc);

void wgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoderId command_encoder_id,
WGPUBufferId source,
Expand Down Expand Up @@ -721,27 +762,30 @@ void wgpu_command_encoder_destroy(WGPUCommandEncoderId command_encoder_id);
WGPUCommandBufferId wgpu_command_encoder_finish(WGPUCommandEncoderId encoder_id,
const WGPUCommandBufferDescriptor *desc);

void wgpu_compute_pass_dispatch(WGPUComputePassId pass_id, uint32_t x, uint32_t y, uint32_t z);
void wgpu_compute_pass_dispatch(WGPURawPass *pass,
uint32_t groups_x,
uint32_t groups_y,
uint32_t groups_z);

void wgpu_compute_pass_dispatch_indirect(WGPUComputePassId pass_id,
WGPUBufferId indirect_buffer_id,
WGPUBufferAddress indirect_offset);
void wgpu_compute_pass_dispatch_indirect(WGPURawPass *pass,
WGPUBufferId buffer_id,
WGPUBufferAddress offset);

void wgpu_compute_pass_end_pass(WGPUComputePassId pass_id);

void wgpu_compute_pass_insert_debug_marker(WGPUComputePassId _pass_id, WGPURawString _label);
void wgpu_compute_pass_insert_debug_marker(WGPURawPass *_pass, WGPURawString _label);

void wgpu_compute_pass_pop_debug_group(WGPUComputePassId _pass_id);
void wgpu_compute_pass_pop_debug_group(WGPURawPass *_pass);

void wgpu_compute_pass_push_debug_group(WGPUComputePassId _pass_id, WGPURawString _label);
void wgpu_compute_pass_push_debug_group(WGPURawPass *_pass, WGPURawString _label);

void wgpu_compute_pass_set_bind_group(WGPUComputePassId pass_id,
void wgpu_compute_pass_set_bind_group(WGPURawPass *pass,
uint32_t index,
WGPUBindGroupId bind_group_id,
const WGPUBufferAddress *offsets,
uintptr_t offsets_length);
uintptr_t offset_length);

void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipelineId pipeline_id);
void wgpu_compute_pass_set_pipeline(WGPURawPass *pass, WGPUComputePipelineId pipeline_id);

WGPUSurfaceId wgpu_create_surface_from_metal_layer(void *layer);

Expand Down Expand Up @@ -798,74 +842,74 @@ void wgpu_queue_submit(WGPUQueueId queue_id,
const WGPUCommandBufferId *command_buffers,
uintptr_t command_buffers_length);

void wgpu_render_pass_draw(WGPURenderPassId pass_id,
void wgpu_render_pass_draw(WGPURawRenderPass *pass,
uint32_t vertex_count,
uint32_t instance_count,
uint32_t first_vertex,
uint32_t first_instance);

void wgpu_render_pass_draw_indexed(WGPURenderPassId pass_id,
void wgpu_render_pass_draw_indexed(WGPURawRenderPass *pass,
uint32_t index_count,
uint32_t instance_count,
uint32_t first_index,
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_indexed_indirect(WGPURawRenderPass *pass,
WGPUBufferId buffer_id,
WGPUBufferAddress offset);

void wgpu_render_pass_draw_indirect(WGPURenderPassId pass_id,
WGPUBufferId indirect_buffer_id,
WGPUBufferAddress indirect_offset);
void wgpu_render_pass_draw_indirect(WGPURawRenderPass *pass,
WGPUBufferId buffer_id,
WGPUBufferAddress offset);

void wgpu_render_pass_end_pass(WGPURenderPassId pass_id);

void wgpu_render_pass_execute_bundles(WGPURenderPassId _pass_id,
void wgpu_render_pass_execute_bundles(WGPURawRenderPass *_pass,
const WGPURenderBundleId *_bundles,
uintptr_t _bundles_length);

void wgpu_render_pass_insert_debug_marker(WGPURenderPassId _pass_id, WGPURawString _label);
void wgpu_render_pass_insert_debug_marker(WGPURawRenderPass *_pass, WGPURawString _label);

void wgpu_render_pass_pop_debug_group(WGPURenderPassId _pass_id);
void wgpu_render_pass_pop_debug_group(WGPURawRenderPass *_pass);

void wgpu_render_pass_push_debug_group(WGPURenderPassId _pass_id, WGPURawString _label);
void wgpu_render_pass_push_debug_group(WGPURawRenderPass *_pass, WGPURawString _label);

void wgpu_render_pass_set_bind_group(WGPURenderPassId pass_id,
void wgpu_render_pass_set_bind_group(WGPURawRenderPass *pass,
uint32_t index,
WGPUBindGroupId bind_group_id,
const WGPUBufferAddress *offsets,
uintptr_t offsets_length);
uintptr_t offset_length);

void wgpu_render_pass_set_blend_color(WGPURenderPassId pass_id, const WGPUColor *color);
void wgpu_render_pass_set_blend_color(WGPURawRenderPass *pass, const WGPUColor *color);

void wgpu_render_pass_set_index_buffer(WGPURenderPassId pass_id,
void wgpu_render_pass_set_index_buffer(WGPURawRenderPass *pass,
WGPUBufferId buffer_id,
WGPUBufferAddress offset);

void wgpu_render_pass_set_pipeline(WGPURenderPassId pass_id, WGPURenderPipelineId pipeline_id);
void wgpu_render_pass_set_pipeline(WGPURawRenderPass *pass, WGPURenderPipelineId pipeline_id);

void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id,
void wgpu_render_pass_set_scissor_rect(WGPURawRenderPass *pass,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h);

void wgpu_render_pass_set_stencil_reference(WGPURenderPassId pass_id, uint32_t value);
void wgpu_render_pass_set_stencil_reference(WGPURawRenderPass *pass, uint32_t value);

void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id,
void wgpu_render_pass_set_vertex_buffers(WGPURawRenderPass *pass,
uint32_t start_slot,
const WGPUBufferId *buffers,
const WGPUBufferId *buffer_ids,
const WGPUBufferAddress *offsets,
uintptr_t length);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly relevant to this PR but many of these uintptr_t are uint64_t in webgpu-headers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to #452


void wgpu_render_pass_set_viewport(WGPURenderPassId pass_id,
void wgpu_render_pass_set_viewport(WGPURawRenderPass *pass,
float x,
float y,
float w,
float h,
float min_depth,
float max_depth);
float depth_min,
float depth_max);

void wgpu_request_adapter_async(const WGPURequestAdapterOptions *desc,
WGPUBackendBit mask,
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ log = "0.4"
hal = { package = "gfx-hal", version = "0.4" }
gfx-backend-empty = { version = "0.4" }
parking_lot = "0.9"
peek-poke = { git = "https://github.com/kvark/peek-poke", rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075" }
rendy-memory = "0.5"
rendy-descriptor = "0.5"
serde = { version = "1.0", features = ["serde_derive"], optional = true }
Expand Down
Loading