From 248bbe85c608e4eeacebba2031a5f24351a40b82 Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Wed, 27 Dec 2023 23:19:39 +0100 Subject: [PATCH 1/2] hello_compute: check for missing command-line args Fixes off-by-one error when checking for missing arguments. Before this, running the example gave this scary looking error message: ``` $ cargo run --bin wgpu-examples hello_compute Finished dev [unoptimized + debuginfo] target(s) in 0.13s Running `target/debug/wgpu-examples hello_compute` [2023-12-27T22:14:26Z ERROR wgpu::backend::direct] Handling wgpu errors as fatal by default thread 'main' panicked at 'wgpu error: Validation Error Caused by: In Device::create_bind_group Buffer binding size 0 is less than minimum 4 note: buffer = `Storage Buffer` ', wgpu/src/backend/direct.rs:3139:5 ``` As this was the first example I tried to run, it almost scared me away, thinking it was a driver issue. Instead, without arguments the example should use defaults. --- examples/src/hello_compute/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/hello_compute/mod.rs b/examples/src/hello_compute/mod.rs index beffdc7bbc..6b7cfa18e0 100644 --- a/examples/src/hello_compute/mod.rs +++ b/examples/src/hello_compute/mod.rs @@ -6,7 +6,7 @@ const OVERFLOW: u32 = 0xffffffff; #[cfg_attr(test, allow(dead_code))] async fn run() { - let numbers = if std::env::args().len() <= 1 { + let numbers = if std::env::args().len() <= 2 { let default = vec![1, 2, 3, 4]; println!("No numbers were provided, defaulting to {default:?}"); default From 93faef27a8637939872565843f526381ad8d3805 Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Wed, 27 Dec 2023 23:45:21 +0100 Subject: [PATCH 2/2] Add PR #4939 to changelog as instructed --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 995d3f039d..2fdc3d88db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -215,6 +215,7 @@ Passing an owned value `window` to `Surface` will return a `Surface<'static>`. S ### Examples - remove winit dependency from hello-compute example by @psvri in [#4699](https://github.com/gfx-rs/wgpu/pull/4699) +- hello-compute example fix failure with "wgpu error: Validation Error" if arguments are missing by @vilcans in [#4939](https://github.com/gfx-rs/wgpu/pull/4939) ## v0.18.1 (2023-11-15)