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
LLVMContext *Nucleus::context = 0;
Module *Nucleus::module = 0;
llvm::Function *Nucleus::function = 0;
BackoffLock Nucleus::codegenMutex;
class Builder : public IRBuilder<>
{
......@@ -73,6 +74,8 @@ namespace sw
Nucleus::Nucleus()
{
codegenMutex.lock(); // Reactor and LLVM are currently not thread safe
InitializeNativeTarget();
JITEmitDebugInfo = false;
......@@ -129,6 +132,8 @@ namespace sw
routineManager = 0;
function = 0;
module = 0;
codegenMutex.unlock();
}
Routine *Nucleus::acquireRoutine(const wchar_t *name, bool runOptimizations)
......
......@@ -13,6 +13,7 @@
#define sw_Nucleus_hpp
#include "Common/Types.hpp"
#include "Common/MutexLock.hpp"
#include <stdarg.h>
#include <vector>
......@@ -218,6 +219,8 @@ namespace sw
static llvm::LLVMContext *context;
static llvm::Module *module;
static RoutineManager *routineManager;
static BackoffLock codegenMutex;
};
class Byte;
......
......@@ -69,8 +69,6 @@ namespace sw
TranscendentalPrecision rsqPrecision = ACCURATE;
bool perspectiveCorrection = true;
BackoffLock Renderer::codegenMutex;
struct Parameters
{
Renderer *renderer;
......@@ -232,13 +230,9 @@ namespace sw
setupState = SetupProcessor::update();
pixelState = PixelProcessor::update();
codegenMutex.lock();
vertexRoutine = VertexProcessor::routine(vertexState);
setupRoutine = SetupProcessor::routine(setupState);
pixelRoutine = PixelProcessor::routine(pixelState);
codegenMutex.unlock();
}
int batch = batchSize / ms;
......
......@@ -404,7 +404,6 @@ namespace sw
unsigned int qSize;
BackoffLock schedulerMutex;
static BackoffLock codegenMutex;
#if PERF_HUD
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