MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / prepare

Method prepare

framework/vulkan_sample.h:1203–1375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201
1202 // Getting a valid vulkan surface from the platform
1203 surface = static_cast<vk::SurfaceKHR>(window->create_surface(reinterpret_cast<vkb::core::InstanceC &>(*instance)));
1204 if (!surface)
1205 {
1206 throw std::runtime_error("Failed to create window surface.");
1207 }
1208
1209 select_physical_device();
1210
1211 physical_device->set_high_priority_graphics_queue_enable(high_priority_graphics_queue);
1212
1213 // Request to enable ASTC
1214 if (physical_device->get_features().textureCompressionASTC_LDR)
1215 {
1216 physical_device->get_mutable_requested_features().textureCompressionASTC_LDR = true;
1217 }
1218
1219#ifdef VKB_VULKAN_DEBUG
1220 if (!debug_utils)
1221 {
1222 std::vector<vk::ExtensionProperties> available_device_extensions = physical_device->get_handle().enumerateDeviceExtensionProperties();
1223 auto debugExtensionIt =
1224 std::ranges::find_if(available_device_extensions,
1225 [](vk::ExtensionProperties const &ep) { return strcmp(ep.extensionName, VK_EXT_DEBUG_MARKER_EXTENSION_NAME) == 0; });
1226 if (debugExtensionIt != available_device_extensions.end())
1227 {
1228 LOGI("Vulkan debug utils enabled ({})", VK_EXT_DEBUG_MARKER_EXTENSION_NAME);
1229
1230 debug_utils = std::make_unique<vkb::core::HPPDebugMarkerExtDebugUtils>();
1231 }
1232 }
1233 if (!debug_utils)
1234 {
1235 LOGW("Vulkan debug utils were requested, but no extension that provides them was found");
1236 }
1237#endif
1238 if (!debug_utils)
1239 {
1240 debug_utils = std::make_unique<vkb::core::HPPDummyDebugUtils>();
1241 }
1242
1243 if constexpr (bindingType == BindingType::Cpp)
1244 {
1245 device = create_device(*physical_device);
1246 }
1247 else
1248 {
1249 device.reset(reinterpret_cast<vkb::core::DeviceCpp *>(create_device(reinterpret_cast<vkb::core::PhysicalDeviceC &>(*physical_device)).release()));
1250 }
1251
1252 // initialize C++-Bindings default dispatcher, optional third step
1253 VULKAN_HPP_DEFAULT_DISPATCHER.init(device->get_handle());
1254
1255 create_render_context();
1256 prepare_render_context();
1257
1258 stats = std::make_unique<vkb::stats::StatsCpp>(*render_context);
1259
1260 // Start the sample in the first GUI configuration

Callers 1

Calls 9

VulkanExceptionClass · 0.85
get_window_modeMethod · 0.80
endMethod · 0.80
initMethod · 0.45
resetMethod · 0.45
is_extension_enabledMethod · 0.45
get_handleMethod · 0.45
create_surfaceMethod · 0.45

Tested by

no test coverage detected