ContrastAdaptiveSharpening fails on WebGL2: its 4-byte uniform isn't padded to 16 bytes

Aperta Adatta ai principianti
#26,641 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, wasm

Direzione di ricerca

Inizia da CasUniform in crates/bevy_anti_alias/src/contrast_adaptive_sharpening/mod.rs e dalla struct CASUniforms in robust_contrast_adaptive_sharpening.wesl. Copia il pattern di padding WebGL2 usato da SkyboxUniforms (i campi _webgl2_padding_*b dietro lo stesso cfg) e rispecchialo nella struct dello shader. È completato quando la pipeline CAS viene compilata su una build wasm32 WebGL2 senza l'errore di validazione dell'allineamento a 16 byte.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bevy version and features

  • 0.20.1. CasUniform is unchanged on main.
  • default-features = false, features 2d, 3d, ui (which pull in webgl2), built for wasm32-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.

Lingua principale
Rust
Stelle
49.8k
Fork
5.1k
Merge medio
3g 4h
PR unite (30g)
136

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bevyengine/bevy

Tutte le issue di bevyengine/bevy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.