Which functions do I have to mark as `unsafe`?


#1
fn begin_command_buffer(&self,
                        command_buffer: CommandBuffer,
                        create_info: &CommandBufferBeginInfo)
                        -> VkResult<()>
fn end_command_buffer(&self, command_buffer: CommandBuffer) -> VkResult<()>
...
fn allocate_command_buffers(&self,
                            create_info: &CommandBufferAllocateInfo)
                            -> VkResult<Vec<CommandBuffer>>

A CommandBuffer is basically just an u64, which means Clone, Send etc. Almost all functions in Vulkan are “extern sync” which means that I am not allowed to call command_buffer functions on multiple threads at the same time.

Technically those commandbuffer functions are not unsafe but the unsafety comes from the fact that a CommandBuffer is just a u64 which has Clone and Send. Now I can just remove Clone and Send but that would make the library a bit awkard it some situations and I am not sure if I want to do that.

What do I have to mark unsafe here?

To me it seems the only unsafe function here is allocate_command_buffers as it returns the CommandBuffer handle which essentially causes the unsafety.

Edit:

I think I will mark pretty much everything as unsafe. I think marking only allocate_command_buffers would give the wrong impression because it is not allocate_command_buffers which is unsafe but the CommandBuffer that it returns.