diff --git a/crates/bevy_sprite/Cargo.toml b/crates/bevy_sprite/Cargo.toml index a7c2cc47285045..43929eb31b0de1 100644 --- a/crates/bevy_sprite/Cargo.toml +++ b/crates/bevy_sprite/Cargo.toml @@ -8,6 +8,9 @@ repository = "https://github.com/bevyengine/bevy" license = "MIT OR Apache-2.0" keywords = ["bevy"] +[features] +webgl = [] + [dependencies] # bevy bevy_app = { path = "../bevy_app", version = "0.12.0-dev" } diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index fb9fde65fe050e..5f62000bc441ee 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -536,6 +536,13 @@ impl SpecializedMeshPipeline for Mesh2dPipeline { true => ViewTarget::TEXTURE_FORMAT_HDR, false => TextureFormat::bevy_default(), }; + let mut push_constant_ranges = Vec::with_capacity(1); + if cfg!(all(feature = "webgl", target_arch = "wasm32")) { + push_constant_ranges.push(PushConstantRange { + stages: ShaderStages::VERTEX, + range: 0..4, + }); + } Ok(RenderPipelineDescriptor { vertex: VertexState { @@ -555,7 +562,7 @@ impl SpecializedMeshPipeline for Mesh2dPipeline { })], }), layout: vec![self.view_layout.clone(), self.mesh_layout.clone()], - push_constant_ranges: Vec::new(), + push_constant_ranges, primitive: PrimitiveState { front_face: FrontFace::Ccw, cull_mode: None,