Simplify example surface format selection
According to specs for vkGetPhysicalDeviceSurfaceFormatsKHR(), at least one surface format must be returned, and returned formats must not be VK_FORMAT_UNDEFINED.
This commit is contained in:
parent
64d1705730
commit
5d5fc57746
|
@ -326,20 +326,10 @@ impl ExampleBase {
|
||||||
|
|
||||||
let present_queue = device.get_device_queue(queue_family_index as u32, 0);
|
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)
|
.get_physical_device_surface_formats(pdevice, surface)
|
||||||
.unwrap();
|
.unwrap()[0];
|
||||||
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.");
|
|
||||||
let surface_capabilities = surface_loader
|
let surface_capabilities = surface_loader
|
||||||
.get_physical_device_surface_capabilities(pdevice, surface)
|
.get_physical_device_surface_capabilities(pdevice, surface)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue