diff --git a/filament/benchmark/README.md b/filament/benchmark/README.md index 7caab6eb03..01b6259955 100644 --- a/filament/benchmark/README.md +++ b/filament/benchmark/README.md @@ -6,18 +6,36 @@ ## Running the benchmark -`adb shell /data/local/tmp/benchmark_filament` +`adb shell /data/local/tmp/benchmark_filament --benchmark_counters_tabular=true` ## Benchmark results +### Macbook Pro M1 Pro +``` +-------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations items_per_second +-------------------------------------------------------------------------------------- +FilamentCullingFixture/boxCulling 702 ns 702 ns 819874 729.274M/s +FilamentCullingFixture/sphereCulling 485 ns 485 ns 1430396 1054.82M/s +``` + +### Pixel 8 Pro +``` +---------------------------------------------------------------------------------------------------------------------------------- +Benchmark Time CPU Iterations BPU C CPI I items_per_second +---------------------------------------------------------------------------------------------------------------------------------- +FilamentCullingFixture/boxCulling 1212 ns 1208 ns 578797 0 6.87234 0.328354 20.9297 423.884M/s +FilamentCullingFixture/sphereCulling 748 ns 745 ns 938377 0 4.24185 0.39125 10.8418 686.839M/s +``` + ### Galaxy S20+ ``` ---------------------------------------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations BPU C CPI I items_per_second ---------------------------------------------------------------------------------------------------------------------------------- -FilamentFixture/boxCulling 1695 ns 1688 ns 414849 0 9.35888 0.422963 22.127 303.397M/s -FilamentFixture/sphereCulling 1160 ns 1147 ns 610602 0 6.35746 0.526617 12.0723 446.543M/s +FilamentCullingFixture/boxCulling 1695 ns 1688 ns 414849 0 9.35888 0.422963 22.127 303.397M/s +FilamentCullingFixture/sphereCulling 1160 ns 1147 ns 610602 0 6.35746 0.526617 12.0723 446.543M/s ``` ### Pixel 4 @@ -25,6 +43,7 @@ FilamentFixture/sphereCulling 1160 ns 1147 ns 610602 0 ---------------------------------------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations BPU C CPI I items_per_second ---------------------------------------------------------------------------------------------------------------------------------- -FilamentFixture/boxCulling 2114 ns 2106 ns 332395 0 9.93665 0.449074 22.127 243.169M/s -FilamentFixture/sphereCulling 1407 ns 1402 ns 497755 0 6.61423 0.547886 12.0723 365.3M/s +FilamentCullingFixture/boxCulling 2114 ns 2106 ns 332395 0 9.93665 0.449074 22.127 243.169M/s +FilamentCullingFixture/sphereCulling 1407 ns 1402 ns 497755 0 6.61423 0.547886 12.0723 365.3M/s ``` + diff --git a/filament/benchmark/benchmark_filament.cpp b/filament/benchmark/benchmark_filament.cpp index 3a2e6031a1..d323beed00 100644 --- a/filament/benchmark/benchmark_filament.cpp +++ b/filament/benchmark/benchmark_filament.cpp @@ -33,7 +33,7 @@ using namespace filament::math; using namespace utils; -class FilamentFixture : public benchmark::Fixture { +class FilamentCullingFixture : public benchmark::Fixture { protected: static constexpr size_t BATCH_SIZE = 512; @@ -45,7 +45,7 @@ protected: public: - FilamentFixture() { + FilamentCullingFixture() { std::default_random_engine gen; // NOLINT std::uniform_real_distribution rand(-100.0f, 100.0f); @@ -75,12 +75,12 @@ public: visibles = (Culler::result_type*)utils::aligned_alloc(batch * sizeof(*visibles), 32); } - ~FilamentFixture() override { + ~FilamentCullingFixture() override { utils::aligned_free(visibles); } }; -BENCHMARK_F(FilamentFixture, boxCulling)(benchmark::State& state) { +BENCHMARK_F(FilamentCullingFixture, boxCulling)(benchmark::State& state) { { PerformanceCounters pc(state); for (auto _ : state) { @@ -92,7 +92,7 @@ BENCHMARK_F(FilamentFixture, boxCulling)(benchmark::State& state) { } } -BENCHMARK_F(FilamentFixture, sphereCulling)(benchmark::State& state) { +BENCHMARK_F(FilamentCullingFixture, sphereCulling)(benchmark::State& state) { { PerformanceCounters pc(state); for (auto _ : state) { diff --git a/libs/utils/src/EntityManager.cpp b/libs/utils/src/EntityManager.cpp index 733eb4ec72..30149c68ad 100644 --- a/libs/utils/src/EntityManager.cpp +++ b/libs/utils/src/EntityManager.cpp @@ -18,6 +18,8 @@ #include "EntityManagerImpl.h" +#include + namespace utils { EntityManager::EntityManager() @@ -34,8 +36,8 @@ EntityManager::Listener::~Listener() noexcept = default; EntityManager& EntityManager::get() noexcept { // note: we leak the EntityManager because it's more important that it survives everything else - // the leak is really not a problem because the process is terminating anyways. - static EntityManagerImpl* instance = new EntityManagerImpl; + // the leak is really not a problem because the process is terminating anyway. + static EntityManagerImpl* instance = new(std::nothrow) EntityManagerImpl; return *instance; } diff --git a/libs/utils/src/EntityManagerImpl.h b/libs/utils/src/EntityManagerImpl.h index e9c7ef1699..bfda7dbe25 100644 --- a/libs/utils/src/EntityManagerImpl.h +++ b/libs/utils/src/EntityManagerImpl.h @@ -55,7 +55,7 @@ public: uint8_t* const gens = mGens; // this must be thread-safe, acquire the free-list mutex - std::lock_guard lock(mFreeListLock); + std::lock_guard const lock(mFreeListLock); Entity::Type currentIndex = mCurrentIndex; for (size_t i = 0; i < n; i++) { // If we have more than a certain number of freed indices, get one from the list. @@ -106,7 +106,7 @@ public: // against it. We don't guarantee anything about external state -- e.g. the listeners // will be called. if (isAlive(entities[i])) { - Entity::Type index = getIndex(entities[i]); + Entity::Type const index = getIndex(entities[i]); freeList.push_back(index); // The generation update doesn't require the lock because it's only used for isAlive() @@ -130,12 +130,12 @@ public: } void registerListener(EntityManager::Listener* l) noexcept { - std::lock_guard lock(mListenerLock); + std::lock_guard const lock(mListenerLock); mListeners.insert(l); } void unregisterListener(EntityManager::Listener* l) noexcept { - std::lock_guard lock(mListenerLock); + std::lock_guard const lock(mListenerLock); mListeners.erase(l); } @@ -160,7 +160,7 @@ public: private: utils::FixedCapacityVector getListeners() const noexcept { - std::lock_guard lock(mListenerLock); + std::lock_guard const lock(mListenerLock); tsl::robin_set const& listeners = mListeners; utils::FixedCapacityVector result(listeners.size()); result.resize(result.capacity()); // unfortunately this memset()