77#define LOG_PREFIX "[compute]"
88
99static void handle_request_adapter (WGPURequestAdapterStatus status ,
10- WGPUAdapter adapter , char const * message ,
11- void * userdata ) {
10+ WGPUAdapter adapter , WGPUStringView message ,
11+ void * userdata1 , void * userdata2 ) {
1212 UNUSED (status )
1313 UNUSED (message )
14- * (WGPUAdapter * )userdata = adapter ;
14+ UNUSED (userdata2 )
15+ * (WGPUAdapter * )userdata1 = adapter ;
1516}
1617static void handle_request_device (WGPURequestDeviceStatus status ,
17- WGPUDevice device , char const * message ,
18- void * userdata ) {
18+ WGPUDevice device , WGPUStringView message ,
19+ void * userdata1 , void * userdata2 ) {
1920 UNUSED (status )
2021 UNUSED (message )
21- * (WGPUDevice * )userdata = device ;
22+ UNUSED (userdata2 )
23+ * (WGPUDevice * )userdata1 = device ;
2224}
23- static void handle_buffer_map (WGPUBufferMapAsyncStatus status , void * userdata ) {
24- UNUSED (userdata )
25+ static void handle_buffer_map (WGPUMapAsyncStatus status ,
26+ WGPUStringView message ,
27+ void * userdata1 , void * userdata2 ) {
28+ UNUSED (userdata1 )
29+ UNUSED (userdata2 )
2530 printf (LOG_PREFIX " buffer_map status=%#.8x\n" , status );
2631}
2732
@@ -38,13 +43,19 @@ int main(int argc, char *argv[]) {
3843 assert (instance );
3944
4045 WGPUAdapter adapter = NULL ;
41- wgpuInstanceRequestAdapter (instance , NULL, handle_request_adapter ,
42- (void * )& adapter );
46+ wgpuInstanceRequestAdapter (instance , NULL,
47+ (const WGPURequestAdapterCallbackInfo ){
48+ .callback = handle_request_adapter ,
49+ .userdata1 = & adapter
50+ });
4351 assert (adapter );
4452
4553 WGPUDevice device = NULL ;
46- wgpuAdapterRequestDevice (adapter , NULL, handle_request_device ,
47- (void * )& device );
54+ wgpuAdapterRequestDevice (adapter , NULL,
55+ (const WGPURequestDeviceCallbackInfo ){
56+ .callback = handle_request_device ,
57+ .userdata1 = & device
58+ });
4859 assert (device );
4960
5061 WGPUQueue queue = wgpuDeviceGetQueue (device );
@@ -56,7 +67,7 @@ int main(int argc, char *argv[]) {
5667
5768 WGPUBuffer staging_buffer = wgpuDeviceCreateBuffer (
5869 device , & (const WGPUBufferDescriptor ){
59- .label = "staging_buffer" ,
70+ .label = { "staging_buffer" , WGPU_STRLEN } ,
6071 .usage = WGPUBufferUsage_MapRead | WGPUBufferUsage_CopyDst ,
6172 .size = numbers_size ,
6273 .mappedAtCreation = false,
@@ -65,7 +76,7 @@ int main(int argc, char *argv[]) {
6576
6677 WGPUBuffer storage_buffer = wgpuDeviceCreateBuffer (
6778 device , & (const WGPUBufferDescriptor ){
68- .label = "storage_buffer" ,
79+ .label = { "storage_buffer" , WGPU_STRLEN } ,
6980 .usage = WGPUBufferUsage_Storage | WGPUBufferUsage_CopyDst |
7081 WGPUBufferUsage_CopySrc ,
7182 .size = numbers_size ,
@@ -75,11 +86,11 @@ int main(int argc, char *argv[]) {
7586
7687 WGPUComputePipeline compute_pipeline = wgpuDeviceCreateComputePipeline (
7788 device , & (const WGPUComputePipelineDescriptor ){
78- .label = "compute_pipeline" ,
89+ .label = { "compute_pipeline" , WGPU_STRLEN } ,
7990 .compute =
8091 (const WGPUProgrammableStageDescriptor ){
8192 .module = shader_module ,
82- .entryPoint = "main" ,
93+ .entryPoint = { "main" , WGPU_STRLEN } ,
8394 },
8495 });
8596 assert (compute_pipeline );
@@ -90,7 +101,7 @@ int main(int argc, char *argv[]) {
90101
91102 WGPUBindGroup bind_group = wgpuDeviceCreateBindGroup (
92103 device , & (const WGPUBindGroupDescriptor ){
93- .label = "bind_group" ,
104+ .label = { "bind_group" , WGPU_STRLEN } ,
94105 .layout = bind_group_layout ,
95106 .entryCount = 1 ,
96107 .entries =
@@ -107,14 +118,14 @@ int main(int argc, char *argv[]) {
107118
108119 WGPUCommandEncoder command_encoder = wgpuDeviceCreateCommandEncoder (
109120 device , & (const WGPUCommandEncoderDescriptor ){
110- .label = "command_encoder" ,
121+ .label = { "command_encoder" , WGPU_STRLEN } ,
111122 });
112123 assert (command_encoder );
113124
114125 WGPUComputePassEncoder compute_pass_encoder =
115126 wgpuCommandEncoderBeginComputePass (command_encoder ,
116127 & (const WGPUComputePassDescriptor ){
117- .label = "compute_pass" ,
128+ .label = { "compute_pass" , WGPU_STRLEN } ,
118129 });
119130 assert (compute_pass_encoder );
120131
@@ -131,15 +142,17 @@ int main(int argc, char *argv[]) {
131142
132143 WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish (
133144 command_encoder , & (const WGPUCommandBufferDescriptor ){
134- .label = "command_buffer" ,
145+ .label = { "command_buffer" , WGPU_STRLEN } ,
135146 });
136147 assert (command_buffer );
137148
138149 wgpuQueueWriteBuffer (queue , storage_buffer , 0 , & numbers , numbers_size );
139150 wgpuQueueSubmit (queue , 1 , & command_buffer );
140151
141152 wgpuBufferMapAsync (staging_buffer , WGPUMapMode_Read , 0 , numbers_size ,
142- handle_buffer_map , NULL);
153+ (const WGPUBufferMapCallbackInfo ){
154+ .callback = handle_buffer_map
155+ });
143156 wgpuDevicePoll (device , true, NULL) ;
144157
145158 uint32_t * buf =
0 commit comments