Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message #3099

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 12 additions & 5 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2854,11 +2854,18 @@ impl<A: HalApi> Device<A> {
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,
});
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be bytes instead of bits

UnalignedShader { group: u32, binding: u32 },
}

bitflags::bitflags! {
Expand Down