private VkObjectResult<IVkInstance> CreateInstanceInternal(IntPtr data, VkInstanceCreateInfo createInfo, VkAllocationCallbacks allocator) { var unmanaged = (byte*)data; var pCreateInfo = createInfo.MarshalIndirect(ref unmanaged); var pAllocator = allocator.MarshalIndirect(ref unmanaged); VkInstance.HandleType handle; var result = Direct.CreateInstance(pCreateInfo, pAllocator, &handle); var instance = result == VkResult.Success ? new VkInstance(handle, allocator) : null; return new VkObjectResult<IVkInstance>(result, instance); }
public VkObjectResult<IVkInstance> CreateInstance(VkInstanceCreateInfo createInfo, VkAllocationCallbacks allocator) { var size = createInfo.SizeOfMarshalIndirect() + allocator.SizeOfMarshalIndirect(); return VkHelpers.RunWithUnamangedData(size, u => CreateInstanceInternal(u, createInfo, allocator)); }