Skip to content

Commit

Permalink
Simplify example surface format selection
Browse files Browse the repository at this point in the history
According to specs for vkGetPhysicalDeviceSurfaceFormatsKHR(), at least
one surface format must be returned, and returned formats must not be
VK_FORMAT_UNDEFINED.
  • Loading branch information
swooster authored and Ralith committed Oct 14, 2020
1 parent 64d1705 commit 5d5fc57
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,10 @@ impl ExampleBase {

let present_queue = device.get_device_queue(queue_family_index as u32, 0);

let surface_formats = surface_loader
let surface_format = surface_loader
.get_physical_device_surface_formats(pdevice, surface)
.unwrap();
let surface_format = surface_formats
.iter()
.map(|sfmt| match sfmt.format {
vk::Format::UNDEFINED => vk::SurfaceFormatKHR {
format: vk::Format::B8G8R8_UNORM,
color_space: sfmt.color_space,
},
_ => *sfmt,
})
.next()
.expect("Unable to find suitable surface format.");
.unwrap()[0];

let surface_capabilities = surface_loader
.get_physical_device_surface_capabilities(pdevice, surface)
.unwrap();
Expand Down

0 comments on commit 5d5fc57

Please sign in to comment.