Rationalize naming/access to current thread-local-storage scheme. However, the preprocessor tokenizer is not thread-safe, so this may all change.
Also adding missing test. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22249 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
1fde51d3fb
commit
73ed17a87b
10 changed files with 48 additions and 21 deletions
|
|
@ -2038,10 +2038,10 @@ bool InitializeParseContextIndex()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool InitializeGlobalParseContext()
|
||||
bool InitializeThreadParseContext()
|
||||
{
|
||||
if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "InitializeGlobalParseContext(): Parse Context index not initialized");
|
||||
assert(0 && "InitializeThreadParseContext(): Parse Context index not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2053,7 +2053,7 @@ bool InitializeGlobalParseContext()
|
|||
|
||||
TThreadParseContext *lpThreadData = new TThreadParseContext();
|
||||
if (lpThreadData == 0) {
|
||||
assert(0 && "InitializeGlobalParseContext(): Unable to create thread parse context");
|
||||
assert(0 && "InitializeThreadParseContext(): Unable to create thread parse context");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2063,7 +2063,7 @@ bool InitializeGlobalParseContext()
|
|||
return true;
|
||||
}
|
||||
|
||||
TParseContextPointer& GetGlobalParseContext()
|
||||
TParseContextPointer& ThreadLocalParseContext()
|
||||
{
|
||||
//
|
||||
// Minimal error checking for speed
|
||||
|
|
|
|||
|
|
@ -185,8 +185,7 @@ int PaParseComment(int &lineno, TParseContext&);
|
|||
void ResetFlex();
|
||||
|
||||
typedef TParseContext* TParseContextPointer;
|
||||
extern TParseContextPointer& GetGlobalParseContext();
|
||||
#define GlobalParseContext GetGlobalParseContext()
|
||||
TParseContextPointer& ThreadLocalParseContext();
|
||||
|
||||
typedef struct TThreadParseContextRec
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
|
|||
|
||||
TParseContext parseContext(*symbolTable, intermediate, true, version, profile, language, infoSink);
|
||||
|
||||
GlobalParseContext = &parseContext;
|
||||
ThreadLocalParseContext() = &parseContext;
|
||||
|
||||
assert(symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
|
||||
|
||||
|
|
@ -259,15 +259,14 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile)
|
|||
|
||||
}; // end anonymous namespace for local functions
|
||||
|
||||
//
|
||||
// ShInitialize() should be called exactly once per process, not per thread.
|
||||
//
|
||||
int ShInitialize()
|
||||
{
|
||||
if (! InitProcess())
|
||||
return 0;
|
||||
|
||||
// TODO: Quality: Thread safety:
|
||||
// This method should be called once per process. If it's called by multiple threads, then
|
||||
// we need to have thread synchronization code around the initialization of per process
|
||||
// global pool allocator
|
||||
if (! PerProcessGPA) {
|
||||
PerProcessGPA = new TPoolAllocator(true);
|
||||
}
|
||||
|
|
@ -422,7 +421,7 @@ int ShCompile(
|
|||
else if (profile == EEsProfile && version >= 300 && versionNotFirst)
|
||||
parseContext.error(1, "statement must appear first in ESSL shader; before comments or newlines", "#version", "");
|
||||
|
||||
GlobalParseContext = &parseContext;
|
||||
ThreadLocalParseContext() = &parseContext;
|
||||
|
||||
ResetFlex();
|
||||
InitPreprocessor();
|
||||
|
|
|
|||
|
|
@ -724,14 +724,14 @@ void yyerror(const char *s)
|
|||
|
||||
if (pc.AfterEOF) {
|
||||
if (cpp->tokensBeforeEOF == 1)
|
||||
GlobalParseContext->error(yylineno, "", "pre-mature EOF", s, "");
|
||||
ThreadLocalParseContext()->error(yylineno, "", "pre-mature EOF", s, "");
|
||||
} else
|
||||
GlobalParseContext->error(yylineno, "", yytext, s, "");
|
||||
ThreadLocalParseContext()->error(yylineno, "", yytext, s, "");
|
||||
}
|
||||
|
||||
void PaReservedWord()
|
||||
{
|
||||
GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");
|
||||
ThreadLocalParseContext()->error(yylineno, "Reserved word.", yytext, "", "");
|
||||
}
|
||||
|
||||
int PaIdentOrType(const char* yytext, TParseContext& parseContextLocal, YYSTYPE* pyylval)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue