Commit ebe67649 by Nicolas Capens

Add a critical section for dynamic code generation.

Bug 19864302 Change-Id: Iaca49fa72146ff35b6f1e5e40ade5cd2c5c48d0e Reviewed-on: https://swiftshader-review.googlesource.com/2657Reviewed-by: 's avatarGreg Hartman <ghartman@google.com> Tested-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 8b5b5129
...@@ -69,6 +69,8 @@ namespace sw ...@@ -69,6 +69,8 @@ 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;
...@@ -230,9 +232,13 @@ namespace sw ...@@ -230,9 +232,13 @@ 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;
...@@ -593,9 +599,9 @@ namespace sw ...@@ -593,9 +599,9 @@ namespace sw
draw->references = (count + batch - 1) / batch; draw->references = (count + batch - 1) / batch;
mutex.lock(); schedulerMutex.lock();
nextDraw++; nextDraw++;
mutex.unlock(); schedulerMutex.unlock();
if(!threadsAwake) if(!threadsAwake)
{ {
...@@ -726,7 +732,7 @@ namespace sw ...@@ -726,7 +732,7 @@ namespace sw
void Renderer::scheduleTask(int threadIndex) void Renderer::scheduleTask(int threadIndex)
{ {
mutex.lock(); schedulerMutex.lock();
if((int)qSize < threadCount - threadsAwake + 1) if((int)qSize < threadCount - threadsAwake + 1)
{ {
...@@ -763,7 +769,7 @@ namespace sw ...@@ -763,7 +769,7 @@ namespace sw
threadsAwake--; threadsAwake--;
} }
mutex.unlock(); schedulerMutex.unlock();
} }
void Renderer::executeTask(int threadIndex) void Renderer::executeTask(int threadIndex)
......
...@@ -403,7 +403,8 @@ namespace sw ...@@ -403,7 +403,8 @@ namespace sw
unsigned int qHead; unsigned int qHead;
unsigned int qSize; unsigned int qSize;
BackoffLock mutex; 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