MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / createInstance

Method createInstance

src/Renderer/vkRenderer.cpp:178–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178void 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
211void vkRenderer::setupDebugCallback() {
212 if (!enableValidationLayers) return;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected