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
1202template <vkb::BindingType bindingType>
1203inline bool VulkanSample<bindingType>::prepare(const ApplicationOptions &options)
1204{
1205 if (!Parent::prepare(options))
1206 {
1207 return false;
1208 }
1209
1210 LOGI("Initializing Vulkan sample");
1211
1212 // initialize C++-Bindings default dispatcher, first step
1213#if defined(_HPP_VULKAN_LIBRARY)
1214 static vk::detail::DynamicLoader dl(_HPP_VULKAN_LIBRARY);
1215#else
1216 static vk::detail::DynamicLoader dl;
1217#endif
1218 VULKAN_HPP_DEFAULT_DISPATCHER.init(dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"));
1219
1220 bool headless = window->get_window_mode() == Window::Mode::Headless;
1221
1222 // for a while we're running on mixed C- and C++-bindings, needing volk for the C-bindings!
1223 VkResult result = volkInitialize();
1224 if (result)
1225 {
1226 throw VulkanException(result, "Failed to initialize volk.");
1227 }
1228
1229#ifdef VKB_VULKAN_DEBUG
1230 {
1231 std::vector<vk::ExtensionProperties> available_instance_extensions = vk::enumerateInstanceExtensionProperties();
1232 auto debugExtensionIt =
1233 std::ranges::find_if(available_instance_extensions,
1234 [](vk::ExtensionProperties const &ep) { return strcmp(ep.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0; });
1235 if (debugExtensionIt != available_instance_extensions.end())
1236 {
1237 LOGI("Vulkan debug utils enabled ({})", VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
1238
1239 debug_utils = std::make_unique<vkb::core::HPPDebugUtilsExtDebugUtils>();
1240 }
1241 }
1242#endif
1243
1244 if constexpr (bindingType == BindingType::Cpp)
1245 {
1246 instance = create_instance();
1247 }
1248 else
1249 {
1250 instance.reset(reinterpret_cast<vkb::core::InstanceCpp *>(create_instance().release()));
1251 }
1252
1253 // initialize debug utils or report callback based on enabled extensions, if any
1254 if (instance->is_extension_enabled(VK_EXT_DEBUG_UTILS_EXTENSION_NAME))
1255 {
1256 auto const *debug_utils_messenger_create_info = get_debug_utils_messenger_create_info();
1257 if (debug_utils_messenger_create_info)
1258 {
1259 if constexpr (bindingType == BindingType::Cpp)
1260 {

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