| 176 | } |
| 177 | |
| 178 | void vkRenderer::createInstance() { |
| 179 | if (enableValidationLayers && !checkValidationLayerSupport()) { |
| 180 | throw std::runtime_error("validation layers requested, but not available!"); |
| 181 | } |
| 182 | |
| 183 | VkApplicationInfo appInfo = {}; |
| 184 | appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 185 | appInfo.pApplicationName = "Hello Triangle"; |
| 186 | appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); |
| 187 | appInfo.pEngineName = "No Engine"; |
| 188 | appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); |
| 189 | appInfo.apiVersion = VK_API_VERSION_1_0; |
| 190 | |
| 191 | VkInstanceCreateInfo createInfo = {}; |
| 192 | createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; |
| 193 | createInfo.pApplicationInfo = &appInfo; |
| 194 | |
| 195 | auto extensions = getRequiredExtensions(); |
| 196 | createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size()); |
| 197 | createInfo.ppEnabledExtensionNames = extensions.data(); |
| 198 | |
| 199 | if (enableValidationLayers) { |
| 200 | createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size()); |
| 201 | createInfo.ppEnabledLayerNames = validationLayers.data(); |
| 202 | } else { |
| 203 | createInfo.enabledLayerCount = 0; |
| 204 | } |
| 205 | |
| 206 | if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) { |
| 207 | throw std::runtime_error("failed to create instance!"); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | void vkRenderer::setupDebugCallback() { |
| 212 | if (!enableValidationLayers) return; |
nothing calls this directly
no outgoing calls
no test coverage detected