Beispiel #1
0
    virtual void SetUp() {
        VkResult err;

        this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
        this->app_info.pNext = NULL;
        this->app_info.pApplicationName = "base";
        this->app_info.applicationVersion = 1;
        this->app_info.pEngineName = "unittest";
        this->app_info.engineVersion = 1;
        this->app_info.apiVersion = VK_API_VERSION_1_0;
        VkInstanceCreateInfo inst_info = {};
        inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
        inst_info.pNext = NULL;
        inst_info.pApplicationInfo = &app_info;
        inst_info.enabledLayerCount = 0;
        inst_info.ppEnabledLayerNames = NULL;
        inst_info.enabledExtensionCount = 0;
        inst_info.ppEnabledExtensionNames = NULL;
        err = vkCreateInstance(&inst_info, NULL, &this->inst);
        ASSERT_VK_SUCCESS(err);
        err = vkEnumeratePhysicalDevices(this->inst, &this->gpu_count, NULL);
        ASSERT_VK_SUCCESS(err);
        ASSERT_LE(this->gpu_count, ARRAY_SIZE(objs)) << "Too many GPUs";
        err = vkEnumeratePhysicalDevices(this->inst, &this->gpu_count, objs);
        ASSERT_VK_SUCCESS(err);
        ASSERT_GE(this->gpu_count, (uint32_t) 1) << "No GPU available";

        this->m_device = new vk_testing::Device(objs[0]);
        this->m_device->init();
    }
Beispiel #2
0
	vk_instance(const char *app_name,
				unsigned app_version,
				const lib::vector<const char*> &instance_extensions,
				const lib::vector<const char*> &instance_layers)
		: instance_extensions(instance_extensions), instance_layers(instance_layers)
	{
		VkApplicationInfo vk_app_info = {};
		vk_app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
		vk_app_info.pNext = nullptr;
		vk_app_info.pApplicationName = app_name;
		vk_app_info.applicationVersion = app_version;
		vk_app_info.pEngineName = ste_name;
		vk_app_info.engineVersion = (ste_version_major << 16) + ste_version_minor;
		vk_app_info.apiVersion = vk_api_version;

		VkInstanceCreateInfo inst_info = {};
		inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
		inst_info.pNext = nullptr;
		inst_info.flags = 0;
		inst_info.enabledExtensionCount = static_cast<std::uint32_t>(instance_extensions.size());
		inst_info.ppEnabledExtensionNames = &instance_extensions[0];
		inst_info.enabledLayerCount = static_cast<std::uint32_t>(instance_layers.size());
		inst_info.ppEnabledLayerNames = &instance_layers[0];
		inst_info.pApplicationInfo = &vk_app_info;

		VkInstance inst;
		vk_result res = vkCreateInstance(&inst_info, &host_allocator::allocation_callbacks(), &inst);
		if (!res) {
			throw vk_exception(res);
		}

		instance = inst;
	}
Beispiel #3
0
void Instance::create() {
    std::vector<const char*> layers;
    createInfo.enabledLayerCount = enabledLayers.size();
    for (const auto& layer : enabledLayers) {
        layers.push_back(const_cast<char*>(layer.c_str()));
    }
    createInfo.ppEnabledLayerNames = layers.data();

    createInfo.enabledExtensionCount = enabledExtensions.size();
    std::vector<const char*> extensions;
    for (const auto& extension : enabledExtensions) {
        extensions.push_back(const_cast<char*>(extension.c_str()));
    }
    createInfo.ppEnabledExtensionNames = extensions.data();

    VULKAN_CHECK_RESULT(vkCreateInstance(&createInfo, nullptr, &handle), "Failed to create instance");

    if (debugReportFlags) {
        for (const auto& layer : enabledExtensions) {
            if (layer == "VK_EXT_debug_report") {
                debugCallback = std::make_unique<DebugReportCallback>(this);
                debugCallback->setFlags(debugReportFlags);
                debugCallback->create();
                break;
            }
        }
    }
}
VkResult VulkanBase::createInstance(bool enableValidation) {
	this->enableValidation = enableValidation;

	VkApplicationInfo appInfo = {};
	appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	appInfo.pApplicationName = name.c_str();
	appInfo.pEngineName = name.c_str();
	appInfo.apiVersion = VK_MAKE_VERSION(1, 0, 7);

	std::vector<const char*> enabledExtensions = {VK_KHR_SURFACE_EXTENSION_NAME};

	enabledExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);

	VkInstanceCreateInfo instanceCreateInfo = {};
	instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instanceCreateInfo.pNext = NULL;
	instanceCreateInfo.pApplicationInfo = &appInfo;
	if (enabledExtensions.size() > 0){
		if (enableValidation)
			enabledExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
		instanceCreateInfo.enabledExtensionCount = (uint32_t)enabledExtensions.size();
		instanceCreateInfo.ppEnabledExtensionNames = enabledExtensions.data();
	}
	if (enableValidation){
		instanceCreateInfo.enabledLayerCount = vkDebug::validationLayerCount;
		instanceCreateInfo.ppEnabledLayerNames = vkDebug::validationLayerNames;
	}
	return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
}
    void createInstance() {
        if (enableValidationLayers && !checkValidationLayerSupport()) {
            throw std::runtime_error("validation layers requested, but not available!");
        }

        VkApplicationInfo appInfo = {};
        appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
        appInfo.pApplicationName = "Hello Triangle";
        appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
        appInfo.pEngineName = "No Engine";
        appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
        appInfo.apiVersion = VK_API_VERSION_1_0;

        VkInstanceCreateInfo createInfo = {};
        createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
        createInfo.pApplicationInfo = &appInfo;

        auto extensions = getRequiredExtensions();
        createInfo.enabledExtensionCount = extensions.size();
        createInfo.ppEnabledExtensionNames = extensions.data();

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

        if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
            throw std::runtime_error("failed to create instance!");
        }
    }
  bool Tutorial01::CreateInstance() {
    VkApplicationInfo application_info = {
      VK_STRUCTURE_TYPE_APPLICATION_INFO,             // VkStructureType            sType
      nullptr,                                        // const void                *pNext
      "API without Secrets: Introduction to Vulkan",  // const char                *pApplicationName
      VK_MAKE_VERSION( 1, 0, 0 ),                     // uint32_t                   applicationVersion
      "Vulkan Tutorial by Intel",                     // const char                *pEngineName
      VK_MAKE_VERSION( 1, 0, 0 ),                     // uint32_t                   engineVersion
      VK_MAKE_VERSION( 1, 0, 0 )                      // uint32_t                   apiVersion
    };

    VkInstanceCreateInfo instance_create_info = {
      VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,         // VkStructureType            sType
      nullptr,                                        // const void*                pNext
      0,                                              // VkInstanceCreateFlags      flags
      &application_info,                              // const VkApplicationInfo   *pApplicationInfo
      0,                                              // uint32_t                   enabledLayerCount
      nullptr,                                        // const char * const        *ppEnabledLayerNames
      0,                                              // uint32_t                   enabledExtensionCount
      nullptr                                         // const char * const        *ppEnabledExtensionNames
    };

    if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
      std::cout << "Could not create Vulkan instance!" << std::endl;
      return false;
    }
    return true;
  }
Beispiel #7
0
VkInstance CreateVKInstance(const char* appName, const char* engineName) {
	/* Create Vulkan instance */
	VkApplicationInfo appInfo = {};
	appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	appInfo.pApplicationName = appName;
	appInfo.pEngineName = engineName;
	appInfo.apiVersion = VK_API_VERSION_1_0;

	std::vector<const char*> enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME };

	// Enable surface extensions depending on os
#if defined(_WIN32)
	enabledExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#elif defined(__linux__)
	enabledExtensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif

	VkInstanceCreateInfo instanceCreateInfo = {};
	instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instanceCreateInfo.pNext = NULL;
	instanceCreateInfo.pApplicationInfo = &appInfo;
	if (enabledExtensions.size() > 0) {
		instanceCreateInfo.enabledExtensionCount = (uint32_t)enabledExtensions.size();
		instanceCreateInfo.ppEnabledExtensionNames = enabledExtensions.data();
	}

	VkInstance inst;
	VkResult r = vkCreateInstance(&instanceCreateInfo, nullptr, &inst);
	if (r != VK_SUCCESS)
		return nullptr;
	return inst;
}
  bool VulkanCommon::CreateInstance() {
    uint32_t extensions_count = 0;
    if( (vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
        (extensions_count == 0) ) {
      std::cout << "Error occurred during instance extensions enumeration!" << std::endl;
      return false;
    }

    std::vector<VkExtensionProperties> available_extensions( extensions_count );
    if( vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
      std::cout << "Error occurred during instance extensions enumeration!" << std::endl;
      return false;
    }

    std::vector<const char*> extensions = {
      VK_KHR_SURFACE_EXTENSION_NAME,
#if defined(VK_USE_PLATFORM_WIN32_KHR)
      VK_KHR_WIN32_SURFACE_EXTENSION_NAME
#elif defined(VK_USE_PLATFORM_XCB_KHR)
      VK_KHR_XCB_SURFACE_EXTENSION_NAME
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
      VK_KHR_XLIB_SURFACE_EXTENSION_NAME
#endif
    };

    for( size_t i = 0; i < extensions.size(); ++i ) {
      if( !CheckExtensionAvailability( extensions[i], available_extensions ) ) {
        std::cout << "Could not find instance extension named \"" << extensions[i] << "\"!" << std::endl;
        return false;
      }
    }

    VkApplicationInfo application_info = {
      VK_STRUCTURE_TYPE_APPLICATION_INFO,             // VkStructureType            sType
      nullptr,                                        // const void                *pNext
      "API without Secrets: Introduction to Vulkan",  // const char                *pApplicationName
      VK_MAKE_VERSION( 1, 0, 0 ),                     // uint32_t                   applicationVersion
      "Vulkan Tutorial by Intel",                     // const char                *pEngineName
      VK_MAKE_VERSION( 1, 0, 0 ),                     // uint32_t                   engineVersion
      VK_API_VERSION                                  // uint32_t                   apiVersion
    };

    VkInstanceCreateInfo instance_create_info = {
      VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,         // VkStructureType            sType
      nullptr,                                        // const void                *pNext
      0,                                              // VkInstanceCreateFlags      flags
      &application_info,                              // const VkApplicationInfo   *pApplicationInfo
      0,                                              // uint32_t                   enabledLayerCount
      nullptr,                                        // const char * const        *ppEnabledLayerNames
      static_cast<uint32_t>(extensions.size()),       // uint32_t                   enabledExtensionCount
      &extensions[0]                                  // const char * const        *ppEnabledExtensionNames
    };

    if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
      std::cout << "Could not create Vulkan instance!" << std::endl;
      return false;
    }
    return true;
  }
TEST(WrapObjects, Insert)
{
    VkInstance instance = VK_NULL_HANDLE;
    VkResult result = vkCreateInstance(VK::InstanceCreateInfo(), VK_NULL_HANDLE, &instance);
    ASSERT_EQ(result, VK_SUCCESS);

    uint32_t physicalCount = 0;
    result = vkEnumeratePhysicalDevices(instance, &physicalCount, nullptr);
    ASSERT_EQ(result, VK_SUCCESS);
    ASSERT_GT(physicalCount, 0u);

    std::unique_ptr<VkPhysicalDevice[]> physical(new VkPhysicalDevice[physicalCount]);
    result = vkEnumeratePhysicalDevices(instance, &physicalCount, physical.get());
    ASSERT_EQ(result, VK_SUCCESS);
    ASSERT_GT(physicalCount, 0u);

    for(uint32_t p = 0; p < physicalCount; ++p)
    {
        uint32_t familyCount = 0;
        vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, nullptr);
        ASSERT_EQ(result, VK_SUCCESS);
        ASSERT_GT(familyCount, 0u);

        std::unique_ptr<VkQueueFamilyProperties[]> family(new VkQueueFamilyProperties[familyCount]);
        vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, family.get());
        ASSERT_EQ(result, VK_SUCCESS);
        ASSERT_GT(familyCount, 0u);

        for(uint32_t q = 0; q < familyCount; ++q)
        {
            if(~family[q].queueFlags & VK_QUEUE_GRAPHICS_BIT)
            {
                continue;
            }

            float const priorities[] = {0.0f}; // Temporary required due to MSVC bug.
            VkDeviceQueueCreateInfo const queueInfo[1]
            {
                VK::DeviceQueueCreateInfo().
                    queueFamilyIndex(q).
                    queueCount(1).
                    pQueuePriorities(priorities)
            };

            auto const deviceInfo = VK::DeviceCreateInfo().
                queueCreateInfoCount(1).
                pQueueCreateInfos(queueInfo);

            VkDevice device;
            result = vkCreateDevice(physical[p], deviceInfo, nullptr, &device);
            ASSERT_EQ(result, VK_SUCCESS);

            vkDestroyDevice(device, nullptr);
        }
    }

    vkDestroyInstance(instance, nullptr);
}
Beispiel #10
0
void OgldevVulkanCore::CreateInstance()
{
    VkApplicationInfo appInfo = {};       
    appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
    appInfo.pApplicationName = m_appName.c_str();
    appInfo.engineVersion = 1;
    appInfo.apiVersion = VK_API_VERSION_1_0;

    const char* pInstExt[] = {
#ifdef ENABLE_DEBUG_LAYERS
        VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
#endif        
        VK_KHR_SURFACE_EXTENSION_NAME,
#ifdef _WIN32    
        VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
#else    
        VK_KHR_XCB_SURFACE_EXTENSION_NAME
#endif            
    };
    
#ifdef ENABLE_DEBUG_LAYERS    
    const char* pInstLayers[] = {
        "VK_LAYER_LUNARG_standard_validation"
    };
#endif    
    
    VkInstanceCreateInfo instInfo = {};
    instInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    instInfo.pApplicationInfo = &appInfo;
#ifdef ENABLE_DEBUG_LAYERS    
    instInfo.enabledLayerCount = ARRAY_SIZE_IN_ELEMENTS(pInstLayers);
    instInfo.ppEnabledLayerNames = pInstLayers;
#endif    
    instInfo.enabledExtensionCount = ARRAY_SIZE_IN_ELEMENTS(pInstExt);
    instInfo.ppEnabledExtensionNames = pInstExt;         

    VkResult res = vkCreateInstance(&instInfo, NULL, &m_inst);
    CHECK_VULKAN_ERROR("vkCreateInstance %d\n", res);
        
#ifdef ENABLE_DEBUG_LAYERS
    // Get the address to the vkCreateDebugReportCallbackEXT function
    my_vkCreateDebugReportCallbackEXT = reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(vkGetInstanceProcAddr(m_inst, "vkCreateDebugReportCallbackEXT"));
    
    // Register the debug callback
    VkDebugReportCallbackCreateInfoEXT callbackCreateInfo;
    callbackCreateInfo.sType       = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
    callbackCreateInfo.pNext       = NULL;
    callbackCreateInfo.flags       = VK_DEBUG_REPORT_ERROR_BIT_EXT |
                                     VK_DEBUG_REPORT_WARNING_BIT_EXT |
                                     VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
    callbackCreateInfo.pfnCallback = &MyDebugReportCallback;
    callbackCreateInfo.pUserData   = NULL;

    VkDebugReportCallbackEXT callback;
    res = my_vkCreateDebugReportCallbackEXT(m_inst, &callbackCreateInfo, NULL, &callback);
    CHECK_VULKAN_ERROR("my_vkCreateDebugReportCallbackEXT error %d\n", res);
#endif    
}
TEST(CreateInstance, LayerNotPresent)
{
    char const*const names[] = {"NotPresent"}; // Temporary required due to MSVC bug.
    auto const info = VK::InstanceCreateInfo().
        enabledLayerCount(1).
        ppEnabledLayerNames(names);

    VkInstance instance = VK_NULL_HANDLE;
    VkResult result = vkCreateInstance(info, VK_NULL_HANDLE, &instance);
    ASSERT_EQ(result, VK_ERROR_LAYER_NOT_PRESENT);

    // It's not necessary to destroy the instance because it will not be created successfully.
}
// Used by run_loader_tests.sh to test for layer insertion.
TEST(CreateInstance, LayerPresent)
{
    char const*const names[] = {"VK_LAYER_LUNARG_parameter_validation"}; // Temporary required due to MSVC bug.
    auto const info = VK::InstanceCreateInfo().
        enabledLayerCount(1).
        ppEnabledLayerNames(names);

    VkInstance instance = VK_NULL_HANDLE;
    VkResult result = vkCreateInstance(info, VK_NULL_HANDLE, &instance);
    ASSERT_EQ(result, VK_SUCCESS);

    vkDestroyInstance(instance, nullptr);
}
Beispiel #13
0
bool create_instance(const char *app_name) {
    uint32_t extensions_count = 0;
    VK_VERIFY (vkEnumerateInstanceExtensionProperties(nullptr, &extensions_count, nullptr));
    VERIFY_LOG (extensions_count > 0, LOG_TYPE, "Error occurred during instance extensions enumeration!", "");

    std::vector<VkExtensionProperties> available_extensions(extensions_count);
    VK_VERIFY (vkEnumerateInstanceExtensionProperties(nullptr, &extensions_count, &available_extensions[0]));

    std::vector<const char *> extensions = {
        VK_KHR_SURFACE_EXTENSION_NAME,
#ifdef PLATFORM_WINDOWS
        VK_KHR_WIN32_SURFACE_EXTENSION_NAME
#elif PLATFORM_LINUX
        VK_KHR_XCB_SURFACE_EXTENSION_NAME
#endif
    };

    for (size_t i = 0; i < extensions.size(); ++i) {
        VERIFY_LOG(utils::check_extension(extensions[i], available_extensions), LOG_TYPE,
                   "Could not find instance extension named \"%s\"!", extensions[i]);
    }

    VkApplicationInfo application_info = {
        VK_STRUCTURE_TYPE_APPLICATION_INFO,             // VkStructureType            sType
        nullptr,                                        // const void                *pNext
        app_name,                                       // const char                *pApplicationName
        VK_MAKE_VERSION(0, 0, 1),                       // uint32_t                   applicationVersion
        "gladius",                                      // const char                *pEngineName
        VK_MAKE_VERSION(0, 0, 1),                       // uint32_t                   engineVersion
        VK_MAKE_VERSION(1, 0, 21)                       // uint32_t                   apiVersion
    };

    VkInstanceCreateInfo instance_create_info = {
        VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,         // VkStructureType            sType
        nullptr,                                        // const void                *pNext
        0,                                              // VkInstanceCreateFlags      flags
        &application_info,                              // const VkApplicationInfo   *pApplicationInfo
        0,                                              // uint32_t                   enabledLayerCount
        nullptr,                                        // const char * const        *ppEnabledLayerNames
        static_cast<uint32_t>(extensions.size()),      // uint32_t                   enabledExtensionCount
        &extensions[0]                                  // const char * const        *ppEnabledExtensionNames
    };

    VK_VERIFY(vkCreateInstance(&instance_create_info, nullptr, &(vk_globals::instance)));

    GET_INSTANCE_PROC_ADDR(vk_globals::instance, GetPhysicalDeviceSurfaceSupportKHR);
    GET_INSTANCE_PROC_ADDR(vk_globals::instance, GetPhysicalDeviceSurfaceFormatsKHR);

    return true;
}
Beispiel #14
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Vulkan init
//
bool initVkInstance( const char* appName, const char* engineName )
{
	std::cout << "\nTrying to init vulkan API\n";

	std::vector<const char*> extensions;
	std::vector<const char*> layers;

	extensions.push_back( VK_KHR_SURFACE_EXTENSION_NAME );
	extensions.push_back( VK_KHR_WIN32_SURFACE_EXTENSION_NAME );

	VkApplicationInfo appInfo = {};
	appInfo.apiVersion = VK_API_VERSION_1_0;
	appInfo.applicationVersion = 1;
	appInfo.engineVersion = 1;
	appInfo.pApplicationName = appName;
	appInfo.pEngineName = engineName;
	appInfo.pNext = nullptr;
	appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;


	VkInstanceCreateInfo instInfo = {};
	instInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instInfo.pNext = nullptr;
	instInfo.pApplicationInfo = &appInfo;
	instInfo.flags = 0;
	instInfo.enabledExtensionCount = extensions.size();
	instInfo.ppEnabledExtensionNames = extensions.size() ? extensions.data() : nullptr;
	instInfo.enabledLayerCount = layers.size();
	instInfo.ppEnabledLayerNames = layers.size() ? layers.data() : nullptr;

	VkResult res;

	res = vkCreateInstance( &instInfo, nullptr, &gInstance );
	if( res == VK_ERROR_INCOMPATIBLE_DRIVER )
	{
		std::cout << "Incompatible driver\n";
	}
	else if( res )
	{
		std::cout << "Unknown error\n";
	}
	else
	{
		std::cout << "Instance inited\n";
		return true;
	}
	return false;
}
Beispiel #15
0
				instance::instance() {

					if (Aeon::framework::enableValidationLayers && !checkValidationLayerSupport()) {
						throw Aeon::framework::exception("validation layers requested, but not available!");
					}

					// Setup appinfo
					appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
					appInfo.pApplicationName = "Hello Triangle";
					appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
					appInfo.pEngineName = ENGINE_NAME;
					appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
					appInfo.apiVersion = VK_API_VERSION_1_0;

					//Setup create info
					createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
					createInfo.pApplicationInfo = &appInfo;

					auto extensions = getRequiredExtensions();
					createInfo.enabledExtensionCount = extensions.size();
					createInfo.ppEnabledExtensionNames = extensions.data();

					if (Aeon::framework::enableValidationLayers) {
						createInfo.enabledLayerCount = Aeon::framework::validationLayers.size();
						createInfo.ppEnabledLayerNames = Aeon::framework::validationLayers.data();
					}
					else {
						createInfo.enabledLayerCount = 0;
					}

					// Create VKInstance;
					if (vkCreateInstance(&createInfo, nullptr, &pdata) != VK_SUCCESS) {
						throw Aeon::framework::exception("failed to create instance!");
					}

					// Setup debug callback

					if (Aeon::framework::enableValidationLayers) {
						VkDebugReportCallbackCreateInfoEXT dbgcreateInfo = {};
						dbgcreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
						dbgcreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
						dbgcreateInfo.pfnCallback = debugCallback;

						if (CreateDebugReportCallbackEXT(pdata, &dbgcreateInfo, nullptr, &callback) != VK_SUCCESS) {
							throw Aeon::framework::exception("failed to set up debug callback!");
						}
					}
				}
Beispiel #16
0
//Creates our vulkan instance and returns an error if it fails
VkResult gvkInitUtils::initVulkan(VkInstance * inst)
{
	VkApplicationInfo appinfo = {};
	appinfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	appinfo.pNext = nullptr;
	appinfo.pApplicationName = "TODO: CHANGE THIS";
	appinfo.pEngineName = "VKEngine";
	appinfo.apiVersion = VK_API_VERSION_1_0;
	appinfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
	appinfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);

	std::vector<const char *> enableExtensions = { VK_KHR_SURFACE_EXTENSION_NAME};

#ifdef _WIN32
	enableExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#elif defined(__linux__)
	enableExtensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif
	
	VkInstanceCreateInfo instCrInfo = {};
	instCrInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instCrInfo.pApplicationInfo = &appinfo;
	instCrInfo.pNext = nullptr;
#ifdef _DEBUG
	std::array<const char*, 1> enabledLayers = {"VK_LAYER_LUNARG_standard_validation" };
	if (!hasLayer("VK_LAYER_LUNARG_standard_validation")) {
		std::cerr << "ERROR REQUIRED LAYER DOES NOT EXIST" << std::endl;
		return VK_ERROR_INCOMPATIBLE_DRIVER;
	}
	enableExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
	instCrInfo.enabledLayerCount = enabledLayers.size();
	instCrInfo.ppEnabledLayerNames = enabledLayers.data();
	if (!hasExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, "VK_LAYER_LUNARG_standard_validation")) {
		std::cerr << "ERROR: REQUIRED EXTENSION DOES NOT EXIST" << std::endl;
		return VK_ERROR_INCOMPATIBLE_DRIVER;
	}
	
#else
	instCrInfo.enabledLayerCount = 0;
	instCrInfo.ppEnabledLayerNames = nullptr;
#endif
	instCrInfo.flags = 0;

	instCrInfo.enabledExtensionCount = enableExtensions.size();
	instCrInfo.ppEnabledExtensionNames = enableExtensions.data();
	return vkCreateInstance(&instCrInfo, nullptr, inst);
}
PluginRenderVulkan::PluginRenderVulkan(Engine &engine)
    : RenderPlugin(engine)
    , m_instanceIsValid(0)
{
    log().log() << "PluginRenderVulkan start...\n";

    // Filling out application description:
    // sType is mandatory
    m_applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
    // pNext is mandatory
    m_applicationInfo.pNext = nullptr;
    // The name of our application
    m_applicationInfo.pApplicationName = "app";
    // The name of the engine (e.g: Game engine name)
    m_applicationInfo.pEngineName = nullptr;
    // The version of the engine
    m_applicationInfo.engineVersion = 1;
    // The version of Vulkan we're using for this application
    m_applicationInfo.apiVersion = VK_API_VERSION_1_0;

    // Filling out instance description:
    // sType is mandatory
    m_instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    // pNext is mandatory
    m_instanceInfo.pNext = nullptr;
    // flags is mandatory
    m_instanceInfo.flags = 0;
    // The application info structure is then passed through the instance
    m_instanceInfo.pApplicationInfo = &m_applicationInfo;
    // Don't enable and layer
    m_instanceInfo.enabledLayerCount = 0;
    m_instanceInfo.ppEnabledLayerNames = nullptr;
    // Don't enable any extensions
    m_instanceInfo.enabledExtensionCount = 0;
    m_instanceInfo.ppEnabledExtensionNames = nullptr;

    // Now create the desired instance
    VkResult result = vkCreateInstance(&m_instanceInfo, nullptr, &m_instance);
    if (result != VK_SUCCESS)
    {
        log().log() << "Failed to create instance:" << result << "\n";
    }
    else
    {
        m_instanceIsValid = 1;
    }
}
void Renderer::initInstance() {
    VkApplicationInfo applicationInfo{};
    applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
    applicationInfo.apiVersion = VK_MAKE_VERSION(1, 0, 11);
    applicationInfo.applicationVersion = VK_MAKE_VERSION(0, 1, 0);
    applicationInfo.pApplicationName = "Vulkan Test Application";

    VkInstanceCreateInfo instanceCreateInfo{};
    instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    instanceCreateInfo.pApplicationInfo = &applicationInfo;
    instanceCreateInfo.enabledLayerCount = mInstanceLayerList.size();
    instanceCreateInfo.ppEnabledLayerNames = mInstanceLayerList.data();
    instanceCreateInfo.enabledExtensionCount = mInstanceExtensionList.size();
    instanceCreateInfo.ppEnabledExtensionNames = mInstanceExtensionList.data();
    instanceCreateInfo.pNext = &mDebugCallbackCreateInfo;

    errorCheck(vkCreateInstance(&instanceCreateInfo, nullptr, &mInstance));
}
Beispiel #19
0
VkInstance VulkanContext::CreateVulkanInstance(WindowSystemType wstype, bool enable_debug_report,
                                               bool enable_validation_layer)
{
  ExtensionList enabled_extensions;
  if (!SelectInstanceExtensions(&enabled_extensions, wstype, enable_debug_report))
    return VK_NULL_HANDLE;

  VkApplicationInfo app_info = {};
  app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
  app_info.pNext = nullptr;
  app_info.pApplicationName = "Dolphin Emulator";
  app_info.applicationVersion = VK_MAKE_VERSION(5, 0, 0);
  app_info.pEngineName = "Dolphin Emulator";
  app_info.engineVersion = VK_MAKE_VERSION(5, 0, 0);
  app_info.apiVersion = VK_MAKE_VERSION(1, 0, 0);

  VkInstanceCreateInfo instance_create_info = {};
  instance_create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
  instance_create_info.pNext = nullptr;
  instance_create_info.flags = 0;
  instance_create_info.pApplicationInfo = &app_info;
  instance_create_info.enabledExtensionCount = static_cast<uint32_t>(enabled_extensions.size());
  instance_create_info.ppEnabledExtensionNames = enabled_extensions.data();
  instance_create_info.enabledLayerCount = 0;
  instance_create_info.ppEnabledLayerNames = nullptr;

  // Enable debug layer on debug builds
  if (enable_validation_layer)
  {
    static const char* layer_names[] = {"VK_LAYER_LUNARG_standard_validation"};
    instance_create_info.enabledLayerCount = 1;
    instance_create_info.ppEnabledLayerNames = layer_names;
  }

  VkInstance instance;
  VkResult res = vkCreateInstance(&instance_create_info, nullptr, &instance);
  if (res != VK_SUCCESS)
  {
    LOG_VULKAN_ERROR(res, "vkCreateInstance failed: ");
    return nullptr;
  }

  return instance;
}
Beispiel #20
0
void Renderer::_InitInstance()
{
	VkApplicationInfo applicationInfo;
	VkInstanceCreateInfo instanceInfo;

	// Filling out application description:
	// sType is mandatory
	applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	// pNext is mandatory
	applicationInfo.pNext = NULL;
	// The name of our application
	applicationInfo.pApplicationName = "Tutorial 1";
	// The name of the engine (e.g: Game engine name)
	applicationInfo.pEngineName = "GPU Chameleon";
	// The version of the engine
	applicationInfo.engineVersion = 1;
	// The version of Vulkan we're using for this application
	applicationInfo.apiVersion = VK_API_VERSION_1_0;

	// Filling out instance description:
	// sType is mandatory
	instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	// pNext is mandatory
	instanceInfo.pNext = NULL;
	// flags is mandatory
	instanceInfo.flags = 0;
	// The application info structure is then passed through the instance
	instanceInfo.pApplicationInfo = &applicationInfo;
	// Don't enable and layer
	instanceInfo.enabledLayerCount = 0;
	instanceInfo.ppEnabledLayerNames = NULL;
	// Don't enable any extensions
	instanceInfo.enabledExtensionCount = 0;
	instanceInfo.ppEnabledExtensionNames = NULL;

	// Now create the desired instance
	VkResult result = vkCreateInstance(&instanceInfo, NULL, &instance);
	if (result != VK_SUCCESS) {
		fprintf(stderr, "Failed to create instance: %d\n", result);
		abort();
	}

}
Beispiel #21
0
			bool VkContext::CreateInstance(const char* name) {
				VkApplicationInfo appInfo = {};
				appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
				appInfo.pNext = nullptr;
				appInfo.pApplicationName = name;
				appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
				appInfo.pEngineName = "Voxl Engine";
				appInfo.engineVersion = VK_MAKE_VERSION(VOXL_VERSION_MAJOR, VOXL_VERSION_MINOR, VOXL_VERSION_PATCH);
				appInfo.apiVersion = VK_API_VERSION_1_0;

				std::vector<const char *> instanceExtensions;
				std::vector<const char *> instanceLayers;

#ifdef VOXL_DEBUG
				// Add debug report extension
				instanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);

				// Add validation layers
				instanceLayers.push_back("VK_LAYER_LUNARG_standard_validation");
#endif

				// Add GLFW extensions
				u32 glfwExtensionCount = 0;
				const char **glfwExtensions =
					glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
				for (u32 i = 0; i < glfwExtensionCount; i++) {
					instanceExtensions.push_back(glfwExtensions[i]);
				}

				VkInstanceCreateInfo instanceInfo = {};
				instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
				instanceInfo.pNext = nullptr;
				instanceInfo.flags = 0;
				instanceInfo.pApplicationInfo = &appInfo;
				instanceInfo.enabledExtensionCount = (u32)instanceExtensions.size();
				instanceInfo.ppEnabledExtensionNames = instanceExtensions.data();
				instanceInfo.enabledLayerCount = (u32)instanceLayers.size();
				instanceInfo.ppEnabledLayerNames = instanceLayers.data();

				CheckVkResult(vkCreateInstance(&instanceInfo, nullptr, &instance));

				return true;
			}
Beispiel #22
0
void Renderer::_InitInstance()
{
	VkApplicationInfo application_info {};
	application_info.sType							= VK_STRUCTURE_TYPE_APPLICATION_INFO;
	application_info.apiVersion						= VK_MAKE_VERSION( 1, 0, 2 );			// 1.0.2 should work on all vulkan enabled drivers.
	application_info.applicationVersion				= VK_MAKE_VERSION( 0, 1, 0 );
	application_info.pApplicationName				= "Vulkan API Tutorial Series";

	VkInstanceCreateInfo instance_create_info {};
	instance_create_info.sType						= VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instance_create_info.pApplicationInfo			= &application_info;
	instance_create_info.enabledLayerCount			= _instance_layers.size();
	instance_create_info.ppEnabledLayerNames		= _instance_layers.data();
	instance_create_info.enabledExtensionCount		= _instance_extensions.size();
	instance_create_info.ppEnabledExtensionNames	= _instance_extensions.data();
	instance_create_info.pNext						= &_debug_callback_create_info;

	ErrorCheck( vkCreateInstance( &instance_create_info, nullptr, &_instance ) );
}
Beispiel #23
0
VkResult VulkanExampleBase::createInstance(bool enableValidation)
{
	this->enableValidation = enableValidation;

	VkApplicationInfo appInfo = {};
	appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	appInfo.pApplicationName = name.c_str();
	appInfo.pEngineName = name.c_str();
	// Temporary workaround for drivers not supporting SDK 1.0.3 upon launch
	// todo : Use VK_API_VERSION
	appInfo.apiVersion = VK_MAKE_VERSION(1, 0, 2);

	std::vector<const char*> enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME };

	// Enable surface extensions depending on os
#if defined(_WIN32)
	enabledExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#elif defined(__ANDROID__)
	enabledExtensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
#elif defined(__linux__)
	enabledExtensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif

	VkInstanceCreateInfo instanceCreateInfo = {};
	instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instanceCreateInfo.pNext = NULL;
	instanceCreateInfo.pApplicationInfo = &appInfo;
	if (enabledExtensions.size() > 0)
	{
		if (enableValidation)
		{
			enabledExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
		}
		instanceCreateInfo.enabledExtensionCount = (uint32_t)enabledExtensions.size();
		instanceCreateInfo.ppEnabledExtensionNames = enabledExtensions.data();
	}
	if (enableValidation)
	{
		instanceCreateInfo.enabledLayerCount = vkDebug::validationLayerCount;
		instanceCreateInfo.ppEnabledLayerNames = vkDebug::validationLayerNames;
	}
	return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
}
Beispiel #24
0
// Instances
void Renderer::_InitInstance() {
	// Application info
	VkApplicationInfo application_info {};
	application_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	application_info.apiVersion = VK_MAKE_VERSION(1, 0, 13);
	application_info.applicationVersion = VK_MAKE_VERSION(0, 1, 0);
	application_info.pApplicationName = "Vulkan Testing";

	// Instance create info
	VkInstanceCreateInfo instance_create_info{};
	instance_create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instance_create_info.pApplicationInfo = &application_info;
	instance_create_info.enabledLayerCount = (uint32_t) _instance_layer_list.size();
	instance_create_info.ppEnabledLayerNames = _instance_layer_list.data();
	instance_create_info.enabledExtensionCount = (uint32_t) _instance_extension_list.size();
	instance_create_info.ppEnabledExtensionNames = _instance_extension_list.data();
	instance_create_info.pNext = &_debug_callback_create_info;

	ErrorCheck(vkCreateInstance(&instance_create_info, nullptr, &_instance));
}
TEST(LX435, InstanceCreateInfoConst)
{
    VkInstanceCreateInfo const info =
    {
        VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
        nullptr,
        0,
        nullptr,
        0,
        nullptr,
        0,
        nullptr
    };

    VkInstance instance = VK_NULL_HANDLE;
    VkResult result = vkCreateInstance(&info, VK_NULL_HANDLE, &instance);
    EXPECT_EQ(result, VK_SUCCESS);

    vkDestroyInstance(instance, nullptr);
}
VulkanInstance::VulkanInstance(const char* applicationName, 
    unsigned int applicationVersion,
    bool enableValidation)
{
    VulkanLayers vulkanLayer;
    VulkanExtensions vulkanExtensions;
    vulkanExtensions.require("VK_KHR_win32_surface");

    std::vector<const char*> layers = vulkanLayer.getInstanceLayers();
    std::vector<const char*> extensions = vulkanExtensions.getRequiredInstanceExtensions();

    // Set the data for this application.
    VkApplicationInfo applicationInfo;
    applicationInfo.apiVersion = 0; // Must be 0, otherwise must be version that application supports.
    applicationInfo.applicationVersion = applicationVersion; // The name and version supplied by our user.
    applicationInfo.pApplicationName = applicationName;
    applicationInfo.engineVersion = engineVersion; // A preliminary name and version for our graphics engine.
    applicationInfo.pEngineName = engineName;
    applicationInfo.pNext = nullptr; //  pNext must be NULL.
    applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; //  sType must be VK_STRUCTURE_TYPE_APPLICATION_INFO.
    
    // Check that conversions are still correct.
    assert(extensions.size() == static_cast<uint32_t>(extensions.size()));

    VkInstanceCreateInfo createInfo;
    createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size());
    createInfo.enabledLayerCount = static_cast<uint32_t>(layers.size());
    createInfo.flags = 0; //  flags must be 0.
    createInfo.pApplicationInfo = nullptr; // &applicationInfo;
    createInfo.pNext = nullptr; //  pNext must be NULL.
    createInfo.ppEnabledExtensionNames = (extensions.size() > 0) ? extensions.data() : nullptr;
    createInfo.ppEnabledLayerNames = (layers.size() > 0) ? layers.data() : nullptr;
    createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; // sType must be VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO.
    
    // Create the instance.
    VKR_VK_VERIFY(Fatal, vkCreateInstance(&createInfo,
        nullptr,
        &m_instance));

}
    void createInstance()
    {
        // Get the required vulkan extensions
        auto extensions = std::move(getRequiredExtensions());

        // Fetch the validation layers we watch
        if(enableValidationLayers && !checkValidationLayerSupport()) {
            throw std::runtime_error("Requested validation layers unavailable");
        }

        // Setup some simple application information for Vulkan
        VkApplicationInfo appInfo  = {};
        appInfo.sType              = VK_STRUCTURE_TYPE_APPLICATION_INFO;
        appInfo.pApplicationName   = TITLE;
        appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
        appInfo.pEngineName        = "Derpgin";
        appInfo.engineVersion      = VK_MAKE_VERSION(1, 0, 0);
        appInfo.apiVersion         = VK_API_VERSION_1_0;

        // Setup the instance information
        VkInstanceCreateInfo createInfo    = {};
        createInfo.sType                   = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
        createInfo.pApplicationInfo        = &appInfo;
        createInfo.enabledExtensionCount   = extensions.size();
        createInfo.ppEnabledExtensionNames = extensions.data();
        createInfo.enabledLayerCount       = 0;

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

        // Create the vulkan instance
        if(vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
            throw std::runtime_error("Failed to create Vulkan instance");
        }
    }
Beispiel #28
0
bool VKAppInstance::Initialize(std::string title)
{
    VkResult res = VK_SUCCESS;

    if(!CheckInstanceExtensions())
        return false;

    VkApplicationInfo info;
    info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
    info.pNext = nullptr;
    info.pApplicationName = title.c_str();
    info.applicationVersion = 0;
    info.pEngineName = "VulkanExamples";
    info.engineVersion = 0;
    info.apiVersion = VK_MAKE_VERSION(1, 0, 11);

    for(auto layers : m_instanceLayerCollection)
    {
        m_enabledLayerNames = layers;

        VkInstanceCreateInfo cInfo;
        cInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
        cInfo.pNext = nullptr;
        cInfo.flags = 0;
        cInfo.pApplicationInfo = &info;
        cInfo.enabledLayerCount = static_cast<uint32_t>(layers.size());
        cInfo.ppEnabledLayerNames = &layers[0];
        cInfo.enabledExtensionCount = m_enabledExtNames.size();
        cInfo.ppEnabledExtensionNames = &m_enabledExtNames[0];

        res = vkCreateInstance(&cInfo, nullptr, &m_instance);
        if(res == VK_SUCCESS)
            break;
        else
            std::cerr << "Failed to create Vulkan instance." << std::endl;
    }

    return true;
}
TEST(EnumerateDeviceExtensionProperties, DeviceExtensionEnumerated)
{
    VkInstance instance = VK_NULL_HANDLE;
    VkResult result = vkCreateInstance(VK::InstanceCreateInfo(), VK_NULL_HANDLE, &instance);
    ASSERT_EQ(result, VK_SUCCESS);

    uint32_t physicalCount = 0;
    result = vkEnumeratePhysicalDevices(instance, &physicalCount, nullptr);
    ASSERT_EQ(result, VK_SUCCESS);
    ASSERT_GT(physicalCount, 0u);

    std::unique_ptr<VkPhysicalDevice[]> physical(new VkPhysicalDevice[physicalCount]);
    result = vkEnumeratePhysicalDevices(instance, &physicalCount, physical.get());
    ASSERT_EQ(result, VK_SUCCESS);
    ASSERT_GT(physicalCount, 0u);

    for(uint32_t p = 0; p < physicalCount; ++p)
    {
        uint32_t count = 0u;
        result = vkEnumerateDeviceExtensionProperties(physical[p], nullptr, &count, nullptr);
        ASSERT_EQ(result, VK_SUCCESS);

        std::unique_ptr<VkExtensionProperties[]> properties(new VkExtensionProperties[count]);
        result = vkEnumerateDeviceExtensionProperties(physical[p], nullptr, &count, properties.get());
        ASSERT_EQ(result, VK_SUCCESS);

        ASSERT_NE(std::find_if(
            &properties[0],
            &properties[count],
            [](VkExtensionProperties const& properties)
            {
                return strcmp(properties.extensionName, "VK_KHR_swapchain") == 0;
            }),
            &properties[count]);
    }

    vkDestroyInstance(instance, nullptr);
}
Beispiel #30
0
	VkResult Instance::create()
	{
		const char* extensionNames[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME };

		VkApplicationInfo applicationInfo = {};
		applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
		applicationInfo.pApplicationName = "test_vk";
		applicationInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
		applicationInfo.pEngineName = "test_vk";
		applicationInfo.engineVersion = VK_MAKE_VERSION(0, 9, 0);
		applicationInfo.apiVersion = VK_API_VERSION;

		VkInstanceCreateInfo instanceCreateInfo = {};
		instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
		instanceCreateInfo.flags = 0;
		instanceCreateInfo.pApplicationInfo = &applicationInfo;
		instanceCreateInfo.enabledLayerCount = 0;
		instanceCreateInfo.ppEnabledLayerNames = nullptr;
		instanceCreateInfo.enabledExtensionCount = 2;
		instanceCreateInfo.ppEnabledExtensionNames = extensionNames;

		return vkCreateInstance(&instanceCreateInfo, nullptr, &m_instance);
	}