diff --git a/wgpu-native/src/command.rs b/wgpu-native/src/command.rs index ddbb67a6d..bccdffc5d 100644 --- a/wgpu-native/src/command.rs +++ b/wgpu-native/src/command.rs @@ -83,6 +83,11 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture( } +/// # Safety +/// +/// This function is unsafe because improper use may lead to memory +/// problems. For example, a double-free may occur if the function is called +/// twice on the same raw pointer. #[no_mangle] pub unsafe extern "C" fn wgpu_render_pass_end_pass(pass_id: id::RenderPassId) { let (pass_data, encoder_id, targets) = Box::from_raw(pass_id).finish_render(); @@ -114,6 +119,11 @@ pub unsafe extern "C" fn wgpu_render_pass_end_pass(pass_id: id::RenderPassId) { gfx_select!(encoder_id => GLOBAL.command_encoder_run_render_pass(encoder_id, &color_attachments, depth_stencil_attachment, &pass_data)) } +/// # Safety +/// +/// This function is unsafe because improper use may lead to memory +/// problems. For example, a double-free may occur if the function is called +/// twice on the same raw pointer. #[no_mangle] pub unsafe extern "C" fn wgpu_compute_pass_end_pass(pass_id: id::ComputePassId) { let (pass_data, encoder_id) = Box::from_raw(pass_id).finish_compute(); diff --git a/wgpu-native/src/device.rs b/wgpu-native/src/device.rs index f178b014a..5107869ca 100644 --- a/wgpu-native/src/device.rs +++ b/wgpu-native/src/device.rs @@ -135,6 +135,9 @@ pub extern "C" fn wgpu_create_surface_from_windows_hwnd( )) } +/// # Safety +/// +/// This function is unsafe as it calls an unsafe extern callback. #[no_mangle] pub unsafe extern "C" fn wgpu_request_adapter_async( desc: Option<&core::instance::RequestAdapterOptions>, @@ -181,6 +184,10 @@ pub extern "C" fn wgpu_device_create_buffer( gfx_select!(device_id => GLOBAL.device_create_buffer(device_id, desc, PhantomData)) } +/// # Safety +/// +/// This function is unsafe as there is no guarantee that the given pointer +/// dereferenced in this function is valid. #[no_mangle] pub unsafe extern "C" fn wgpu_device_create_buffer_mapped( device_id: id::DeviceId, @@ -297,6 +304,10 @@ pub extern "C" fn wgpu_device_get_queue(device_id: id::DeviceId) -> id::QueueId device_id } +/// # Safety +/// +/// This function is unsafe as there is no guarantee that the given pointer is +/// valid for `command_buffers_length` elements. #[no_mangle] pub unsafe extern "C" fn wgpu_queue_submit( queue_id: id::QueueId,