From 92b722e0eee7dcc10f228154dfbcf48ee549bce9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 8 Dec 2018 11:56:31 +0100 Subject: [PATCH] - don't put mutexes into static local variables. Their initialization semantics are not safe for synchronization objects. --- src/polyrenderer/poly_renderthread.cpp | 6 ++---- src/swrenderer/r_renderthread.cpp | 6 ++---- src/swrenderer/r_swcolormaps.cpp | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/polyrenderer/poly_renderthread.cpp b/src/polyrenderer/poly_renderthread.cpp index 7febb4bb7..22900c17a 100644 --- a/src/polyrenderer/poly_renderthread.cpp +++ b/src/polyrenderer/poly_renderthread.cpp @@ -74,6 +74,7 @@ void PolyRenderThread::FlushDrawQueue() } } +static std::mutex loadmutex; void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) { if (texture == nullptr) @@ -87,8 +88,6 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) // It is critical that this function is called before any direct // calls to GetPixels for this to work. - static std::mutex loadmutex; - std::unique_lock lock(loadmutex); texture->GetPixels(style); @@ -101,10 +100,9 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) } } +static std::mutex polyobjmutex; void PolyRenderThread::PreparePolyObject(subsector_t *sub) { - static std::mutex polyobjmutex; - std::unique_lock lock(polyobjmutex); if (sub->BSP == nullptr || sub->BSP->bDirty) diff --git a/src/swrenderer/r_renderthread.cpp b/src/swrenderer/r_renderthread.cpp index 986879618..90a0792ea 100644 --- a/src/swrenderer/r_renderthread.cpp +++ b/src/swrenderer/r_renderthread.cpp @@ -89,6 +89,7 @@ namespace swrenderer return pal_drawers.get(); } + static std::mutex loadmutex; void RenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) { if (texture == nullptr) @@ -102,8 +103,6 @@ namespace swrenderer // It is critical that this function is called before any direct // calls to GetPixels for this to work. - static std::mutex loadmutex; - std::unique_lock lock(loadmutex); texture->GetPixels(style); @@ -116,10 +115,9 @@ namespace swrenderer } } + static std::mutex polyobjmutex; void RenderThread::PreparePolyObject(subsector_t *sub) { - static std::mutex polyobjmutex; - std::unique_lock lock(polyobjmutex); if (sub->BSP == nullptr || sub->BSP->bDirty) diff --git a/src/swrenderer/r_swcolormaps.cpp b/src/swrenderer/r_swcolormaps.cpp index 13c66706b..d5b374ad1 100644 --- a/src/swrenderer/r_swcolormaps.cpp +++ b/src/swrenderer/r_swcolormaps.cpp @@ -70,12 +70,12 @@ TArray SpecialSWColormaps; // Colored Lighting Stuffs // //========================================================================== +static std::mutex buildmapmutex; static FDynamicColormap *CreateSpecialLights (PalEntry color, PalEntry fade, int desaturate) { // GetSpecialLights is called by the scene worker threads. // If we didn't find the colormap, search again, but this time one thread at a time - static std::mutex buildmapmutex; std::unique_lock lock(buildmapmutex); // If this colormap has already been created, just return it