Profiling support (#743)

This commit is contained in:
Thierry Berger
2024-11-19 16:33:26 +01:00
committed by GitHub
parent ff79f4c674
commit 510237cc29
56 changed files with 185 additions and 635 deletions

View File

@@ -254,6 +254,7 @@ impl BroadPhaseMultiSap {
/// This will:
/// - Remove all the subregion proxies from the larger layer.
/// - Pre-insert all the smaller layer's region proxies into this layer.
#[profiling::function]
fn finalize_layer_insertion(&mut self, layer_id: u8) {
// Remove all the region endpoints from the larger layer.
// They will be automatically replaced by the new layer's regions.
@@ -289,6 +290,7 @@ impl BroadPhaseMultiSap {
/// the `update` function.
/// 4. All the regions from the smaller layer are added to that new
/// layer.
#[profiling::function]
fn ensure_layer_exists(&mut self, new_depth: i8) -> u8 {
// Special case: we don't have any layers yet.
if self.layers.is_empty() {
@@ -473,6 +475,7 @@ impl BroadPhaseMultiSap {
/// added to its larger layer so we can detect when an object
/// in a larger layer may start interacting with objects in a smaller
/// layer.
#[profiling::function]
fn propagate_created_regions(&mut self) {
let mut curr_layer = Some(self.smallest_layer);
@@ -502,6 +505,7 @@ impl BroadPhaseMultiSap {
}
}
#[profiling::function]
fn update_layers_and_find_pairs(&mut self, out_events: &mut Vec<BroadPhasePairEvent>) {
if self.layers.is_empty() {
return;
@@ -579,6 +583,7 @@ impl BroadPhaseMultiSap {
impl BroadPhase for BroadPhaseMultiSap {
/// Updates the broad-phase, taking into account the new collider positions.
#[profiling::function]
fn update(
&mut self,
dt: Real,

View File

@@ -36,6 +36,7 @@ impl SAPAxis {
self.endpoints.push(SAPEndpoint::end_sentinel());
}
#[profiling::function]
pub fn batch_insert(
&mut self,
dim: usize,

View File

@@ -49,6 +49,7 @@ impl SAPLayer {
/// Deletes from all the regions of this layer, all the endpoints corresponding
/// to subregions. Clears the arrays of subregions indices from all the regions of
/// this layer.
#[profiling::function]
pub fn unregister_all_subregions(&mut self, proxies: &mut SAPProxies) {
for region_id in self.regions.values() {
// Extract the region to make the borrow-checker happy.
@@ -108,6 +109,7 @@ impl SAPLayer {
/// that subregion center. Because the hierarchical grid cells have aligned boundaries
/// at each depth, we have the guarantee that a given subregion will only be part of
/// one region on its parent "larger" layer.
#[profiling::function]
fn register_subregion(
&mut self,
proxy_id: BroadPhaseProxyIndex,
@@ -145,6 +147,7 @@ impl SAPLayer {
}
}
#[profiling::function]
fn unregister_subregion(
&mut self,
proxy_id: BroadPhaseProxyIndex,
@@ -273,6 +276,7 @@ impl SAPLayer {
}
}
#[profiling::function]
pub fn predelete_proxy(&mut self, proxies: &mut SAPProxies, proxy_index: BroadPhaseProxyIndex) {
// Discretize the Aabb to find the regions that need to be invalidated.
let proxy_aabb = &mut proxies[proxy_index].aabb;

View File

@@ -214,6 +214,7 @@ impl SAPRegion {
}
}
#[profiling::function]
pub fn update(
&mut self,
proxies: &SAPProxies,

View File

@@ -186,6 +186,7 @@ impl ContactPair {
///
/// Returns a reference to the contact, as well as the contact manifold
/// it is part of.
#[profiling::function]
pub fn find_deepest_contact(&self) -> Option<(&ContactManifold, &Contact)> {
let mut deepest = None;

View File

@@ -96,6 +96,7 @@ impl<N: Copy, E> InteractionGraph<N, E> {
}
/// The interaction between the two collision objects identified by their graph index.
#[profiling::function]
pub fn interaction_pair(
&self,
id1: ColliderGraphIndex,
@@ -111,6 +112,7 @@ impl<N: Copy, E> InteractionGraph<N, E> {
}
/// The interaction between the two collision objects identified by their graph index.
#[profiling::function]
pub fn interaction_pair_mut(
&mut self,
id1: ColliderGraphIndex,

View File

@@ -53,6 +53,7 @@ pub enum MeshConverter {
impl MeshConverter {
/// Applies the conversion rule described by this [`MeshConverter`] to build a shape from
/// the given vertex and index buffers.
#[profiling::function]
pub fn convert(
&self,
vertices: Vec<Point<Real>>,

View File

@@ -268,6 +268,7 @@ impl NarrowPhase {
// }
/// Maintain the narrow-phase internal state by taking collider removal into account.
#[profiling::function]
pub fn handle_user_changes(
&mut self,
mut islands: Option<&mut IslandManager>,
@@ -321,6 +322,7 @@ impl NarrowPhase {
);
}
#[profiling::function]
pub(crate) fn remove_collider(
&mut self,
intersection_graph_id: ColliderGraphIndex,
@@ -412,6 +414,7 @@ impl NarrowPhase {
}
}
#[profiling::function]
pub(crate) fn handle_user_changes_on_colliders(
&mut self,
mut islands: Option<&mut IslandManager>,
@@ -513,6 +516,7 @@ impl NarrowPhase {
}
}
#[profiling::function]
fn remove_pair(
&mut self,
islands: Option<&mut IslandManager>,
@@ -584,6 +588,7 @@ impl NarrowPhase {
}
}
#[profiling::function]
fn add_pair(&mut self, colliders: &ColliderSet, pair: &ColliderPair) {
if let (Some(co1), Some(co2)) =
(colliders.get(pair.collider1), colliders.get(pair.collider2))
@@ -687,6 +692,7 @@ impl NarrowPhase {
}
}
#[profiling::function]
pub(crate) fn compute_intersections(
&mut self,
bodies: &RigidBodySet,
@@ -785,6 +791,7 @@ impl NarrowPhase {
});
}
#[profiling::function]
pub(crate) fn compute_contacts(
&mut self,
prediction_distance: Real,