Remove utterly useless multithreading switch

Since we're using OpenGL, everything has to be done in the same thread anyways. Besides that, the actual "multithreading" implementation was basically starting an empty thread that did absolutely nothing, then wait synchronously for it to complete and join it on the next frame.
This commit is contained in:
Kai Blaschke
2024-02-01 19:03:21 +01:00
parent 184766b2c8
commit 27f3308ac3
7 changed files with 1 additions and 170 deletions

View File

@ -32,27 +32,17 @@
#include "Renderer/TextureManager.hpp"
#include "Renderer/TransitionShaderManager.hpp"
#if PROJECTM_USE_THREADS
#include "libprojectM/BackgroundWorker.hpp"
#endif
namespace libprojectM {
ProjectM::ProjectM()
: m_presetFactoryManager(std::make_unique<PresetFactoryManager>())
#if PROJECTM_USE_THREADS
, m_workerSync(std::make_unique<BackgroundWorkerSync>())
#endif
{
Initialize();
}
ProjectM::~ProjectM()
{
#if PROJECTM_USE_THREADS
m_workerSync->FinishUp();
m_workerThread.join();
#endif
// Can't use "=default" in the header due to unique_ptr requiring the actual type declarations.
}
void ProjectM::PresetSwitchRequestedEvent(bool) const
@ -113,22 +103,6 @@ void ProjectM::ResetTextures()
m_textureManager = std::make_unique<Renderer::TextureManager>(m_textureSearchPaths);
}
#if PROJECTM_USE_THREADS
void ProjectM::ThreadWorker()
{
while (true)
{
if (!m_workerSync->WaitForWork())
{
return;
}
m_workerSync->FinishedWork();
}
}
#endif
void ProjectM::RenderFrame()
{
// Don't render if window area is zero.
@ -137,10 +111,6 @@ void ProjectM::RenderFrame()
return;
}
#if PROJECTM_USE_THREADS
std::lock_guard<std::recursive_mutex> guard(m_presetSwitchMutex);
#endif
// Update FPS and other timer values.
m_timeKeeper->UpdateTimers();
@ -181,12 +151,6 @@ void ProjectM::RenderFrame()
if (m_timeKeeper->IsSmoothing() && m_transitioningPreset != nullptr)
{
#if PROJECTM_USE_THREADS
m_workerSync->WakeUpBackgroundTask();
// FIXME: Instead of waiting after a single render pass, check every frame if it's done.
m_workerSync->WaitForBackgroundTaskToFinish();
#endif
// ToDo: check if new preset is loaded.
if (m_timeKeeper->SmoothRatio() >= 1.0)
@ -256,11 +220,6 @@ void ProjectM::Initialize()
LoadIdlePreset();
#if PROJECTM_USE_THREADS
m_workerSync->Reset();
m_workerThread = std::thread(&ProjectM::ThreadWorker, this);
#endif
m_timeKeeper->StartPreset();
}