@@ -29,7 +29,7 @@ static void handle_request_device(WGPURequestDeviceStatus status,
2929 UNUSED (userdata2 )
3030 * (WGPUDevice * )userdata1 = device ;
3131}
32- static void handle_buffer_map (WGPUMapAsyncStatus status ,
32+ static void handle_buffer_map (WGPUMapAsyncStatus status ,
3333 WGPUStringView message ,
3434 void * userdata1 , void * userdata2 ) {
3535 UNUSED (message )
@@ -73,19 +73,29 @@ int main(int argc, char *argv[]) {
7373 assert (instance );
7474
7575 WGPUAdapter adapter = NULL ;
76- wgpuInstanceRequestAdapter (instance , NULL,
76+ WGPUFuture future = wgpuInstanceRequestAdapter (instance , NULL ,
7777 (const WGPURequestAdapterCallbackInfo ){
7878 .callback = handle_request_adapter ,
7979 .userdata1 = & adapter
8080 });
81+ WGPUFutureWaitInfo wait_info = {
82+ .future = future ,
83+ .completed = false,
84+ };
85+ assert (WGPUWaitStatus_Success == wgpuInstanceWaitAny (instance , 1 , & wait_info , 0 ));
8186 assert (adapter );
8287
8388 WGPUDevice device = NULL ;
84- wgpuAdapterRequestDevice (adapter , NULL,
85- (const WGPURequestDeviceCallbackInfo ){
89+ future = wgpuAdapterRequestDevice (adapter , NULL ,
90+ (const WGPURequestDeviceCallbackInfo ){
8691 .callback = handle_request_device ,
8792 .userdata1 = & device
8893 });
94+ wait_info = (WGPUFutureWaitInfo ){
95+ .future = future ,
96+ .completed = false,
97+ };
98+ assert (WGPUWaitStatus_Success == wgpuInstanceWaitAny (instance , 1 , & wait_info , 0 ));
8999 assert (device );
90100
91101 WGPUQueue queue = wgpuDeviceGetQueue (device );
@@ -186,11 +196,16 @@ int main(int argc, char *argv[]) {
186196
187197 wgpuQueueSubmit (queue , 1 , (const WGPUCommandBuffer []){command_buffer });
188198
189- wgpuBufferMapAsync (output_buffer , WGPUMapMode_Read , 0 , buffer_size ,
199+ future = wgpuBufferMapAsync (output_buffer , WGPUMapMode_Read , 0 , buffer_size ,
190200 (const WGPUBufferMapCallbackInfo ){
191201 .callback = handle_buffer_map
192202 });
193203 wgpuDevicePoll (device , true, NULL);
204+ wait_info = (WGPUFutureWaitInfo ){
205+ .future = future ,
206+ .completed = false,
207+ };
208+ assert (WGPUWaitStatus_Success == wgpuInstanceWaitAny (instance , 1 , & wait_info , 0 ));
194209
195210 uint8_t * buf =
196211 (uint8_t * )wgpuBufferGetConstMappedRange (output_buffer , 0 , buffer_size );
0 commit comments