| 150 | } |
| 151 | |
| 152 | void |
| 153 | Manager::createInstance() |
| 154 | { |
| 155 | |
| 156 | KP_LOG_DEBUG("Kompute Manager creating instance"); |
| 157 | |
| 158 | this->mFreeInstance = true; |
| 159 | |
| 160 | vk::ApplicationInfo applicationInfo; |
| 161 | applicationInfo.pApplicationName = "Kompute"; |
| 162 | applicationInfo.pEngineName = "Kompute"; |
| 163 | applicationInfo.apiVersion = KOMPUTE_VK_API_VERSION; |
| 164 | applicationInfo.engineVersion = KOMPUTE_VK_API_VERSION; |
| 165 | applicationInfo.applicationVersion = KOMPUTE_VK_API_VERSION; |
| 166 | |
| 167 | std::vector<const char*> applicationExtensions; |
| 168 | |
| 169 | #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS |
| 170 | applicationExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
| 171 | #endif |
| 172 | |
| 173 | vk::InstanceCreateInfo computeInstanceCreateInfo; |
| 174 | computeInstanceCreateInfo.pApplicationInfo = &applicationInfo; |
| 175 | if (!applicationExtensions.empty()) { |
| 176 | computeInstanceCreateInfo.enabledExtensionCount = |
| 177 | (uint32_t)applicationExtensions.size(); |
| 178 | computeInstanceCreateInfo.ppEnabledExtensionNames = |
| 179 | applicationExtensions.data(); |
| 180 | } |
| 181 | |
| 182 | #ifndef KOMPUTE_DISABLE_VK_DEBUG_LAYERS |
| 183 | KP_LOG_DEBUG("Kompute Manager adding debug validation layers"); |
| 184 | // We'll identify the layers that are supported |
| 185 | std::vector<const char*> validLayerNames; |
| 186 | std::vector<const char*> desiredLayerNames = { |
| 187 | "VK_LAYER_LUNARG_assistant_layer", |
| 188 | "VK_LAYER_LUNARG_standard_validation", |
| 189 | "VK_LAYER_KHRONOS_validation", |
| 190 | }; |
| 191 | std::vector<std::string> envLayerNames; |
| 192 | const char* envLayerNamesVal = std::getenv("KOMPUTE_ENV_DEBUG_LAYERS"); |
| 193 | if (envLayerNamesVal != nullptr && *envLayerNamesVal != '\0') { |
| 194 | KP_LOG_DEBUG("Kompute Manager adding environment layers: {}", |
| 195 | envLayerNamesVal); |
| 196 | std::istringstream iss(envLayerNamesVal); |
| 197 | std::istream_iterator<std::string> beg(iss); |
| 198 | std::istream_iterator<std::string> end; |
| 199 | envLayerNames = std::vector<std::string>(beg, end); |
| 200 | for (const std::string& layerName : envLayerNames) { |
| 201 | desiredLayerNames.push_back(layerName.c_str()); |
| 202 | } |
| 203 | KP_LOG_DEBUG("Desired layers: {}", fmt::join(desiredLayerNames, ", ")); |
| 204 | } |
| 205 | |
| 206 | // Identify the valid layer names based on the desiredLayerNames |
| 207 | { |
| 208 | std::set<std::string> uniqueLayerNames; |
| 209 | std::vector<vk::LayerProperties> availableLayerProperties = |