diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 631488dfec..80bec01e35 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -225,6 +225,12 @@ pub mod compute_ffi { }; use std::{convert::TryInto, slice}; + /// # Safety + /// + /// This function is unsafe as there is no guarantee that the given pointer is + /// valid for `offset_length` elements. + // TODO: There might be other safety issues, such as using the unsafe + // `RawPass::encode` and `RawPass::encode_slice`. #[no_mangle] pub unsafe extern "C" fn wgpu_compute_pass_set_bind_group( pass: &mut RawPass, diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index d623e646df..4f373c22b8 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -197,7 +197,7 @@ pub struct CommandBufferDescriptor { } #[no_mangle] -pub unsafe extern "C" fn wgpu_command_encoder_begin_compute_pass( +pub extern "C" fn wgpu_command_encoder_begin_compute_pass( encoder_id: id::CommandEncoderId, _desc: Option<&ComputePassDescriptor>, ) -> *mut RawPass { @@ -220,6 +220,11 @@ pub struct RawRenderPass { targets: RawRenderTargets, } +/// # Safety +/// +/// This function is unsafe as there is no guarantee that the given pointer +/// (`RenderPassDescriptor::color_attachments`) is valid for +/// `RenderPassDescriptor::color_attachments_length` elements. #[no_mangle] pub unsafe extern "C" fn wgpu_command_encoder_begin_render_pass( encoder_id: id::CommandEncoderId, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 959cf7f04e..29a3609a09 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1127,6 +1127,12 @@ pub mod render_ffi { }; use std::{convert::TryInto, slice}; + /// # Safety + /// + /// This function is unsafe as there is no guarantee that the given pointer is + /// valid for `offset_length` elements. + // TODO: There might be other safety issues, such as using the unsafe + // `RawPass::encode` and `RawPass::encode_slice`. #[no_mangle] pub unsafe extern "C" fn wgpu_render_pass_set_bind_group( pass: &mut RawRenderPass, @@ -1166,6 +1172,12 @@ pub mod render_ffi { }); } + /// # Safety + /// + /// This function is unsafe as there is no guarantee that the given pointers + /// (`buffer_ids` and `offsets`) are valid for `length` elements. + // TODO: There might be other safety issues, such as using the unsafe + // `RawPass::encode` and `RawPass::encode_slice`. #[no_mangle] pub unsafe extern "C" fn wgpu_render_pass_set_vertex_buffers( pass: &mut RawRenderPass,