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

Function choose_present_mode

framework/core/hpp_swapchain.cpp:63–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63vk::PresentModeKHR choose_present_mode(vk::PresentModeKHR request_present_mode,
64 const std::vector<vk::PresentModeKHR> &available_present_modes,
65 const std::vector<vk::PresentModeKHR> &present_mode_priority_list)
66{
67 // Try to find the requested present mode in the available present modes
68 auto const present_mode_it = std::ranges::find(available_present_modes, request_present_mode);
69 if (present_mode_it == available_present_modes.end())
70 {
71 // If the requested present mode isn't found, then try to find a mode from the priority list
72 auto const chosen_present_mode_it =
73 std::ranges::find_if(present_mode_priority_list,
74 [&available_present_modes](vk::PresentModeKHR present_mode) { return std::ranges::find(available_present_modes, present_mode) != available_present_modes.end(); });
75
76 // If nothing found, always default to FIFO
77 vk::PresentModeKHR const chosen_present_mode = (chosen_present_mode_it != present_mode_priority_list.end()) ? *chosen_present_mode_it : vk::PresentModeKHR::eFifo;
78
79 LOGW("(HPPSwapchain) Present mode '{}' not supported. Selecting '{}'.", vk::to_string(request_present_mode), vk::to_string(chosen_present_mode));
80 return chosen_present_mode;
81 }
82 else
83 {
84 LOGI("(HPPSwapchain) Present mode selected: {}", to_string(request_present_mode));
85 return request_present_mode;
86 }
87}
88
89vk::SurfaceFormatKHR choose_surface_format(const vk::SurfaceFormatKHR requested_surface_format,
90 const std::vector<vk::SurfaceFormatKHR> &available_surface_formats,

Callers 1

HPPSwapchainMethod · 0.70

Calls 2

endMethod · 0.80
to_stringFunction · 0.50

Tested by

no test coverage detected