Exemplo n.º 1
0
        private void createInstance()
        {
            if (enableValidationLayers && !checkValidationLayerSupport())
            {
                throw Program.Throw("validation layers requested, but not available");
            }

            VkApplicationInfo appInfo = new VkApplicationInfo();

            appInfo.sType              = VkStructureType.VK_STRUCTURE_TYPE_APPLICATION_INFO;
            appInfo.pApplicationName   = "Hello Triangle";
            appInfo.applicationVersion = Vulkan.VK_MAKE_VERSION(1, 0, 0);
            appInfo.pEngineName        = "No Engine";
            appInfo.engineVersion      = Vulkan.VK_MAKE_VERSION(1, 0, 0);
            appInfo.apiVersion         = VkApiVersion.VK_API_VERSION_1_0;

            VkInstanceCreateInfo createInfo = new VkInstanceCreateInfo();

            createInfo.sType            = VkStructureType.VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
            createInfo.pApplicationInfo = appInfo;

            List <string> extensions = getRequiredExtensions();

            createInfo.enabledExtensionCount   = extensions.Count;
            createInfo.ppEnabledExtensionNames = extensions.ToArray();

            if (enableValidationLayers)
            {
                createInfo.enabledLayerCount   = validationLayers.Length;
                createInfo.ppEnabledLayerNames = validationLayers;
            }
            else
            {
                createInfo.enabledLayerCount = 0;
            }

            VkResult result = Vulkan.vkCreateInstance(createInfo, null, out instance);

            if (result != VkResult.VK_SUCCESS)
            {
                throw Program.Throw("failed to create instance!", result);
            }
        }