mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 15:24:34 +00:00
Revert behavior change with desired formats not being available
This commit is contained in:
parent
b9a98c61b3
commit
73295fed0b
@ -443,7 +443,7 @@ const char* to_string(SwapchainError err) {
|
||||
CASE_TO_STRING(SwapchainError, failed_get_swapchain_images)
|
||||
CASE_TO_STRING(SwapchainError, failed_create_swapchain_image_views)
|
||||
CASE_TO_STRING(SwapchainError, required_min_image_count_too_low)
|
||||
CASE_TO_STRING(SwapchainError, required_usage_or_features_not_supported)
|
||||
CASE_TO_STRING(SwapchainError, required_usage_not_supported)
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@ -1585,8 +1585,7 @@ enum class SurfaceSupportError {
|
||||
surface_handle_null,
|
||||
failed_get_surface_capabilities,
|
||||
failed_enumerate_surface_formats,
|
||||
failed_enumerate_present_modes,
|
||||
no_suitable_format
|
||||
failed_enumerate_present_modes
|
||||
};
|
||||
|
||||
struct SurfaceSupportErrorCategory : std::error_category {
|
||||
@ -1633,7 +1632,7 @@ Result<SurfaceSupportDetails> query_surface_support_details(VkPhysicalDevice phy
|
||||
return SurfaceSupportDetails{ capabilities, formats, present_modes };
|
||||
}
|
||||
|
||||
Result<VkSurfaceFormatKHR> find_surface_format(VkPhysicalDevice phys_device,
|
||||
VkSurfaceFormatKHR find_surface_format(VkPhysicalDevice phys_device,
|
||||
std::vector<VkSurfaceFormatKHR> const& available_formats,
|
||||
std::vector<VkSurfaceFormatKHR> const& desired_formats,
|
||||
VkFormatFeatureFlags feature_flags) {
|
||||
@ -1648,8 +1647,8 @@ Result<VkSurfaceFormatKHR> find_surface_format(VkPhysicalDevice phys_device,
|
||||
}
|
||||
}
|
||||
|
||||
// If no format supports the provided feature, we report that no format is suitable to the user request
|
||||
return { make_error_code(SurfaceSupportError::no_suitable_format) };
|
||||
// use the first available one if any desired formats aren't found
|
||||
return available_formats[0];
|
||||
}
|
||||
|
||||
VkPresentModeKHR find_present_mode(std::vector<VkPresentModeKHR> const& available_resent_modes,
|
||||
@ -1772,10 +1771,8 @@ Result<Swapchain> SwapchainBuilder::build() const {
|
||||
image_count = surface_support.capabilities.maxImageCount;
|
||||
}
|
||||
|
||||
auto surface_format_ret =
|
||||
VkSurfaceFormatKHR surface_format =
|
||||
detail::find_surface_format(info.physical_device, surface_support.formats, desired_formats, info.format_feature_flags);
|
||||
if (!surface_format_ret.has_value()) return Error{ SwapchainError::required_usage_or_features_not_supported };
|
||||
auto surface_format = surface_format_ret.value();
|
||||
|
||||
VkExtent2D extent = detail::find_extent(surface_support.capabilities, info.desired_width, info.desired_height);
|
||||
|
||||
@ -1791,7 +1788,7 @@ Result<Swapchain> SwapchainBuilder::build() const {
|
||||
|
||||
if (detail::is_unextended_present_mode(present_mode) &&
|
||||
(info.image_usage_flags & surface_support.capabilities.supportedUsageFlags) != info.image_usage_flags) {
|
||||
return Error{ SwapchainError::required_usage_or_features_not_supported };
|
||||
return Error{ SwapchainError::required_usage_not_supported };
|
||||
}
|
||||
|
||||
VkSurfaceTransformFlagBitsKHR pre_transform = info.pre_transform;
|
||||
|
@ -213,7 +213,7 @@ enum class SwapchainError {
|
||||
failed_get_swapchain_images,
|
||||
failed_create_swapchain_image_views,
|
||||
required_min_image_count_too_low,
|
||||
required_usage_or_features_not_supported
|
||||
required_usage_not_supported
|
||||
};
|
||||
|
||||
std::error_code make_error_code(InstanceError instance_error);
|
||||
@ -851,9 +851,8 @@ class SwapchainBuilder {
|
||||
SwapchainBuilder& use_default_image_usage_flags();
|
||||
|
||||
// Set the bitmask of the format feature flag for acquired swapchain images.
|
||||
// If the desired formats cannot allow it, building the swapchain will result in the
|
||||
// `SwapchainError::required_usage_or_features_not_supported` error. Use this functionnality only if you require
|
||||
// formats to support a set of feature flags that are not already implied by set_image_usage_flags
|
||||
// Use this functionnality only if you require formats to support a set of feature flags
|
||||
// that are not already implied by set_image_usage_flags
|
||||
SwapchainBuilder& set_format_feature_flags(VkFormatFeatureFlags feature_flags);
|
||||
// Add a format feature to the bitmask for acquired swapchain images.
|
||||
SwapchainBuilder& add_format_feature_flags(VkFormatFeatureFlags feature_flags);
|
||||
|
@ -305,7 +305,6 @@ TEST_CASE("Swapchain", "[VkBootstrap.bootstrap]") {
|
||||
vkb::SwapchainBuilder swapchain_builder(device);
|
||||
auto swapchain_ret = swapchain_builder.set_desired_extent(256, 256)
|
||||
.set_desired_format({ VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR })
|
||||
.add_fallback_format({ VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR })
|
||||
.set_desired_present_mode(VK_PRESENT_MODE_IMMEDIATE_KHR)
|
||||
.set_pre_transform_flags(VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR)
|
||||
.set_composite_alpha_flags(VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR)
|
||||
|
Loading…
Reference in New Issue
Block a user