Commit b7ea984f by Nicolas Capens

Move the code generation mutex to Reactor.

Generation of the routines for copying surfaces and blitting were not protected by the same critical section as the renderer. Change-Id: I10eb386bdeebb04abc999b3313dc2c3b52adc090 Reviewed-on: https://swiftshader-review.googlesource.com/2772Tested-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 447ad838
...@@ -66,6 +66,7 @@ namespace sw ...@@ -66,6 +66,7 @@ namespace sw
LLVMContext *Nucleus::context = 0; LLVMContext *Nucleus::context = 0;
Module *Nucleus::module = 0; Module *Nucleus::module = 0;
llvm::Function *Nucleus::function = 0; llvm::Function *Nucleus::function = 0;
BackoffLock Nucleus::codegenMutex;
class Builder : public IRBuilder<> class Builder : public IRBuilder<>
{ {
...@@ -73,6 +74,8 @@ namespace sw ...@@ -73,6 +74,8 @@ namespace sw
Nucleus::Nucleus() Nucleus::Nucleus()
{ {
codegenMutex.lock(); // Reactor and LLVM are currently not thread safe
InitializeNativeTarget(); InitializeNativeTarget();
JITEmitDebugInfo = false; JITEmitDebugInfo = false;
...@@ -129,6 +132,8 @@ namespace sw ...@@ -129,6 +132,8 @@ namespace sw
routineManager = 0; routineManager = 0;
function = 0; function = 0;
module = 0; module = 0;
codegenMutex.unlock();
} }
Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations) Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations)
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define sw_Nucleus_hpp #define sw_Nucleus_hpp
#include "Common/Types.hpp" #include "Common/Types.hpp"
#include "Common/MutexLock.hpp"
#include <stdarg.h> #include <stdarg.h>
#include <vector> #include <vector>
...@@ -218,6 +219,8 @@ namespace sw ...@@ -218,6 +219,8 @@ namespace sw
static llvm::LLVMContext *context; static llvm::LLVMContext *context;
static llvm::Module *module; static llvm::Module *module;
static RoutineManager *routineManager; static RoutineManager *routineManager;
static BackoffLock codegenMutex;
}; };
class Byte; class Byte;
......
...@@ -69,8 +69,6 @@ namespace sw ...@@ -69,8 +69,6 @@ namespace sw
TranscendentalPrecision rsqPrecision = ACCURATE; TranscendentalPrecision rsqPrecision = ACCURATE;
bool perspectiveCorrection = true; bool perspectiveCorrection = true;
BackoffLock Renderer::codegenMutex;
struct Parameters struct Parameters
{ {
Renderer *renderer; Renderer *renderer;
...@@ -232,13 +230,9 @@ namespace sw ...@@ -232,13 +230,9 @@ namespace sw
setupState = SetupProcessor::update(); setupState = SetupProcessor::update();
pixelState = PixelProcessor::update(); pixelState = PixelProcessor::update();
codegenMutex.lock();
vertexRoutine = VertexProcessor::routine(vertexState); vertexRoutine = VertexProcessor::routine(vertexState);
setupRoutine = SetupProcessor::routine(setupState); setupRoutine = SetupProcessor::routine(setupState);
pixelRoutine = PixelProcessor::routine(pixelState); pixelRoutine = PixelProcessor::routine(pixelState);
codegenMutex.unlock();
} }
int batch = batchSize / ms; int batch = batchSize / ms;
......
...@@ -404,7 +404,6 @@ namespace sw ...@@ -404,7 +404,6 @@ namespace sw
unsigned int qSize; unsigned int qSize;
BackoffLock schedulerMutex; BackoffLock schedulerMutex;
static BackoffLock codegenMutex;
#if PERF_HUD #if PERF_HUD
int64_t vertexTime[16]; int64_t vertexTime[16];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment