Skip to content

Commit f9ea001

Browse files
committed
upgrade wgpu 23 -> 25
1 parent cba0eb6 commit f9ea001

File tree

9 files changed

+370
-176
lines changed

9 files changed

+370
-176
lines changed

Cargo.lock

Lines changed: 158 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deny.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ skip = [
3333
{ name = "raw-window-handle", version = "=0.5.2" },
3434
{ name = "raw-window-handle", version = "=0.6.2" },
3535

36-
# HACK(eddyb) the newer version hasn't propagated through the ecosystem yet.
37-
{ name = "cfg_aliases", version = "=0.1.1" },
38-
{ name = "cfg_aliases", version = "=0.2.1" },
39-
4036
# HACK(eddyb) the newer version hasn't propagated through the ecosystem yet.
4137
{ name = "hashbrown", version = "=0.14.5" },
4238
{ name = "hashbrown", version = "=0.15.2" },

examples/runners/wgpu/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cfg-if = "1.0.0"
2121
shared = { path = "../../shaders/shared" }
2222
futures = { version = "0.3", default-features = false, features = ["std", "executor"] }
2323
# Vulkan SDK or MoltenVK needs to be installed for `vulkan-portability` to work on macOS
24-
wgpu = { version = "23", features = ["spirv", "vulkan-portability"] }
24+
wgpu = { version = "25.0.2", features = ["spirv", "vulkan-portability"] }
2525
winit = { version = "0.30.0", features = ["android-native-activity", "rwh_05"] }
2626
clap = { version = "4", features = ["derive"] }
2727
strum = { version = "0.26.0", default-features = false, features = ["std", "derive"] }

examples/runners/wgpu/src/compute.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ pub fn start(options: &Options) {
1212
}
1313

1414
async fn start_internal(options: &Options, compiled_shader_modules: CompiledShaderModules) {
15-
let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY);
16-
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
15+
let backends = wgpu::Backends::from_env().unwrap_or(wgpu::Backends::PRIMARY);
16+
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
1717
backends,
18-
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
1918
..Default::default()
2019
});
2120
let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None)
@@ -43,15 +42,13 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad
4342
}
4443

4544
let (device, queue) = adapter
46-
.request_device(
47-
&wgpu::DeviceDescriptor {
48-
label: None,
49-
required_features,
50-
required_limits: wgpu::Limits::default(),
51-
memory_hints: wgpu::MemoryHints::Performance,
52-
},
53-
None,
54-
)
45+
.request_device(&wgpu::DeviceDescriptor {
46+
label: None,
47+
required_features,
48+
required_limits: wgpu::Limits::default(),
49+
memory_hints: wgpu::MemoryHints::Performance,
50+
trace: Default::default(),
51+
})
5552
.await
5653
.expect("Failed to create device");
5754
drop(instance);
@@ -67,7 +64,11 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad
6764
// FIXME(eddyb) automate this decision by default.
6865
let module = compiled_shader_modules.spv_module_for_entry_point(entry_point);
6966
let module = if options.force_spirv_passthru {
70-
unsafe { device.create_shader_module_spirv(&module) }
67+
unsafe {
68+
device.create_shader_module_passthrough(wgpu::ShaderModuleDescriptorPassthrough::SpirV(
69+
module,
70+
))
71+
}
7172
} else {
7273
let wgpu::ShaderModuleDescriptorSpirV { label, source } = module;
7374
device.create_shader_module(wgpu::ShaderModuleDescriptor {
@@ -225,7 +226,7 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad
225226
buffer_slice.map_async(wgpu::MapMode::Read, |r| r.unwrap());
226227
// NOTE(eddyb) `poll` should return only after the above callbacks fire
227228
// (see also https://github.com/gfx-rs/wgpu/pull/2698 for more details).
228-
device.poll(wgpu::Maintain::Wait);
229+
device.poll(wgpu::PollType::Wait).unwrap();
229230

230231
if timestamping {
231232
if let (Some(timestamp_readback_buffer), Some(timestamp_period)) =

examples/runners/wgpu/src/graphics.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{CompiledShaderModules, Options, maybe_watch};
2+
use wgpu::ShaderModuleDescriptorPassthrough;
23

34
use shared::ShaderConstants;
45
use winit::{
@@ -39,11 +40,10 @@ async fn run(
3940
window: Window,
4041
compiled_shader_modules: CompiledShaderModules,
4142
) {
42-
let backends = wgpu::util::backend_bits_from_env()
43-
.unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL);
44-
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
43+
let backends =
44+
wgpu::Backends::from_env().unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL);
45+
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
4546
backends,
46-
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
4747
..Default::default()
4848
});
4949

@@ -83,15 +83,13 @@ async fn run(
8383

8484
// Create the logical device and command queue
8585
let (device, queue) = adapter
86-
.request_device(
87-
&wgpu::DeviceDescriptor {
88-
label: None,
89-
required_features,
90-
required_limits,
91-
memory_hints: wgpu::MemoryHints::Performance,
92-
},
93-
None,
94-
)
86+
.request_device(&wgpu::DeviceDescriptor {
87+
label: None,
88+
required_features,
89+
required_limits,
90+
memory_hints: wgpu::MemoryHints::Performance,
91+
trace: Default::default(),
92+
})
9593
.await
9694
.expect("Failed to create device");
9795

@@ -373,7 +371,11 @@ fn create_pipeline(
373371
// FIXME(eddyb) automate this decision by default.
374372
let create_module = |module| {
375373
if options.force_spirv_passthru {
376-
unsafe { device.create_shader_module_spirv(&module) }
374+
unsafe {
375+
device.create_shader_module_passthrough(ShaderModuleDescriptorPassthrough::SpirV(
376+
module,
377+
))
378+
}
377379
} else {
378380
let wgpu::ShaderModuleDescriptorSpirV { label, source } = module;
379381
device.create_shader_module(wgpu::ShaderModuleDescriptor {

examples/runners/wgpu/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ fn maybe_watch(
216216
RustGPUShader::Compute => wgpu::include_spirv_raw!(env!("compute_shader.spv")),
217217
RustGPUShader::Mouse => wgpu::include_spirv_raw!(env!("mouse_shader.spv")),
218218
};
219+
let spirv = match module {
220+
wgpu::ShaderModuleDescriptorPassthrough::SpirV(spirv) => spirv,
221+
_ => panic!("not spirv"),
222+
};
219223
CompiledShaderModules {
220-
named_spv_modules: vec![(None, module)],
224+
named_spv_modules: vec![(None, spirv)],
221225
}
222226
}
223227
}

tests/difftests/lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use-compiled-tools = [
1919
spirv-builder.workspace = true
2020
serde = { version = "1.0", features = ["derive"] }
2121
serde_json = "1.0"
22-
wgpu = { version = "23", features = ["spirv", "vulkan-portability"] }
22+
wgpu = { version = "25.0.2", features = ["spirv", "vulkan-portability"] }
2323
tempfile = "3.5"
2424
futures = "0.3.31"
2525
bytemuck = "1.21.0"

tests/difftests/lib/src/scaffold/compute/wgpu.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,13 @@ where
123123

124124
fn init() -> anyhow::Result<(wgpu::Device, wgpu::Queue)> {
125125
block_on(async {
126-
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
126+
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
127127
#[cfg(target_os = "linux")]
128128
backends: wgpu::Backends::VULKAN,
129129
#[cfg(not(target_os = "linux"))]
130130
backends: wgpu::Backends::PRIMARY,
131-
dx12_shader_compiler: Default::default(),
132131
flags: Default::default(),
133-
gles_minor_version: Default::default(),
132+
backend_options: Default::default(),
134133
});
135134
let adapter = instance
136135
.request_adapter(&wgpu::RequestAdapterOptions {
@@ -141,18 +140,16 @@ where
141140
.await
142141
.context("Failed to find a suitable GPU adapter")?;
143142
let (device, queue) = adapter
144-
.request_device(
145-
&wgpu::DeviceDescriptor {
146-
label: Some("wgpu Device"),
147-
#[cfg(target_os = "linux")]
148-
required_features: wgpu::Features::SPIRV_SHADER_PASSTHROUGH,
149-
#[cfg(not(target_os = "linux"))]
150-
required_features: wgpu::Features::empty(),
151-
required_limits: wgpu::Limits::default(),
152-
memory_hints: Default::default(),
153-
},
154-
None,
155-
)
143+
.request_device(&wgpu::DeviceDescriptor {
144+
label: Some("wgpu Device"),
145+
#[cfg(target_os = "linux")]
146+
required_features: wgpu::Features::SPIRV_SHADER_PASSTHROUGH,
147+
#[cfg(not(target_os = "linux"))]
148+
required_features: wgpu::Features::empty(),
149+
required_limits: wgpu::Limits::default(),
150+
memory_hints: Default::default(),
151+
trace: Default::default(),
152+
})
156153
.await
157154
.context("Failed to create device")?;
158155
Ok((device, queue))
@@ -255,7 +252,7 @@ where
255252
buffer_slice.map_async(wgpu::MapMode::Read, move |res| {
256253
let _ = sender.send(res);
257254
});
258-
device.poll(wgpu::Maintain::Wait);
255+
device.poll(wgpu::PollType::Wait)?;
259256
block_on(receiver)
260257
.context("mapping canceled")?
261258
.context("mapping failed")?;

0 commit comments

Comments
 (0)