From 77763b15b35eac186f46ea77443a723d86591295 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Fri, 21 Feb 2025 22:46:18 -0500 Subject: [PATCH] Remove `getrandom` from examples (#7194) --- Cargo.lock | 1 - Cargo.toml | 1 - examples/features/Cargo.toml | 1 - examples/features/src/repeated_compute/mod.rs | 10 +++------- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89fccee596..004351f012 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4595,7 +4595,6 @@ dependencies = [ "env_logger", "fern", "flume", - "getrandom 0.2.15", "glam", "ktx2", "log", diff --git a/Cargo.toml b/Cargo.toml index 61d9c74a3a..a3761ce5da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,6 @@ env_logger = "0.11" fern = "0.7" flume = "0.11" futures-lite = "2" -getrandom = "0.2" glam = "0.29" hashbrown = { version = "0.14.5", default-features = false, features = [ "ahash", diff --git a/examples/features/Cargo.toml b/examples/features/Cargo.toml index 3165f2af27..11cf6b2115 100644 --- a/examples/features/Cargo.toml +++ b/examples/features/Cargo.toml @@ -35,7 +35,6 @@ bytemuck.workspace = true cfg-if.workspace = true encase = { workspace = true, features = ["glam"] } flume.workspace = true -getrandom.workspace = true glam = { workspace = true, features = ["bytemuck"] } ktx2.workspace = true log.workspace = true diff --git a/examples/features/src/repeated_compute/mod.rs b/examples/features/src/repeated_compute/mod.rs index 4f7b37b99f..a31a456e63 100644 --- a/examples/features/src/repeated_compute/mod.rs +++ b/examples/features/src/repeated_compute/mod.rs @@ -5,6 +5,8 @@ //! hello-compute example does not such as mapping buffers //! and why use the async channels. +use nanorand::Rng; + const OVERFLOW: u32 = 0xffffffff; async fn run() { @@ -13,7 +15,7 @@ async fn run() { for _ in 0..10 { for p in numbers.iter_mut() { - *p = generate_rand() as u32; + *p = nanorand::tls_rng().generate::() as u32; } compute(&mut numbers, &context).await; @@ -29,12 +31,6 @@ async fn run() { } } -fn generate_rand() -> u16 { - let mut bytes = [0u8; 2]; - getrandom::getrandom(&mut bytes[..]).unwrap(); - u16::from_le_bytes(bytes) -} - async fn compute(local_buffer: &mut [u32], context: &WgpuContext) { log::info!("Beginning GPU compute on data {local_buffer:?}."); // Local buffer contents -> GPU storage buffer