diff --git a/examples/capture/main.c b/examples/capture/main.c index e7133836..6d0ad184 100644 --- a/examples/capture/main.c +++ b/examples/capture/main.c @@ -15,20 +15,26 @@ const size_t COPY_BYTES_PER_ROW_ALIGNMENT = 256; static void handle_request_adapter(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { UNUSED(status) UNUSED(message) - *(WGPUAdapter *)userdata = adapter; + UNUSED(userdata2) + *(WGPUAdapter *)userdata1 = adapter; } static void handle_request_device(WGPURequestDeviceStatus status, WGPUDevice device, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { UNUSED(status) UNUSED(message) - *(WGPUDevice *)userdata = device; + UNUSED(userdata2) + *(WGPUDevice *)userdata1 = device; } -static void handle_buffer_map(WGPUBufferMapAsyncStatus status, void *userdata) { - UNUSED(userdata) +static void handle_buffer_map(WGPUBufferMapAsyncStatus status, + char const *message, + void *userdata1, void *userdata2) { + UNUSED(message) + UNUSED(userdata1) + UNUSED(userdata2) printf(LOG_PREFIX " buffer_map status=%#.8x\n", status); } @@ -67,14 +73,21 @@ int main(int argc, char *argv[]) { assert(instance); WGPUAdapter adapter = NULL; - wgpuInstanceRequestAdapter(instance, NULL, handle_request_adapter, - (void *)&adapter); + wgpuInstanceRequestAdapter(instance, NULL, + (const WGPURequestAdapterCallbackInfo){ + .callback = handle_request_adapter, + .userdata1 = &adapter + }); assert(adapter); WGPUDevice device = NULL; - wgpuAdapterRequestDevice(adapter, NULL, handle_request_device, - (void *)&device); + wgpuAdapterRequestDevice(adapter, NULL, + (const WGPURequestDeviceCallbackInfo){ + .callback = handle_request_device, + .userdata1 = &device + }); assert(device); + WGPUQueue queue = wgpuDeviceGetQueue(device); assert(queue); @@ -174,7 +187,9 @@ int main(int argc, char *argv[]) { wgpuQueueSubmit(queue, 1, (const WGPUCommandBuffer[]){command_buffer}); wgpuBufferMapAsync(output_buffer, WGPUMapMode_Read, 0, buffer_size, - handle_buffer_map, NULL); + (const WGPUBufferMapCallbackInfo){ + .callback = handle_buffer_map + }); wgpuDevicePoll(device, true, NULL); uint8_t *buf = diff --git a/examples/compute/main.c b/examples/compute/main.c index 03dcaeba..83ed6c6b 100644 --- a/examples/compute/main.c +++ b/examples/compute/main.c @@ -8,20 +8,25 @@ static void handle_request_adapter(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { UNUSED(status) UNUSED(message) - *(WGPUAdapter *)userdata = adapter; + UNUSED(userdata2) + *(WGPUAdapter *)userdata1 = adapter; } static void handle_request_device(WGPURequestDeviceStatus status, WGPUDevice device, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { UNUSED(status) UNUSED(message) - *(WGPUDevice *)userdata = device; + UNUSED(userdata2) + *(WGPUDevice *)userdata1 = device; } -static void handle_buffer_map(WGPUBufferMapAsyncStatus status, void *userdata) { - UNUSED(userdata) +static void handle_buffer_map(WGPUBufferMapAsyncStatus status, + char const * message, + void *userdata1, void *userdata2) { + UNUSED(userdata1) + UNUSED(userdata2) printf(LOG_PREFIX " buffer_map status=%#.8x\n", status); } @@ -38,13 +43,19 @@ int main(int argc, char *argv[]) { assert(instance); WGPUAdapter adapter = NULL; - wgpuInstanceRequestAdapter(instance, NULL, handle_request_adapter, - (void *)&adapter); + wgpuInstanceRequestAdapter(instance, NULL, + (const WGPURequestAdapterCallbackInfo){ + .callback = handle_request_adapter, + .userdata1 = &adapter + }); assert(adapter); WGPUDevice device = NULL; - wgpuAdapterRequestDevice(adapter, NULL, handle_request_device, - (void *)&device); + wgpuAdapterRequestDevice(adapter, NULL, + (const WGPURequestDeviceCallbackInfo){ + .callback = handle_request_device, + .userdata1 = &device + }); assert(device); WGPUQueue queue = wgpuDeviceGetQueue(device); @@ -139,7 +150,9 @@ int main(int argc, char *argv[]) { wgpuQueueSubmit(queue, 1, &command_buffer); wgpuBufferMapAsync(staging_buffer, WGPUMapMode_Read, 0, numbers_size, - handle_buffer_map, NULL); + (const WGPUBufferMapCallbackInfo){ + .callback = handle_buffer_map + }); wgpuDevicePoll(device, true, NULL); uint32_t *buf = diff --git a/examples/framework/framework.c b/examples/framework/framework.c index f0729e51..3a02e540 100644 --- a/examples/framework/framework.c +++ b/examples/framework/framework.c @@ -67,10 +67,10 @@ WGPUShaderModule frmwrk_load_shader_module(WGPUDevice device, .label = name, .nextInChain = (const WGPUChainedStruct *)&( - const WGPUShaderModuleWGSLDescriptor){ + const WGPUShaderSourceWGSL){ .chain = (const WGPUChainedStruct){ - .sType = WGPUSType_ShaderModuleWGSLDescriptor, + .sType = WGPUSType_ShaderSourceWGSL, }, .code = buf, }, diff --git a/examples/framework/framework.h b/examples/framework/framework.h index c10084d7..cbde32bf 100644 --- a/examples/framework/framework.h +++ b/examples/framework/framework.h @@ -12,7 +12,7 @@ typedef struct frmwrk_buffer_init_descriptor { WGPU_NULLABLE char const *label; - WGPUBufferUsageFlags usage; + WGPUBufferUsage usage; void *content; size_t content_size; } frmwrk_buffer_init_descriptor; diff --git a/examples/texture_arrays/main.c b/examples/texture_arrays/main.c index 907355f7..c33fd993 100644 --- a/examples/texture_arrays/main.c +++ b/examples/texture_arrays/main.c @@ -27,9 +27,10 @@ struct demo { static void handle_request_adapter(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { + UNUSED(userdata2) if (status == WGPURequestAdapterStatus_Success) { - struct demo *demo = userdata; + struct demo *demo = userdata1; demo->adapter = adapter; } else { printf(LOG_PREFIX " request_adapter status=%#.8x message=%s\n", status, @@ -38,9 +39,10 @@ static void handle_request_adapter(WGPURequestAdapterStatus status, } static void handle_request_device(WGPURequestDeviceStatus status, WGPUDevice device, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { + UNUSED(userdata2) if (status == WGPURequestDeviceStatus_Success) { - struct demo *demo = userdata; + struct demo *demo = userdata1; demo->device = device; } else { printf(LOG_PREFIX " request_device status=%#.8x message=%s\n", status, @@ -147,10 +149,10 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromMetalLayer){ + const WGPUSurfaceSourceromMetalLayer){ .chain = (const WGPUChainedStruct){ - .sType = WGPUSType_SurfaceDescriptorFromMetalLayer, + .sType = WGPUSType_SurfaceSourceMetalLayer, }, .layer = metal_layer, }, @@ -165,10 +167,10 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromXlibWindow){ + const WGPUSurfaceSourceXlibWindow){ .chain = (const WGPUChainedStruct){ - .sType = WGPUSType_SurfaceDescriptorFromXlibWindow, + .sType = WGPUSType_SurfaceSourceXlibWindow, }, .display = x11_display, .window = x11_window, @@ -183,11 +185,11 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromWaylandSurface){ + const WGPUSurfaceSourceWaylandSurface){ .chain = (const WGPUChainedStruct){ .sType = - WGPUSType_SurfaceDescriptorFromWaylandSurface, + WGPUSType_SurfaceSourceWaylandSurface, }, .display = wayland_display, .surface = wayland_surface, @@ -203,10 +205,10 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromWindowsHWND){ + const WGPUSurfaceSourceWindowsHWND){ .chain = (const WGPUChainedStruct){ - .sType = WGPUSType_SurfaceDescriptorFromWindowsHWND, + .sType = WGPUSType_SurfaceSourceWindowsHWND, }, .hinstance = hinstance, .hwnd = hwnd, @@ -222,7 +224,10 @@ int main(int argc, char *argv[]) { &(const WGPURequestAdapterOptions){ .compatibleSurface = demo.surface, }, - handle_request_adapter, &demo); + (const WGPURequestAdapterCallbackInfo){ + .callback = handle_request_adapter, + .userdata1 = &demo + }); assert(demo.adapter); WGPUSurfaceCapabilities surface_capabilities = {0}; @@ -260,13 +265,15 @@ int main(int argc, char *argv[]) { required_device_feature_count++; } - wgpuAdapterRequestDevice( - demo.adapter, - &(const WGPUDeviceDescriptor){ - .requiredFeatureCount = required_device_feature_count, - .requiredFeatures = required_device_features, - }, - handle_request_device, &demo); + wgpuAdapterRequestDevice(demo.adapter, + &(const WGPUDeviceDescriptor){ + .requiredFeatureCount = required_device_feature_count, + .requiredFeatures = required_device_features, + }, + (const WGPURequestDeviceCallbackInfo){ + .callback = handle_request_device, + .userdata1 = &demo + }); assert(demo.device); WGPUQueue queue = wgpuDeviceGetQueue(demo.device); @@ -648,8 +655,9 @@ int main(int argc, char *argv[]) { WGPUSurfaceTexture surface_texture; wgpuSurfaceGetCurrentTexture(demo.surface, &surface_texture); switch (surface_texture.status) { - case WGPUSurfaceGetCurrentTextureStatus_Success: - // All good, could check for `surface_texture.suboptimal` here. + case WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal: + case WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal: + // All good, could handle suboptimal here break; case WGPUSurfaceGetCurrentTextureStatus_Timeout: case WGPUSurfaceGetCurrentTextureStatus_Outdated: diff --git a/examples/triangle/main.c b/examples/triangle/main.c index fb6eacdd..81ee2d88 100644 --- a/examples/triangle/main.c +++ b/examples/triangle/main.c @@ -27,9 +27,10 @@ struct demo { static void handle_request_adapter(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { + UNUSED(userdata2) if (status == WGPURequestAdapterStatus_Success) { - struct demo *demo = userdata; + struct demo *demo = userdata1; demo->adapter = adapter; } else { printf(LOG_PREFIX " request_adapter status=%#.8x message=%s\n", status, @@ -38,9 +39,10 @@ static void handle_request_adapter(WGPURequestAdapterStatus status, } static void handle_request_device(WGPURequestDeviceStatus status, WGPUDevice device, char const *message, - void *userdata) { + void *userdata1, void *userdata2) { + UNUSED(userdata2) if (status == WGPURequestDeviceStatus_Success) { - struct demo *demo = userdata; + struct demo *demo = userdata1; demo->device = device; } else { printf(LOG_PREFIX " request_device status=%#.8x message=%s\n", status, @@ -110,10 +112,10 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromMetalLayer){ + const WGPUSurfaceSourceromMetalLayer){ .chain = (const WGPUChainedStruct){ - .sType = WGPUSType_SurfaceDescriptorFromMetalLayer, + .sType = WGPUSType_SurfaceSourceMetalLayer, }, .layer = metal_layer, }, @@ -128,10 +130,10 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromXlibWindow){ + const WGPUSurfaceSourceXlibWindow){ .chain = (const WGPUChainedStruct){ - .sType = WGPUSType_SurfaceDescriptorFromXlibWindow, + .sType = WGPUSType_SurfaceSourceXlibWindow, }, .display = x11_display, .window = x11_window, @@ -146,11 +148,11 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromWaylandSurface){ + const WGPUSurfaceSourceWaylandSurface){ .chain = (const WGPUChainedStruct){ .sType = - WGPUSType_SurfaceDescriptorFromWaylandSurface, + WGPUSType_SurfaceSourceWaylandSurface, }, .display = wayland_display, .surface = wayland_surface, @@ -166,10 +168,10 @@ int main(int argc, char *argv[]) { &(const WGPUSurfaceDescriptor){ .nextInChain = (const WGPUChainedStruct *)&( - const WGPUSurfaceDescriptorFromWindowsHWND){ + const WGPUSurfaceSourceWindowsHWND){ .chain = (const WGPUChainedStruct){ - .sType = WGPUSType_SurfaceDescriptorFromWindowsHWND, + .sType = WGPUSType_SurfaceSourceWindowsHWND, }, .hinstance = hinstance, .hwnd = hwnd, @@ -185,12 +187,19 @@ int main(int argc, char *argv[]) { &(const WGPURequestAdapterOptions){ .compatibleSurface = demo.surface, }, - handle_request_adapter, &demo); + (const WGPURequestAdapterCallbackInfo){ + .callback = handle_request_adapter, + .userdata1 = &demo + }); assert(demo.adapter); frmwrk_print_adapter_info(demo.adapter); - wgpuAdapterRequestDevice(demo.adapter, NULL, handle_request_device, &demo); + wgpuAdapterRequestDevice(demo.adapter, NULL, + (const WGPURequestDeviceCallbackInfo){ + .callback = handle_request_device, + .userdata1 = &demo + }); assert(demo.device); WGPUQueue queue = wgpuDeviceGetQueue(demo.device); @@ -267,8 +276,9 @@ int main(int argc, char *argv[]) { WGPUSurfaceTexture surface_texture; wgpuSurfaceGetCurrentTexture(demo.surface, &surface_texture); switch (surface_texture.status) { - case WGPUSurfaceGetCurrentTextureStatus_Success: - // All good, could check for `surface_texture.suboptimal` here. + case WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal: + case WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal: + // All good, could handle suboptimal here break; case WGPUSurfaceGetCurrentTextureStatus_Timeout: case WGPUSurfaceGetCurrentTextureStatus_Outdated: