public static IntPtr vkGetInstanceProcAddr(IntPtr instance, string name) { int byteCount = Interop.GetMaxByteCount(name); var stringPtr = stackalloc byte[byteCount]; Interop.StringToPointer(name, stringPtr, byteCount); return(vkGetInstanceProcAddr(instance, stringPtr)); }
/// <summary> /// Returns properties of available physical device extensions /// </summary> /// <param name="physicalDevice">The <see cref="VkPhysicalDevice"/> that will be queried.</param> /// <param name="layerName">Is either null/empty or a string naming the layer to retrieve extensions from.</param> /// <returns>A <see cref="ReadOnlySpan{VkExtensionProperties}"/>.</returns> /// <exception cref="VkException">Vulkan returns an error code.</exception> public static ReadOnlySpan <VkExtensionProperties> vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, string layerName = "") { int dstLayerNameByteCount = Interop.GetMaxByteCount(layerName); var dstLayerNamePtr = stackalloc byte[dstLayerNameByteCount]; Interop.StringToPointer(layerName, dstLayerNamePtr, dstLayerNameByteCount); uint propertyCount = 0; vkEnumerateDeviceExtensionProperties(physicalDevice, dstLayerNamePtr, &propertyCount, null).CheckResult(); ReadOnlySpan <VkExtensionProperties> properties = new VkExtensionProperties[propertyCount]; fixed(VkExtensionProperties *propertiesPtr = properties) { vkEnumerateDeviceExtensionProperties(physicalDevice, dstLayerNamePtr, &propertyCount, propertiesPtr).CheckResult(); } return(properties); }
/// <summary> /// Returns up to requested number of global extension properties /// </summary> /// <param name="layerName">Is either null/empty or a string naming the layer to retrieve extensions from.</param> /// <returns>A <see cref="ReadOnlySpan{VkExtensionProperties}"/> </returns> /// <exception cref="VkException">Vulkan returns an error code.</exception> public static unsafe ReadOnlySpan <VkExtensionProperties> vkEnumerateInstanceExtensionProperties(string?layerName = null) { int dstLayerNameByteCount = Interop.GetMaxByteCount(layerName); byte *dstLayerNamePtr = stackalloc byte[dstLayerNameByteCount]; Interop.StringToPointer(layerName, dstLayerNamePtr, dstLayerNameByteCount); uint count = 0; vkEnumerateInstanceExtensionProperties(dstLayerNamePtr, &count, null).CheckResult(); ReadOnlySpan <VkExtensionProperties> properties = new VkExtensionProperties[count]; fixed(VkExtensionProperties *ptr = properties) { vkEnumerateInstanceExtensionProperties(dstLayerNamePtr, &count, ptr).CheckResult(); } return(properties); }