Skip to content

Commit a72574a

Browse files
bors[bot]kvark
andauthored
Merge #440
440: Stand-alone passes r=me,grovesNL a=kvark Fixes #438 Co-authored-by: Dzmitry Malyshau <[email protected]>
2 parents c0fa61a + a510197 commit a72574a

File tree

16 files changed

+1788
-1564
lines changed

16 files changed

+1788
-1564
lines changed

Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ffi/wgpu.h

Lines changed: 94 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
#include <stdint.h>
2020
#include <stdlib.h>
2121

22+
#define WGPUDEFAULT_BIND_GROUPS 4
23+
24+
#define WGPUDESIRED_NUM_FRAMES 3
25+
26+
#define WGPUMAX_BIND_GROUPS 4
27+
28+
#define WGPUMAX_COLOR_TARGETS 4
29+
30+
#define WGPUMAX_MIP_LEVELS 16
31+
32+
#define WGPUMAX_VERTEX_BUFFERS 8
33+
2234
typedef enum {
2335
WGPUAddressMode_ClampToEdge = 0,
2436
WGPUAddressMode_Repeat = 1,
@@ -282,20 +294,19 @@ typedef uint64_t WGPUId_CommandBuffer_Dummy;
282294

283295
typedef WGPUId_CommandBuffer_Dummy WGPUCommandBufferId;
284296

285-
typedef uint64_t WGPUId_ComputePass_Dummy;
286-
287-
typedef WGPUId_ComputePass_Dummy WGPUComputePassId;
288-
289297
typedef WGPUCommandBufferId WGPUCommandEncoderId;
290298

299+
typedef struct {
300+
uint8_t *data;
301+
uint8_t *base;
302+
uintptr_t capacity;
303+
WGPUCommandEncoderId parent;
304+
} WGPURawPass;
305+
291306
typedef struct {
292307
uint32_t todo;
293308
} WGPUComputePassDescriptor;
294309

295-
typedef uint64_t WGPUId_RenderPass_Dummy;
296-
297-
typedef WGPUId_RenderPass_Dummy WGPURenderPassId;
298-
299310
typedef uint64_t WGPUId_TextureView_Dummy;
300311

301312
typedef WGPUId_TextureView_Dummy WGPUTextureViewId;
@@ -315,11 +326,13 @@ typedef struct {
315326

316327
typedef struct {
317328
WGPUTextureViewId attachment;
318-
const WGPUTextureViewId *resolve_target;
329+
WGPUTextureViewId resolve_target;
319330
WGPULoadOp load_op;
320331
WGPUStoreOp store_op;
321332
WGPUColor clear_color;
322-
} WGPURenderPassColorAttachmentDescriptor;
333+
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId;
334+
335+
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId WGPURawRenderPassColorAttachmentDescriptor;
323336

324337
typedef struct {
325338
WGPUTextureViewId attachment;
@@ -329,12 +342,36 @@ typedef struct {
329342
WGPULoadOp stencil_load_op;
330343
WGPUStoreOp stencil_store_op;
331344
uint32_t clear_stencil;
332-
} WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId;
345+
} WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId;
346+
347+
typedef WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId WGPURenderPassDepthStencilAttachmentDescriptor;
348+
349+
typedef struct {
350+
WGPURawRenderPassColorAttachmentDescriptor colors[WGPUMAX_COLOR_TARGETS];
351+
WGPURenderPassDepthStencilAttachmentDescriptor depth_stencil;
352+
} WGPURawRenderTargets;
353+
354+
typedef struct {
355+
WGPURawPass raw;
356+
WGPURawRenderTargets targets;
357+
} WGPURawRenderPass;
358+
359+
typedef const WGPUTextureViewId *WGPUOptionRef_TextureViewId;
360+
361+
typedef struct {
362+
WGPUTextureViewId attachment;
363+
WGPUOptionRef_TextureViewId resolve_target;
364+
WGPULoadOp load_op;
365+
WGPUStoreOp store_op;
366+
WGPUColor clear_color;
367+
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId;
368+
369+
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId WGPURenderPassColorAttachmentDescriptor;
333370

334371
typedef struct {
335372
const WGPURenderPassColorAttachmentDescriptor *color_attachments;
336373
uintptr_t color_attachments_length;
337-
const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId *depth_stencil_attachment;
374+
const WGPURenderPassDepthStencilAttachmentDescriptor *depth_stencil_attachment;
338375
} WGPURenderPassDescriptor;
339376

340377
typedef struct {
@@ -372,6 +409,8 @@ typedef struct {
372409
uint32_t todo;
373410
} WGPUCommandBufferDescriptor;
374411

412+
typedef WGPURawPass *WGPUComputePassId;
413+
375414
typedef const char *WGPURawString;
376415

377416
typedef uint64_t WGPUId_ComputePipeline_Dummy;
@@ -639,6 +678,8 @@ typedef struct {
639678

640679
typedef WGPUDeviceId WGPUQueueId;
641680

681+
typedef WGPURawRenderPass *WGPURenderPassId;
682+
642683
typedef uint64_t WGPUId_RenderBundle_Dummy;
643684

644685
typedef WGPUId_RenderBundle_Dummy WGPURenderBundleId;
@@ -688,11 +729,11 @@ void wgpu_buffer_unmap(WGPUBufferId buffer_id);
688729

689730
void wgpu_command_buffer_destroy(WGPUCommandBufferId command_buffer_id);
690731

691-
WGPUComputePassId wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encoder_id,
692-
const WGPUComputePassDescriptor *desc);
732+
WGPURawPass *wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encoder_id,
733+
const WGPUComputePassDescriptor *_desc);
693734

694-
WGPURenderPassId wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id,
695-
const WGPURenderPassDescriptor *desc);
735+
WGPURawRenderPass *wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id,
736+
const WGPURenderPassDescriptor *desc);
696737

697738
void wgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoderId command_encoder_id,
698739
WGPUBufferId source,
@@ -721,27 +762,30 @@ void wgpu_command_encoder_destroy(WGPUCommandEncoderId command_encoder_id);
721762
WGPUCommandBufferId wgpu_command_encoder_finish(WGPUCommandEncoderId encoder_id,
722763
const WGPUCommandBufferDescriptor *desc);
723764

724-
void wgpu_compute_pass_dispatch(WGPUComputePassId pass_id, uint32_t x, uint32_t y, uint32_t z);
765+
void wgpu_compute_pass_dispatch(WGPURawPass *pass,
766+
uint32_t groups_x,
767+
uint32_t groups_y,
768+
uint32_t groups_z);
725769

726-
void wgpu_compute_pass_dispatch_indirect(WGPUComputePassId pass_id,
727-
WGPUBufferId indirect_buffer_id,
728-
WGPUBufferAddress indirect_offset);
770+
void wgpu_compute_pass_dispatch_indirect(WGPURawPass *pass,
771+
WGPUBufferId buffer_id,
772+
WGPUBufferAddress offset);
729773

730774
void wgpu_compute_pass_end_pass(WGPUComputePassId pass_id);
731775

732-
void wgpu_compute_pass_insert_debug_marker(WGPUComputePassId _pass_id, WGPURawString _label);
776+
void wgpu_compute_pass_insert_debug_marker(WGPURawPass *_pass, WGPURawString _label);
733777

734-
void wgpu_compute_pass_pop_debug_group(WGPUComputePassId _pass_id);
778+
void wgpu_compute_pass_pop_debug_group(WGPURawPass *_pass);
735779

736-
void wgpu_compute_pass_push_debug_group(WGPUComputePassId _pass_id, WGPURawString _label);
780+
void wgpu_compute_pass_push_debug_group(WGPURawPass *_pass, WGPURawString _label);
737781

738-
void wgpu_compute_pass_set_bind_group(WGPUComputePassId pass_id,
782+
void wgpu_compute_pass_set_bind_group(WGPURawPass *pass,
739783
uint32_t index,
740784
WGPUBindGroupId bind_group_id,
741785
const WGPUBufferAddress *offsets,
742-
uintptr_t offsets_length);
786+
uintptr_t offset_length);
743787

744-
void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipelineId pipeline_id);
788+
void wgpu_compute_pass_set_pipeline(WGPURawPass *pass, WGPUComputePipelineId pipeline_id);
745789

746790
WGPUSurfaceId wgpu_create_surface_from_metal_layer(void *layer);
747791

@@ -798,74 +842,74 @@ void wgpu_queue_submit(WGPUQueueId queue_id,
798842
const WGPUCommandBufferId *command_buffers,
799843
uintptr_t command_buffers_length);
800844

801-
void wgpu_render_pass_draw(WGPURenderPassId pass_id,
845+
void wgpu_render_pass_draw(WGPURawRenderPass *pass,
802846
uint32_t vertex_count,
803847
uint32_t instance_count,
804848
uint32_t first_vertex,
805849
uint32_t first_instance);
806850

807-
void wgpu_render_pass_draw_indexed(WGPURenderPassId pass_id,
851+
void wgpu_render_pass_draw_indexed(WGPURawRenderPass *pass,
808852
uint32_t index_count,
809853
uint32_t instance_count,
810854
uint32_t first_index,
811855
int32_t base_vertex,
812856
uint32_t first_instance);
813857

814-
void wgpu_render_pass_draw_indexed_indirect(WGPURenderPassId pass_id,
815-
WGPUBufferId indirect_buffer_id,
816-
WGPUBufferAddress indirect_offset);
858+
void wgpu_render_pass_draw_indexed_indirect(WGPURawRenderPass *pass,
859+
WGPUBufferId buffer_id,
860+
WGPUBufferAddress offset);
817861

818-
void wgpu_render_pass_draw_indirect(WGPURenderPassId pass_id,
819-
WGPUBufferId indirect_buffer_id,
820-
WGPUBufferAddress indirect_offset);
862+
void wgpu_render_pass_draw_indirect(WGPURawRenderPass *pass,
863+
WGPUBufferId buffer_id,
864+
WGPUBufferAddress offset);
821865

822866
void wgpu_render_pass_end_pass(WGPURenderPassId pass_id);
823867

824-
void wgpu_render_pass_execute_bundles(WGPURenderPassId _pass_id,
868+
void wgpu_render_pass_execute_bundles(WGPURawRenderPass *_pass,
825869
const WGPURenderBundleId *_bundles,
826870
uintptr_t _bundles_length);
827871

828-
void wgpu_render_pass_insert_debug_marker(WGPURenderPassId _pass_id, WGPURawString _label);
872+
void wgpu_render_pass_insert_debug_marker(WGPURawRenderPass *_pass, WGPURawString _label);
829873

830-
void wgpu_render_pass_pop_debug_group(WGPURenderPassId _pass_id);
874+
void wgpu_render_pass_pop_debug_group(WGPURawRenderPass *_pass);
831875

832-
void wgpu_render_pass_push_debug_group(WGPURenderPassId _pass_id, WGPURawString _label);
876+
void wgpu_render_pass_push_debug_group(WGPURawRenderPass *_pass, WGPURawString _label);
833877

834-
void wgpu_render_pass_set_bind_group(WGPURenderPassId pass_id,
878+
void wgpu_render_pass_set_bind_group(WGPURawRenderPass *pass,
835879
uint32_t index,
836880
WGPUBindGroupId bind_group_id,
837881
const WGPUBufferAddress *offsets,
838-
uintptr_t offsets_length);
882+
uintptr_t offset_length);
839883

840-
void wgpu_render_pass_set_blend_color(WGPURenderPassId pass_id, const WGPUColor *color);
884+
void wgpu_render_pass_set_blend_color(WGPURawRenderPass *pass, const WGPUColor *color);
841885

842-
void wgpu_render_pass_set_index_buffer(WGPURenderPassId pass_id,
886+
void wgpu_render_pass_set_index_buffer(WGPURawRenderPass *pass,
843887
WGPUBufferId buffer_id,
844888
WGPUBufferAddress offset);
845889

846-
void wgpu_render_pass_set_pipeline(WGPURenderPassId pass_id, WGPURenderPipelineId pipeline_id);
890+
void wgpu_render_pass_set_pipeline(WGPURawRenderPass *pass, WGPURenderPipelineId pipeline_id);
847891

848-
void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id,
892+
void wgpu_render_pass_set_scissor_rect(WGPURawRenderPass *pass,
849893
uint32_t x,
850894
uint32_t y,
851895
uint32_t w,
852896
uint32_t h);
853897

854-
void wgpu_render_pass_set_stencil_reference(WGPURenderPassId pass_id, uint32_t value);
898+
void wgpu_render_pass_set_stencil_reference(WGPURawRenderPass *pass, uint32_t value);
855899

856-
void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id,
900+
void wgpu_render_pass_set_vertex_buffers(WGPURawRenderPass *pass,
857901
uint32_t start_slot,
858-
const WGPUBufferId *buffers,
902+
const WGPUBufferId *buffer_ids,
859903
const WGPUBufferAddress *offsets,
860904
uintptr_t length);
861905

862-
void wgpu_render_pass_set_viewport(WGPURenderPassId pass_id,
906+
void wgpu_render_pass_set_viewport(WGPURawRenderPass *pass,
863907
float x,
864908
float y,
865909
float w,
866910
float h,
867-
float min_depth,
868-
float max_depth);
911+
float depth_min,
912+
float depth_max);
869913

870914
void wgpu_request_adapter_async(const WGPURequestAdapterOptions *desc,
871915
WGPUBackendBit mask,

wgpu-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ log = "0.4"
2929
hal = { package = "gfx-hal", version = "0.4" }
3030
gfx-backend-empty = { version = "0.4" }
3131
parking_lot = "0.9"
32+
peek-poke = { git = "https://github.com/kvark/peek-poke", rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075" }
3233
rendy-memory = "0.5"
3334
rendy-descriptor = "0.5"
3435
serde = { version = "1.0", features = ["serde_derive"], optional = true }

0 commit comments

Comments
 (0)