Skip to content

Commit 768bfc6

Browse files
committed
feat: update to wgpu 28
1 parent 73105bc commit 768bfc6

File tree

6 files changed

+112
-53
lines changed

6 files changed

+112
-53
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ wasmtime-wasi = "41.0"
2020
wasmtime-wasi-io = "41.0"
2121
anyhow = "1.0"
2222
winit = { version = "0.30", features = [ "android-native-activity" ] }
23-
wgpu-core = "27"
24-
wgpu-types = "27"
23+
wgpu-core = "28"
24+
wgpu-types = "28"
2525
raw-window-handle = "0.6"
2626
async-trait = "0.1"
2727
rand = "0.9"

crates/wasi-webgpu-wasmtime/src/enum_conversions.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,25 @@ impl From<webgpu::GpuMipmapFilterMode> for wgpu_types::FilterMode {
303303
}
304304
}
305305

306+
// TODO: change to GpuMipmapFilterMode once in wasi:webgpu
307+
impl From<webgpu::GpuFilterMode> for wgpu_types::MipmapFilterMode {
308+
fn from(value: webgpu::GpuFilterMode) -> Self {
309+
match value {
310+
webgpu::GpuFilterMode::Nearest => wgpu_types::MipmapFilterMode::Nearest,
311+
webgpu::GpuFilterMode::Linear => wgpu_types::MipmapFilterMode::Linear,
312+
}
313+
}
314+
}
315+
316+
impl From<webgpu::GpuMipmapFilterMode> for wgpu_types::MipmapFilterMode {
317+
fn from(value: webgpu::GpuMipmapFilterMode) -> Self {
318+
match value {
319+
webgpu::GpuMipmapFilterMode::Nearest => wgpu_types::MipmapFilterMode::Nearest,
320+
webgpu::GpuMipmapFilterMode::Linear => wgpu_types::MipmapFilterMode::Linear,
321+
}
322+
}
323+
}
324+
306325
impl From<webgpu::GpuCompareFunction> for wgpu_types::CompareFunction {
307326
fn from(value: webgpu::GpuCompareFunction) -> Self {
308327
match value {

crates/wasi-webgpu-wasmtime/src/to_core_conversions.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ impl<'a> ToCore<wgpu_core::binding_model::PipelineLayoutDescriptor<'a>>
166166
})
167167
.collect::<Vec<_>>()
168168
.into(),
169-
push_constant_ranges: vec![].into(),
169+
// immediate_size is not present in WebGPU
170+
immediate_size: 0,
170171
}
171172
}
172173
}
@@ -189,8 +190,8 @@ impl<'a> ToCore<wgpu_core::pipeline::RenderPipelineDescriptor<'a>>
189190
.map(|ms| ms.to_core(table))
190191
.unwrap_or_default(),
191192
fragment: self.fragment.map(|f| f.to_core(table)),
192-
// multiview and cache are not present in WebGPU
193-
multiview: None,
193+
// multiview_mask and cache are not present in WebGPU
194+
multiview_mask: None,
194195
cache: None,
195196
}
196197
}
@@ -466,7 +467,7 @@ impl<'a> ToCore<wgpu_core::resource::SamplerDescriptor<'a>> for webgpu::GpuSampl
466467
mipmap_filter: self
467468
.mipmap_filter
468469
.map(|mf| mf.into())
469-
.unwrap_or(wgpu_types::FilterMode::Nearest),
470+
.unwrap_or(wgpu_types::MipmapFilterMode::Nearest),
470471
lod_min_clamp: self.lod_min_clamp.unwrap_or(0.0),
471472
lod_max_clamp: self.lod_max_clamp.unwrap_or(32.0),
472473
compare: self.compare.map(|compare| compare.into()),
@@ -600,13 +601,13 @@ impl ToCore<wgpu_types::BindingType> for webgpu::GpuStorageTextureBindingLayout
600601
// }
601602
// }
602603

603-
impl ToCore<wgpu_core::command::RenderPassDepthStencilAttachment>
604+
impl ToCore<wgpu_core::command::RenderPassDepthStencilAttachment<wgpu_core::id::TextureViewId>>
604605
for webgpu::GpuRenderPassDepthStencilAttachment
605606
{
606607
fn to_core(
607608
self,
608609
table: &ResourceTable,
609-
) -> wgpu_core::command::RenderPassDepthStencilAttachment {
610+
) -> wgpu_core::command::RenderPassDepthStencilAttachment<wgpu_core::id::TextureViewId> {
610611
fn pass_channel_from_options<V>(
611612
load_op: Option<webgpu::GpuLoadOp>,
612613
store_op: Option<webgpu::GpuStoreOp>,

crates/wasi-webgpu-wasmtime/src/trait_impls.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ impl<T: WasiWebGpuView> webgpu::HostGpuDevice for WasiWebGpuImpl<T> {
514514
address_modes: [wgpu_types::AddressMode::ClampToEdge; 3],
515515
mag_filter: wgpu_types::FilterMode::Nearest,
516516
min_filter: wgpu_types::FilterMode::Nearest,
517-
mipmap_filter: wgpu_types::FilterMode::Nearest,
517+
mipmap_filter: wgpu_types::MipmapFilterMode::Nearest,
518518
lod_min_clamp: 0.0,
519519
lod_max_clamp: 32.0,
520520
compare: None,
@@ -645,7 +645,6 @@ impl<T: WasiWebGpuView> webgpu::HostGpuDevice for WasiWebGpuImpl<T> {
645645
let render_bundle_encoder = wgpu_core::command::RenderBundleEncoder::new(
646646
&descriptor.to_core(self.table()),
647647
device_id,
648-
None,
649648
)
650649
.unwrap();
651650
self.table()
@@ -1082,6 +1081,8 @@ impl<T: WasiWebGpuView> webgpu::HostGpuCommandEncoder for WasiWebGpuImpl<T> {
10821081
occlusion_query_set: descriptor
10831082
.occlusion_query_set
10841083
.map(|oqs| oqs.to_core(self.table())),
1084+
// multiview_mask is not present in WebGPU
1085+
multiview_mask: None,
10851086
// TODO: self.max_draw_count not used
10861087
};
10871088
let (render_pass, err) = self
@@ -1110,6 +1111,9 @@ impl<T: WasiWebGpuView> webgpu::HostGpuCommandEncoder for WasiWebGpuImpl<T> {
11101111
.unwrap_or(wgpu_types::CommandBufferDescriptor::default()),
11111112
None,
11121113
);
1114+
// dropping the label.
1115+
// TODO: reconsider when implementing real labels.
1116+
let err = err.map(|(_label, err)| err);
11131117
error_handler.handle_possible_error(err);
11141118
self.table().push(command_buffer).unwrap()
11151119
}

examples/runtime/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl HostState {
5353
backend_options: Default::default(),
5454
memory_budget_thresholds: Default::default(),
5555
},
56+
None,
5657
)),
5758
main_thread_proxy: Arc::new(main_thread_proxy),
5859
}

0 commit comments

Comments
 (0)