Skip to content

Commit ffd7337

Browse files
authored
Update wasm32 dependencies, set alpha_mode on web target (#3040)
1 parent 65e4051 commit ffd7337

File tree

4 files changed

+50
-41
lines changed

4 files changed

+50
-41
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ SurfaceConfiguration {
140140
- Document that `write_buffer_with()` is sound but unwise to read from by @kpreid in [#3006](https://github.com/gfx-rs/wgpu/pull/3006)
141141
- Explain why `Adapter::as_hal` and `Device::as_hal` have to take callback functions. By @jimblandy in [#2992](https://github.com/gfx-rs/wgpu/pull/2992)
142142

143+
### Dependency Updates
144+
145+
#### WebGPU
146+
- Update wasm32 dependencies, set `alpha_mode` on web target by @jinleili in [#3040](https://github.com/gfx-rs/wgpu/pull/3040)
147+
143148
### Build Configuration
144149

145150
- Add the `"strict_asserts"` feature, to enable additional internal

Cargo.lock

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

wgpu/Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ noise = { version = "0.7", default-features = false }
132132
obj = "0.10"
133133
png = "0.17"
134134
nanorand = { version = "0.7", default-features = false, features = ["wyrand"] }
135-
winit = "0.27.1" # for "halmark" example
135+
winit = "0.27.1" # for "halmark" example
136136

137137
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
138138
async-executor = "1.0"
@@ -160,7 +160,7 @@ version = "0.9"
160160
features = ["wgsl-out"]
161161

162162
[target.'cfg(target_arch = "wasm32")'.dependencies]
163-
web-sys = { version = "0.3.58", features = [
163+
web-sys = { version = "0.3.60", features = [
164164
"Document",
165165
"Navigator",
166166
"Node",
@@ -184,6 +184,7 @@ web-sys = { version = "0.3.58", features = [
184184
"GpuBufferBindingLayout",
185185
"GpuBufferBindingType",
186186
"GpuBufferDescriptor",
187+
"GpuCanvasAlphaMode",
187188
"GpuCanvasContext",
188189
"GpuCanvasConfiguration",
189190
"GpuColorDict",
@@ -284,14 +285,14 @@ web-sys = { version = "0.3.58", features = [
284285
"ImageBitmapRenderingContext",
285286
"Window"
286287
] }
287-
wasm-bindgen = "0.2.81"
288-
js-sys = "0.3.58"
289-
wasm-bindgen-futures = "0.4.31"
288+
wasm-bindgen = "0.2.83"
289+
js-sys = "0.3.60"
290+
wasm-bindgen-futures = "0.4.33"
290291
# parking_lot 0.12 switches from `winapi` to `windows`; permit either
291292
parking_lot = ">=0.11,<0.13"
292293

293294
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
294-
console_error_panic_hook = "0.1.6"
295+
console_error_panic_hook = "0.1.7"
295296
console_log = "0.2"
296297
# We need the Location feature in the framework examples
297-
web-sys = { version = "0.3.58", features = ["Location"] }
298+
web-sys = { version = "0.3.60", features = ["Location"] }

wgpu/src/backend/web.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture
550550
TextureFormat::Depth32FloatStencil8 => tf::Depth32floatStencil8,
551551
TextureFormat::Depth24Plus => tf::Depth24plus,
552552
TextureFormat::Depth24PlusStencil8 => tf::Depth24plusStencil8,
553-
TextureFormat::Depth24UnormStencil8 => tf::Depth24unormStencil8,
554553
_ => unimplemented!(),
555554
}
556555
}
@@ -1239,15 +1238,19 @@ impl crate::Context for Context {
12391238
if let wgt::PresentMode::Mailbox | wgt::PresentMode::Immediate = config.present_mode {
12401239
panic!("Only FIFO/Auto* is supported on web");
12411240
}
1242-
if let wgt::CompositeAlphaMode::PreMultiplied
1243-
| wgt::CompositeAlphaMode::PostMultiplied
1244-
| wgt::CompositeAlphaMode::Inherit = config.alpha_mode
1241+
if let wgt::CompositeAlphaMode::PostMultiplied | wgt::CompositeAlphaMode::Inherit =
1242+
config.alpha_mode
12451243
{
1246-
panic!("Only Opaque/Auto alpha mode is supported on web");
1244+
panic!("Only Opaque/Auto or PreMultiplied alpha mode are supported on web");
12471245
}
1246+
let alpha_mode = match config.alpha_mode {
1247+
wgt::CompositeAlphaMode::PreMultiplied => web_sys::GpuCanvasAlphaMode::Premultiplied,
1248+
_ => web_sys::GpuCanvasAlphaMode::Opaque,
1249+
};
12481250
let mut mapped =
12491251
web_sys::GpuCanvasConfiguration::new(&device.0, map_texture_format(config.format));
12501252
mapped.usage(config.usage.bits());
1253+
mapped.alpha_mode(alpha_mode);
12511254
surface.0.configure(&mapped);
12521255
}
12531256

0 commit comments

Comments
 (0)