From 4618852f8843a1763edfe180749480d077619333 Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Thu, 19 Mar 2020 11:43:38 -0400 Subject: [PATCH 1/2] Remove lifetime from SwapChainOutput --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bca88b7e3b..5bd5a04808 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -397,9 +397,9 @@ pub struct RenderPassDescriptor<'a, 'b> { /// A swap chain image that can be rendered to. #[derive(Debug)] -pub struct SwapChainOutput<'a> { +pub struct SwapChainOutput { pub view: TextureView, - swap_chain_id: &'a wgc::id::SwapChainId, + swap_chain_id: wgc::id::SwapChainId, } /// A view of a buffer which can be used to copy to or from a texture. @@ -1465,10 +1465,10 @@ impl Queue { } } -impl<'a> Drop for SwapChainOutput<'a> { +impl Drop for SwapChainOutput { fn drop(&mut self) { if !thread::panicking() { - wgn::wgpu_swap_chain_present(*self.swap_chain_id); + wgn::wgpu_swap_chain_present(self.swap_chain_id); } } } @@ -1490,7 +1490,7 @@ impl SwapChain { id: output.view_id, owned: false, }, - swap_chain_id: &self.id, + swap_chain_id: self.id, }) } } From dcccbd8107fe270eb796c25a0546bf80827e5c84 Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Fri, 20 Mar 2020 14:33:29 -0400 Subject: [PATCH 2/2] Note that `get_next_texture` will error if a previous output is still alive. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5bd5a04808..6f0dec1801 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1479,7 +1479,8 @@ impl SwapChain { /// When the [`SwapChainOutput`] returned by this method is dropped, the swapchain will present /// the texture to the associated [`Surface`]. /// - /// Returns an `Err` if the GPU timed out when attempting to acquire the next texture. + /// Returns an `Err` if the GPU timed out when attempting to acquire the next texture or if a + /// previous output is still alive. pub fn get_next_texture(&mut self) -> Result { let output = wgn::wgpu_swap_chain_get_next_texture(self.id); if output.view_id == wgc::id::Id::ERROR {