19
19
#include <stdint.h>
20
20
#include <stdlib.h>
21
21
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
+
22
34
typedef enum {
23
35
WGPUAddressMode_ClampToEdge = 0 ,
24
36
WGPUAddressMode_Repeat = 1 ,
@@ -282,20 +294,19 @@ typedef uint64_t WGPUId_CommandBuffer_Dummy;
282
294
283
295
typedef WGPUId_CommandBuffer_Dummy WGPUCommandBufferId ;
284
296
285
- typedef uint64_t WGPUId_ComputePass_Dummy ;
286
-
287
- typedef WGPUId_ComputePass_Dummy WGPUComputePassId ;
288
-
289
297
typedef WGPUCommandBufferId WGPUCommandEncoderId ;
290
298
299
+ typedef struct {
300
+ uint8_t * data ;
301
+ uint8_t * base ;
302
+ uintptr_t capacity ;
303
+ WGPUCommandEncoderId parent ;
304
+ } WGPURawPass ;
305
+
291
306
typedef struct {
292
307
uint32_t todo ;
293
308
} WGPUComputePassDescriptor ;
294
309
295
- typedef uint64_t WGPUId_RenderPass_Dummy ;
296
-
297
- typedef WGPUId_RenderPass_Dummy WGPURenderPassId ;
298
-
299
310
typedef uint64_t WGPUId_TextureView_Dummy ;
300
311
301
312
typedef WGPUId_TextureView_Dummy WGPUTextureViewId ;
@@ -315,11 +326,13 @@ typedef struct {
315
326
316
327
typedef struct {
317
328
WGPUTextureViewId attachment ;
318
- const WGPUTextureViewId * resolve_target ;
329
+ WGPUTextureViewId resolve_target ;
319
330
WGPULoadOp load_op ;
320
331
WGPUStoreOp store_op ;
321
332
WGPUColor clear_color ;
322
- } WGPURenderPassColorAttachmentDescriptor ;
333
+ } WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId ;
334
+
335
+ typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId WGPURawRenderPassColorAttachmentDescriptor ;
323
336
324
337
typedef struct {
325
338
WGPUTextureViewId attachment ;
@@ -329,12 +342,36 @@ typedef struct {
329
342
WGPULoadOp stencil_load_op ;
330
343
WGPUStoreOp stencil_store_op ;
331
344
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 ;
333
370
334
371
typedef struct {
335
372
const WGPURenderPassColorAttachmentDescriptor * color_attachments ;
336
373
uintptr_t color_attachments_length ;
337
- const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId * depth_stencil_attachment ;
374
+ const WGPURenderPassDepthStencilAttachmentDescriptor * depth_stencil_attachment ;
338
375
} WGPURenderPassDescriptor ;
339
376
340
377
typedef struct {
@@ -372,6 +409,8 @@ typedef struct {
372
409
uint32_t todo ;
373
410
} WGPUCommandBufferDescriptor ;
374
411
412
+ typedef WGPURawPass * WGPUComputePassId ;
413
+
375
414
typedef const char * WGPURawString ;
376
415
377
416
typedef uint64_t WGPUId_ComputePipeline_Dummy ;
@@ -639,6 +678,8 @@ typedef struct {
639
678
640
679
typedef WGPUDeviceId WGPUQueueId ;
641
680
681
+ typedef WGPURawRenderPass * WGPURenderPassId ;
682
+
642
683
typedef uint64_t WGPUId_RenderBundle_Dummy ;
643
684
644
685
typedef WGPUId_RenderBundle_Dummy WGPURenderBundleId ;
@@ -688,11 +729,11 @@ void wgpu_buffer_unmap(WGPUBufferId buffer_id);
688
729
689
730
void wgpu_command_buffer_destroy (WGPUCommandBufferId command_buffer_id );
690
731
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 );
693
734
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 );
696
737
697
738
void wgpu_command_encoder_copy_buffer_to_buffer (WGPUCommandEncoderId command_encoder_id ,
698
739
WGPUBufferId source ,
@@ -721,27 +762,30 @@ void wgpu_command_encoder_destroy(WGPUCommandEncoderId command_encoder_id);
721
762
WGPUCommandBufferId wgpu_command_encoder_finish (WGPUCommandEncoderId encoder_id ,
722
763
const WGPUCommandBufferDescriptor * desc );
723
764
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 );
725
769
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 );
729
773
730
774
void wgpu_compute_pass_end_pass (WGPUComputePassId pass_id );
731
775
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 );
733
777
734
- void wgpu_compute_pass_pop_debug_group (WGPUComputePassId _pass_id );
778
+ void wgpu_compute_pass_pop_debug_group (WGPURawPass * _pass );
735
779
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 );
737
781
738
- void wgpu_compute_pass_set_bind_group (WGPUComputePassId pass_id ,
782
+ void wgpu_compute_pass_set_bind_group (WGPURawPass * pass ,
739
783
uint32_t index ,
740
784
WGPUBindGroupId bind_group_id ,
741
785
const WGPUBufferAddress * offsets ,
742
- uintptr_t offsets_length );
786
+ uintptr_t offset_length );
743
787
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 );
745
789
746
790
WGPUSurfaceId wgpu_create_surface_from_metal_layer (void * layer );
747
791
@@ -798,74 +842,74 @@ void wgpu_queue_submit(WGPUQueueId queue_id,
798
842
const WGPUCommandBufferId * command_buffers ,
799
843
uintptr_t command_buffers_length );
800
844
801
- void wgpu_render_pass_draw (WGPURenderPassId pass_id ,
845
+ void wgpu_render_pass_draw (WGPURawRenderPass * pass ,
802
846
uint32_t vertex_count ,
803
847
uint32_t instance_count ,
804
848
uint32_t first_vertex ,
805
849
uint32_t first_instance );
806
850
807
- void wgpu_render_pass_draw_indexed (WGPURenderPassId pass_id ,
851
+ void wgpu_render_pass_draw_indexed (WGPURawRenderPass * pass ,
808
852
uint32_t index_count ,
809
853
uint32_t instance_count ,
810
854
uint32_t first_index ,
811
855
int32_t base_vertex ,
812
856
uint32_t first_instance );
813
857
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 );
817
861
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 );
821
865
822
866
void wgpu_render_pass_end_pass (WGPURenderPassId pass_id );
823
867
824
- void wgpu_render_pass_execute_bundles (WGPURenderPassId _pass_id ,
868
+ void wgpu_render_pass_execute_bundles (WGPURawRenderPass * _pass ,
825
869
const WGPURenderBundleId * _bundles ,
826
870
uintptr_t _bundles_length );
827
871
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 );
829
873
830
- void wgpu_render_pass_pop_debug_group (WGPURenderPassId _pass_id );
874
+ void wgpu_render_pass_pop_debug_group (WGPURawRenderPass * _pass );
831
875
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 );
833
877
834
- void wgpu_render_pass_set_bind_group (WGPURenderPassId pass_id ,
878
+ void wgpu_render_pass_set_bind_group (WGPURawRenderPass * pass ,
835
879
uint32_t index ,
836
880
WGPUBindGroupId bind_group_id ,
837
881
const WGPUBufferAddress * offsets ,
838
- uintptr_t offsets_length );
882
+ uintptr_t offset_length );
839
883
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 );
841
885
842
- void wgpu_render_pass_set_index_buffer (WGPURenderPassId pass_id ,
886
+ void wgpu_render_pass_set_index_buffer (WGPURawRenderPass * pass ,
843
887
WGPUBufferId buffer_id ,
844
888
WGPUBufferAddress offset );
845
889
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 );
847
891
848
- void wgpu_render_pass_set_scissor_rect (WGPURenderPassId pass_id ,
892
+ void wgpu_render_pass_set_scissor_rect (WGPURawRenderPass * pass ,
849
893
uint32_t x ,
850
894
uint32_t y ,
851
895
uint32_t w ,
852
896
uint32_t h );
853
897
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 );
855
899
856
- void wgpu_render_pass_set_vertex_buffers (WGPURenderPassId pass_id ,
900
+ void wgpu_render_pass_set_vertex_buffers (WGPURawRenderPass * pass ,
857
901
uint32_t start_slot ,
858
- const WGPUBufferId * buffers ,
902
+ const WGPUBufferId * buffer_ids ,
859
903
const WGPUBufferAddress * offsets ,
860
904
uintptr_t length );
861
905
862
- void wgpu_render_pass_set_viewport (WGPURenderPassId pass_id ,
906
+ void wgpu_render_pass_set_viewport (WGPURawRenderPass * pass ,
863
907
float x ,
864
908
float y ,
865
909
float w ,
866
910
float h ,
867
- float min_depth ,
868
- float max_depth );
911
+ float depth_min ,
912
+ float depth_max );
869
913
870
914
void wgpu_request_adapter_async (const WGPURequestAdapterOptions * desc ,
871
915
WGPUBackendBit mask ,
0 commit comments