Skip to content

Commit

Permalink
revert sorting by bind group as I don't have time to fix the unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
Elabajaba committed Feb 4, 2024
1 parent b478174 commit 964b6ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 4 additions & 5 deletions crates/bevy_core_pipeline/src/core_3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ use bevy_render::{
RenderPhase,
},
render_resource::{
BindGroupId, CachedRenderPipelineId, Extent3d, FilterMode, Sampler, SamplerDescriptor,
Texture, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, TextureView,
CachedRenderPipelineId, Extent3d, FilterMode, Sampler, SamplerDescriptor, Texture,
TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, TextureView,
},
renderer::RenderDevice,
texture::{BevyDefault, ColorAttachment, TextureCache},
Expand Down Expand Up @@ -185,7 +185,6 @@ impl Plugin for Core3dPlugin {

pub struct Opaque3d {
pub asset_id: AssetId<Mesh>,
pub bind_group_id: BindGroupId,
pub pipeline: CachedRenderPipelineId,
pub entity: Entity,
pub draw_function: DrawFunctionId,
Expand All @@ -194,7 +193,7 @@ pub struct Opaque3d {
}

impl PhaseItem for Opaque3d {
type SortKey = (usize, BindGroupId, AssetId<Mesh>);
type SortKey = (usize, AssetId<Mesh>);

#[inline]
fn entity(&self) -> Entity {
Expand All @@ -204,7 +203,7 @@ impl PhaseItem for Opaque3d {
#[inline]
fn sort_key(&self) -> Self::SortKey {
// Sort by pipeline, then by mesh to massively decrease drawcall counts in real scenes.
(self.pipeline.id(), self.bind_group_id, self.asset_id)
(self.pipeline.id(), self.asset_id)
}

#[inline]
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,6 @@ pub fn queue_material_meshes<M: Material>(
draw_function: draw_opaque_pbr,
pipeline: pipeline_id,
asset_id: mesh_instance.mesh_asset_id,
// TODO: Remove this unwrap somehow. Sorting by the bind_group_id gets us another 9% fps in my testing
bind_group_id: mesh_instance.material_bind_group_id.0.unwrap(),
batch_range: 0..1,
dynamic_offset: None,
});
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/render_resource/resource_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ macro_rules! render_resource_wrapper {
#[macro_export]
macro_rules! define_atomic_id {
($atomic_id_type:ident) => {
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug)]
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
pub struct $atomic_id_type(core::num::NonZeroU32);

// We use new instead of default to indicate that each ID created will be unique.
Expand Down

0 comments on commit 964b6ac

Please sign in to comment.