Skip to content

Commit 81127b3

Browse files
authored
Increase MaterialProperties::draw_functions inline capacity (#24844)
# Objective We have 11 draw functions but `MaterialProperties::draw_functions` SmallVec only inlines 4 on the stack, which means currently it offers no benefit over `Vec`. ## Solution Increases its capacity to 11. The size of `PreparedMaterial` doesn't matter, because it's stored on the heap anyway (inside `ErasedRenderAssets<PreparedMaterial>`). ## Testing CI
1 parent 9bc5b6e commit 81127b3

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

crates/bevy_material/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ pub struct MaterialProperties {
7474
pub reads_view_transmission_texture: bool,
7575
pub render_phase_type: RenderPhaseType,
7676
pub material_layout: Option<BindGroupLayoutDescriptor>,
77-
/// Backing array is a size of 4 because the [`StandardMaterial`](https://docs.rs/bevy/latest/bevy/pbr/struct.StandardMaterial.html)
78-
/// needs 4 draw functions by default
79-
pub draw_functions: SmallVec<[(InternedDrawFunctionLabel, DrawFunctionId); 4]>,
77+
/// Backing array is a size of 11 because the [`StandardMaterial`](https://docs.rs/bevy/latest/bevy/pbr/struct.StandardMaterial.html)
78+
/// needs 11 draw functions by default
79+
pub draw_functions: SmallVec<[(InternedDrawFunctionLabel, DrawFunctionId); 11]>,
8080
/// Backing array is a size of 6 because the [`StandardMaterial`](https://docs.rs/bevy/latest/bevy/pbr/struct.StandardMaterial.html)
8181
/// has 6 custom shaders (`frag`, `prepass_frag`, `deferred_frag`, `vertex`, `prepass_vertex`,
8282
/// `deferred vertex`) which is the most common use case

crates/bevy_pbr/src/material.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,7 @@ where
17071707
let draw_shadows = shadow_draw_functions.read().id::<DrawPrepass>();
17081708
let draw_shadows_depth_only = shadow_draw_functions.read().id::<DrawDepthOnlyPrepass>();
17091709

1710-
let draw_functions = SmallVec::from_iter([
1710+
let draw_functions = SmallVec::from_const([
17111711
(MainPassOpaqueDrawFunction.intern(), draw_opaque_pbr),
17121712
(MainPassAlphaMaskDrawFunction.intern(), draw_alpha_mask_pbr),
17131713
(

0 commit comments

Comments
 (0)