diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 1f68d67ddf0ec..fa760345e5753 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -17,8 +17,9 @@ use bevy::{ render_resource::{ BlendState, ColorTargetState, ColorWrites, Face, FragmentState, FrontFace, MultisampleState, PipelineCache, PolygonMode, PrimitiveState, PrimitiveTopology, - RenderPipelineDescriptor, SpecializedRenderPipeline, SpecializedRenderPipelines, - TextureFormat, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, + PushConstantRange, RenderPipelineDescriptor, ShaderStages, SpecializedRenderPipeline, + SpecializedRenderPipelines, TextureFormat, VertexBufferLayout, VertexFormat, + VertexState, VertexStepMode, }, texture::BevyDefault, view::{ExtractedView, ViewTarget, VisibleEntities}, @@ -157,6 +158,18 @@ impl SpecializedRenderPipeline for ColoredMesh2dPipeline { false => TextureFormat::bevy_default(), }; + let mut push_constant_ranges = Vec::with_capacity(1); + if cfg!(all( + feature = "webgl2", + target_arch = "wasm32", + not(feature = "webgpu") + )) { + push_constant_ranges.push(PushConstantRange { + stages: ShaderStages::VERTEX, + range: 0..4, + }); + } + RenderPipelineDescriptor { vertex: VertexState { // Use our custom shader @@ -184,7 +197,7 @@ impl SpecializedRenderPipeline for ColoredMesh2dPipeline { // Bind group 1 is the mesh uniform self.mesh2d_pipeline.mesh_layout.clone(), ], - push_constant_ranges: Vec::new(), + push_constant_ranges, primitive: PrimitiveState { front_face: FrontFace::Ccw, cull_mode: Some(Face::Back),