diff --git a/filament/src/Scene.cpp b/filament/src/Scene.cpp index 541af9a74e..a9337bc3f3 100644 --- a/filament/src/Scene.cpp +++ b/filament/src/Scene.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,8 @@ void FScene::prepare(const mat4f& worldOriginTransform) { // TODO: can we skip this in most cases? Since we rely on indices staying the same, // we could only skip, if nothing changed in the RCM. + SYSTRACE_CALL(); + FEngine& engine = mEngine; EntityManager& em = engine.getEntityManager(); FRenderableManager& rcm = engine.getRenderableManager(); diff --git a/filament/src/ShadowMap.cpp b/filament/src/ShadowMap.cpp index 36e1f9f666..36594dd7af 100644 --- a/filament/src/ShadowMap.cpp +++ b/filament/src/ShadowMap.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -1061,6 +1062,8 @@ float ShadowMap::texelSizeWorldSpace(const mat4f& Wp, const mat4f& MbMtF) const template void ShadowMap::visitScene(const FScene& scene, uint32_t visibleLayers, Casters casters, Receivers receivers) noexcept { + SYSTRACE_CALL(); + using State = FRenderableManager::Visibility; FScene::RenderableSoa const& UTILS_RESTRICT soa = scene.getRenderableData(); float3 const* const UTILS_RESTRICT worldAABBCenter = soa.data(); diff --git a/filament/src/View.cpp b/filament/src/View.cpp index 473193a4b0..016c306ea5 100644 --- a/filament/src/View.cpp +++ b/filament/src/View.cpp @@ -743,6 +743,7 @@ void FView::prepareVisibleRenderables(JobSystem& js, void FView::cullRenderables(JobSystem& js, FScene::RenderableSoa& renderableData, Frustum const& frustum, size_t bit) noexcept { + SYSTRACE_CALL(); float3 const* worldAABBCenter = renderableData.data(); float3 const* worldAABBExtent = renderableData.data(); diff --git a/libs/utils/include/utils/JobSystem.h b/libs/utils/include/utils/JobSystem.h index 31382bad6f..241d69922c 100644 --- a/libs/utils/include/utils/JobSystem.h +++ b/libs/utils/include/utils/JobSystem.h @@ -470,6 +470,7 @@ struct ParallelForJobData { } void parallelWithJobs(JobSystem& js, JobSystem::Job* parent) noexcept { + assert(parent); // We first split about the number of threads we have, and only then we split the rest // in a single thread (but execute the final cut in new jobs, see parallel() below), diff --git a/libs/utils/src/JobSystem.cpp b/libs/utils/src/JobSystem.cpp index fc2b8cfe48..46c719b6b2 100644 --- a/libs/utils/src/JobSystem.cpp +++ b/libs/utils/src/JobSystem.cpp @@ -253,8 +253,13 @@ void JobSystem::wake() noexcept { lock.lock(); // this empty critical section is needed -- it guarantees that notifiy_all() happens // after the condition variables are set. - lock.unlock(); + + // We signal the condition inside the lock (which is not required), because this seems to + // yield to better scheduling on Android. When we signal outside the critical section, + // it looks like this thread gives its time slice to the waking thread and just sits there + // being runnable, but not running. mWaiterCondition.notify_all(); + lock.unlock(); } inline JobSystem::ThreadState& JobSystem::getState() noexcept {