-
Notifications
You must be signed in to change notification settings - Fork 967
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
Uniform block sizes seem to be rounded up to the nearest 16 on WebGL #2072
Comments
Interesting. So it sounds like a validation issue? Other backends do not require this. |
Apparently this used to be a layout requirement for uniform buffers, but was removed in gpuweb/gpuweb#1560. |
This isn't a clear as we'd hope. See gpuweb/gpuweb#1558 and https://github.com/austinEng/webgpu-samples/issues/149, which notably has zero responses. |
I think gpuweb/gpuweb#425 (comment) is deriving the alignment from the types of the fields though, so we wouldn't necessarily end up with 16-byte alignment for something like Should we go ahead with having WebGL validation to enforce alignment to We probably need some way to surface this size too, because we don't know the size in advance (i.e. besides guessing 16-byte alignment/rounding up). |
Uniform buffers require that all structs be rounded up to 16, so that would still be align 16. The only potential issue is if someone had a uniform buffer of a bare u32. This can be a downlevel feature forcing all assignments to 16. |
Description
WebGL seems to be rounding the size of uniforms up to the nearest 16, causing errors to be thrown when the slightly-smaller buffer is passed to a draw call. Adding some padding to the buffer solves the problem.
Repro steps
None of wgpu's examples use uniforms with alignments less than 16, so I created a toy example which draws a vertical line: https://github.com/Liamolucko/wgpu-uniform-repro. Build with
cargo build && wasm-bindgen target/wasm32-unknown-unknown/debug/wgpu-uniform-repro.wasm --target web --out-dir pkg
, and then start a http server for the folder.Expected vs observed behavior
Expected:
Observed:
Platform
wgpu
0.11.0, Firefox 93 (also fails in Chromium), Manjaro Linux, nVidia GeForce GTX 780.The text was updated successfully, but these errors were encountered: