mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 15:24:34 +00:00
Check usage flags when iterating desired formats
This commit is contained in:
parent
470ad2c980
commit
8d4ac0db50
@ -1603,14 +1603,20 @@ Result<SurfaceSupportDetails> query_surface_support_details(VkPhysicalDevice phy
|
||||
return SurfaceSupportDetails{ capabilities, formats, present_modes };
|
||||
}
|
||||
|
||||
VkSurfaceFormatKHR find_surface_format(std::vector<VkSurfaceFormatKHR> const& available_formats,
|
||||
std::vector<VkSurfaceFormatKHR> const& desired_formats) {
|
||||
VkSurfaceFormatKHR find_surface_format(VkPhysicalDevice phys_device,
|
||||
std::vector<VkSurfaceFormatKHR> const& available_formats,
|
||||
std::vector<VkSurfaceFormatKHR> const& desired_formats,
|
||||
VkImageUsageFlags usage_flags) {
|
||||
for (auto const& desired_format : desired_formats) {
|
||||
for (auto const& available_format : available_formats) {
|
||||
// finds the first format that is desired and available
|
||||
if (desired_format.format == available_format.format &&
|
||||
desired_format.colorSpace == available_format.colorSpace) {
|
||||
return desired_format;
|
||||
VkFormatProperties properties;
|
||||
detail::vulkan_functions().fp_vkGetPhysicalDeviceFormatProperties(
|
||||
phys_device, desired_format.format, &properties);
|
||||
if ((properties.optimalTilingFeatures & usage_flags) == usage_flags)
|
||||
return desired_format;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1720,7 +1726,8 @@ detail::Result<Swapchain> SwapchainBuilder::build() const {
|
||||
if (surface_support.capabilities.maxImageCount > 0 && image_count > surface_support.capabilities.maxImageCount) {
|
||||
image_count = surface_support.capabilities.maxImageCount;
|
||||
}
|
||||
VkSurfaceFormatKHR surface_format = detail::find_surface_format(surface_support.formats, desired_formats);
|
||||
VkSurfaceFormatKHR surface_format = detail::find_surface_format(
|
||||
info.physical_device, surface_support.formats, desired_formats, info.image_usage_flags);
|
||||
|
||||
VkExtent2D extent =
|
||||
detail::find_extent(surface_support.capabilities, info.desired_width, info.desired_height);
|
||||
|
Loading…
Reference in New Issue
Block a user