/// <summary> /// Create a new device instance. /// </summary> /// <param name="flags"> /// Reserved for future use. /// </param> /// <param name="queueCreateInfos"> /// </param> /// <param name="enabledLayerNames"> /// ppEnabledLayerNames is deprecated and ignored. See Device Layer /// Deprecation. /// </param> /// <param name="enabledExtensionNames"> /// An array of enabledExtensionCount strings containing the names of /// extensions to enable for the created device. See the Extensions /// section for further details. /// </param> /// <param name="enabledFeatures"> /// Null or a PhysicalDeviceFeatures structure that contains boolean /// indicators of all the features to be enabled. Refer to the Features /// section for further details. /// </param> /// <param name="physicalDeviceFeatures2Khr"> /// Extension struct /// </param> /// <param name="deviceGroupDeviceCreateInfoKhx"> /// Extension struct /// </param> /// <param name="allocator"> /// An optional AllocationCallbacks instance that controls host memory /// allocation. /// </param> public unsafe SharpVk.Device CreateDevice(ArrayProxy <SharpVk.DeviceQueueCreateInfo>?queueCreateInfos, ArrayProxy <string>?enabledLayerNames, ArrayProxy <string>?enabledExtensionNames, SharpVk.DeviceCreateFlags?flags = default(SharpVk.DeviceCreateFlags?), SharpVk.PhysicalDeviceFeatures?enabledFeatures = default(SharpVk.PhysicalDeviceFeatures?), SharpVk.Khronos.PhysicalDeviceFeatures2?physicalDeviceFeatures2Khr = null, SharpVk.Khronos.Experimental.DeviceGroupDeviceCreateInfo?deviceGroupDeviceCreateInfoKhx = null, SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Device result = default(SharpVk.Device); SharpVk.Interop.DeviceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.DeviceCreateInfo *); void *nextPointer = default(void *); SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Device marshalledDevice = default(SharpVk.Interop.Device); if (physicalDeviceFeatures2Khr != null) { SharpVk.Interop.Khronos.PhysicalDeviceFeatures2 *extensionPointer = default(SharpVk.Interop.Khronos.PhysicalDeviceFeatures2 *); extensionPointer = (SharpVk.Interop.Khronos.PhysicalDeviceFeatures2 *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PhysicalDeviceFeatures2>()); physicalDeviceFeatures2Khr.Value.MarshalTo(extensionPointer); extensionPointer->Next = nextPointer; nextPointer = extensionPointer; } if (deviceGroupDeviceCreateInfoKhx != null) { SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo *extensionPointer = default(SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo *); extensionPointer = (SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo>()); deviceGroupDeviceCreateInfoKhx.Value.MarshalTo(extensionPointer); extensionPointer->Next = nextPointer; nextPointer = extensionPointer; } marshalledCreateInfo = (SharpVk.Interop.DeviceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.DeviceCreateInfo>()); marshalledCreateInfo->SType = StructureType.DeviceCreateInfo; marshalledCreateInfo->Next = nextPointer; if (flags != null) { marshalledCreateInfo->Flags = flags.Value; } else { marshalledCreateInfo->Flags = default(SharpVk.DeviceCreateFlags); } marshalledCreateInfo->QueueCreateInfoCount = (uint)(Interop.HeapUtil.GetLength(queueCreateInfos)); if (queueCreateInfos.IsNull()) { marshalledCreateInfo->QueueCreateInfos = null; } else { if (queueCreateInfos.Value.Contents == ProxyContents.Single) { marshalledCreateInfo->QueueCreateInfos = (SharpVk.Interop.DeviceQueueCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.DeviceQueueCreateInfo>()); queueCreateInfos.Value.GetSingleValue().MarshalTo(&*(SharpVk.Interop.DeviceQueueCreateInfo *)(marshalledCreateInfo->QueueCreateInfos)); } else { var fieldPointer = (SharpVk.Interop.DeviceQueueCreateInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.DeviceQueueCreateInfo>(Interop.HeapUtil.GetLength(queueCreateInfos.Value)).ToPointer()); for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(queueCreateInfos.Value)); index++) { queueCreateInfos.Value[index].MarshalTo(&fieldPointer[index]); } marshalledCreateInfo->QueueCreateInfos = fieldPointer; } } marshalledCreateInfo->EnabledLayerCount = (uint)(Interop.HeapUtil.GetLength(enabledLayerNames)); marshalledCreateInfo->EnabledLayerNames = Interop.HeapUtil.MarshalTo(enabledLayerNames); marshalledCreateInfo->EnabledExtensionCount = (uint)(Interop.HeapUtil.GetLength(enabledExtensionNames)); marshalledCreateInfo->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(enabledExtensionNames); if (enabledFeatures != null) { marshalledCreateInfo->EnabledFeatures = (SharpVk.Interop.PhysicalDeviceFeatures *)(Interop.HeapUtil.Allocate <SharpVk.Interop.PhysicalDeviceFeatures>()); enabledFeatures.Value.MarshalTo(marshalledCreateInfo->EnabledFeatures); } else { marshalledCreateInfo->EnabledFeatures = default(SharpVk.Interop.PhysicalDeviceFeatures *); } if (allocator != null) { marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>()); allocator.Value.MarshalTo(marshalledAllocator); } else { marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); } SharpVk.Interop.VkPhysicalDeviceCreateDeviceDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.VkPhysicalDeviceCreateDeviceDelegate>("vkCreateDevice", ""); Result methodResult = commandDelegate(this.handle, marshalledCreateInfo, marshalledAllocator, &marshalledDevice); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } result = new SharpVk.Device(this, marshalledDevice); return(result); } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="proxy"></param> /// <returns></returns> public static bool IsNull <T>(this ArrayProxy <T>?proxy) { return(proxy == null || proxy.Value.Contents == ProxyContents.Null); }
/// <summary> /// Create a new Vulkan instance. /// </summary> /// <param name="flags"> /// Reserved for future use. /// </param> /// <param name="applicationInfo"> /// Null or an instance of ApplicationInfo. If not Null, this /// information helps implementations recognize behavior inherent to /// classes of applications. ApplicationInfo is defined in detail /// below. /// </param> /// <param name="enabledLayerNames"> /// An array of enabledLayerCount strings containing the names of /// layers to enable for the created instance. See the Layers section /// for further details. /// </param> /// <param name="enabledExtensionNames"> /// An array of enabledExtensionCount strings containing the names of /// extensions to enable. /// </param> /// <param name="allocator"> /// An optional AllocationCallbacks instance that controls host memory /// allocation. /// </param> public static unsafe SharpVk.Instance Create(CommandCache commandCache, ArrayProxy <string>?enabledLayerNames, ArrayProxy <string>?enabledExtensionNames, SharpVk.InstanceCreateFlags?flags = default(SharpVk.InstanceCreateFlags?), SharpVk.ApplicationInfo?applicationInfo = default(SharpVk.ApplicationInfo?), SharpVk.Multivendor.DebugReportCallbackCreateInfo?debugReportCallbackCreateInfoExt = null, SharpVk.Multivendor.ValidationFlags?validationFlagsExt = null, SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Instance result = default(SharpVk.Instance); SharpVk.Interop.InstanceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.InstanceCreateInfo *); void *nextPointer = default(void *); SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Instance marshalledInstance = default(SharpVk.Interop.Instance); if (debugReportCallbackCreateInfoExt != null) { SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *extensionPointer = default(SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *); extensionPointer = (SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo>()); debugReportCallbackCreateInfoExt.Value.MarshalTo(extensionPointer); extensionPointer->Next = nextPointer; nextPointer = extensionPointer; } if (validationFlagsExt != null) { SharpVk.Interop.Multivendor.ValidationFlags *extensionPointer = default(SharpVk.Interop.Multivendor.ValidationFlags *); extensionPointer = (SharpVk.Interop.Multivendor.ValidationFlags *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.ValidationFlags>()); validationFlagsExt.Value.MarshalTo(extensionPointer); extensionPointer->Next = nextPointer; nextPointer = extensionPointer; } marshalledCreateInfo = (SharpVk.Interop.InstanceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.InstanceCreateInfo>()); marshalledCreateInfo->SType = StructureType.InstanceCreateInfo; marshalledCreateInfo->Next = nextPointer; if (flags != null) { marshalledCreateInfo->Flags = flags.Value; } else { marshalledCreateInfo->Flags = default(SharpVk.InstanceCreateFlags); } if (applicationInfo != null) { marshalledCreateInfo->ApplicationInfo = (SharpVk.Interop.ApplicationInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.ApplicationInfo>()); applicationInfo.Value.MarshalTo(marshalledCreateInfo->ApplicationInfo); } else { marshalledCreateInfo->ApplicationInfo = default(SharpVk.Interop.ApplicationInfo *); } marshalledCreateInfo->EnabledLayerCount = (uint)(Interop.HeapUtil.GetLength(enabledLayerNames)); marshalledCreateInfo->EnabledLayerNames = Interop.HeapUtil.MarshalTo(enabledLayerNames); marshalledCreateInfo->EnabledExtensionCount = (uint)(Interop.HeapUtil.GetLength(enabledExtensionNames)); marshalledCreateInfo->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(enabledExtensionNames); if (allocator != null) { marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>()); allocator.Value.MarshalTo(marshalledAllocator); } else { marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); } SharpVk.Interop.VkInstanceCreateDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.VkInstanceCreateDelegate>("vkCreateInstance", ""); Result methodResult = commandDelegate(marshalledCreateInfo, marshalledAllocator, &marshalledInstance); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } result = new SharpVk.Instance(commandCache, marshalledInstance); return(result); } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="proxy"></param> /// <returns></returns> public static bool IsNull <T>(this ArrayProxy <T> proxy) { return(proxy.Contents == ProxyContents.Null); }