Skip to content

Upgrade wgpu 23 -> 25 #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025
Merged
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
252 changes: 161 additions & 91 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ skip = [
{ name = "raw-window-handle", version = "=0.5.2" },
{ name = "raw-window-handle", version = "=0.6.2" },

# HACK(eddyb) the newer version hasn't propagated through the ecosystem yet.
{ name = "cfg_aliases", version = "=0.1.1" },
{ name = "cfg_aliases", version = "=0.2.1" },

# HACK(eddyb) the newer version hasn't propagated through the ecosystem yet.
{ name = "hashbrown", version = "=0.14.5" },
{ name = "hashbrown", version = "=0.15.2" },
Expand Down
2 changes: 1 addition & 1 deletion examples/runners/wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cfg-if = "1.0.0"
shared = { path = "../../shaders/shared" }
futures = { version = "0.3", default-features = false, features = ["std", "executor"] }
# Vulkan SDK or MoltenVK needs to be installed for `vulkan-portability` to work on macOS
wgpu = { version = "23", features = ["spirv", "vulkan-portability"] }
wgpu = { version = "25.0.2", features = ["spirv", "vulkan-portability"] }
winit = { version = "0.30.0", features = ["android-native-activity", "rwh_05"] }
clap = { version = "4", features = ["derive"] }
strum = { version = "0.26.0", default-features = false, features = ["std", "derive"] }
Expand Down
29 changes: 15 additions & 14 deletions examples/runners/wgpu/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ pub fn start(options: &Options) {
}

async fn start_internal(options: &Options, compiled_shader_modules: CompiledShaderModules) {
let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY);
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
let backends = wgpu::Backends::from_env().unwrap_or(wgpu::Backends::PRIMARY);
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends,
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
..Default::default()
});
let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None)
Expand Down Expand Up @@ -43,15 +42,13 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad
}

let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
label: None,
required_features,
required_limits: wgpu::Limits::default(),
memory_hints: wgpu::MemoryHints::Performance,
},
None,
)
.request_device(&wgpu::DeviceDescriptor {
label: None,
required_features,
required_limits: wgpu::Limits::default(),
memory_hints: wgpu::MemoryHints::Performance,
trace: Default::default(),
})
.await
.expect("Failed to create device");
drop(instance);
Expand All @@ -67,7 +64,11 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad
// FIXME(eddyb) automate this decision by default.
let module = compiled_shader_modules.spv_module_for_entry_point(entry_point);
let module = if options.force_spirv_passthru {
unsafe { device.create_shader_module_spirv(&module) }
unsafe {
device.create_shader_module_passthrough(wgpu::ShaderModuleDescriptorPassthrough::SpirV(
module,
))
}
} else {
let wgpu::ShaderModuleDescriptorSpirV { label, source } = module;
device.create_shader_module(wgpu::ShaderModuleDescriptor {
Expand Down Expand Up @@ -225,7 +226,7 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad
buffer_slice.map_async(wgpu::MapMode::Read, |r| r.unwrap());
// NOTE(eddyb) `poll` should return only after the above callbacks fire
// (see also https://github.com/gfx-rs/wgpu/pull/2698 for more details).
device.poll(wgpu::Maintain::Wait);
device.poll(wgpu::PollType::Wait).unwrap();

if timestamping {
if let (Some(timestamp_readback_buffer), Some(timestamp_period)) =
Expand Down
30 changes: 16 additions & 14 deletions examples/runners/wgpu/src/graphics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{CompiledShaderModules, Options, maybe_watch};
use wgpu::ShaderModuleDescriptorPassthrough;

use shared::ShaderConstants;
use winit::{
Expand Down Expand Up @@ -39,11 +40,10 @@ async fn run(
window: Window,
compiled_shader_modules: CompiledShaderModules,
) {
let backends = wgpu::util::backend_bits_from_env()
.unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL);
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
let backends =
wgpu::Backends::from_env().unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL);
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends,
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
..Default::default()
});

Expand Down Expand Up @@ -83,15 +83,13 @@ async fn run(

// Create the logical device and command queue
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
label: None,
required_features,
required_limits,
memory_hints: wgpu::MemoryHints::Performance,
},
None,
)
.request_device(&wgpu::DeviceDescriptor {
label: None,
required_features,
required_limits,
memory_hints: wgpu::MemoryHints::Performance,
trace: Default::default(),
})
.await
.expect("Failed to create device");

Expand Down Expand Up @@ -373,7 +371,11 @@ fn create_pipeline(
// FIXME(eddyb) automate this decision by default.
let create_module = |module| {
if options.force_spirv_passthru {
unsafe { device.create_shader_module_spirv(&module) }
unsafe {
device.create_shader_module_passthrough(ShaderModuleDescriptorPassthrough::SpirV(
module,
))
}
} else {
let wgpu::ShaderModuleDescriptorSpirV { label, source } = module;
device.create_shader_module(wgpu::ShaderModuleDescriptor {
Expand Down
6 changes: 5 additions & 1 deletion examples/runners/wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,12 @@ fn maybe_watch(
RustGPUShader::Compute => wgpu::include_spirv_raw!(env!("compute_shader.spv")),
RustGPUShader::Mouse => wgpu::include_spirv_raw!(env!("mouse_shader.spv")),
};
let spirv = match module {
wgpu::ShaderModuleDescriptorPassthrough::SpirV(spirv) => spirv,
_ => panic!("not spirv"),
};
CompiledShaderModules {
named_spv_modules: vec![(None, module)],
named_spv_modules: vec![(None, spirv)],
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/difftests/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use-compiled-tools = [
spirv-builder.workspace = true
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wgpu = { version = "23", features = ["spirv", "vulkan-portability"] }
wgpu = { version = "25.0.2", features = ["spirv", "vulkan-portability"] }
tempfile = "3.5"
futures = "0.3.31"
bytemuck = "1.21.0"
thiserror = "1.0"
anyhow = "1.0.98"

[lints]
workspace = true
11 changes: 1 addition & 10 deletions tests/difftests/lib/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
use serde::Deserialize;
use std::{fs, path::Path};
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ConfigError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
}

#[derive(Debug, Deserialize)]
pub struct Config {
pub output_path: std::path::PathBuf,
}

impl Config {
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, ConfigError> {
pub fn from_path<P: AsRef<Path>>(path: P) -> anyhow::Result<Self> {
let content = fs::read_to_string(path)?;
let config = serde_json::from_str(&content)?;
Ok(config)
Expand Down
Loading