Commit 90033b9e by alokp@chromium.org

ShInitialize/ShFinalize is designed to be called once per process, or it would…

ShInitialize/ShFinalize is designed to be called once per process, or it would crash at random locations. I changed ShFinalize() to properly cleanup and reset global variables so that they can be called multiple times. I think that the compiler setup is much more complicated than it needs to be. It unnecessarily uses global variables. A custom pool allocator is overkill too. Review URL: http://codereview.appspot.com/1238045 git-svn-id: https://angleproject.googlecode.com/svn/trunk@316 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 866f318d
......@@ -22,7 +22,7 @@
// set of built-ins, and we want to preserve that from
// compile to compile.
//
TSymbolTable SymbolTables[EShLangCount];
TSymbolTable* SymbolTables[EShLangCount];
TPoolAllocator* PerProcessGPA = 0;
......@@ -59,8 +59,10 @@ int ShInitialize()
PerProcessGPA->push();
SetGlobalPoolAllocatorPtr(PerProcessGPA);
SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]);
SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]);
SymbolTables[EShLangVertex] = new TSymbolTable;
SymbolTables[EShLangVertex]->copyTable(symTables[EShLangVertex]);
SymbolTables[EShLangFragment] = new TSymbolTable;
SymbolTables[EShLangFragment]->copyTable(symTables[EShLangFragment]);
SetGlobalPoolAllocatorPtr(gPoolAllocator);
......@@ -133,6 +135,11 @@ int __fastcall ShFinalize()
if (PerProcessGPA) {
PerProcessGPA->popAll();
delete PerProcessGPA;
PerProcessGPA = 0;
}
for (int i = 0; i < EShLangCount; ++i) {
delete SymbolTables[i];
SymbolTables[i] = 0;
}
return 1;
}
......@@ -252,7 +259,7 @@ int ShCompile(
return 1;
TIntermediate intermediate(infoSink);
TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
TSymbolTable symbolTable(*SymbolTables[compiler->getLanguage()]);
GenerateBuiltInSymbolTable(resources, infoSink, &symbolTable, compiler->getLanguage());
......
......@@ -215,6 +215,8 @@ void Shader::releaseCompiler()
mFragmentCompiler = NULL;
mVertexCompiler = NULL;
ShFinalize();
}
void Shader::parseVaryings()
......
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