Skip to content

Commit bb876f3

Browse files
IceSentrycwfitzgeraldgilescope
authored
Better error message for 16 byte alignment error (#3414)
Co-authored-by: Connor Fitzgerald <[email protected]> Co-authored-by: gilescope <[email protected]> Closes #3099 Closes #2832
1 parent 5da2b8a commit bb876f3

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ Bottom level categories:
3838
- Hal
3939
-->
4040

41-
## Unreleased
42-
4341
### Major Changes
4442

4543
#### Backend selection by features
@@ -186,6 +184,7 @@ let texture = device.create_texture(&wgpu::TextureDescriptor {
186184
- 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)
187185
- 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]
188186
- Implement `view_formats` in TextureDescriptor to match the WebGPU spec. By @jinleili in [#3237](https://github.com/gfx-rs/wgpu/pull/3237)
187+
- Show more information in error message for non-aligned buffer bindings in WebGL [#3414](https://github.com/gfx-rs/wgpu/pull/3414)
189188
- Update `TextureView` validation according to the WebGPU spec. By @teoxoy in [#3410](https://github.com/gfx-rs/wgpu/pull/3410)
190189

191190
#### WebGPU
@@ -197,7 +196,7 @@ let texture = device.create_texture(&wgpu::TextureDescriptor {
197196

198197
- Browsers that support `OVR_multiview2` now report the `MULTIVIEW` feature by @expenses in [#3121](https://github.com/gfx-rs/wgpu/pull/3121).
199198
- `Limits::max_push_constant_size` on GLES is now 256 by @Dinnerbone in [#3374](https://github.com/gfx-rs/wgpu/pull/3374).
200-
- Creating multiple pipelines with the same shaders will now be faster, by @Dinnerbone in [#3380](https://github.com/gfx-rs/wgpu/pull/3380).
199+
- Creating multiple pipelines with the same shaders will now be faster, by @Dinnerbone in [#3380](https://github.com/gfx-rs/wgpu/pull/3380).
201200

202201
#### Vulkan
203202

wgpu-core/src/device/mod.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,11 +2997,19 @@ impl<A: HalApi> Device<A> {
29972997
self.require_features(wgt::Features::MULTIVIEW)?;
29982998
}
29992999

3000-
for size in shader_binding_sizes.values() {
3001-
if size.get() % 16 != 0 {
3002-
self.require_downlevel_flags(
3003-
wgt::DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED,
3004-
)?;
3000+
if !self
3001+
.downlevel
3002+
.flags
3003+
.contains(wgt::DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED)
3004+
{
3005+
for (binding, size) in shader_binding_sizes.iter() {
3006+
if size.get() % 16 != 0 {
3007+
return Err(pipeline::CreateRenderPipelineError::UnalignedShader {
3008+
binding: binding.binding,
3009+
group: binding.group,
3010+
size: size.get(),
3011+
});
3012+
}
30053013
}
30063014
}
30073015

wgpu-core/src/pipeline.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ pub enum CreateRenderPipelineError {
373373
stage: wgt::ShaderStages,
374374
error: String,
375375
},
376+
#[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.")]
377+
UnalignedShader { group: u32, binding: u32, size: u64 },
376378
}
377379

378380
bitflags::bitflags! {

0 commit comments

Comments
 (0)