Improve multi-threading and move Standalone to a multi-threading model (currently off though).

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22565 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich
2013-07-31 18:44:13 +00:00
parent b40a488e89
commit 2b07c7e70a
21 changed files with 402 additions and 203 deletions

View File

@@ -92,7 +92,7 @@ typedef pool_allocator<char> TStringAllocator;
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
inline TString* NewPoolTString(const char* s)
{
void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
void* memory = GetThreadPoolAllocator().allocate(sizeof(TString));
return new(memory) TString(s);
}

View File

@@ -41,7 +41,7 @@
class constUnion {
public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
void setIConst(int i)
{
iConst = i;

View File

@@ -144,7 +144,7 @@ private:
//
class TPoolAllocator {
public:
TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16);
TPoolAllocator(int growthIncrement = 8*1024, int allocationAlignment = 16);
//
// Don't call the destructor just to free up the memory, call pop()
@@ -222,7 +222,6 @@ protected:
return TAllocation::offsetAllocation(memory);
}
bool global; // should be true if this object is globally scoped
size_t pageSize; // granularity of allocation from the OS
size_t alignment; // all returned allocations will be aligned at
// this granularity, which will be a power of 2
@@ -249,16 +248,14 @@ private:
// with everyone using the same global allocator.
//
typedef TPoolAllocator* PoolAllocatorPointer;
extern TPoolAllocator& GetGlobalPoolAllocator();
#define GlobalPoolAllocator GetGlobalPoolAllocator()
extern TPoolAllocator& GetThreadPoolAllocator();
struct TThreadGlobalPools
{
TPoolAllocator* globalPoolAllocator;
};
void SetGlobalPoolAllocatorPtr(TPoolAllocator& poolAllocator);
void SetThreadPoolAllocator(TPoolAllocator& poolAllocator);
//
// This STL compatible allocator is intended to be used as the allocator
@@ -284,7 +281,7 @@ public:
pointer address(reference x) const { return &x; }
const_pointer address(const_reference x) const { return &x; }
pool_allocator() : allocator(GlobalPoolAllocator) { }
pool_allocator() : allocator(GetThreadPoolAllocator()) { }
pool_allocator(TPoolAllocator& a) : allocator(a) { }
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }

View File

@@ -150,7 +150,7 @@ typedef TVector<TTypeLoc> TTypeList;
inline TTypeList* NewPoolTTypeList()
{
void* memory = GlobalPoolAllocator.allocate(sizeof(TTypeList));
void* memory = GetThreadPoolAllocator().allocate(sizeof(TTypeList));
return new(memory) TTypeList;
}
@@ -158,7 +158,7 @@ typedef TVector<TString*> TIdentifierList;
inline TIdentifierList* NewPoolTIdentifierList()
{
void* memory = GlobalPoolAllocator.allocate(sizeof(TIdentifierList));
void* memory = GetThreadPoolAllocator().allocate(sizeof(TIdentifierList));
return new(memory) TIdentifierList;
}
@@ -176,7 +176,7 @@ typedef TVector<int>* TArraySizes;
inline TArraySizes NewPoolTArraySizes()
{
void* memory = GlobalPoolAllocator.allocate(sizeof(TVector<int>));
void* memory = GetThreadPoolAllocator().allocate(sizeof(TVector<int>));
return new(memory) TVector<int>;
}
@@ -401,7 +401,7 @@ typedef std::map<TTypeList*, TTypeList*>::const_iterator TStructureMapIterator;
//
class TType {
public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
explicit TType(TBasicType t, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0) :
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(0),
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0),

View File

@@ -318,7 +318,7 @@ class TInfoSink;
//
class TIntermNode {
public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TIntermNode() { loc.line = 0; loc.string = 0; }
virtual TSourceLoc getLoc() const { return loc; }
@@ -601,7 +601,7 @@ protected:
//
class TIntermTraverser {
public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TIntermTraverser() :
visitSymbol(0),