diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49c4c0fa3..f3419a1d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,6 +188,13 @@ jobs: tier: 2 kind: web + - name: WebAssembly 64-bit + os: ubuntu-24.04 + target: wasm64-unknown-unknown + kind: wgpu-only + tier: 3 + extra-flags: -Zbuild-std=std,panic_abort + - name: Emscripten os: ubuntu-24.04 target: wasm32-unknown-emscripten diff --git a/CHANGELOG.md b/CHANGELOG.md index 16b84206d..500a5c5f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ Bottom level categories: ### Added/New Features +#### General + +- Support the `wasm64-unknown-unknown` target for the web backend. Building for wasm64 requires a nightly toolchain with `-Z build-std=std,panic_abort`. By @nickbabcock in [#9836](https://github.com/gfx-rs/wgpu/pull/9836). + #### Hal - Add `BufferBinding::buffer`, a public read accessor for the bound buffer, which was previously inaccessible to out-of-tree `wgpu_hal::Api` implementations. By @danlehmann in [#9820](https://github.com/gfx-rs/wgpu/pull/9820). @@ -82,6 +86,16 @@ Bottom level categories: - Fixed signed integer `%` (and `%=`) returning the wrong result for negative operands in the GLSL (OpenGL/GLES) backend, e.g. `-1 % 768` yielding `255` instead of `-1`. GLSL's `%` is undefined when either operand is negative, so signed remainder is now lowered as `a - b * (a / b)`, matching the SPIR-V, HLSL, and Metal backends. By @mstampfli in [#9687](https://github.com/gfx-rs/wgpu/pull/9687). +### Dependency Updates + +#### General + +- Raise the minimum version of the `wasm-bindgen` family to the earliest releases that support wasm64. By @nickbabcock in [#9836](https://github.com/gfx-rs/wgpu/pull/9836). + +#### GLES + +- Update `glow` to 0.18 for wasm64 support. By @nickbabcock in [#9836](https://github.com/gfx-rs/wgpu/pull/9836). + ## v30.0.0 (2026-07-01) ### Major changes diff --git a/Cargo.lock b/Cargo.lock index 3d874e74a..1db853f8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1624,9 +1624,9 @@ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "glow" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" +checksum = "263218b0ba2b0715c3370fb04674f5f8aa331594b521c94ff0a8e4a8472d1386" dependencies = [ "js-sys", "slotmap", diff --git a/Cargo.toml b/Cargo.toml index 8067695c9..2ec57705a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -294,7 +294,7 @@ gpu-allocator = { version = "0.28", default-features = false, features = [ # Gles dependencies khronos-egl = "6" -glow = "0.17" +glow = "0.18" glutin = { version = "0.32", default-features = false } glutin-winit = { version = "0.5", default-features = false } glutin_wgl_sys = "0.6" @@ -302,13 +302,13 @@ glutin_wgl_sys = "0.6" # DX12 and GLES dependencies windows = { version = "0.62", default-features = false } -# wasm32 dependencies +# wasm dependencies console_error_panic_hook = "0.1.5" console_log = "1" -js-sys = { version = "0.3.85", default-features = false } -wasm-bindgen = { version = "0.2.108", default-features = false } -wasm-bindgen-futures = { version = "0.4.58", default-features = false } -web-sys = { version = "0.3.85", default-features = false } +js-sys = { version = "0.3.100", default-features = false } +wasm-bindgen = { version = "0.2.123", default-features = false } +wasm-bindgen-futures = { version = "0.4.73", default-features = false } +web-sys = { version = "0.3.100", default-features = false } web-time = "1.1.0" # deno dependencies diff --git a/examples/standalone/03_hdr_surface/Cargo.toml b/examples/standalone/03_hdr_surface/Cargo.toml index f54a59ffb..108ec0cbf 100644 --- a/examples/standalone/03_hdr_surface/Cargo.toml +++ b/examples/standalone/03_hdr_surface/Cargo.toml @@ -24,9 +24,9 @@ block2 = "0.6.2" [target.'cfg(target_arch = "wasm32")'.dependencies] console_error_panic_hook = "0.1.5" -wasm-bindgen = "0.2.108" -wasm-bindgen-futures = "0.4.58" -web-sys = { version = "0.3.85", features = [ +wasm-bindgen = "0.2.123" +wasm-bindgen-futures = "0.4.73" +web-sys = { version = "0.3.100", features = [ "console", "Document", "Element", diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index a0db72109..59785aff4 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -172,7 +172,7 @@ wgpu-core-deps-apple = { workspace = true, optional = true } [target.'cfg(target_os = "emscripten")'.dependencies] wgpu-core-deps-emscripten = { workspace = true, optional = true } -[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] +[target.'cfg(all(target_family = "wasm", not(target_os = "emscripten")))'.dependencies] wgpu-core-deps-wasm = { workspace = true, optional = true } [target.'cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))'.dependencies] diff --git a/wgpu-core/build.rs b/wgpu-core/build.rs index efea44182..849afb835 100644 --- a/wgpu-core/build.rs +++ b/wgpu-core/build.rs @@ -4,12 +4,12 @@ fn main() { send_sync: { all( feature = "std", any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all(feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics")) ) ) }, dx12: { all(target_os = "windows", feature = "dx12") }, - webgl: { all(target_arch = "wasm32", not(target_os = "emscripten"), feature = "webgl") }, + webgl: { all(target_family = "wasm", not(target_os = "emscripten"), feature = "webgl") }, gles: { any( all(windows_linux_android, feature = "gles"), // Regular GLES all(webgl), // WebGL diff --git a/wgpu-core/platform-deps/wasm/Cargo.toml b/wgpu-core/platform-deps/wasm/Cargo.toml index a5b52d0b8..861177e0f 100644 --- a/wgpu-core/platform-deps/wasm/Cargo.toml +++ b/wgpu-core/platform-deps/wasm/Cargo.toml @@ -19,7 +19,7 @@ rust-version = "1.76" webgl = ["wgpu-hal/gles"] # Depend on wgpu-hal conditionally, so that the above features only apply to wgpu-hal on this set of platforms. -[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] +[target.'cfg(all(target_family = "wasm", not(target_os = "emscripten")))'.dependencies] wgpu-hal.workspace = true [lints] diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 9b21ced1e..88998f0ec 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -5938,7 +5938,7 @@ impl Device { Ok(wgt::PollStatus::Poll) => { unreachable!("Cannot get a Poll result from a Wait action.") } - Err(WaitIdleError::Timeout) if cfg!(target_arch = "wasm32") => { + Err(WaitIdleError::Timeout) if cfg!(target_family = "wasm") => { // On wasm, you cannot actually successfully wait for the surface. // However WebGL does not actually require you do this, so ignoring // the failure is totally fine. See diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index ca49aa2ee..0043fa3f1 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -12,7 +12,7 @@ // When we have no backends, we end up with a lot of dead or otherwise unreachable code. #![cfg_attr( all( - not(all(feature = "vulkan", not(target_arch = "wasm32"))), + not(all(feature = "vulkan", not(target_family = "wasm"))), not(all(feature = "metal", any(target_vendor = "apple"))), not(all(feature = "dx12", windows)), not(feature = "gles"), diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index f04e4cb40..e538b12cb 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -234,7 +234,7 @@ glow = { workspace = true, optional = true } ### Platform: Native ### ######################## -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +[target.'cfg(not(target_family = "wasm"))'.dependencies] # Backend: Vulkan and Dx12 gpu-allocator = { workspace = true, optional = true } # Backend: Vulkan @@ -317,7 +317,7 @@ ndk-sys = { workspace = true, optional = true } ### Platform: Webassembly ### ############################# -[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] +[target.'cfg(all(target_family = "wasm", not(target_os = "emscripten")))'.dependencies] # Backend: GLES wasm-bindgen = { workspace = true, optional = true } web-sys = { workspace = true, optional = true, features = [ @@ -361,6 +361,6 @@ naga = { workspace = true, features = ["wgsl-in", "termcolor"] } winit.workspace = true # for "halmark" example ### Platform: Windows + MacOS + Linux for "raw-gles" example ### -[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos", target_env = "ohos")))'.dev-dependencies] +[target.'cfg(not(any(target_family = "wasm", target_os = "ios", target_os = "visionos", target_env = "ohos")))'.dev-dependencies] glutin-winit = { workspace = true, features = ["egl", "wgl", "wayland", "x11"] } glutin = { workspace = true, features = ["egl", "wgl", "wayland", "x11"] } diff --git a/wgpu-hal/build.rs b/wgpu-hal/build.rs index 7430ccba2..dc441284c 100644 --- a/wgpu-hal/build.rs +++ b/wgpu-hal/build.rs @@ -1,11 +1,11 @@ fn main() { cfg_aliases::cfg_aliases! { - native: { not(target_arch = "wasm32") }, + native: { not(target_family = "wasm") }, send_sync: { any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all(feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics")) ) }, - webgl: { all(target_arch = "wasm32", not(target_os = "emscripten"), gles) }, + webgl: { all(target_family = "wasm", not(target_os = "emscripten"), gles) }, Emscripten: { all(target_os = "emscripten", gles) }, dx12: { all(target_os = "windows", feature = "dx12") }, gles: { all(feature = "gles") }, @@ -14,7 +14,7 @@ fn main() { gles_with_std: { all( feature = "gles", any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), // Accept wasm32-unknown-unknown, which uniquely has a stub `std` all(target_vendor = "unknown", target_os = "unknown"), // Accept wasm32-unknown-emscripten and similar, which has a real `std` @@ -22,7 +22,7 @@ fn main() { ) ) }, metal: { all(target_vendor = "apple", feature = "metal") }, - vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") }, + vulkan: { all(not(target_family = "wasm"), feature = "vulkan") }, drm: { all( feature = "drm", any(target_os = "linux", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd") diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 47b8115a8..2b5f3f58f 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -941,7 +941,7 @@ impl super::Adapter { // Drop the GL guard so we can move the context into AdapterShared // ( on Wasm the gl handle is just a ref so we tell clippy to allow // dropping the ref ) - #[cfg_attr(target_arch = "wasm32", allow(dropping_references))] + #[cfg_attr(target_family = "wasm", allow(dropping_references))] drop(gl); Some(crate::ExposedAdapter { diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 1c61cf3b7..573558d70 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -246,7 +246,7 @@ impl super::Device { gl: &glow::Context, shader: &str, naga_stage: naga::ShaderStage, - #[cfg_attr(target_arch = "wasm32", allow(unused))] label: Option<&str>, + #[cfg_attr(target_family = "wasm", allow(unused))] label: Option<&str>, ) -> Result { let target = match naga_stage { naga::ShaderStage::Vertex => glow::VERTEX_SHADER, @@ -400,7 +400,7 @@ impl super::Device { gl: &glow::Context, shaders: ArrayVec, { crate::MAX_CONCURRENT_SHADER_STAGES }>, layout: &super::PipelineLayout, - #[cfg_attr(target_arch = "wasm32", allow(unused))] label: Option<&str>, + #[cfg_attr(target_family = "wasm", allow(unused))] label: Option<&str>, multiview_mask: Option, ) -> Result, crate::PipelineError> { let mut program_stages = ArrayVec::new(); @@ -462,7 +462,7 @@ impl super::Device { gl: &glow::Context, shaders: ArrayVec, { crate::MAX_CONCURRENT_SHADER_STAGES }>, layout: &super::PipelineLayout, - #[cfg_attr(target_arch = "wasm32", allow(unused))] label: Option<&str>, + #[cfg_attr(target_family = "wasm", allow(unused))] label: Option<&str>, multiview_mask: Option, glsl_version: naga::back::glsl::Version, private_caps: PrivateCapabilities, @@ -1680,7 +1680,7 @@ impl crate::Device for super::Device { } unsafe fn destroy_pipeline_cache(&self, _: super::PipelineCache) {} - #[cfg_attr(target_arch = "wasm32", allow(unused))] + #[cfg_attr(target_family = "wasm", allow(unused))] unsafe fn create_query_set( &self, desc: &wgt::QuerySetDescriptor, @@ -1736,7 +1736,7 @@ impl crate::Device for super::Device { &self, fence: &super::Fence, ) -> Result { - #[cfg_attr(target_arch = "wasm32", allow(clippy::needless_borrow))] + #[cfg_attr(target_family = "wasm", allow(clippy::needless_borrow))] Ok(fence.get_latest(&self.shared.context.lock())) } unsafe fn wait( diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 9984cd555..70a2f8848 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -193,7 +193,7 @@ impl super::Queue { &self, gl: &glow::Context, command: &C, - #[cfg_attr(target_arch = "wasm32", allow(unused))] data_bytes: &[u8], + #[cfg_attr(target_family = "wasm", allow(unused))] data_bytes: &[u8], queries: &[glow::Query], ) { match *command { diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 487a15cac..7a4d65f10 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -68,7 +68,7 @@ serde = { workspace = true, default-features = false, features = [ ], optional = true } static_assertions.workspace = true -[target.'cfg(target_arch = "wasm32")'.dependencies] +[target.'cfg(target_family = "wasm")'.dependencies] js-sys = { workspace = true, optional = true, default-features = false } web-sys = { workspace = true, optional = true, default-features = false, features = [ "ImageBitmap", diff --git a/wgpu-types/src/send_sync.rs b/wgpu-types/src/send_sync.rs index 2f35207ce..feb0d8a84 100644 --- a/wgpu-types/src/send_sync.rs +++ b/wgpu-types/src/send_sync.rs @@ -1,7 +1,7 @@ pub trait WasmNotSendSync: WasmNotSend + WasmNotSync {} impl WasmNotSendSync for T {} #[cfg(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") @@ -9,7 +9,7 @@ impl WasmNotSendSync for T {} ))] pub trait WasmNotSend: Send {} #[cfg(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") @@ -17,7 +17,7 @@ pub trait WasmNotSend: Send {} ))] impl WasmNotSend for T {} #[cfg(not(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") @@ -25,7 +25,7 @@ impl WasmNotSend for T {} )))] pub trait WasmNotSend {} #[cfg(not(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") @@ -34,7 +34,7 @@ pub trait WasmNotSend {} impl WasmNotSend for T {} #[cfg(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") @@ -42,7 +42,7 @@ impl WasmNotSend for T {} ))] pub trait WasmNotSync: Sync {} #[cfg(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") @@ -50,7 +50,7 @@ pub trait WasmNotSync: Sync {} ))] impl WasmNotSync for T {} #[cfg(not(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") @@ -58,7 +58,7 @@ impl WasmNotSync for T {} )))] pub trait WasmNotSync {} #[cfg(not(any( - not(target_arch = "wasm32"), + not(target_family = "wasm"), all( feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") diff --git a/wgpu-types/src/texture/external_image.rs b/wgpu-types/src/texture/external_image.rs index bc786d325..58e21ed14 100644 --- a/wgpu-types/src/texture/external_image.rs +++ b/wgpu-types/src/texture/external_image.rs @@ -5,7 +5,7 @@ use crate::{DownlevelFlags, Origin2d}; /// /// Corresponds to [WebGPU `GPUCopyExternalImageSourceInfo`]( /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopyexternalimage). -#[cfg(all(target_arch = "wasm32", feature = "web"))] +#[cfg(all(target_family = "wasm", feature = "web"))] #[derive(Clone, Debug)] pub struct CopyExternalImageSourceInfo { /// The texture to be copied from. The copy source data is captured at the moment @@ -28,7 +28,7 @@ pub struct CopyExternalImageSourceInfo { /// /// Corresponds to the [implicit union type on WebGPU `GPUCopyExternalImageSourceInfo.source`]( /// https://gpuweb.github.io/gpuweb/#dom-gpuimagecopyexternalimage-source). -#[cfg(all(target_arch = "wasm32", feature = "web"))] +#[cfg(all(target_family = "wasm", feature = "web"))] #[derive(Clone, Debug)] pub enum ExternalImageSource { /// Copy from a previously-decoded image bitmap. @@ -49,7 +49,7 @@ pub enum ExternalImageSource { VideoFrame(web_sys::VideoFrame), } -#[cfg(all(target_arch = "wasm32", feature = "web"))] +#[cfg(all(target_family = "wasm", feature = "web"))] impl ExternalImageSource { /// Gets the pixel, not css, width of the source. pub fn width(&self) -> u32 { @@ -78,7 +78,7 @@ impl ExternalImageSource { } } -#[cfg(all(target_arch = "wasm32", feature = "web"))] +#[cfg(all(target_family = "wasm", feature = "web"))] impl core::ops::Deref for ExternalImageSource { type Target = js_sys::Object; @@ -96,14 +96,14 @@ impl core::ops::Deref for ExternalImageSource { } #[cfg(all( - target_arch = "wasm32", + target_family = "wasm", feature = "web", feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") ))] unsafe impl Send for ExternalImageSource {} #[cfg(all( - target_arch = "wasm32", + target_family = "wasm", feature = "web", feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics") diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 530777c3c..2eaf54d94 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -229,7 +229,7 @@ static_assertions.workspace = true ################### # Not Webassembly # ################### -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +[target.'cfg(not(target_family = "wasm"))'.dependencies] # Needed for only wgpu-core backend. Not optional as only wgpu-core backend exists on native platforms. wgpu-core = { workspace = true, features = [ "renderdoc", @@ -243,7 +243,7 @@ smallvec.workspace = true ############### # Webassembly # ############### -[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] +[target.'cfg(all(target_family = "wasm", not(target_os = "emscripten")))'.dependencies] # Needed for all backends js-sys = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } diff --git a/wgpu/build.rs b/wgpu/build.rs index 191566520..7490e49e7 100644 --- a/wgpu/build.rs +++ b/wgpu/build.rs @@ -1,8 +1,8 @@ fn main() { cfg_aliases::cfg_aliases! { - native: { not(target_arch = "wasm32") }, - Emscripten: { all(target_arch = "wasm32", target_os = "emscripten") }, - web: { all(target_arch = "wasm32", not(Emscripten), feature = "web") }, + native: { not(target_family = "wasm") }, + Emscripten: { all(target_family = "wasm", target_os = "emscripten") }, + web: { all(target_family = "wasm", not(Emscripten), feature = "web") }, send_sync: { any( native,