Skip to content
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

Update wasm32 dependencies, set alpha_mode on web target #3040

Merged
merged 2 commits into from
Sep 20, 2022
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ SurfaceConfiguration {
- Document that `write_buffer_with()` is sound but unwise to read from by @kpreid in [#3006](https://github.com/gfx-rs/wgpu/pull/3006)
- 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)

### Dependency Updates

#### WebGPU
- Update wasm32 dependencies, set `alpha_mode` on web target by @jinleili in [#3040](https://github.com/gfx-rs/wgpu/pull/3040)

### Build Configuration

- Add the `"strict_asserts"` feature, to enable additional internal
Expand Down
58 changes: 29 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ noise = { version = "0.7", default-features = false }
obj = "0.10"
png = "0.17"
nanorand = { version = "0.7", default-features = false, features = ["wyrand"] }
winit = "0.27.1" # for "halmark" example
winit = "0.27.1" # for "halmark" example

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

[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3.58", features = [
web-sys = { version = "0.3.60", features = [
"Document",
"Navigator",
"Node",
Expand All @@ -184,6 +184,7 @@ web-sys = { version = "0.3.58", features = [
"GpuBufferBindingLayout",
"GpuBufferBindingType",
"GpuBufferDescriptor",
"GpuCanvasAlphaMode",
"GpuCanvasContext",
"GpuCanvasConfiguration",
"GpuColorDict",
Expand Down Expand Up @@ -284,14 +285,14 @@ web-sys = { version = "0.3.58", features = [
"ImageBitmapRenderingContext",
"Window"
] }
wasm-bindgen = "0.2.81"
js-sys = "0.3.58"
wasm-bindgen-futures = "0.4.31"
wasm-bindgen = "0.2.83"
js-sys = "0.3.60"
wasm-bindgen-futures = "0.4.33"
# parking_lot 0.12 switches from `winapi` to `windows`; permit either
parking_lot = ">=0.11,<0.13"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
console_error_panic_hook = "0.1.6"
console_error_panic_hook = "0.1.7"
console_log = "0.2"
# We need the Location feature in the framework examples
web-sys = { version = "0.3.58", features = ["Location"] }
web-sys = { version = "0.3.60", features = ["Location"] }
13 changes: 8 additions & 5 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture
TextureFormat::Depth32FloatStencil8 => tf::Depth32floatStencil8,
TextureFormat::Depth24Plus => tf::Depth24plus,
TextureFormat::Depth24PlusStencil8 => tf::Depth24plusStencil8,
TextureFormat::Depth24UnormStencil8 => tf::Depth24unormStencil8,
_ => unimplemented!(),
}
}
Expand Down Expand Up @@ -1239,15 +1238,19 @@ impl crate::Context for Context {
if let wgt::PresentMode::Mailbox | wgt::PresentMode::Immediate = config.present_mode {
panic!("Only FIFO/Auto* is supported on web");
}
if let wgt::CompositeAlphaMode::PreMultiplied
| wgt::CompositeAlphaMode::PostMultiplied
| wgt::CompositeAlphaMode::Inherit = config.alpha_mode
if let wgt::CompositeAlphaMode::PostMultiplied | wgt::CompositeAlphaMode::Inherit =
config.alpha_mode
{
panic!("Only Opaque/Auto alpha mode is supported on web");
panic!("Only Opaque/Auto or PreMultiplied alpha mode are supported on web");
}
let alpha_mode = match config.alpha_mode {
wgt::CompositeAlphaMode::PreMultiplied => web_sys::GpuCanvasAlphaMode::Premultiplied,
_ => web_sys::GpuCanvasAlphaMode::Opaque,
};
let mut mapped =
web_sys::GpuCanvasConfiguration::new(&device.0, map_texture_format(config.format));
mapped.usage(config.usage.bits());
mapped.alpha_mode(alpha_mode);
surface.0.configure(&mapped);
}

Expand Down