/// <summary> /// Combine the data stores of pipeline caches. /// </summary> public unsafe void MergePipelineCaches(ArrayProxy <SharpVk.PipelineCache>?sourceCaches) { try { SharpVk.Interop.PipelineCache *marshalledSourceCaches = default(SharpVk.Interop.PipelineCache *); if (sourceCaches.IsNull()) { marshalledSourceCaches = null; } else { if (sourceCaches.Value.Contents == ProxyContents.Single) { marshalledSourceCaches = (SharpVk.Interop.PipelineCache *)(Interop.HeapUtil.Allocate <SharpVk.Interop.PipelineCache>()); *(SharpVk.Interop.PipelineCache *)(marshalledSourceCaches) = sourceCaches.Value.GetSingleValue()?.handle ?? default(SharpVk.Interop.PipelineCache); } else { var fieldPointer = (SharpVk.Interop.PipelineCache *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.PipelineCache>(Interop.HeapUtil.GetLength(sourceCaches.Value)).ToPointer()); for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(sourceCaches.Value)); index++) { fieldPointer[index] = sourceCaches.Value[index]?.handle ?? default(SharpVk.Interop.PipelineCache); } marshalledSourceCaches = fieldPointer; } } Result methodResult = Interop.Commands.vkMergePipelineCaches(this.parent.handle, this.handle, (uint)(Interop.HeapUtil.GetLength(sourceCaches)), marshalledSourceCaches); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// Query supported presentation modes. /// </summary> public PresentMode[] GetSurfacePresentModes(Surface surface) { unsafe { try { var commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkGetPhysicalDeviceSurfacePresentModesKHR>("vkGetPhysicalDeviceSurfacePresentModesKHR", "instance"); PresentMode[] result = default(PresentMode[]); Result commandResult; Interop.Surface marshalledSurface = default(Interop.Surface); surface?.MarshalTo(&marshalledSurface); uint presentModeCount; PresentMode *marshalledPresentModes = null; commandResult = commandDelegate(this.handle, marshalledSurface, &presentModeCount, null); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } marshalledPresentModes = (PresentMode *)Interop.HeapUtil.Allocate <int>((uint)presentModeCount); commandResult = commandDelegate(this.handle, marshalledSurface, &presentModeCount, marshalledPresentModes); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } result = new PresentMode[(uint)presentModeCount]; for (int index = 0; index < (uint)presentModeCount; index++) { result[index] = marshalledPresentModes[index]; } return(result); } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Query the set of mode properties supported by the display. /// </summary> public DisplayModeProperties[] GetDisplayModeProperties(Display display) { unsafe { try { var commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkGetDisplayModePropertiesKHR>("vkGetDisplayModePropertiesKHR", "instance"); DisplayModeProperties[] result = default(DisplayModeProperties[]); Result commandResult; Interop.Display marshalledDisplay = default(Interop.Display); display?.MarshalTo(&marshalledDisplay); uint propertyCount; Interop.DisplayModeProperties *marshalledProperties = null; commandResult = commandDelegate(this.handle, marshalledDisplay, &propertyCount, null); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } marshalledProperties = (Interop.DisplayModeProperties *)Interop.HeapUtil.Allocate <Interop.DisplayModeProperties>((uint)propertyCount); commandResult = commandDelegate(this.handle, marshalledDisplay, &propertyCount, marshalledProperties); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } result = new DisplayModeProperties[(uint)propertyCount]; for (int index = 0; index < (uint)propertyCount; index++) { result[index] = DisplayModeProperties.MarshalFrom(&marshalledProperties[index]); } return(result); } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Resets a descriptor pool object. /// </summary> public unsafe void Reset(SharpVk.DescriptorPoolResetFlags?flags = default(SharpVk.DescriptorPoolResetFlags?)) { try { SharpVk.DescriptorPoolResetFlags marshalledFlags = default(SharpVk.DescriptorPoolResetFlags); if (flags != null) { marshalledFlags = flags.Value; } else { marshalledFlags = default(SharpVk.DescriptorPoolResetFlags); } Result methodResult = Interop.Commands.vkResetDescriptorPool(this.parent.handle, this.handle, marshalledFlags); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// Query surface capabilities. /// </summary> public SurfaceCapabilities GetSurfaceCapabilities(Surface surface) { unsafe { try { var commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkGetPhysicalDeviceSurfaceCapabilitiesKHR>("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", "instance"); SurfaceCapabilities result = default(SurfaceCapabilities); Result commandResult; Interop.Surface marshalledSurface = default(Interop.Surface); surface?.MarshalTo(&marshalledSurface); commandResult = commandDelegate(this.handle, marshalledSurface, &result); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } return(result); } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Query if presentation is supported. /// </summary> public Bool32 GetSurfaceSupport(uint queueFamilyIndex, Surface surface) { unsafe { try { var commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkGetPhysicalDeviceSurfaceSupportKHR>("vkGetPhysicalDeviceSurfaceSupportKHR", "instance"); Bool32 result = default(Bool32); Result commandResult; Interop.Surface marshalledSurface = default(Interop.Surface); surface?.MarshalTo(&marshalledSurface); commandResult = commandDelegate(this.handle, queueFamilyIndex, marshalledSurface, &result); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } return(result); } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Query the VkDisplayKHR corresponding to an X11 RandR Output. /// </summary> public Display GetRandROutputDisplay(IntPtr dpy, IntPtr rrOutput) { unsafe { try { var commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkGetRandROutputDisplayEXT>("vkGetRandROutputDisplayEXT", "instance"); Display result = default(Display); Result commandResult; Interop.Display marshalledDisplay; commandResult = commandDelegate(this.handle, &dpy, rrOutput, &marshalledDisplay); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } result = new Display(marshalledDisplay, this.parent.Allocator, this.commandCache); return(result); } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// /// </summary> public unsafe void Begin(SharpVk.CommandBufferUsageFlags?flags = default(SharpVk.CommandBufferUsageFlags?), SharpVk.CommandBufferInheritanceInfo?inheritanceInfo = default(SharpVk.CommandBufferInheritanceInfo?)) { try { SharpVk.Interop.CommandBufferBeginInfo *marshalledBeginInfo = default(SharpVk.Interop.CommandBufferBeginInfo *); marshalledBeginInfo = (SharpVk.Interop.CommandBufferBeginInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.CommandBufferBeginInfo>()); marshalledBeginInfo->SType = StructureType.CommandBufferBeginInfo; marshalledBeginInfo->Next = null; if (flags != null) { marshalledBeginInfo->Flags = flags.Value; } else { marshalledBeginInfo->Flags = default(SharpVk.CommandBufferUsageFlags); } if (inheritanceInfo != null) { marshalledBeginInfo->InheritanceInfo = (SharpVk.Interop.CommandBufferInheritanceInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.CommandBufferInheritanceInfo>()); inheritanceInfo.Value.MarshalTo(marshalledBeginInfo->InheritanceInfo); } else { marshalledBeginInfo->InheritanceInfo = default(SharpVk.Interop.CommandBufferInheritanceInfo *); } Result methodResult = Interop.Commands.vkBeginCommandBuffer(this.handle, marshalledBeginInfo); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// Create a new device instance. /// </summary> /// <param name="flags"> /// Reserved for future use. /// </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="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> public void RegisterObjects(ArrayProxy <ObjectTableEntry> objectTableEntries, ArrayProxy <uint> objectIndices) { unsafe { try { var commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkRegisterObjectsNVX>("vkRegisterObjectsNVX", "device"); Result commandResult; GCHandle objectTableEntriesHandle = default(GCHandle); ObjectTableEntry * marshalledObjectTableEntries = null; ObjectTableEntry **doubleMarshalledObjectTableEntries = null; if (objectTableEntries.Contents != ProxyContents.Null) { if (objectTableEntries.Contents == ProxyContents.Single) { ObjectTableEntry *dataPointer = stackalloc ObjectTableEntry[1]; *dataPointer = objectTableEntries.GetSingleValue(); marshalledObjectTableEntries = dataPointer; doubleMarshalledObjectTableEntries = &marshalledObjectTableEntries; } else { var arrayValue = objectTableEntries.GetArrayValue(); objectTableEntriesHandle = GCHandle.Alloc(arrayValue.Array, GCHandleType.Pinned); marshalledObjectTableEntries = (ObjectTableEntry *)(objectTableEntriesHandle.AddrOfPinnedObject() + (int)(MemUtil.SizeOf <ObjectTableEntry>() * arrayValue.Offset)).ToPointer(); ObjectTableEntry **dataPointer = stackalloc ObjectTableEntry *[objectTableEntries.Length]; doubleMarshalledObjectTableEntries = dataPointer; for (int marshalIndex = 0; marshalIndex < objectTableEntries.Length; marshalIndex++) { doubleMarshalledObjectTableEntries[marshalIndex] = &marshalledObjectTableEntries[marshalIndex]; } } } else { marshalledObjectTableEntries = null; } GCHandle objectIndicesHandle = default(GCHandle); uint * marshalledObjectIndices = null; if (objectIndices.Contents != ProxyContents.Null) { if (objectIndices.Contents == ProxyContents.Single) { uint *dataPointer = stackalloc uint[1]; * dataPointer = objectIndices.GetSingleValue(); marshalledObjectIndices = dataPointer; } else { var arrayValue = objectIndices.GetArrayValue(); objectIndicesHandle = GCHandle.Alloc(arrayValue.Array, GCHandleType.Pinned); marshalledObjectIndices = (uint *)(objectIndicesHandle.AddrOfPinnedObject() + (int)(MemUtil.SizeOf <uint>() * arrayValue.Offset)).ToPointer(); } } else { marshalledObjectIndices = null; } commandResult = commandDelegate(this.parent.handle, this.handle, (uint)(objectIndices.Length), doubleMarshalledObjectTableEntries, marshalledObjectIndices); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } if (objectTableEntriesHandle.IsAllocated) { objectTableEntriesHandle.Free(); } if (objectIndicesHandle.IsAllocated) { objectIndicesHandle.Free(); } } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Create a new Vulkan instance. /// </summary> /// <param name="commandCache"> /// </param> /// <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="debugReportCallbackCreateInfoExt"> /// Extension struct /// </param> /// <param name="validationFlagsExt"> /// Extension struct /// </param> /// <param name="validationFeaturesExt"> /// Extension struct /// </param> /// <param name="debugUtilsMessengerCreateInfoExt"> /// Extension struct /// </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.Multivendor.ValidationFeatures?validationFeaturesExt = null, SharpVk.Multivendor.DebugUtilsMessengerCreateInfo?debugUtilsMessengerCreateInfoExt = null, SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Instance result = default(SharpVk.Instance); SharpVk.Interop.InstanceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.InstanceCreateInfo *); void *vkInstanceCreateInfoNextPointer = 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 = vkInstanceCreateInfoNextPointer; vkInstanceCreateInfoNextPointer = 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 = vkInstanceCreateInfoNextPointer; vkInstanceCreateInfoNextPointer = extensionPointer; } if (validationFeaturesExt != null) { SharpVk.Interop.Multivendor.ValidationFeatures *extensionPointer = default(SharpVk.Interop.Multivendor.ValidationFeatures *); extensionPointer = (SharpVk.Interop.Multivendor.ValidationFeatures *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.ValidationFeatures>()); validationFeaturesExt.Value.MarshalTo(extensionPointer); extensionPointer->Next = vkInstanceCreateInfoNextPointer; vkInstanceCreateInfoNextPointer = extensionPointer; } if (debugUtilsMessengerCreateInfoExt != null) { SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo *extensionPointer = default(SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo *); extensionPointer = (SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo>()); debugUtilsMessengerCreateInfoExt.Value.MarshalTo(extensionPointer); extensionPointer->Next = vkInstanceCreateInfoNextPointer; vkInstanceCreateInfoNextPointer = extensionPointer; } marshalledCreateInfo = (SharpVk.Interop.InstanceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.InstanceCreateInfo>()); marshalledCreateInfo->SType = StructureType.InstanceCreateInfo; marshalledCreateInfo->Next = vkInstanceCreateInfoNextPointer; 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.Cache.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> public static unsafe SharpVk.Instance Create(string[] enabledLayerNames, string[] enabledExtensionNames, SharpVk.InstanceCreateFlags?flags = default(SharpVk.InstanceCreateFlags?), SharpVk.ApplicationInfo?applicationInfo = default(SharpVk.ApplicationInfo?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Instance result = default(SharpVk.Instance); SharpVk.Interop.InstanceCreateInfo * marshalledCreateInfo = default(SharpVk.Interop.InstanceCreateInfo *); SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Instance marshalledInstance = default(SharpVk.Interop.Instance); marshalledCreateInfo = (SharpVk.Interop.InstanceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.InstanceCreateInfo>()); marshalledCreateInfo->SType = StructureType.InstanceCreateInfo; marshalledCreateInfo->Next = null; 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)(enabledLayerNames?.Length ?? 0); if (enabledLayerNames != null) { marshalledCreateInfo->EnabledLayerNames = Interop.HeapUtil.MarshalTo(enabledLayerNames); } else { } marshalledCreateInfo->EnabledExtensionCount = (uint)(enabledExtensionNames?.Length ?? 0); if (enabledExtensionNames != null) { marshalledCreateInfo->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(enabledExtensionNames); } else { } if (allocator != null) { marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>()); allocator.Value.MarshalTo(marshalledAllocator); } else { marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); } Result methodResult = Interop.Commands.vkCreateInstance(marshalledCreateInfo, marshalledAllocator, &marshalledInstance); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } result = new SharpVk.Instance(marshalledInstance); return(result); } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// /// </summary> public unsafe SharpVk.Device CreateDevice(SharpVk.DeviceQueueCreateInfo[] queueCreateInfos, string[] enabledLayerNames, string[] enabledExtensionNames, SharpVk.DeviceCreateFlags?flags = default(SharpVk.DeviceCreateFlags?), SharpVk.PhysicalDeviceFeatures?enabledFeatures = default(SharpVk.PhysicalDeviceFeatures?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Device result = default(SharpVk.Device); SharpVk.Interop.DeviceCreateInfo * marshalledCreateInfo = default(SharpVk.Interop.DeviceCreateInfo *); SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Device marshalledDevice = default(SharpVk.Interop.Device); marshalledCreateInfo = (SharpVk.Interop.DeviceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.DeviceCreateInfo>()); marshalledCreateInfo->SType = StructureType.DeviceCreateInfo; marshalledCreateInfo->Next = null; if (flags != null) { marshalledCreateInfo->Flags = flags.Value; } else { marshalledCreateInfo->Flags = default(SharpVk.DeviceCreateFlags); } marshalledCreateInfo->QueueCreateInfoCount = (uint)(queueCreateInfos?.Length ?? 0); if (queueCreateInfos != null) { var fieldPointer = (SharpVk.Interop.DeviceQueueCreateInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.DeviceQueueCreateInfo>(queueCreateInfos.Length).ToPointer()); for (int index = 0; index < (uint)(queueCreateInfos.Length); index++) { queueCreateInfos[index].MarshalTo(&fieldPointer[index]); } marshalledCreateInfo->QueueCreateInfos = fieldPointer; } else { marshalledCreateInfo->QueueCreateInfos = null; } marshalledCreateInfo->EnabledLayerCount = (uint)(enabledLayerNames?.Length ?? 0); if (enabledLayerNames != null) { marshalledCreateInfo->EnabledLayerNames = Interop.HeapUtil.MarshalTo(enabledLayerNames); } else { } marshalledCreateInfo->EnabledExtensionCount = (uint)(enabledExtensionNames?.Length ?? 0); if (enabledExtensionNames != null) { marshalledCreateInfo->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(enabledExtensionNames); } else { } 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 *); } Result methodResult = Interop.Commands.vkCreateDevice(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(); } }