338: Prefer the specific number of frames in a swap chain r=kvark a=kvark

Fixes https://github.com/gfx-rs/wgpu-rs/issues/72

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]andDzmitry Malyshau authored and GitHub committed 2019-09-11 17:26:44 +00:00
commit 7ef8665ea3
2 files changed
+5 -3

No files matched your search

+4 -3
View File
@@ -1916,7 +1916,9 @@ pub fn device_create_swap_chain<B: GfxBackend>(
assert!(suf.supports_queue_family(&adapter.raw.queue_families[0]));
suf.compatibility(&adapter.raw.physical_device)
};
let num_frames = *caps.image_count.start(); //TODO: configure?
let num_frames = swap_chain::DESIRED_NUM_FRAMES
.max(*caps.image_count.start())
.min(*caps.image_count.end());
let config = desc.to_hal(num_frames);
if let Some(formats) = formats {
@@ -1936,10 +1938,9 @@ pub fn device_create_swap_chain<B: GfxBackend>(
desc.width, desc.height, caps.extents);
}
let hal_desc = desc.to_hal(num_frames);
unsafe {
B::get_surface_mut(surface)
.configure_swapchain(&device.raw, hal_desc)
.configure_swapchain(&device.raw, config)
.unwrap();
}
+1
View File
@@ -52,6 +52,7 @@ use hal::{
use std::marker::PhantomData;
const FRAME_TIMEOUT_MS: u64 = 1000;
pub const DESIRED_NUM_FRAMES: u32 = 3;
#[derive(Debug)]
pub struct SwapChain<B: hal::Backend> {