Skip to content

Commit

Permalink
Remove unused push constants (#13076)
Browse files Browse the repository at this point in the history
The shader code was removed in #11280, but we never cleaned up the rust
code.
  • Loading branch information
JMS55 authored Apr 23, 2024
1 parent 30b0931 commit 17633c1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 66 deletions.
14 changes: 1 addition & 13 deletions crates/bevy_pbr/src/prepass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -585,7 +573,7 @@ where
mask: !0,
alpha_to_coverage_enabled: false,
},
push_constant_ranges,
push_constant_ranges: vec![],
label: Some("prepass_pipeline".into()),
};

Expand Down
20 changes: 1 addition & 19 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down Expand Up @@ -1794,12 +1782,6 @@ impl<P: PhaseItem> RenderCommand<P> 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,
Expand Down
19 changes: 1 addition & 18 deletions crates/bevy_sprite/src/mesh2d/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -699,12 +688,6 @@ impl<P: PhaseItem> RenderCommand<P> 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,
Expand Down
19 changes: 3 additions & 16 deletions examples/2d/mesh2d_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 17633c1

Please sign in to comment.