wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

Helpful information for `BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`

Open kpreid opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

  1. Write a shader, uniform buffers, etc.
  2. Try to run the program with the WebGL backend.
  3. Get an error that tells you BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED is unsupported, and the pipeline name, and nothing else.

Describe the solution you'd like Provide diagnostic information to help fix the alignment problem, such as:

  • The fact that this error is provoked by the shader's code, not the size of CPU-provided buffers.
  • The name or number of the binding that was the wrong size.
  • The field layout of the struct type of that binding, if it is a struct.

All but the first of these improvements would require making the MissingDownlevelFlags error able to carry additional context, or some other kind of refactoring of the error types.

kpreid avatar Jul 02 '22 02:07 kpreid

I am a bevy user experiencing this error while migrating to a version of bevy that uses wgpu 0.13, and I would definitely love to have any sort of idea what's going on.

rparrett avatar Jul 20 '22 02:07 rparrett

The problem is that the size of your shader side struct must be aligned to size 16 - if it isn't, it needs to be padded out to be size 16

cwfitzgerald avatar Jul 20 '22 07:07 cwfitzgerald

One of your shader structs isn't aligned. Not going to tell you which one. You have to find the needle in the haystack. Sad face.

gilescope avatar Oct 10 '22 21:10 gilescope

@gilescope We should have the binding information available in the key of the hash map we're iterating through here, so a PR adding this information shouldn't be that difficult. https://github.com/gfx-rs/wgpu/blob/master/wgpu-core/src/device/mod.rs#L2857

cwfitzgerald avatar Oct 10 '22 23:10 cwfitzgerald