From 866202899796f7c342da4245f3e946f7a3bdebd7 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Wed, 14 Aug 2024 10:25:16 +0100 Subject: [PATCH 01/10] =?UTF-8?q?WIP:=20build:=20update=20Rust=201.76=20?= =?UTF-8?q?=E2=86=92=201.78?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 45bb8d6d51..55cd54c76b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.76" +channel = "1.78" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] From cdfa879125853d8d36bce1849d914aee3681a10d Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Wed, 24 Jul 2024 11:00:13 -0400 Subject: [PATCH 02/10] chore: warn on `clippy::ref_as_ptr` --- wgpu-core/src/lib.rs | 1 + wgpu-hal/src/lib.rs | 1 + wgpu-types/src/lib.rs | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index b87b2cd638..f451dff814 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -42,6 +42,7 @@ )] #![warn( clippy::ptr_as_ptr, + clippy::ref_as_ptr, trivial_casts, trivial_numeric_casts, unsafe_op_in_unsafe_fn, diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 0cddb69976..5a513f1876 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -227,6 +227,7 @@ )] #![warn( clippy::ptr_as_ptr, + clippy::ref_as_ptr, trivial_casts, trivial_numeric_casts, unsafe_op_in_unsafe_fn, diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 89abd63b51..ad389266a5 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -6,7 +6,12 @@ // We don't use syntax sugar where it's not necessary. clippy::match_like_matches_macro, )] -#![warn(clippy::ptr_as_ptr, missing_docs, unsafe_op_in_unsafe_fn)] +#![warn( + clippy::ptr_as_ptr, + clippy::ref_as_ptr, + missing_docs, + unsafe_op_in_unsafe_fn +)] #[cfg(any(feature = "serde", test))] use serde::Deserialize; From 26ed3689e719b5406444dfb845e811d96965143d Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 12 Aug 2024 13:08:10 +0100 Subject: [PATCH 03/10] =?UTF-8?q?build(ci):=20update=20`nightly`=202024-01?= =?UTF-8?q?-31=20=E2=86=92=202024-08-11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46e8443ee5..df9ab38305 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ env: # We sometimes need nightly to use special things in CI. # # In order to prevent CI regressions, we pin the nightly version. - NIGHTLY_VERSION: "nightly-2023-12-17" + NIGHTLY_VERSION: "nightly-2024-08-11" # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. REPO_MSRV: "1.76" # This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates, From fba3bdec2cc93fb370e92b8c92793d94d8978632 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 12 Aug 2024 13:05:16 +0100 Subject: [PATCH 04/10] =?UTF-8?q?build:=20upgrade=20`rust-version`=20for?= =?UTF-8?q?=20Firefox=20crates=201.77.2=20=E2=86=92=201.80.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 2 +- naga/Cargo.toml | 2 +- rust-toolchain.toml | 2 +- wgpu-core/Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 2 +- wgpu-types/Cargo.toml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df9ab38305..1999eeca44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,10 +36,10 @@ env: # In order to prevent CI regressions, we pin the nightly version. NIGHTLY_VERSION: "nightly-2024-08-11" # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.76" + REPO_MSRV: "1.80.1" # This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates, # to ensure that they can be used with firefox. - CORE_MSRV: "1.76" + CORE_MSRV: "1.80.1" # # Environment variables diff --git a/Cargo.toml b/Cargo.toml index 024502ba0c..a317ae0495 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ default-members = [ [workspace.package] edition = "2021" -rust-version = "1.76" +rust-version = "1.80.1" keywords = ["graphics"] license = "MIT OR Apache-2.0" homepage = "https://wgpu.rs/" diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 0d54c964cc..0828023e93 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -15,7 +15,7 @@ autotests = false # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.76" +rust-version = "1.80.0" [[test]] name = "naga-test" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 55cd54c76b..a561eb92f0 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.78" +channel = "1.80.1" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 5906aeb339..cef08b13e5 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.76" +rust-version = "1.80.0" [package.metadata.docs.rs] all-features = true diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 35e85f45da..b67659fef0 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.76" +rust-version = "1.80.0" [package.metadata.docs.rs] # Ideally we would enable all the features. diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index e79ae330e5..5fc5504e65 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.76" +rust-version = "1.80.0" [package.metadata.docs.rs] all-features = true From 2fe43bd17513c9f98fd44964632ecbd56933a82f Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 12 Aug 2024 11:06:30 +0100 Subject: [PATCH 05/10] =?UTF-8?q?build:=20upgrade=20`cfg=5Faliases`=200.1.?= =?UTF-8?q?1=20=E2=86=92=200.2.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consumes [`cfg_aliases`#8](https://github.com/katharostech/cfg_aliases/pull/8) to eliminate warnings from `rustc`. --- Cargo.lock | 20 +++++++++++++------- Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59c7e19875..eebad20cfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -461,6 +461,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "cgl" version = "0.3.2" @@ -1325,7 +1331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18fcd4ae4e86d991ad1300b8f57166e5be0c95ef1f63f3f5b827f8a164548746" dependencies = [ "bitflags 2.6.0", - "cfg_aliases", + "cfg_aliases 0.1.1", "cgl", "core-foundation", "dispatch", @@ -1347,7 +1353,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebcdfba24f73b8412c5181e56f092b5eff16671c514ce896b258a0a64bd7735" dependencies = [ - "cfg_aliases", + "cfg_aliases 0.1.1", "glutin", "raw-window-handle 0.5.2", "winit", @@ -1881,7 +1887,7 @@ dependencies = [ "arrayvec", "bit-set", "bitflags 2.6.0", - "cfg_aliases", + "cfg_aliases 0.2.1", "codespan-reporting", "diff", "env_logger", @@ -3568,7 +3574,7 @@ name = "wgpu" version = "23.0.0" dependencies = [ "arrayvec", - "cfg_aliases", + "cfg_aliases 0.2.1", "document-features", "js-sys", "log", @@ -3612,7 +3618,7 @@ dependencies = [ "bit-vec", "bitflags 2.6.0", "bytemuck", - "cfg_aliases", + "cfg_aliases 0.2.1", "document-features", "indexmap", "log", @@ -3673,7 +3679,7 @@ dependencies = [ "block", "bytemuck", "cfg-if", - "cfg_aliases", + "cfg_aliases 0.2.1", "core-graphics-types", "env_logger", "glam", @@ -4113,7 +4119,7 @@ dependencies = [ "bitflags 2.6.0", "bytemuck", "calloop", - "cfg_aliases", + "cfg_aliases 0.1.1", "core-foundation", "core-graphics", "cursor-icon", diff --git a/Cargo.toml b/Cargo.toml index a317ae0495..de8fb3a5f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,7 @@ bincode = "1" bit-vec = "0.8" bitflags = "2.6" bytemuck = { version = "1.19" } -cfg_aliases = "0.1" +cfg_aliases = "0.2.1" cfg-if = "1" criterion = "0.5" codespan-reporting = "0.11" From 1b33ee20cf049e16b54757c9e68bb69884fd17dd Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 12 Aug 2024 11:56:01 +0100 Subject: [PATCH 06/10] chore(core): allow `wgpu_*` `cfg` keys not exposed in `features` This resolves remaining outstanding cases that offend [`--check-cfg` in Rust 1.80](https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html#checked-cfg-names-and-values) in `wgpu-core`. --- wgpu-core/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wgpu-core/build.rs b/wgpu-core/build.rs index 2f715fdb2a..1dfa8f035e 100644 --- a/wgpu-core/build.rs +++ b/wgpu-core/build.rs @@ -10,4 +10,6 @@ fn main() { metal: { all(any(target_os = "ios", target_os = "macos"), feature = "metal") }, vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") } } + println!("cargo::rustc-check-cfg=cfg(wgpu_core_doc)"); + println!("cargo::rustc-check-cfg=cfg(wgpu_validate_locks)"); } From 161222d41ea894b9c4926265a24d0ac79d3740a3 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 5 Sep 2024 08:43:47 -0400 Subject: [PATCH 07/10] chore: add `web_sys_unstable_apis` to `lints.rust.unexpected_cfgs.check-cfg` in `wgpu_{hal,types}` --- wgpu-hal/Cargo.toml | 3 +++ wgpu-types/Cargo.toml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index b67659fef0..bf9e3ee2a9 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -106,6 +106,9 @@ device_lost_panic = [] # Only affects the d3d12 and vulkan backends. internal_error_panic = [] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(web_sys_unstable_apis)'] } + [[example]] name = "halmark" diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 5fc5504e65..b7a65b4c09 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -34,6 +34,9 @@ serde = ["dep:serde"] # Enables some internal instrumentation for debugging purposes. counters = [] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(web_sys_unstable_apis)'] } + [dependencies] bitflags.workspace = true serde = { workspace = true, features = ["derive"], optional = true } From a5a787ea42fbe142a8d79256e250e46526a7b4cb Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Wed, 4 Sep 2024 18:35:25 -0400 Subject: [PATCH 08/10] chore(benches): add `tracy` to `lints.rust.unexpected_cfgs.check-cfg` --- benches/Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 82207d5105..ba47bc1b6a 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -21,6 +21,11 @@ path = "benches/root.rs" # tracy = ["dep:tracy-client", "profiling/profile-with-tracy"] # superluminal = ["profiling/profile-with-superluminal"] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(feature, values("tracy"))', +] } + [dependencies] bincode.workspace = true bytemuck.workspace = true From 66cd7cf0ff05cbda94a4d6c111f2fa2c883c64bd Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 12 Aug 2024 11:43:07 +0100 Subject: [PATCH 09/10] chore: remove `std::mem::*` imports now unnecessary with Rust 1.80 `std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust 1.80; see [`rust`#123168](https://github.com/rust-lang/rust/pull/123168/). --- examples/src/boids/mod.rs | 1 - examples/src/bunnymark/mod.rs | 2 +- examples/src/cube/mod.rs | 2 +- examples/src/hello_compute/mod.rs | 2 +- examples/src/hello_synchronization/mod.rs | 2 -- examples/src/hello_workgroups/mod.rs | 2 -- examples/src/mipmap/mod.rs | 2 +- examples/src/msaa_line/mod.rs | 2 +- examples/src/repeated_compute/mod.rs | 2 -- examples/src/shadow/mod.rs | 2 +- examples/src/skybox/mod.rs | 2 +- examples/src/srgb_blend/mod.rs | 1 - examples/src/stencil_triangles/mod.rs | 1 - examples/src/storage_texture/mod.rs | 2 -- examples/src/texture_arrays/mod.rs | 5 +---- examples/src/timestamp_queries/mod.rs | 2 -- examples/src/uniform_values/mod.rs | 2 +- examples/src/water/mod.rs | 2 +- naga/src/back/msl/mod.rs | 1 - naga/src/front/wgsl/error.rs | 3 --- naga/src/non_max_u32.rs | 1 - naga/src/proc/typifier.rs | 1 - player/tests/test.rs | 1 - tests/tests/compute_pass_ownership.rs | 2 +- tests/tests/occlusion_query/mod.rs | 1 - tests/tests/render_pass_ownership.rs | 2 +- tests/tests/subgroup_operations/mod.rs | 2 +- tests/tests/vertex_formats/mod.rs | 2 +- tests/tests/vertex_indices/mod.rs | 2 +- wgpu-core/src/command/bundle.rs | 2 +- wgpu-core/src/command/compute.rs | 2 +- wgpu-core/src/command/render.rs | 2 +- wgpu-core/src/id.rs | 1 - wgpu-core/src/indirect_validation.rs | 1 - wgpu-core/src/pipeline_cache.rs | 2 -- wgpu-core/src/registry.rs | 2 +- wgpu-hal/examples/halmark/main.rs | 4 +--- wgpu-hal/examples/ray-traced-triangle/main.rs | 4 +--- wgpu-hal/src/dx12/adapter.rs | 7 +------ wgpu-hal/src/dx12/device.rs | 3 +-- wgpu-hal/src/dx12/instance.rs | 2 +- wgpu-hal/src/gles/command.rs | 5 +---- wgpu-hal/src/gles/queue.rs | 1 - wgpu-hal/src/gles/wgl.rs | 2 +- wgpu-hal/src/metal/command.rs | 2 +- wgpu-hal/src/vulkan/command.rs | 6 +----- wgpu-types/src/lib.rs | 1 - wgpu/src/macros.rs | 2 -- wgpu/src/util/mod.rs | 6 +----- 49 files changed, 29 insertions(+), 82 deletions(-) diff --git a/examples/src/boids/mod.rs b/examples/src/boids/mod.rs index 53e4239f39..6971a3ef18 100644 --- a/examples/src/boids/mod.rs +++ b/examples/src/boids/mod.rs @@ -2,7 +2,6 @@ // adapted from https://github.com/austinEng/webgpu-samples/blob/master/src/examples/computeBoids.ts use nanorand::{Rng, WyRand}; -use std::mem::size_of; use wgpu::util::DeviceExt; // number of boid particles to simulate diff --git a/examples/src/bunnymark/mod.rs b/examples/src/bunnymark/mod.rs index a4ea8f5c6d..9d44cfdd0e 100644 --- a/examples/src/bunnymark/mod.rs +++ b/examples/src/bunnymark/mod.rs @@ -1,6 +1,6 @@ use bytemuck::{Pod, Zeroable}; use nanorand::{Rng, WyRand}; -use std::{borrow::Cow, mem::size_of}; +use std::borrow::Cow; use wgpu::util::DeviceExt; use winit::{ event::{ElementState, KeyEvent}, diff --git a/examples/src/cube/mod.rs b/examples/src/cube/mod.rs index 13e050cdd0..a3d5312487 100644 --- a/examples/src/cube/mod.rs +++ b/examples/src/cube/mod.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{f32::consts, mem::size_of}; +use std::f32::consts; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/hello_compute/mod.rs b/examples/src/hello_compute/mod.rs index 60de01b074..cc9f5aa81f 100644 --- a/examples/src/hello_compute/mod.rs +++ b/examples/src/hello_compute/mod.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of_val, str::FromStr}; +use std::str::FromStr; use wgpu::util::DeviceExt; // Indicates a u32 overflow in an intermediate Collatz value diff --git a/examples/src/hello_synchronization/mod.rs b/examples/src/hello_synchronization/mod.rs index 128609bb97..fee20eeafa 100644 --- a/examples/src/hello_synchronization/mod.rs +++ b/examples/src/hello_synchronization/mod.rs @@ -1,5 +1,3 @@ -use std::mem::size_of_val; - const ARR_SIZE: usize = 128; struct ExecuteResults { diff --git a/examples/src/hello_workgroups/mod.rs b/examples/src/hello_workgroups/mod.rs index 26b6cccfe5..13535f79c7 100644 --- a/examples/src/hello_workgroups/mod.rs +++ b/examples/src/hello_workgroups/mod.rs @@ -7,8 +7,6 @@ //! //! Only parts specific to this example will be commented. -use std::mem::size_of_val; - use wgpu::util::DeviceExt; async fn run() { diff --git a/examples/src/mipmap/mod.rs b/examples/src/mipmap/mod.rs index 817a6d6259..c56872661d 100644 --- a/examples/src/mipmap/mod.rs +++ b/examples/src/mipmap/mod.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{f32::consts, mem::size_of}; +use std::f32::consts; use wgpu::util::DeviceExt; const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb; diff --git a/examples/src/msaa_line/mod.rs b/examples/src/msaa_line/mod.rs index 1f49b90f4a..d2cbe62018 100644 --- a/examples/src/msaa_line/mod.rs +++ b/examples/src/msaa_line/mod.rs @@ -7,7 +7,7 @@ //! * Set the primitive_topology to PrimitiveTopology::LineList. //! * Vertices and Indices describe the two points that make up a line. -use std::{iter, mem::size_of}; +use std::iter; use bytemuck::{Pod, Zeroable}; use wgpu::util::DeviceExt; diff --git a/examples/src/repeated_compute/mod.rs b/examples/src/repeated_compute/mod.rs index a84ab4ed67..d5b29c7baa 100644 --- a/examples/src/repeated_compute/mod.rs +++ b/examples/src/repeated_compute/mod.rs @@ -5,8 +5,6 @@ //! hello-compute example does not such as mapping buffers //! and why use the async channels. -use std::mem::size_of_val; - const OVERFLOW: u32 = 0xffffffff; async fn run() { diff --git a/examples/src/shadow/mod.rs b/examples/src/shadow/mod.rs index 44ad84a73f..109fae8a76 100644 --- a/examples/src/shadow/mod.rs +++ b/examples/src/shadow/mod.rs @@ -1,4 +1,4 @@ -use std::{f32::consts, iter, mem::size_of, ops::Range, sync::Arc}; +use std::{f32::consts, iter, ops::Range, sync::Arc}; use bytemuck::{Pod, Zeroable}; use wgpu::util::{align_to, DeviceExt}; diff --git a/examples/src/skybox/mod.rs b/examples/src/skybox/mod.rs index 095a1e9fbb..b772935cdd 100644 --- a/examples/src/skybox/mod.rs +++ b/examples/src/skybox/mod.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{f32::consts, mem::size_of}; +use std::f32::consts; use wgpu::{util::DeviceExt, AstcBlock, AstcChannel}; const IMAGE_SIZE: u32 = 256; diff --git a/examples/src/srgb_blend/mod.rs b/examples/src/srgb_blend/mod.rs index ac0343f690..d56cea7bce 100644 --- a/examples/src/srgb_blend/mod.rs +++ b/examples/src/srgb_blend/mod.rs @@ -1,5 +1,4 @@ use bytemuck::{Pod, Zeroable}; -use std::mem::size_of; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/stencil_triangles/mod.rs b/examples/src/stencil_triangles/mod.rs index fcd37f813e..761a9ef602 100644 --- a/examples/src/stencil_triangles/mod.rs +++ b/examples/src/stencil_triangles/mod.rs @@ -1,5 +1,4 @@ use bytemuck::{Pod, Zeroable}; -use std::mem::size_of; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/storage_texture/mod.rs b/examples/src/storage_texture/mod.rs index 56c8b2a643..40dd58f3f7 100644 --- a/examples/src/storage_texture/mod.rs +++ b/examples/src/storage_texture/mod.rs @@ -14,8 +14,6 @@ //! A lot of things aren't explained here via comments. See hello-compute and //! repeated-compute for code that is more thoroughly commented. -use std::mem::size_of_val; - #[cfg(not(target_arch = "wasm32"))] use crate::utils::output_image_native; #[cfg(target_arch = "wasm32")] diff --git a/examples/src/texture_arrays/mod.rs b/examples/src/texture_arrays/mod.rs index 00b90603fd..fe86bae557 100644 --- a/examples/src/texture_arrays/mod.rs +++ b/examples/src/texture_arrays/mod.rs @@ -1,8 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{ - mem::size_of, - num::{NonZeroU32, NonZeroU64}, -}; +use std::num::{NonZeroU32, NonZeroU64}; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/timestamp_queries/mod.rs b/examples/src/timestamp_queries/mod.rs index 69f5c57dd6..9ed80a8b93 100644 --- a/examples/src/timestamp_queries/mod.rs +++ b/examples/src/timestamp_queries/mod.rs @@ -17,8 +17,6 @@ //! The period, i.e. the unit of time, of the timestamps in wgpu is undetermined and needs to be queried with `wgpu::Queue::get_timestamp_period` //! in order to get comparable results. -use std::mem::size_of; - use wgpu::util::DeviceExt; struct Queries { diff --git a/examples/src/uniform_values/mod.rs b/examples/src/uniform_values/mod.rs index a5c1e14c54..e58e18a2b5 100644 --- a/examples/src/uniform_values/mod.rs +++ b/examples/src/uniform_values/mod.rs @@ -16,7 +16,7 @@ //! The usage of the uniform buffer within the shader itself is pretty self-explanatory given //! some understanding of WGSL. -use std::{mem::size_of, sync::Arc}; +use std::sync::Arc; // We won't bring StorageBuffer into scope as that might be too easy to confuse // with actual GPU-allocated WGPU storage buffers. use encase::ShaderType; diff --git a/examples/src/water/mod.rs b/examples/src/water/mod.rs index a60dc0279e..7e2980f43c 100644 --- a/examples/src/water/mod.rs +++ b/examples/src/water/mod.rs @@ -3,7 +3,7 @@ mod point_gen; use bytemuck::{Pod, Zeroable}; use glam::Vec3; use nanorand::{Rng, WyRand}; -use std::{f32::consts, iter, mem::size_of}; +use std::{f32::consts, iter}; use wgpu::util::DeviceExt; /// diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index fbeaa4cc8d..c2d0ae7495 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -668,6 +668,5 @@ pub fn write_string( #[test] fn test_error_size() { - use std::mem::size_of; assert_eq!(size_of::(), 32); } diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index f5e6332085..9aaae0c5aa 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -17,9 +17,6 @@ use std::ops::Range; use termcolor::{ColorChoice, NoColor, StandardStream}; use thiserror::Error; -#[cfg(test)] -use std::mem::size_of; - #[derive(Clone, Debug)] pub struct ParseError { message: String, diff --git a/naga/src/non_max_u32.rs b/naga/src/non_max_u32.rs index 2ad402e497..7cb641b4e9 100644 --- a/naga/src/non_max_u32.rs +++ b/naga/src/non_max_u32.rs @@ -140,6 +140,5 @@ impl<'de> serde::Deserialize<'de> for NonMaxU32 { #[test] fn size() { - use core::mem::size_of; assert_eq!(size_of::>(), size_of::()); } diff --git a/naga/src/proc/typifier.rs b/naga/src/proc/typifier.rs index a94546fbce..e13e9381f6 100644 --- a/naga/src/proc/typifier.rs +++ b/naga/src/proc/typifier.rs @@ -917,6 +917,5 @@ impl<'a> ResolveContext<'a> { #[test] fn test_error_size() { - use std::mem::size_of; assert_eq!(size_of::(), 32); } diff --git a/player/tests/test.rs b/player/tests/test.rs index 107481b742..74dbd16d7b 100644 --- a/player/tests/test.rs +++ b/player/tests/test.rs @@ -14,7 +14,6 @@ use player::GlobalPlay; use std::{ fs::{read_to_string, File}, io::{Read, Seek, SeekFrom}, - mem::size_of, path::{Path, PathBuf}, slice, }; diff --git a/tests/tests/compute_pass_ownership.rs b/tests/tests/compute_pass_ownership.rs index df50f51e05..c05185828e 100644 --- a/tests/tests/compute_pass_ownership.rs +++ b/tests/tests/compute_pass_ownership.rs @@ -1,7 +1,7 @@ //! Tests that compute passes take ownership of resources that are associated with. //! I.e. once a resource is passed in to a compute pass, it can be dropped. -use std::{mem::size_of, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu::util::DeviceExt as _; use wgpu_test::{gpu_test, valid, GpuTestConfiguration, TestParameters, TestingContext}; diff --git a/tests/tests/occlusion_query/mod.rs b/tests/tests/occlusion_query/mod.rs index 2cedab0299..98c50095ae 100644 --- a/tests/tests/occlusion_query/mod.rs +++ b/tests/tests/occlusion_query/mod.rs @@ -1,4 +1,3 @@ -use std::mem::size_of; use wgpu_test::{gpu_test, FailureCase, GpuTestConfiguration, TestParameters}; #[gpu_test] diff --git a/tests/tests/render_pass_ownership.rs b/tests/tests/render_pass_ownership.rs index 7c41c85916..cdbd1f45ff 100644 --- a/tests/tests/render_pass_ownership.rs +++ b/tests/tests/render_pass_ownership.rs @@ -9,7 +9,7 @@ //! * rpass.multi_draw_indirect_count //! * rpass.multi_draw_indexed_indirect_count //! -use std::{mem::size_of, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu::util::DeviceExt as _; use wgpu_test::{gpu_test, valid, GpuTestConfiguration, TestParameters, TestingContext}; diff --git a/tests/tests/subgroup_operations/mod.rs b/tests/tests/subgroup_operations/mod.rs index 84de70ee5e..25fddf120d 100644 --- a/tests/tests/subgroup_operations/mod.rs +++ b/tests/tests/subgroup_operations/mod.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters}; diff --git a/tests/tests/vertex_formats/mod.rs b/tests/tests/vertex_formats/mod.rs index e956455786..cb6a96826d 100644 --- a/tests/tests/vertex_formats/mod.rs +++ b/tests/tests/vertex_formats/mod.rs @@ -1,6 +1,6 @@ //! Tests that vertex formats pass through to vertex shaders accurately. -use std::{mem::size_of_val, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu::util::{BufferInitDescriptor, DeviceExt}; diff --git a/tests/tests/vertex_indices/mod.rs b/tests/tests/vertex_indices/mod.rs index 300a97eeb8..7dd4779964 100644 --- a/tests/tests/vertex_indices/mod.rs +++ b/tests/tests/vertex_indices/mod.rs @@ -3,7 +3,7 @@ //! We need tests for these as the backends use various schemes to work around the lack //! of support for things like `gl_BaseInstance` in shaders. -use std::{mem::size_of_val, num::NonZeroU64, ops::Range}; +use std::{num::NonZeroU64, ops::Range}; use itertools::Itertools; use strum::IntoEnumIterator; diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index b0d90976dd..be55be7e3f 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -103,7 +103,7 @@ use crate::{ }; use arrayvec::ArrayVec; -use std::{borrow::Cow, mem::size_of, num::NonZeroU32, ops::Range, sync::Arc}; +use std::{borrow::Cow, num::NonZeroU32, ops::Range, sync::Arc}; use thiserror::Error; use super::{ diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 93654c9235..ff6533c99a 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -29,7 +29,7 @@ use thiserror::Error; use wgt::{BufferAddress, DynamicOffset}; use std::sync::Arc; -use std::{fmt, mem::size_of, str}; +use std::{fmt, str}; use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions}; diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 6102d0d492..86eda5bdc2 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -46,7 +46,7 @@ use serde::Deserialize; use serde::Serialize; use std::sync::Arc; -use std::{borrow::Cow, fmt, iter, mem::size_of, num::NonZeroU32, ops::Range, str}; +use std::{borrow::Cow, fmt, iter, num::NonZeroU32, ops::Range, str}; use super::render_command::ArcRenderCommand; use super::{ diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index 4e4897c832..5e723ea7d3 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -4,7 +4,6 @@ use std::{ fmt::{self, Debug}, hash::Hash, marker::PhantomData, - mem::size_of, num::NonZeroU64, }; use wgt::WasmNotSendSync; diff --git a/wgpu-core/src/indirect_validation.rs b/wgpu-core/src/indirect_validation.rs index 35a95f8bbf..3a59dd0ae0 100644 --- a/wgpu-core/src/indirect_validation.rs +++ b/wgpu-core/src/indirect_validation.rs @@ -1,4 +1,3 @@ -use std::mem::size_of; use std::num::NonZeroU64; use thiserror::Error; diff --git a/wgpu-core/src/pipeline_cache.rs b/wgpu-core/src/pipeline_cache.rs index e506d2cd5b..057223fb57 100644 --- a/wgpu-core/src/pipeline_cache.rs +++ b/wgpu-core/src/pipeline_cache.rs @@ -1,5 +1,3 @@ -use std::mem::size_of; - use thiserror::Error; use wgt::AdapterInfo; diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index b3349235e9..aded1a3c72 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of, sync::Arc}; +use std::sync::Arc; use crate::{ id::Id, diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 8ab7f1cb47..8f92f8137b 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -14,9 +14,7 @@ use winit::{ use std::{ borrow::{Borrow, Cow}, - iter, - mem::size_of, - ptr, + iter, ptr, time::Instant, }; diff --git a/wgpu-hal/examples/ray-traced-triangle/main.rs b/wgpu-hal/examples/ray-traced-triangle/main.rs index 4eedfe7817..980add2574 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -8,9 +8,7 @@ use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; use glam::{Affine3A, Mat4, Vec3}; use std::{ borrow::{Borrow, Cow}, - iter, - mem::size_of, - ptr, + iter, ptr, time::Instant, }; use winit::window::WindowButtons; diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 45d69f5584..d464ce91a2 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -1,9 +1,4 @@ -use std::{ - mem::{size_of, size_of_val}, - ptr, - sync::Arc, - thread, -}; +use std::{ptr, sync::Arc, thread}; use parking_lot::Mutex; use windows::{ diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 12edf6179d..564e24d6d7 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -1,6 +1,5 @@ use std::{ - ffi, - mem::{self, size_of, size_of_val}, + ffi, mem, num::NonZeroU32, ptr, sync::Arc, diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 31d0511d39..9d25c2f3f6 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of_val, sync::Arc}; +use std::sync::Arc; use parking_lot::RwLock; use windows::{ diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index 2df3c1a991..7d8ce41375 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -1,9 +1,6 @@ use super::{conv, Command as C}; use arrayvec::ArrayVec; -use std::{ - mem::{self, size_of, size_of_val}, - ops::Range, -}; +use std::{mem, ops::Range}; #[derive(Clone, Copy, Debug, Default)] struct TextureSlotDesc { diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index fc106eb23d..562a1f2a03 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -2,7 +2,6 @@ use super::{conv::is_layered_target, Command as C, PrivateCapabilities}; use arrayvec::ArrayVec; use glow::HasContext; use std::{ - mem::size_of, slice, sync::{atomic::Ordering, Arc}, }; diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index 2d6c91aee0..dfb7bf25db 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -1,7 +1,7 @@ use std::{ collections::HashSet, ffi::{c_void, CStr, CString}, - mem::{self, size_of, size_of_val, ManuallyDrop}, + mem::{self, ManuallyDrop}, os::raw::c_int, ptr, sync::{ diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index f113639a13..2b63e43730 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -1,6 +1,6 @@ use super::{conv, AsNative, TimestampQuerySupport}; use crate::CommandEncoder as _; -use std::{borrow::Cow, mem::size_of, ops::Range}; +use std::{borrow::Cow, ops::Range}; // has to match `Temp::binding_sizes` const WORD_SIZE: usize = 4; diff --git a/wgpu-hal/src/vulkan/command.rs b/wgpu-hal/src/vulkan/command.rs index 6b02e35f4e..5759ad53b0 100644 --- a/wgpu-hal/src/vulkan/command.rs +++ b/wgpu-hal/src/vulkan/command.rs @@ -3,11 +3,7 @@ use super::conv; use arrayvec::ArrayVec; use ash::vk; -use std::{ - mem::{self, size_of}, - ops::Range, - slice, -}; +use std::{mem, ops::Range, slice}; const ALLOCATION_GRANULARITY: u32 = 16; const DST_IMAGE_LAYOUT: vk::ImageLayout = vk::ImageLayout::TRANSFER_DST_OPTIMAL; diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index ad389266a5..b69c57f009 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -18,7 +18,6 @@ use serde::Deserialize; #[cfg(any(feature = "serde", test))] use serde::Serialize; use std::hash::{Hash, Hasher}; -use std::mem::size_of; use std::path::PathBuf; use std::{num::NonZeroU32, ops::Range}; diff --git a/wgpu/src/macros.rs b/wgpu/src/macros.rs index db9548d90c..4acbb30e89 100644 --- a/wgpu/src/macros.rs +++ b/wgpu/src/macros.rs @@ -32,8 +32,6 @@ macro_rules! vertex_attr_array { #[test] fn test_vertex_attr_array() { - use std::mem::size_of; - let attrs = vertex_attr_array![0 => Float32x2, 3 => Uint16x4]; // VertexAttribute does not support PartialEq, so we cannot test directly assert_eq!(attrs.len(), 2); diff --git a/wgpu/src/util/mod.rs b/wgpu/src/util/mod.rs index 11148179b4..339b08dddc 100644 --- a/wgpu/src/util/mod.rs +++ b/wgpu/src/util/mod.rs @@ -9,11 +9,7 @@ mod encoder; mod init; use std::sync::Arc; -use std::{ - borrow::Cow, - mem::{align_of, size_of}, - ptr::copy_nonoverlapping, -}; +use std::{borrow::Cow, ptr::copy_nonoverlapping}; pub use belt::StagingBelt; pub use device::{BufferInitDescriptor, DeviceExt, TextureDataOrder}; From 8d79c857badc99e22ce4a957b1125299da4ad282 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 10 Oct 2024 14:28:42 -0400 Subject: [PATCH 10/10] refactor: s/once_cell::Lazy/std::sync::LazyLock Weaken our dependence on the `once_cell` crate by using functionality from `std` instead that was upstreamed from `once_cell`, this time with what's available in Rust 1.80+. It's not yet possible to eliminate this dependency entirely, but do what we can for now. --- Cargo.lock | 2 -- benches/Cargo.toml | 1 - benches/benches/computepass.rs | 12 ++++++------ benches/benches/renderpass.rs | 12 ++++++------ benches/benches/resource_creation.rs | 6 +++--- wgpu-hal/Cargo.toml | 1 - wgpu-hal/src/gles/egl.rs | 7 ++++--- wgpu-hal/src/gles/wgl.rs | 7 +++---- 8 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eebad20cfe..a4eb6c3d4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3602,7 +3602,6 @@ dependencies = [ "criterion", "naga", "nanorand", - "once_cell", "pollster", "profiling", "rayon", @@ -3699,7 +3698,6 @@ dependencies = [ "naga", "ndk-sys", "objc", - "once_cell", "parking_lot", "profiling", "range-alloc", diff --git a/benches/Cargo.toml b/benches/Cargo.toml index ba47bc1b6a..d3e4966502 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -43,7 +43,6 @@ naga = { workspace = true, features = [ "wgsl-out", ] } nanorand.workspace = true -once_cell.workspace = true pollster.workspace = true profiling.workspace = true rayon.workspace = true diff --git a/benches/benches/computepass.rs b/benches/benches/computepass.rs index 2a5a9d3a04..d6cd107130 100644 --- a/benches/benches/computepass.rs +++ b/benches/benches/computepass.rs @@ -5,8 +5,8 @@ use std::{ use criterion::{criterion_group, Criterion, Throughput}; use nanorand::{Rng, WyRand}; -use once_cell::sync::Lazy; use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::sync::LazyLock; use crate::DeviceState; @@ -424,7 +424,7 @@ impl ComputepassState { } fn run_bench(ctx: &mut Criterion) { - let state = Lazy::new(ComputepassState::new); + let state = LazyLock::new(ComputepassState::new); let dispatch_count = dispatch_count(); let dispatch_count_bindless = dispatch_count_bindless(); @@ -449,7 +449,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{cpasses} computepasses x {dispatch_per_pass} dispatches ({label})"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -498,7 +498,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{threads} threads x {dispatch_per_pass} dispatch"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -538,7 +538,7 @@ fn run_bench(ctx: &mut Criterion) { group.throughput(Throughput::Elements(dispatch_count_bindless as _)); group.bench_function(format!("{dispatch_count_bindless} dispatch"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -579,7 +579,7 @@ fn run_bench(ctx: &mut Criterion) { texture_count + storage_texture_count + storage_buffer_count ), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter(|| state.device_state.queue.submit([])); }, diff --git a/benches/benches/renderpass.rs b/benches/benches/renderpass.rs index f8153df82b..f6c45fd07a 100644 --- a/benches/benches/renderpass.rs +++ b/benches/benches/renderpass.rs @@ -5,8 +5,8 @@ use std::{ use criterion::{criterion_group, Criterion, Throughput}; use nanorand::{Rng, WyRand}; -use once_cell::sync::Lazy; use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::sync::LazyLock; use crate::DeviceState; @@ -427,7 +427,7 @@ impl RenderpassState { } fn run_bench(ctx: &mut Criterion) { - let state = Lazy::new(RenderpassState::new); + let state = LazyLock::new(RenderpassState::new); let draw_count = draw_count(); let vertex_buffer_count = draw_count * VERTEX_BUFFERS_PER_DRAW; @@ -450,7 +450,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{rpasses} renderpasses x {draws_per_pass} draws ({label})"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -502,7 +502,7 @@ fn run_bench(ctx: &mut Criterion) { for threads in [2, 4, 8] { let draws_per_pass = draw_count / threads; group.bench_function(format!("{threads} threads x {draws_per_pass} draws"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -541,7 +541,7 @@ fn run_bench(ctx: &mut Criterion) { group.throughput(Throughput::Elements(draw_count as _)); group.bench_function(format!("{draw_count} draws"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -577,7 +577,7 @@ fn run_bench(ctx: &mut Criterion) { texture_count + vertex_buffer_count ), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter(|| state.device_state.queue.submit([])); }, diff --git a/benches/benches/resource_creation.rs b/benches/benches/resource_creation.rs index da0c79a406..8423192ddc 100644 --- a/benches/benches/resource_creation.rs +++ b/benches/benches/resource_creation.rs @@ -1,13 +1,13 @@ use std::time::{Duration, Instant}; use criterion::{criterion_group, Criterion, Throughput}; -use once_cell::sync::Lazy; use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::sync::LazyLock; use crate::DeviceState; fn run_bench(ctx: &mut Criterion) { - let state = Lazy::new(DeviceState::new); + let state = LazyLock::new(DeviceState::new); const RESOURCES_TO_CREATE: usize = 8; @@ -19,7 +19,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{threads} threads x {resources_per_thread} resource"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index bf9e3ee2a9..82fa6fd40e 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -122,7 +122,6 @@ parking_lot.workspace = true profiling = { workspace = true, default-features = false } raw-window-handle.workspace = true thiserror.workspace = true -once_cell.workspace = true # backends common arrayvec.workspace = true diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 42aec2b253..9fc800cf5c 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -1,9 +1,9 @@ use glow::HasContext; -use once_cell::sync::Lazy; use parking_lot::{MappedMutexGuard, Mutex, MutexGuard, RwLock}; use std::{ - collections::HashMap, ffi, mem::ManuallyDrop, os::raw, ptr, rc::Rc, sync::Arc, time::Duration, + collections::HashMap, ffi, mem::ManuallyDrop, os::raw, ptr, rc::Rc, sync::Arc, sync::LazyLock, + time::Duration, }; /// The amount of time to wait while trying to obtain a lock to the adapter context @@ -466,7 +466,8 @@ struct Inner { // Different calls to `eglGetPlatformDisplay` may return the same `Display`, making it a global // state of all our `EglContext`s. This forces us to track the number of such context to prevent // terminating the display if it's currently used by another `EglContext`. -static DISPLAYS_REFERENCE_COUNT: Lazy>> = Lazy::new(Default::default); +static DISPLAYS_REFERENCE_COUNT: LazyLock>> = + LazyLock::new(Default::default); fn initialize_display( egl: &EglInstance, diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index dfb7bf25db..c94e0727d4 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -6,7 +6,7 @@ use std::{ ptr, sync::{ mpsc::{sync_channel, SyncSender}, - Arc, + Arc, LazyLock, }, thread, time::Duration, @@ -17,7 +17,6 @@ use glutin_wgl_sys::wgl_extra::{ Wgl, CONTEXT_CORE_PROFILE_BIT_ARB, CONTEXT_DEBUG_BIT_ARB, CONTEXT_FLAGS_ARB, CONTEXT_PROFILE_MASK_ARB, }; -use once_cell::sync::Lazy; use parking_lot::{Mutex, MutexGuard, RwLock}; use raw_window_handle::{RawDisplayHandle, RawWindowHandle}; use wgt::InstanceFlags; @@ -319,8 +318,8 @@ fn create_global_window_class() -> Result { } fn get_global_window_class() -> Result { - static GLOBAL: Lazy> = - Lazy::new(create_global_window_class); + static GLOBAL: LazyLock> = + LazyLock::new(create_global_window_class); GLOBAL.clone() }