From 7539be97e70147c30bb1db2a9ec2d9bd284607d0 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Mon, 5 Dec 2022 18:39:36 +0100 Subject: [PATCH 1/3] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98d7be13c2..3eb6804ddf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,6 +114,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non - Combine `Surface::get_supported_formats`, `Surface::get_supported_present_modes`, and `Surface::get_supported_alpha_modes` into `Surface::get_capabilities` and `SurfaceCapabilities`. By @cwfitzgerald in [#3157](https://github.com/gfx-rs/wgpu/pull/3157) - Make `Surface::get_default_config` return an Option to prevent panics. By @cwfitzgerald in [#3157](https://github.com/gfx-rs/wgpu/pull/3157) - Lower the `max_buffer_size` limit value for compatibility with Apple2 and WebGPU compliance. By @jinleili in [#3255](https://github.com/gfx-rs/wgpu/pull/3255) +- Limits `min_uniform_buffer_offset_alignment` and `min_storage_buffer_offset_alignment` is now always at least 32. By @wumpf [#3262](https://github.com/gfx-rs/wgpu/pull/3262) #### WebGPU From b787007192c1e27088d639c1c586f43ffebc1acb Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sat, 17 Dec 2022 21:24:20 +0100 Subject: [PATCH 2/3] force wgpu core adapater to report min_uniform_buffer_offset_alignment/min_storage_buffer_offset_alignment of at least 32 --- wgpu-core/src/instance.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 5b10d73840..d208383a00 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -176,7 +176,19 @@ pub struct Adapter { } impl Adapter { - fn new(raw: hal::ExposedAdapter) -> Self { + fn new(mut raw: hal::ExposedAdapter) -> Self { + // WebGPU requires this offset alignment as lower bound on all adapters. + const MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND: u32 = 32; + + let limits = &mut raw.capabilities.limits; + + limits.min_uniform_buffer_offset_alignment = limits + .min_uniform_buffer_offset_alignment + .min(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND); + limits.min_storage_buffer_offset_alignment = limits + .min_storage_buffer_offset_alignment + .min(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND); + Self { raw, life_guard: LifeGuard::new(""), From 8e5a6355ec48189614f647391d1261d9886cbfe5 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 21 Dec 2022 19:35:45 +0100 Subject: [PATCH 3/3] fix confusion about min/max with MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND --- wgpu-core/src/instance.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index bc216b9356..5bbf03543f 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -184,10 +184,10 @@ impl Adapter { limits.min_uniform_buffer_offset_alignment = limits .min_uniform_buffer_offset_alignment - .min(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND); + .max(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND); limits.min_storage_buffer_offset_alignment = limits .min_storage_buffer_offset_alignment - .min(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND); + .max(MIN_BUFFER_OFFSET_ALIGNMENT_LOWER_BOUND); Self { raw,