Skip to content
Merged

29.0 #667

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 184 additions & 136 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exclude = [
]

[workspace.dependencies]
wgpu = "28.0"
wgpu = "29.0"
anyhow = "1"
glam = { version = "0.30.9", features = ["bytemuck"] }
bytemuck = { version = "1.13.1", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial1-window/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ anyhow = "1.0"
winit = { version = "0.30" }
env_logger = "0.10"
log = "0.4"
wgpu = "28.0"
wgpu = "29.0"
pollster = "0.3"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.6"
console_log = "1.0"
wgpu = { version = "28.0", features = ["webgl"]}
wgpu = { version = "29.0", features = ["webgl"]}
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4.30"
web-sys = { version = "0.3.69", features = [
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial2-surface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ anyhow = "1.0"
winit = { version = "0.30", features = ["android-native-activity"] }
env_logger = "0.10"
log = "0.4"
wgpu = "28.0"
wgpu = "29.0"
pollster = "0.3"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.6"
console_log = "1.0"
wgpu = { version = "28.0", features = ["webgl"]}
wgpu = { version = "29.0", features = ["webgl"]}
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", features = [
Expand Down
41 changes: 31 additions & 10 deletions code/beginner/tutorial2-surface/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ impl State {

// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
flags: Default::default(),
memory_budget_thresholds: Default::default(),
backend_options: Default::default(),
display: None,
});

let surface = instance.create_surface(window.clone()).unwrap();
Expand Down Expand Up @@ -111,10 +114,31 @@ impl State {
#[allow(unused)]
fn update(&mut self) {}

fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
fn render(&mut self) -> anyhow::Result<()> {
self.window.request_redraw();

let output = self.surface.get_current_texture()?;
let output = match self.surface.get_current_texture() {
wgpu::CurrentSurfaceTexture::Success(surface_texture) => surface_texture,
wgpu::CurrentSurfaceTexture::Suboptimal(surface_texture) => {
self.surface.configure(&self.device, &self.config);
surface_texture
}
wgpu::CurrentSurfaceTexture::Timeout
| wgpu::CurrentSurfaceTexture::Occluded
| wgpu::CurrentSurfaceTexture::Validation => {
// Skip this frame
return Ok(());
}
wgpu::CurrentSurfaceTexture::Outdated => {
self.surface.configure(&self.device, &self.config);
return Ok(());
}
wgpu::CurrentSurfaceTexture::Lost => {
// You could recreate the devices and all resources
// created with it here, but we'll just bail
anyhow::bail!("Lost device");
}
};
let view = output
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
Expand Down Expand Up @@ -255,13 +279,10 @@ impl ApplicationHandler<State> for App {
WindowEvent::RedrawRequested => {
match state.render() {
Ok(_) => {}
// Reconfigure the surface if it's lost or outdated
Err(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => {
let size = state.window.inner_size();
state.resize(size.width, size.height);
}
Err(e) => {
log::error!("Unable to render {}", e);
// Log the error and exit gracefully
log::error!("{e}");
event_loop.exit();
}
}
}
Expand Down
41 changes: 31 additions & 10 deletions code/beginner/tutorial2-surface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ impl State {

// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
flags: Default::default(),
memory_budget_thresholds: Default::default(),
backend_options: Default::default(),
display: None,
});

let surface = instance.create_surface(window.clone()).unwrap();
Expand Down Expand Up @@ -106,15 +109,36 @@ impl State {

fn update(&mut self) {}

fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
fn render(&mut self) -> anyhow::Result<()> {
self.window.request_redraw();

// We can't render unless the surface is configured
if !self.is_surface_configured {
return Ok(());
}

let output = self.surface.get_current_texture()?;
let output = match self.surface.get_current_texture() {
wgpu::CurrentSurfaceTexture::Success(surface_texture) => surface_texture,
wgpu::CurrentSurfaceTexture::Suboptimal(surface_texture) => {
self.surface.configure(&self.device, &self.config);
surface_texture
}
wgpu::CurrentSurfaceTexture::Timeout
| wgpu::CurrentSurfaceTexture::Occluded
| wgpu::CurrentSurfaceTexture::Validation => {
// Skip this frame
return Ok(());
}
wgpu::CurrentSurfaceTexture::Outdated => {
self.surface.configure(&self.device, &self.config);
return Ok(());
}
wgpu::CurrentSurfaceTexture::Lost => {
// You could recreate the devices and all resources
// created with it here, but we'll just bail
anyhow::bail!("Lost device");
}
};
let view = output
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
Expand Down Expand Up @@ -256,13 +280,10 @@ impl ApplicationHandler<State> for App {
state.update();
match state.render() {
Ok(_) => {}
// Reconfigure the surface if it's lost or outdated
Err(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => {
let size = state.window.inner_size();
state.resize(size.width, size.height);
}
Err(e) => {
log::error!("Unable to render {}", e);
// Log the error and exit gracefully
log::error!("{e}");
event_loop.exit();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial3-pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ anyhow = "1.0"
winit = { version = "0.30", features = ["android-native-activity"] }
env_logger = "0.10"
log = "0.4"
wgpu = "28.0"
wgpu = "29.0"
pollster = "0.3"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.6"
console_log = "1.0"
wgpu = { version = "28.0", features = ["webgl"]}
wgpu = { version = "29.0", features = ["webgl"]}
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", features = [
Expand Down
41 changes: 31 additions & 10 deletions code/beginner/tutorial3-pipeline/src/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ impl State {

// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
flags: Default::default(),
memory_budget_thresholds: Default::default(),
backend_options: Default::default(),
display: None,
});

let surface = instance.create_surface(window.clone()).unwrap();
Expand Down Expand Up @@ -232,15 +235,36 @@ impl State {
#[allow(dead_code)]
fn update(&mut self) {}

fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
fn render(&mut self) -> anyhow::Result<()> {
self.window.request_redraw();

// We can't render unless the surface is configured
if !self.is_surface_configured {
return Ok(());
}

let output = self.surface.get_current_texture()?;
let output = match self.surface.get_current_texture() {
wgpu::CurrentSurfaceTexture::Success(surface_texture) => surface_texture,
wgpu::CurrentSurfaceTexture::Suboptimal(surface_texture) => {
self.surface.configure(&self.device, &self.config);
surface_texture
}
wgpu::CurrentSurfaceTexture::Timeout
| wgpu::CurrentSurfaceTexture::Occluded
| wgpu::CurrentSurfaceTexture::Validation => {
// Skip this frame
return Ok(());
}
wgpu::CurrentSurfaceTexture::Outdated => {
self.surface.configure(&self.device, &self.config);
return Ok(());
}
wgpu::CurrentSurfaceTexture::Lost => {
// You could recreate the devices and all resources
// created with it here, but we'll just bail
anyhow::bail!("Lost device");
}
};
let view = output
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
Expand Down Expand Up @@ -385,13 +409,10 @@ impl ApplicationHandler<State> for App {
WindowEvent::RedrawRequested => {
match state.render() {
Ok(_) => {}
// Reconfigure the surface if it's lost or outdated
Err(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => {
let size = state.window.inner_size();
state.resize(size.width, size.height);
}
Err(e) => {
log::error!("Unable to render {}", e);
// Log the error and exit gracefully
log::error!("{e}");
event_loop.exit();
}
}
}
Expand Down
41 changes: 31 additions & 10 deletions code/beginner/tutorial3-pipeline/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ impl State {

// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
flags: Default::default(),
memory_budget_thresholds: Default::default(),
backend_options: Default::default(),
display: None,
});

let surface = instance.create_surface(window.clone()).unwrap();
Expand Down Expand Up @@ -177,15 +180,36 @@ impl State {

fn update(&mut self) {}

fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
fn render(&mut self) -> anyhow::Result<()> {
self.window.request_redraw();

// We can't render unless the surface is configured
if !self.is_surface_configured {
return Ok(());
}

let output = self.surface.get_current_texture()?;
let output = match self.surface.get_current_texture() {
wgpu::CurrentSurfaceTexture::Success(surface_texture) => surface_texture,
wgpu::CurrentSurfaceTexture::Suboptimal(surface_texture) => {
self.surface.configure(&self.device, &self.config);
surface_texture
}
wgpu::CurrentSurfaceTexture::Timeout
| wgpu::CurrentSurfaceTexture::Occluded
| wgpu::CurrentSurfaceTexture::Validation => {
// Skip this frame
return Ok(());
}
wgpu::CurrentSurfaceTexture::Outdated => {
self.surface.configure(&self.device, &self.config);
return Ok(());
}
wgpu::CurrentSurfaceTexture::Lost => {
// You could recreate the devices and all resources
// created with it here, but we'll just bail
anyhow::bail!("Lost device");
}
};
let view = output
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
Expand Down Expand Up @@ -323,13 +347,10 @@ impl ApplicationHandler<State> for App {
state.update();
match state.render() {
Ok(_) => {}
// Reconfigure the surface if it's lost or outdated
Err(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => {
let size = state.window.inner_size();
state.resize(size.width, size.height);
}
Err(e) => {
log::error!("Unable to render {}", e);
// Log the error and exit gracefully
log::error!("{e}");
event_loop.exit();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions code/beginner/tutorial4-buffer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
anyhow = "1.0"
winit = { version = "0.30", features = ["android-native-activity"] }
wgpu = "28.0"
wgpu = "29.0"
env_logger = "0.10"
log = "0.4"
pollster = "0.3"
Expand All @@ -21,7 +21,7 @@ bytemuck = { version = "1.24", features = [ "derive" ] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
console_log = "1.0"
wgpu = { version = "28.0", features = ["webgl"]}
wgpu = { version = "29.0", features = ["webgl"]}
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", features = [
Expand Down
Loading
Loading