From 17633c1f758d65aa96ba5d2a6b7a4a39345ff0fa Mon Sep 17 00:00:00 2001 From: JMS55 <47158642+JMS55@users.noreply.github.com> Date: Tue, 23 Apr 2024 14:43:46 -0700 Subject: [PATCH] Remove unused push constants (#13076) The shader code was removed in #11280, but we never cleaned up the rust code. --- crates/bevy_pbr/src/prepass/mod.rs | 14 +------------- crates/bevy_pbr/src/render/mesh.rs | 20 +------------------- crates/bevy_sprite/src/mesh2d/mesh.rs | 19 +------------------ examples/2d/mesh2d_manual.rs | 19 +++---------------- 4 files changed, 6 insertions(+), 66 deletions(-) diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 682935c504c2d..18b7eeeb3ab35 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -534,18 +534,6 @@ where PREPASS_SHADER_HANDLE }; - let mut push_constant_ranges = Vec::with_capacity(1); - if cfg!(all( - feature = "webgl", - target_arch = "wasm32", - not(feature = "webgpu") - )) { - push_constant_ranges.push(PushConstantRange { - stages: ShaderStages::VERTEX, - range: 0..4, - }); - } - let mut descriptor = RenderPipelineDescriptor { vertex: VertexState { shader: vert_shader_handle, @@ -585,7 +573,7 @@ where mask: !0, alpha_to_coverage_enabled: false, }, - push_constant_ranges, + push_constant_ranges: vec![], label: Some("prepass_pipeline".into()), }; diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index 959c77ed6881a..1fd8319f4b59c 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -1467,18 +1467,6 @@ impl SpecializedMeshPipeline for MeshPipeline { )); } - let mut push_constant_ranges = Vec::with_capacity(1); - if cfg!(all( - feature = "webgl", - target_arch = "wasm32", - not(feature = "webgpu") - )) { - push_constant_ranges.push(PushConstantRange { - stages: ShaderStages::VERTEX, - range: 0..4, - }); - } - Ok(RenderPipelineDescriptor { vertex: VertexState { shader: MESH_SHADER_HANDLE, @@ -1497,7 +1485,7 @@ impl SpecializedMeshPipeline for MeshPipeline { })], }), layout: bind_group_layout, - push_constant_ranges, + push_constant_ranges: vec![], primitive: PrimitiveState { front_face: FrontFace::Ccw, cull_mode: Some(Face::Back), @@ -1794,12 +1782,6 @@ impl RenderCommand

for DrawMesh { pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..)); let batch_range = item.batch_range(); - #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] - pass.set_push_constants( - ShaderStages::VERTEX, - 0, - &(batch_range.start as i32).to_le_bytes(), - ); match &gpu_mesh.buffer_info { GpuBufferInfo::Indexed { buffer, diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 7a26b46972ad4..90a67f7517179 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -517,17 +517,6 @@ 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", - not(feature = "webgpu") - )) { - push_constant_ranges.push(PushConstantRange { - stages: ShaderStages::VERTEX, - range: 0..4, - }); - } Ok(RenderPipelineDescriptor { vertex: VertexState { @@ -547,7 +536,7 @@ impl SpecializedMeshPipeline for Mesh2dPipeline { })], }), layout: vec![self.view_layout.clone(), self.mesh_layout.clone()], - push_constant_ranges, + push_constant_ranges: vec![], primitive: PrimitiveState { front_face: FrontFace::Ccw, cull_mode: None, @@ -699,12 +688,6 @@ impl RenderCommand

for DrawMesh2d { pass.set_vertex_buffer(0, gpu_mesh.vertex_buffer.slice(..)); let batch_range = item.batch_range(); - #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] - pass.set_push_constants( - ShaderStages::VERTEX, - 0, - &(batch_range.start as i32).to_le_bytes(), - ); match &gpu_mesh.buffer_info { GpuBufferInfo::Indexed { buffer, diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 82d65753253ef..b99c23a9c93ed 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -17,9 +17,8 @@ use bevy::{ render_resource::{ BlendState, ColorTargetState, ColorWrites, Face, FragmentState, FrontFace, MultisampleState, PipelineCache, PolygonMode, PrimitiveState, PrimitiveTopology, - PushConstantRange, RenderPipelineDescriptor, ShaderStages, SpecializedRenderPipeline, - SpecializedRenderPipelines, TextureFormat, VertexBufferLayout, VertexFormat, - VertexState, VertexStepMode, + RenderPipelineDescriptor, SpecializedRenderPipeline, SpecializedRenderPipelines, + TextureFormat, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, }, texture::BevyDefault, view::{ExtractedView, ViewTarget, VisibleEntities}, @@ -158,18 +157,6 @@ 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 @@ -197,7 +184,7 @@ impl SpecializedRenderPipeline for ColoredMesh2dPipeline { // Bind group 1 is the mesh uniform self.mesh2d_pipeline.mesh_layout.clone(), ], - push_constant_ranges, + push_constant_ranges: vec![], primitive: PrimitiveState { front_face: FrontFace::Ccw, cull_mode: Some(Face::Back),