I'm attempting to call this method from swift:
VkResult vkMapMemory( VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData);
which takes a pointer to a void pointer as the final argument, followed by
void* memcpy( void* dest, const void* src, std::size_t count );
which takes a void pointer as the first argument.
On macOS, I'm able to pass a variable which is declared like so:
let dstPointer: UnsafeMutablePointer<UnsafeMutableRawPointer?> = UnsafeMutablePointer<UnsafeMutableRawPointer?>.allocate(capacity: 1) vkMapMemory(..., dstPointer) memcpy(dstPointer.pointee, ...)
However on Linux, this gives me an error on
error: value of optional type 'UnsafeMutableRawPointer?' must be unwrapped to a value of type 'UnsafeMutableRawPointer' memcpy(dstPointer.pointee, rawBufferPointer.baseAddress!, Int(bufferSize))
I've tried changing the pointer to be non-optional, but this creates an issue on macOS when calling vkMapMemory:
Cannot convert value of type 'UnsafeMutablePointer<UnsafeMutableRawPointer>' to expected argument type 'UnsafeMutablePointer<UnsafeMutableRawPointer?>?'
Is there a reason these pointer types would be bridged differently on each platofrm? Also is there a better way of handling pointers to avoid this?