MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Tools / init_vk

Method init_vk

cube/cube.cpp:1563–1848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1561}
1562
1563void Demo::init_vk() {
1564 VULKAN_HPP_DEFAULT_DISPATCHER.init();
1565
1566 uint32_t apiVersion = 0;
1567 vk::Result enumerate_instance_version_result = vk::enumerateInstanceVersion(&apiVersion);
1568 if (protected_output) {
1569 if (enumerate_instance_version_result != vk::Result::eSuccess) {
1570 ERR_EXIT("Failed to query instance version.", "vkCreateInstance Failure");
1571 }
1572 if (apiVersion < VK_MAKE_VERSION(1, 1, 0)) {
1573 ERR_EXIT("Need Vulkan 1.1 instance for protected output.", "vkCreateInstance Failure");
1574 }
1575 }
1576
1577 std::vector<char const *> instance_validation_layers = {"VK_LAYER_KHRONOS_validation"};
1578
1579 // Look for validation layers
1580 vk::Bool32 validation_found = VK_FALSE;
1581 if (validate) {
1582 auto layers = vk::enumerateInstanceLayerProperties();
1583 VERIFY(layers.result == vk::Result::eSuccess);
1584
1585 validation_found = check_layers(instance_validation_layers, layers.value);
1586 if (validation_found) {
1587 enabled_layers.push_back("VK_LAYER_KHRONOS_validation");
1588 }
1589
1590 else {
1591 ERR_EXIT(
1592 "vkEnumerateInstanceLayerProperties failed to find required validation layer.\n\n"
1593 "Please look at the Getting Started guide for additional information.\n",
1594 "vkCreateInstance Failure");
1595 }
1596 }
1597
1598 /* Look for instance extensions */
1599 vk::Bool32 surfaceExtFound = VK_FALSE;
1600 vk::Bool32 platformSurfaceExtFound = VK_FALSE;
1601 bool portabilityEnumerationActive = false;
1602
1603 // Some platforms (for example, Fuchsia) may have their WSI instance
1604 // extension in layers and require the client to manually specify the
1605 // instance extension layer.
1606 vk::Optional<const std::string> instance_extension_layer = nullptr;
1607#if VK_USE_PLATFORM_FUCHSIA
1608 const char *image_pipe_layer_name = get_fuchsia_image_pipe_layer();
1609 enabled_layers.push_back(image_pipe_layer_name);
1610
1611 const std::string image_pipe_layer_name_str = image_pipe_layer_name;
1612 instance_extension_layer = image_pipe_layer_name_str;
1613#endif // VK_USE_PLATFORM_FUCHSIA
1614
1615 auto instance_extensions_return = vk::enumerateInstanceExtensionProperties(instance_extension_layer);
1616 VERIFY(instance_extensions_return.result == vk::Result::eSuccess);
1617
1618 for (const auto &extension : instance_extensions_return.value) {
1619 if (!strcmp(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, extension.extensionName)) {
1620 enabled_instance_extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);

Callers

nothing calls this directly

Calls 2

initMethod · 0.80
wsi_to_stringFunction · 0.70

Tested by

no test coverage detected