ContrastAdaptiveSharpening fails on WebGL2: its 4-byte uniform isn't padded to 16 bytes
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust, wasm
- Domain
- computer-graphics
Research direction
Start with CasUniform in crates/bevy_anti_alias/src/contrast_adaptive_sharpening/mod.rs and the CASUniforms struct in robust_contrast_adaptive_sharpening.wesl. Copy the WebGL2 padding pattern used by SkyboxUniforms (the _webgl2_padding_*b fields behind the same cfg), and mirror it in the shader struct. Done when the CAS pipeline builds on a wasm32 WebGL2 build without the 16-byte alignment validation error.
Written by the indexing model from the issue text.
Description
Bevy version and features
- 0.20.1.
CasUniformis unchanged onmain. default-features = false, features2d,3d,ui(which pull inwebgl2), built forwasm32-unknown-unknown.
[Optional] Relevant system information
- Rust 1.97.1, Chromium 156 on Linux.
AdapterInfo { name: "ANGLE (AMD, AMD Radeon RX 6650 XT (radeonsi navi23 ACO), OpenGL ES 3.2)", vendor: 4098, device: 0, device_type: Other, driver_info: "WebGL 2.0 (OpenGL ES 3.0 Chromium)", backend: Gl, .. }
What you did
Added ContrastAdaptiveSharpening::default() to a camera in a WebGL2 build.
What went wrong
Expected: the camera's output is sharpened, as it is natively.
Actual: creating the CAS pipeline fails validation, and Bevy quits:
Caught rendering error: Validation Error
Caused by:
In Device::create_render_pipeline, label = 'contrast_adaptive_sharpening'
In the provided shader, the type given for group 0 binding 2 has a size of 4. 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.
Caught rendering error: Validation Error
Caused by:
In a CommandEncoder ...
In a set_pipeline command
RenderPipeline with 'contrast_adaptive_sharpening' label is invalid
Quitting the application due to Validation RenderError
Additional information
CasUniform (crates/bevy_anti_alias/src/contrast_adaptive_sharpening/mod.rs) and CASUniforms in robust_contrast_adaptive_sharpening.wesl hold a single f32. Other uniforms are padded for WebGL2 behind cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu"))); SkyboxUniforms is one example, with its _webgl2_padding_*b fields. The same padding here, mirrored in the shader struct, should fix it.
Workaround: we run the same RCAS math in our own Material2d, with a vec4 uniform.
- Dominant language
- Rust
- Stars
- 49.8k
- Forks
- 5.1k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 136
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bevyengine/bevy
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bevyengine/bevy#26642 ·
Maintainers usually reply within 2 days
-
A-Animation AI-Assisted C-Bug D-Trivial S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy#26637 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy#26635 ·
Maintainers usually reply within 2 days
-
Feathers checkbox outline should have flex_shrink: 0Possibly taken @Tatsuya0330 claimed this today. OpenC-Bug S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bevyengine/bevy#26630 ·
Maintainers usually reply within 2 days
-
A-UI C-Examples C-Refinement D-Straightforward S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bevyengine/bevy#26584 · 1 comment ·
Maintainers usually reply within 2 days
Similar issues
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
bug triaged tui ux wontfix
Difficulty 2/5 Half a day Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day