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
TranscendentalPrecision rsqPrecision = ACCURATE;
bool perspectiveCorrection = true;
BackoffLock Renderer::codegenMutex;
struct Parameters
{
Renderer *renderer;
......@@ -230,9 +232,13 @@ 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;
......@@ -593,9 +599,9 @@ namespace sw
draw->references = (count + batch - 1) / batch;
mutex.lock();
schedulerMutex.lock();
nextDraw++;
mutex.unlock();
schedulerMutex.unlock();
if(!threadsAwake)
{
......@@ -726,7 +732,7 @@ namespace sw
void Renderer::scheduleTask(int threadIndex)
{
mutex.lock();
schedulerMutex.lock();
if((int)qSize < threadCount - threadsAwake + 1)
{
......@@ -763,7 +769,7 @@ namespace sw
threadsAwake--;
}
mutex.unlock();
schedulerMutex.unlock();
}
void Renderer::executeTask(int threadIndex)
......
......@@ -403,7 +403,8 @@ namespace sw
unsigned int qHead;
unsigned int qSize;
BackoffLock mutex;
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