public unsafe bool GetDeviceExtensionSupported(string extName) { uint propCount = 0; vkEnumerateDeviceExtensionProperties(phy, IntPtr.Zero, out propCount, IntPtr.Zero); VkExtensionProperties[] extProps = new VkExtensionProperties[propCount]; vkEnumerateDeviceExtensionProperties(phy, IntPtr.Zero, out propCount, extProps.Pin()); extProps.Unpin(); for (int i = 0; i < extProps.Length; i++) { fixed(VkExtensionProperties *ep = extProps) { IntPtr n = (IntPtr)ep[i].extensionName; if (Marshal.PtrToStringAnsi(n) == extName) { return(true); } } } Console.WriteLine($"INFO: unsuported device extension: {extName}"); return(false); }
unsafe void init() { // Gather physical Device memory properties IntPtr tmp = Marshal.AllocHGlobal(Marshal.SizeOf <VkPhysicalDeviceMemoryProperties>()); vkGetPhysicalDeviceMemoryProperties(phy, tmp); memoryProperties = Marshal.PtrToStructure <VkPhysicalDeviceMemoryProperties> (tmp); uint queueFamilyCount = 0; vkGetPhysicalDeviceQueueFamilyProperties(phy, out queueFamilyCount, IntPtr.Zero); QueueFamilies = new VkQueueFamilyProperties[queueFamilyCount]; if (queueFamilyCount <= 0) { throw new Exception("No queues found for physical device"); } vkGetPhysicalDeviceQueueFamilyProperties(phy, out queueFamilyCount, QueueFamilies.Pin()); QueueFamilies.Unpin(); uint propCount = 0; vkEnumerateDeviceExtensionProperties(phy, IntPtr.Zero, out propCount, IntPtr.Zero); VkExtensionProperties[] extProps = new VkExtensionProperties[propCount]; vkEnumerateDeviceExtensionProperties(phy, IntPtr.Zero, out propCount, extProps.Pin()); extProps.Unpin(); for (int i = 0; i < extProps.Length; i++) { fixed(VkExtensionProperties *ep = extProps) { IntPtr n = (IntPtr)ep[i].extensionName; switch (Marshal.PtrToStringAnsi(n)) { case "VK_KHR_swapchain": HasSwapChainSupport = true; break; } } } }