mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[rs] Update to latest wgpu
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -266,12 +266,12 @@ fn start<E: Example>(
|
||||
}
|
||||
},
|
||||
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!")
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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::<SmallVec<[_; 4]>>();
|
||||
|
||||
gfx_select!(*queue => self.queue_submit(*queue, &temp_command_buffers))
|
||||
gfx_select!(*queue => self.queue_submit(*queue, &temp_command_buffers)).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
) -> (
|
||||
|
||||
@@ -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<BufferAddress>,
|
||||
) -> &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<SwapChainFrame, SwapChainError> {
|
||||
pub fn get_current_frame(&mut self) -> Result<SwapChainFrame, SwapChainError> {
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user