From 9f99d67a63babfe2b721d187f64112ab9d37c2c1 Mon Sep 17 00:00:00 2001 From: Rukai Date: Sun, 19 Jul 2020 18:10:20 +1000 Subject: [PATCH] [rs] Update to latest wgpu --- wgpu/Cargo.toml | 4 ++-- wgpu/examples/framework.rs | 4 ++-- wgpu/examples/hello-triangle/main.rs | 2 +- wgpu/src/backend/direct.rs | 27 ++++++++++++++++----------- wgpu/src/backend/web.rs | 2 +- wgpu/src/lib.rs | 11 +++++------ 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index ecbe817ab0..c80820aaf6 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -27,14 +27,14 @@ vulkan = ["wgc/gfx-backend-vulkan"] package = "wgpu-core" version = "0.5" git = "https://github.com/gfx-rs/wgpu" -rev = "a0ed09a6a83dc0d16c6ad711cf139a5fcfbb9c35" +rev = "3c6ee8766ae8df8fc5c2b70f7c37d634ff3b79aa" features = ["raw-window-handle"] [dependencies.wgt] package = "wgpu-types" version = "0.5" git = "https://github.com/gfx-rs/wgpu" -rev = "a0ed09a6a83dc0d16c6ad711cf139a5fcfbb9c35" +rev = "3c6ee8766ae8df8fc5c2b70f7c37d634ff3b79aa" [dependencies] arrayvec = "0.5" diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index f12ab437b0..fc3ad06aca 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -266,12 +266,12 @@ fn start( } }, event::Event::RedrawRequested(_) => { - let frame = match swap_chain.get_next_frame() { + let frame = match swap_chain.get_current_frame() { Ok(frame) => frame, Err(_) => { swap_chain = device.create_swap_chain(&surface, &sc_desc); swap_chain - .get_next_frame() + .get_current_frame() .expect("Failed to acquire next swap chain texture!") } }; diff --git a/wgpu/examples/hello-triangle/main.rs b/wgpu/examples/hello-triangle/main.rs index 69889ded0d..b26e7ff161 100644 --- a/wgpu/examples/hello-triangle/main.rs +++ b/wgpu/examples/hello-triangle/main.rs @@ -103,7 +103,7 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu:: } Event::RedrawRequested(_) => { let frame = swap_chain - .get_next_frame() + .get_current_frame() .expect("Failed to acquire next swap chain texture") .output; let mut encoder = diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 2bf23e81e1..3ddb4353a3 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -724,6 +724,7 @@ impl crate::Context for Context { &desc.map_label(|_| owned_label.as_ptr()), PhantomData )) + .unwrap() } fn device_create_texture( @@ -737,6 +738,7 @@ impl crate::Context for Context { &desc.map_label(|_| owned_label.as_ptr()), PhantomData )) + .unwrap() } fn device_create_sampler( @@ -777,7 +779,7 @@ impl crate::Context for Context { fn device_drop(&self, device: &Self::DeviceId) { #[cfg(not(target_arch = "wasm32"))] - gfx_select!(*device => self.device_poll(*device, true)); + gfx_select!(*device => self.device_poll(*device, true)).unwrap(); //TODO: make this work in general #[cfg(not(target_arch = "wasm32"))] #[cfg(feature = "metal-auto-capture")] @@ -791,7 +793,8 @@ impl crate::Context for Context { crate::Maintain::Poll => false, crate::Maintain::Wait => true, } - )); + )) + .unwrap(); } fn buffer_map_async( @@ -824,7 +827,7 @@ impl crate::Context for Context { callback: buffer_map_future_wrapper, user_data: completion.to_raw() as _, }; - gfx_select!(*buffer => self.buffer_map_async(*buffer, range, operation)); + gfx_select!(*buffer => self.buffer_map_async(*buffer, range, operation)).unwrap(); future } @@ -839,7 +842,8 @@ impl crate::Context for Context { *buffer, sub_range.start, wgt::BufferSize::new(size) - )); + )) + .unwrap(); unsafe { slice::from_raw_parts(ptr, size as usize) } } @@ -853,15 +857,16 @@ impl crate::Context for Context { *buffer, sub_range.start, wgt::BufferSize::new(size) - )); + )) + .unwrap(); unsafe { slice::from_raw_parts_mut(ptr, size as usize) } } fn buffer_unmap(&self, buffer: &Self::BufferId) { - gfx_select!(*buffer => self.buffer_unmap(*buffer)) + gfx_select!(*buffer => self.buffer_unmap(*buffer)).unwrap(); } - fn swap_chain_get_next_texture( + fn swap_chain_get_current_texture_view( &self, swap_chain: &Self::SwapChainId, ) -> ( @@ -870,7 +875,7 @@ impl crate::Context for Context { Self::SwapChainOutputDetail, ) { let wgc::swap_chain::SwapChainOutput { status, view_id } = - gfx_select!(*swap_chain => self.swap_chain_get_next_texture(*swap_chain, PhantomData)); + gfx_select!(*swap_chain => self.swap_chain_get_current_texture_view(*swap_chain, PhantomData)).unwrap(); ( view_id, @@ -882,7 +887,7 @@ impl crate::Context for Context { } fn swap_chain_present(&self, view: &Self::TextureViewId, detail: &Self::SwapChainOutputDetail) { - gfx_select!(*view => self.swap_chain_present(detail.swap_chain_id)) + gfx_select!(*view => self.swap_chain_present(detail.swap_chain_id)).unwrap(); } fn texture_create_view( @@ -1058,7 +1063,7 @@ impl crate::Context for Context { fn command_encoder_finish(&self, encoder: &Self::CommandEncoderId) -> Self::CommandBufferId { let desc = wgt::CommandBufferDescriptor::default(); - gfx_select!(*encoder => self.command_encoder_finish(*encoder, &desc)) + gfx_select!(*encoder => self.command_encoder_finish(*encoder, &desc)).unwrap() } fn render_bundle_encoder_finish( @@ -1109,7 +1114,7 @@ impl crate::Context for Context { ) { let temp_command_buffers = command_buffers.collect::>(); - gfx_select!(*queue => self.queue_submit(*queue, &temp_command_buffers)) + gfx_select!(*queue => self.queue_submit(*queue, &temp_command_buffers)).unwrap() } } diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index b3df3023be..cd8e710a41 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1149,7 +1149,7 @@ impl crate::Context for Context { buffer.0.unmap(); } - fn swap_chain_get_next_texture( + fn swap_chain_get_current_texture_view( &self, swap_chain: &Self::SwapChainId, ) -> ( diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 73c8e87cf4..2b6a830473 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -22,10 +22,10 @@ use std::{ use futures::FutureExt as _; use parking_lot::Mutex; -#[cfg(feature = "trace")] -use serde::Serialize; #[cfg(feature = "replay")] use serde::Deserialize; +#[cfg(feature = "trace")] +use serde::Serialize; #[cfg(not(target_arch = "wasm32"))] pub use wgc::instance::{AdapterInfo, DeviceType}; @@ -278,7 +278,7 @@ trait Context: Sized { sub_range: Range, ) -> &mut [u8]; fn buffer_unmap(&self, buffer: &Self::BufferId); - fn swap_chain_get_next_texture( + fn swap_chain_get_current_texture_view( &self, swap_chain: &Self::SwapChainId, ) -> ( @@ -2287,9 +2287,9 @@ impl SwapChain { /// /// If a SwapChainFrame referencing this surface is alive when the swapchain is recreated, /// recreating the swapchain will panic. - pub fn get_next_frame(&mut self) -> Result { + pub fn get_current_frame(&mut self) -> Result { let (view_id, status, detail) = - Context::swap_chain_get_next_texture(&*self.context, &self.id); + Context::swap_chain_get_current_texture_view(&*self.context, &self.id); let output = view_id.map(|id| SwapChainTexture { view: TextureView { context: Arc::clone(&self.context), @@ -2311,7 +2311,6 @@ impl SwapChain { SwapChainStatus::Timeout => Err(SwapChainError::Timeout), SwapChainStatus::Outdated => Err(SwapChainError::Outdated), SwapChainStatus::Lost => Err(SwapChainError::Lost), - SwapChainStatus::OutOfMemory => Err(SwapChainError::OutOfMemory), } } }