Commit 20c6f342 by Nicolas Capens

Create a global and thread-safe Blitter.

Bug 21716622 Change-Id: I090154cdfbb6f8781df578b3f493d3ecd297c847 Reviewed-on: https://swiftshader-review.googlesource.com/3437Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 130c27a3
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
namespace sw namespace sw
{ {
Blitter blitter;
Blitter::Blitter() Blitter::Blitter()
{ {
blitCache = new RoutineCache<BlitState>(1024); blitCache = new RoutineCache<BlitState>(1024);
...@@ -400,6 +402,7 @@ namespace sw ...@@ -400,6 +402,7 @@ namespace sw
state.destFormat = dest->getInternalFormat(); state.destFormat = dest->getInternalFormat();
state.filter = filter; state.filter = filter;
criticalSection.lock();
Routine *blitRoutine = blitCache->query(state); Routine *blitRoutine = blitCache->query(state);
if(!blitRoutine) if(!blitRoutine)
...@@ -408,12 +411,15 @@ namespace sw ...@@ -408,12 +411,15 @@ namespace sw
if(!blitRoutine) if(!blitRoutine)
{ {
criticalSection.unlock();
return false; return false;
} }
blitCache->add(state, blitRoutine); blitCache->add(state, blitRoutine);
} }
criticalSection.unlock();
void (*blitFunction)(const BlitData *data) = (void(*)(const BlitData*))blitRoutine->getEntry(); void (*blitFunction)(const BlitData *data) = (void(*)(const BlitData*))blitRoutine->getEntry();
BlitData data; BlitData data;
......
...@@ -69,7 +69,10 @@ namespace sw ...@@ -69,7 +69,10 @@ namespace sw
Routine *generate(BlitState &state); Routine *generate(BlitState &state);
RoutineCache<BlitState> *blitCache; RoutineCache<BlitState> *blitCache;
BackoffLock criticalSection;
}; };
extern Blitter blitter;
} }
#endif // sw_Blitter_hpp #endif // sw_Blitter_hpp
...@@ -442,8 +442,6 @@ namespace sw ...@@ -442,8 +442,6 @@ namespace sw
VertexProcessor::State vertexState; VertexProcessor::State vertexState;
SetupProcessor::State setupState; SetupProcessor::State setupState;
PixelProcessor::State pixelState; PixelProcessor::State pixelState;
Blitter blitter;
}; };
} }
......
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