From d421e45c828f6f853a145f726f0b9425d31146eb Mon Sep 17 00:00:00 2001 From: Erin Catto Date: Sun, 12 Jul 2026 22:49:25 -0700 Subject: [PATCH] Update benchmarks (#77) The large pyramid got larger, not slower. Renamed b3CreateCompound to b3CreateBakedCompound and added some comments. There is confusion between run-time compounds and baked compounds. --- benchmark/amd7950x_sse2/convex_pile.csv | 9 +++++++++ benchmark/amd7950x_sse2/joint_grid.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/junkyard.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/large_pyramid.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/large_world.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/many_pyramids.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/rain.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/trees100.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/trees25.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/trees50.csv | 16 ++++++++-------- benchmark/amd7950x_sse2/washer.csv | 16 ++++++++-------- include/box3d/box3d.h | 7 +++++-- include/box3d/types.h | 4 ++-- samples/sample_compound.cpp | 12 ++++++------ src/recording_replay.c | 2 +- src/shape.c | 2 +- test/test_recording.c | 2 +- test/test_world.c | 2 +- 18 files changed, 106 insertions(+), 94 deletions(-) create mode 100644 benchmark/amd7950x_sse2/convex_pile.csv diff --git a/benchmark/amd7950x_sse2/convex_pile.csv b/benchmark/amd7950x_sse2/convex_pile.csv new file mode 100644 index 0000000..b1584e4 --- /dev/null +++ b/benchmark/amd7950x_sse2/convex_pile.csv @@ -0,0 +1,9 @@ +threads,ms +1,50240.2 +2,37216.3 +3,31420.6 +4,23466.2 +5,19266 +6,16078.2 +7,13874.8 +8,12405.8 diff --git a/benchmark/amd7950x_sse2/joint_grid.csv b/benchmark/amd7950x_sse2/joint_grid.csv index 01362c8..5dee352 100644 --- a/benchmark/amd7950x_sse2/joint_grid.csv +++ b/benchmark/amd7950x_sse2/joint_grid.csv @@ -1,9 +1,9 @@ threads,ms -1,1405.95 -2,771.262 -3,525.161 -4,396.555 -5,319.261 -6,273.429 -7,236.346 -8,212.377 +1,1488.56 +2,760.38 +3,512.213 +4,389.109 +5,316.481 +6,268.681 +7,234.538 +8,208.135 diff --git a/benchmark/amd7950x_sse2/junkyard.csv b/benchmark/amd7950x_sse2/junkyard.csv index 096c056..b6f3fd7 100644 --- a/benchmark/amd7950x_sse2/junkyard.csv +++ b/benchmark/amd7950x_sse2/junkyard.csv @@ -1,9 +1,9 @@ threads,ms -1,24484.3 -2,13666.7 -3,9769.51 -4,7573.72 -5,6165.49 -6,5234.91 -7,4569.35 -8,4096.21 +1,24363.8 +2,13463.4 +3,9229.2 +4,7110.22 +5,5784.18 +6,4952.28 +7,4305.77 +8,3859.87 diff --git a/benchmark/amd7950x_sse2/large_pyramid.csv b/benchmark/amd7950x_sse2/large_pyramid.csv index 19b651d..1ba6824 100644 --- a/benchmark/amd7950x_sse2/large_pyramid.csv +++ b/benchmark/amd7950x_sse2/large_pyramid.csv @@ -1,9 +1,9 @@ threads,ms -1,1776.98 -2,887.705 -3,611.107 -4,477.959 -5,393.24 -6,338.688 -7,301.258 -8,272.38 +1,2182.19 +2,1111.43 +3,770.761 +4,588.373 +5,487.242 +6,412.618 +7,361.125 +8,327.371 diff --git a/benchmark/amd7950x_sse2/large_world.csv b/benchmark/amd7950x_sse2/large_world.csv index cc2e0e8..f22c3aa 100644 --- a/benchmark/amd7950x_sse2/large_world.csv +++ b/benchmark/amd7950x_sse2/large_world.csv @@ -1,9 +1,9 @@ threads,ms -1,9.6721 -2,12.2776 -3,13.8174 -4,15.0718 -5,14.2408 -6,14.8061 -7,15.4252 -8,15.7804 +1,10.0177 +2,12.2186 +3,13.1469 +4,13.9029 +5,14.4534 +6,14.2852 +7,14.2133 +8,14.433 diff --git a/benchmark/amd7950x_sse2/many_pyramids.csv b/benchmark/amd7950x_sse2/many_pyramids.csv index a340236..dc673a0 100644 --- a/benchmark/amd7950x_sse2/many_pyramids.csv +++ b/benchmark/amd7950x_sse2/many_pyramids.csv @@ -1,9 +1,9 @@ threads,ms -1,2540.44 -2,1220.31 -3,813.901 -4,609.715 -5,497.305 -6,413.889 -7,361.679 -8,319.254 +1,2415.01 +2,1205.83 +3,797.971 +4,608.846 +5,493.836 +6,413.397 +7,352.727 +8,311.869 diff --git a/benchmark/amd7950x_sse2/rain.csv b/benchmark/amd7950x_sse2/rain.csv index 8684c76..32d2c9d 100644 --- a/benchmark/amd7950x_sse2/rain.csv +++ b/benchmark/amd7950x_sse2/rain.csv @@ -1,9 +1,9 @@ threads,ms -1,2314.36 -2,1306.31 -3,932.724 -4,735.735 -5,610.991 -6,529.984 -7,478.004 -8,442.816 +1,2295.15 +2,1266.67 +3,891.229 +4,705.264 +5,586.454 +6,511.619 +7,460.223 +8,424.157 diff --git a/benchmark/amd7950x_sse2/trees100.csv b/benchmark/amd7950x_sse2/trees100.csv index 29fac99..3006d9f 100644 --- a/benchmark/amd7950x_sse2/trees100.csv +++ b/benchmark/amd7950x_sse2/trees100.csv @@ -1,9 +1,9 @@ threads,ms -1,252.889 -2,159.521 -3,130.152 -4,114.981 -5,110.742 -6,98.8688 -7,99.0887 -8,99.0417 +1,209.402 +2,136.201 +3,109.042 +4,96.4747 +5,90.4057 +6,86.776 +7,84.5495 +8,82.5579 diff --git a/benchmark/amd7950x_sse2/trees25.csv b/benchmark/amd7950x_sse2/trees25.csv index 83313ef..f444483 100644 --- a/benchmark/amd7950x_sse2/trees25.csv +++ b/benchmark/amd7950x_sse2/trees25.csv @@ -1,9 +1,9 @@ threads,ms -1,816.219 -2,486.479 -3,371.869 -4,315.809 -5,282.72 -6,262.329 -7,252.624 -8,244.159 +1,717.735 +2,409.163 +3,304.326 +4,258.89 +5,234.893 +6,218.016 +7,206.416 +8,200.162 diff --git a/benchmark/amd7950x_sse2/trees50.csv b/benchmark/amd7950x_sse2/trees50.csv index 7b2874c..9feb624 100644 --- a/benchmark/amd7950x_sse2/trees50.csv +++ b/benchmark/amd7950x_sse2/trees50.csv @@ -1,9 +1,9 @@ threads,ms -1,334.239 -2,226.053 -3,182.466 -4,159.489 -5,149.676 -6,140.113 -7,132.326 -8,132.251 +1,325.527 +2,199.714 +3,152.192 +4,133.217 +5,123.004 +6,115.157 +7,111.613 +8,108.696 diff --git a/benchmark/amd7950x_sse2/washer.csv b/benchmark/amd7950x_sse2/washer.csv index 997ec05..9865102 100644 --- a/benchmark/amd7950x_sse2/washer.csv +++ b/benchmark/amd7950x_sse2/washer.csv @@ -1,9 +1,9 @@ threads,ms -1,30675.7 -2,16370.1 -3,11431 -4,8895.99 -5,7391.02 -6,6300.97 -7,5618.21 -8,5073.84 +1,27144.2 +2,14602.3 +3,10240.3 +4,8022.88 +5,6649.81 +6,5770.75 +7,5112.17 +8,4749.63 diff --git a/include/box3d/box3d.h b/include/box3d/box3d.h index 05b69dd..569117f 100644 --- a/include/box3d/box3d.h +++ b/include/box3d/box3d.h @@ -777,6 +777,7 @@ B3_API int b3Body_CollideMover( b3BodyId bodyId, b3BodyPlaneResult* bodyPlanes, * @defgroup shape Shape * Functions to create, destroy, and access. * Shapes bind raw geometry to bodies and hold material properties including friction and restitution. + * You may add multiple shapes to a single body. There are no hard limits on shape count per body. * @{ */ @@ -816,8 +817,10 @@ B3_API b3ShapeId b3CreateMeshShape( b3BodyId bodyId, const b3ShapeDef* def, cons /// @return the shape id for accessing the shape B3_API b3ShapeId b3CreateHeightFieldShape( b3BodyId bodyId, const b3ShapeDef* def, const b3HeightFieldData* heightField ); -/// Compound shapes are only allowed on static bodies. -B3_API b3ShapeId b3CreateCompoundShape( b3BodyId bodyId, b3ShapeDef* def, const b3CompoundData* compound ); +/// Baked compound shapes are only allowed on static bodies. +/// Note: runtime compounds are achieved by adding multiple shapes to a body. +/// Runtime compounds can be dynamic and/or kinematic. +B3_API b3ShapeId b3CreateBakedCompoundShape( b3BodyId bodyId, b3ShapeDef* def, const b3CompoundData* compound ); /// Destroy a shape. You may defer the body mass update which can improve performance if several shapes on a /// body are destroyed at once. diff --git a/include/box3d/types.h b/include/box3d/types.h index b0a8bb8..65918dc 100644 --- a/include/box3d/types.h +++ b/include/box3d/types.h @@ -2407,14 +2407,14 @@ typedef struct b3CompoundDef int sphereCount; } b3CompoundDef; -/// The compound version depends on the tree, mesh, and hull versions. +/// The baked compound version depends on the tree, mesh, and hull versions. #define B3_COMPOUND_VERSION ( 0x830778DB07086EB4ull ^ B3_DYNAMIC_TREE_VERSION ^ B3_MESH_VERSION ^ B3_HULL_VERSION ) /// Meshes used in compounds have limited space for materials. If you have /// a mesh with many materials, you can use it outside of the compound. #define B3_MAX_COMPOUND_MESH_MATERIALS 4 -/// The runtime data for a baked compound shape. This is a potentially large yet highly optimized +/// The data for a baked compound shape. This is a potentially large yet highly optimized /// data structure. It can contain thousands of child shapes, yet at runtime it populates /// into the world as a single shape in the runtime broad-phase. /// This data structure has data living off the end and must be accessed using offsets. diff --git a/samples/sample_compound.cpp b/samples/sample_compound.cpp index a994797..c7c6f95 100644 --- a/samples/sample_compound.cpp +++ b/samples/sample_compound.cpp @@ -51,7 +51,7 @@ public: b3BodyId groundId = b3CreateBody( m_worldId, &bodyDef ); b3ShapeDef shapeDef = b3DefaultShapeDef(); - (void)b3CreateCompoundShape( groundId, &shapeDef, m_compound ); + (void)b3CreateBakedCompoundShape( groundId, &shapeDef, m_compound ); } b3World_SetContactRecycleDistance( m_worldId, 0.0f ); @@ -138,7 +138,7 @@ public: b3BodyId groundId = b3CreateBody( m_worldId, &bodyDef ); b3ShapeDef shapeDef = b3DefaultShapeDef(); - (void)b3CreateCompoundShape( groundId, &shapeDef, m_compound ); + (void)b3CreateBakedCompoundShape( groundId, &shapeDef, m_compound ); } ~CompoundSpheres() override @@ -212,7 +212,7 @@ public: b3BodyId groundId = b3CreateBody( m_worldId, &bodyDef ); b3ShapeDef shapeDef = b3DefaultShapeDef(); - (void)b3CreateCompoundShape( groundId, &shapeDef, m_compound ); + (void)b3CreateBakedCompoundShape( groundId, &shapeDef, m_compound ); } ~CompoundHulls() override @@ -297,7 +297,7 @@ public: b3BodyId groundId = b3CreateBody( m_worldId, &bodyDef ); b3ShapeDef shapeDef = b3DefaultShapeDef(); - (void)b3CreateCompoundShape( groundId, &shapeDef, m_compound ); + (void)b3CreateBakedCompoundShape( groundId, &shapeDef, m_compound ); delete[] hulls; hulls = nullptr; @@ -420,7 +420,7 @@ public: b3BodyId groundId = b3CreateBody( m_worldId, &bodyDef ); b3ShapeDef shapeDef = b3DefaultShapeDef(); - (void)b3CreateCompoundShape( groundId, &shapeDef, m_compound ); + (void)b3CreateBakedCompoundShape( groundId, &shapeDef, m_compound ); } #if 0 @@ -650,7 +650,7 @@ public: b3BodyId groundId = b3CreateBody( m_worldId, &bodyDef ); b3ShapeDef shapeDef = b3DefaultShapeDef(); - (void)b3CreateCompoundShape( groundId, &shapeDef, m_compound ); + (void)b3CreateBakedCompoundShape( groundId, &shapeDef, m_compound ); delete[] capsules; capsules = nullptr; diff --git a/src/recording_replay.c b/src/recording_replay.c index 584912d..adf4ec8 100644 --- a/src/recording_replay.c +++ b/src/recording_replay.c @@ -1071,7 +1071,7 @@ static void b3RecDispatch_CreateCompoundShape( const b3RecArgs_CreateCompoundSha b3BodyId bodyId = b3RecMakeBodyId( rdr, a->body ); // b3CreateCompoundShape takes a non-const def pointer; cast away const for the scratch def b3ShapeDef shapeDef = a->def; - b3ShapeId gotId = b3CreateCompoundShape( bodyId, &shapeDef, compound ); + b3ShapeId gotId = b3CreateBakedCompoundShape( bodyId, &shapeDef, compound ); b3RecCheckShapeId( rdr, gotId, recId ); } diff --git a/src/shape.c b/src/shape.c index e4d9d9e..61c14d1 100644 --- a/src/shape.c +++ b/src/shape.c @@ -424,7 +424,7 @@ b3ShapeId b3CreateHeightFieldShape( b3BodyId bodyId, const b3ShapeDef* def, cons return shapeId; } -b3ShapeId b3CreateCompoundShape( b3BodyId bodyId, b3ShapeDef* def, const b3CompoundData* compound ) +b3ShapeId b3CreateBakedCompoundShape( b3BodyId bodyId, b3ShapeDef* def, const b3CompoundData* compound ) { b3ShapeId shapeId = b3CreateShape( bodyId, def, compound, b3_compoundShape, b3Transform_identity, b3Vec3_one, false ); if ( shapeId.index1 != 0 ) diff --git a/test/test_recording.c b/test/test_recording.c index d00c7a2..e877f3a 100644 --- a/test/test_recording.c +++ b/test/test_recording.c @@ -1144,7 +1144,7 @@ static int AllOps( void ) b3CompoundData* compound = b3CreateCompound( &compoundDef ); ENSURE( compound != NULL ); b3ShapeDef compoundShapeDef = b3DefaultShapeDef(); - b3CreateCompoundShape( compoundBodyId, &compoundShapeDef, compound ); + b3CreateBakedCompoundShape( compoundBodyId, &compoundShapeDef, compound ); // Throwaway shape to exercise DestroyShape b3Sphere tmpSphere = { { 0.0f, 0.0f, 0.0f }, 0.1f }; diff --git a/test/test_world.c b/test/test_world.c index b4abd19..a94070e 100644 --- a/test/test_world.c +++ b/test/test_world.c @@ -570,7 +570,7 @@ static int TestCompoundHitEvents( void ) bodyDef.type = b3_staticBody; b3BodyId compoundBodyId = b3CreateBody( worldId, &bodyDef ); b3ShapeDef compoundShapeDef = b3DefaultShapeDef(); - b3CreateCompoundShape( compoundBodyId, &compoundShapeDef, compound ); + b3CreateBakedCompoundShape( compoundBodyId, &compoundShapeDef, compound ); // Sphere driven straight down onto the chosen child bodyDef = b3DefaultBodyDef();