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 @@ ...@@ -22,7 +22,7 @@
// set of built-ins, and we want to preserve that from // set of built-ins, and we want to preserve that from
// compile to compile. // compile to compile.
// //
TSymbolTable SymbolTables[EShLangCount]; TSymbolTable* SymbolTables[EShLangCount];
TPoolAllocator* PerProcessGPA = 0; TPoolAllocator* PerProcessGPA = 0;
...@@ -59,8 +59,10 @@ int ShInitialize() ...@@ -59,8 +59,10 @@ int ShInitialize()
PerProcessGPA->push(); PerProcessGPA->push();
SetGlobalPoolAllocatorPtr(PerProcessGPA); SetGlobalPoolAllocatorPtr(PerProcessGPA);
SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]); SymbolTables[EShLangVertex] = new TSymbolTable;
SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]); SymbolTables[EShLangVertex]->copyTable(symTables[EShLangVertex]);
SymbolTables[EShLangFragment] = new TSymbolTable;
SymbolTables[EShLangFragment]->copyTable(symTables[EShLangFragment]);
SetGlobalPoolAllocatorPtr(gPoolAllocator); SetGlobalPoolAllocatorPtr(gPoolAllocator);
...@@ -133,6 +135,11 @@ int __fastcall ShFinalize() ...@@ -133,6 +135,11 @@ int __fastcall ShFinalize()
if (PerProcessGPA) { if (PerProcessGPA) {
PerProcessGPA->popAll(); PerProcessGPA->popAll();
delete PerProcessGPA; delete PerProcessGPA;
PerProcessGPA = 0;
}
for (int i = 0; i < EShLangCount; ++i) {
delete SymbolTables[i];
SymbolTables[i] = 0;
} }
return 1; return 1;
} }
...@@ -252,7 +259,7 @@ int ShCompile( ...@@ -252,7 +259,7 @@ int ShCompile(
return 1; return 1;
TIntermediate intermediate(infoSink); TIntermediate intermediate(infoSink);
TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]); TSymbolTable symbolTable(*SymbolTables[compiler->getLanguage()]);
GenerateBuiltInSymbolTable(resources, infoSink, &symbolTable, compiler->getLanguage()); GenerateBuiltInSymbolTable(resources, infoSink, &symbolTable, compiler->getLanguage());
......
...@@ -215,6 +215,8 @@ void Shader::releaseCompiler() ...@@ -215,6 +215,8 @@ void Shader::releaseCompiler()
mFragmentCompiler = NULL; mFragmentCompiler = NULL;
mVertexCompiler = NULL; mVertexCompiler = NULL;
ShFinalize();
} }
void Shader::parseVaryings() 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