From 08dd49bf788913fd6eecdc24316b84b1aab45540 Mon Sep 17 00:00:00 2001 From: gilescope Date: Thu, 13 Oct 2022 08:30:00 +0100 Subject: [PATCH 1/7] Better error message --- wgpu-core/src/device/mod.rs | 17 ++++++++++++----- wgpu-core/src/pipeline.rs | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 8f3e5ce4d3..4538ab5f88 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -2854,11 +2854,18 @@ impl Device { self.require_features(wgt::Features::MULTIVIEW)?; } - for size in shader_binding_sizes.values() { - if size.get() % 16 != 0 { - self.require_downlevel_flags( - wgt::DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED, - )?; + if !self + .downlevel + .flags + .contains(wgt::DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED) + { + for (binding, size) in shader_binding_sizes.iter() { + if size.get() % 16 != 0 { + return Err(pipeline::CreateRenderPipelineError::UnalignedShader { + binding: binding.binding, + group: binding.group, + }); + } } } diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 667b8b96ed..b1badf80ee 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -371,6 +371,8 @@ pub enum CreateRenderPipelineError { stage: wgt::ShaderStages, error: String, }, + #[error("shader group {group} binding {binding} must be 16bit aligned as device does not support DownlevelFlags `BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`")] + UnalignedShader { group: u32, binding: u32 }, } bitflags::bitflags! { From fa0bd5edc9159fe25a2e6da6ee0c95f62e780f06 Mon Sep 17 00:00:00 2001 From: gilescope Date: Thu, 13 Oct 2022 09:15:16 +0100 Subject: [PATCH 2/7] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba1c3cd815..34eb4c297f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Bottom level categories: --> ## Unreleased +- Better error message for non-aligned shaders in WebGL [#3099](https://github.com/gfx-rs/wgpu/pull/3099) ### Changes From fb18021e2d1bda1e1681611fe0126d020d243da3 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Sat, 21 Jan 2023 16:11:31 -0500 Subject: [PATCH 3/7] fix message --- wgpu-core/src/pipeline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index b1badf80ee..54263dc29d 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -371,7 +371,7 @@ pub enum CreateRenderPipelineError { stage: wgt::ShaderStages, error: String, }, - #[error("shader group {group} binding {binding} must be 16bit aligned as device does not support DownlevelFlags `BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`")] + #[error("shader group {group} binding {binding} must be 16 bytes aligned as device does not support DownlevelFlags `BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`")] UnalignedShader { group: u32, binding: u32 }, } From 635f533f482b92adbf71f54b739318ddd94225b6 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Sat, 21 Jan 2023 16:23:55 -0500 Subject: [PATCH 4/7] update changelog --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08526b8b2d..a20bc263b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,9 +38,6 @@ Bottom level categories: - Hal --> -## Unreleased -- Better error message for non-aligned shaders in WebGL [#3099](https://github.com/gfx-rs/wgpu/pull/3099) - ### Major Changes #### Backend selection by features @@ -183,6 +180,7 @@ let texture = device.create_texture(&wgpu::TextureDescriptor { - Add validation in accordance with WebGPU `GPUSamplerDescriptor` valid usage for `lodMinClamp` and `lodMaxClamp`. By @James2022-rgb in [#3353](https://github.com/gfx-rs/wgpu/pull/3353) - Remove panics in `Deref` implementations for `QueueWriteBufferView` and `BufferViewMut`. Instead, warnings are logged, since reading from these types is not recommended. By @botahamec in [#3336] - Implement `view_formats` in TextureDescriptor to match the WebGPU spec. By @jinleili in [#3237](https://github.com/gfx-rs/wgpu/pull/3237) +- Show more information in error message for non-aligned buffer bindings in WebGL [#3414](https://github.com/gfx-rs/wgpu/pull/3414) #### WebGPU @@ -193,7 +191,7 @@ let texture = device.create_texture(&wgpu::TextureDescriptor { - Browsers that support `OVR_multiview2` now report the `MULTIVIEW` feature by @expenses in [#3121](https://github.com/gfx-rs/wgpu/pull/3121). - `Limits::max_push_constant_size` on GLES is now 256 by @Dinnerbone in [#3374](https://github.com/gfx-rs/wgpu/pull/3374). -- Creating multiple pipelines with the same shaders will now be faster, by @Dinnerbone in [#3380](https://github.com/gfx-rs/wgpu/pull/3380). +- Creating multiple pipelines with the same shaders will now be faster, by @Dinnerbone in [#3380](https://github.com/gfx-rs/wgpu/pull/3380). #### Vulkan From 38d51cd530101ff8391e1fbdfcd5c612adfb68ec Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 24 Jan 2023 13:55:43 -0500 Subject: [PATCH 5/7] Update wgpu-core/src/pipeline.rs Co-authored-by: Connor Fitzgerald --- wgpu-core/src/pipeline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index e600721f64..b235806b7d 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -373,7 +373,7 @@ pub enum CreateRenderPipelineError { stage: wgt::ShaderStages, error: String, }, - #[error("shader group {group} binding {binding} must be 16 bytes aligned as device does not support DownlevelFlags `BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`")] + #[error("In the provided shader, the type given for group {group} binding {binding} has an alignment of {alignment}. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have an alignment of at least 16.")] UnalignedShader { group: u32, binding: u32 }, } From d640902a9b0a3319a5b828abe69a4e37463063d0 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 24 Jan 2023 15:32:31 -0500 Subject: [PATCH 6/7] add size to error message --- wgpu-core/src/device/mod.rs | 1 + wgpu-core/src/pipeline.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 955c70d402..2c03b8fb0a 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -3007,6 +3007,7 @@ impl Device { return Err(pipeline::CreateRenderPipelineError::UnalignedShader { binding: binding.binding, group: binding.group, + size: size.get(), }); } } diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index b235806b7d..a5546e8ea8 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -373,8 +373,8 @@ pub enum CreateRenderPipelineError { stage: wgt::ShaderStages, error: String, }, - #[error("In the provided shader, the type given for group {group} binding {binding} has an alignment of {alignment}. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have an alignment of at least 16.")] - UnalignedShader { group: u32, binding: u32 }, + #[error("In the provided shader, the type given for group {group} binding {binding} has a size of {size}. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have an alignment of a multiple of 16 bytes.")] + UnalignedShader { group: u32, binding: u32, size: u64 }, } bitflags::bitflags! { From dd62f054a3acbe45b612acfaa1c0b276f792b713 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Tue, 24 Jan 2023 15:33:33 -0500 Subject: [PATCH 7/7] wording --- wgpu-core/src/pipeline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index a5546e8ea8..7749171442 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -373,7 +373,7 @@ pub enum CreateRenderPipelineError { stage: wgt::ShaderStages, error: String, }, - #[error("In the provided shader, the type given for group {group} binding {binding} has a size of {size}. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have an alignment of a multiple of 16 bytes.")] + #[error("In the provided shader, the type given for group {group} binding {binding} has a size of {size}. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have a size that is a multiple of 16 bytes.")] UnalignedShader { group: u32, binding: u32, size: u64 }, }