Include per-shader and per-program pools in the new C++ interface to glslang. (And picked up missing test result from previous check in.)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23844 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
@@ -537,7 +537,7 @@ void CompileAndLinkShaders()
|
||||
// Per-shader processing...
|
||||
//
|
||||
|
||||
glslang::TProgram program;
|
||||
glslang::TProgram& program = *new glslang::TProgram;
|
||||
glslang::TWorkItem* workItem;
|
||||
while (Worklist.remove(workItem)) {
|
||||
EShLanguage stage = FindLanguage(workItem->name);
|
||||
@@ -575,13 +575,15 @@ void CompileAndLinkShaders()
|
||||
puts(program.getInfoDebugLog());
|
||||
}
|
||||
|
||||
// free everything up
|
||||
// Free everything up, program has to go before the shaders
|
||||
// because it might have merged stuff from the shaders, and
|
||||
// the stuff from the shaders has to have its destructors called
|
||||
// before the pools holding the memory in the shaders is freed.
|
||||
delete &program;
|
||||
while (shaders.size() > 0) {
|
||||
delete shaders.back();
|
||||
shaders.pop_back();
|
||||
}
|
||||
|
||||
// TODO: memory: for each compile, need a GetThreadPoolAllocator().pop();
|
||||
}
|
||||
|
||||
int C_DECL main(int argc, char* argv[])
|
||||
@@ -613,7 +615,6 @@ int C_DECL main(int argc, char* argv[])
|
||||
|
||||
ProcessConfigFile();
|
||||
|
||||
|
||||
//
|
||||
// Two modes:
|
||||
// 1) linking all arguments together, single-threaded, new C++ interface
|
||||
|
||||
@@ -34,13 +34,15 @@ ERROR: 0:52: 'arrays of arrays' : not supported with this profile: none
|
||||
ERROR: 0:53: 'arrays of arrays' : not supported with this profile: none
|
||||
ERROR: 0:56: 'out' : overloaded functions must have the same parameter qualifiers
|
||||
ERROR: 0:57: 'float' : overloaded functions must have the same return type
|
||||
ERROR: 0:86: 'overloadC' : no matching overloaded function found
|
||||
ERROR: 0:91: 'overloadD' : ambiguous function signature match: multiple signatures match under implicit type conversion
|
||||
ERROR: 0:102: 'overloadC' : no matching overloaded function found
|
||||
ERROR: 0:103: 'overloadE' : no matching overloaded function found
|
||||
ERROR: 0:104: 'overloadE' : no matching overloaded function found
|
||||
ERROR: 0:87: 'overloadC' : no matching overloaded function found
|
||||
ERROR: 0:90: 'overloadC' : no matching overloaded function found
|
||||
ERROR: 0:95: 'overloadD' : ambiguous function signature match: multiple signatures match under implicit type conversion
|
||||
ERROR: 0:106: 'overloadC' : no matching overloaded function found
|
||||
ERROR: 0:107: 'overloadE' : no matching overloaded function found
|
||||
ERROR: 42 compilation errors. No code generated.
|
||||
ERROR: 0:108: 'overloadE' : no matching overloaded function found
|
||||
ERROR: 0:111: 'overloadE' : no matching overloaded function found
|
||||
ERROR: 0:117: 'overloadF' : no matching overloaded function found
|
||||
ERROR: 44 compilation errors. No code generated.
|
||||
|
||||
ERROR: node is still EOpNull!
|
||||
0:15 Function Definition: main( (void)
|
||||
@@ -88,97 +90,104 @@ ERROR: node is still EOpNull!
|
||||
0:43 'gl_PointSize' (invariant gl_PointSize float)
|
||||
0:43 Constant:
|
||||
0:43 3.800000
|
||||
0:75 Function Definition: foo( (void)
|
||||
0:75 Function Parameters:
|
||||
0:78 Function Definition: foo( (void)
|
||||
0:78 Function Parameters:
|
||||
0:? Sequence
|
||||
0:80 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:80 'f' (float)
|
||||
0:80 'f' (float)
|
||||
0:81 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:81 'f' (float)
|
||||
0:81 Constant:
|
||||
0:81 2 (const int)
|
||||
0:82 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:82 Constant:
|
||||
0:82 1 (const int)
|
||||
0:82 'i' (int)
|
||||
0:84 Function Call: overloadC(i1;i1; (2-component vector of float)
|
||||
0:83 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:83 'f' (float)
|
||||
0:83 'f' (float)
|
||||
0:84 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:84 'f' (float)
|
||||
0:84 Constant:
|
||||
0:84 1 (const int)
|
||||
0:84 'i' (int)
|
||||
0:85 Function Call: overloadC(vf2;vf2; (2-component vector of float)
|
||||
0:84 2 (const int)
|
||||
0:85 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:85 Constant:
|
||||
0:85 1.000000
|
||||
0:85 1.000000
|
||||
0:85 Constant:
|
||||
0:85 2.000000
|
||||
0:85 2.000000
|
||||
0:86 Constant:
|
||||
0:86 0.000000
|
||||
0:87 Function Call: overloadC(vf2;vf2; (2-component vector of float)
|
||||
0:87 Constant:
|
||||
0:87 1 (const int)
|
||||
0:87 1 (const int)
|
||||
0:87 Constant:
|
||||
0:87 2.000000
|
||||
0:87 2.000000
|
||||
0:89 Function Call: overloadD(i1;f1; (3-component vector of float)
|
||||
0:89 'i' (int)
|
||||
0:89 'f' (float)
|
||||
0:90 Function Call: overloadD(f1;i1; (3-component vector of float)
|
||||
0:90 'f' (float)
|
||||
0:90 'i' (int)
|
||||
0:91 Function Call: overloadD(f1;i1; (3-component vector of float)
|
||||
0:91 'i' (int)
|
||||
0:91 'i' (int)
|
||||
0:94 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:94 Constant:
|
||||
0:94 1 (const int)
|
||||
0:85 1 (const int)
|
||||
0:85 'i' (int)
|
||||
0:87 Constant:
|
||||
0:87 0.000000
|
||||
0:88 Function Call: overloadC(i1;i1; (2-component vector of float)
|
||||
0:88 Constant:
|
||||
0:88 1 (const int)
|
||||
0:88 'i' (int)
|
||||
0:89 Function Call: overloadC(vf2;vf2; (2-component vector of float)
|
||||
0:89 Constant:
|
||||
0:89 1.000000
|
||||
0:89 1.000000
|
||||
0:89 Constant:
|
||||
0:89 2.000000
|
||||
0:89 2.000000
|
||||
0:90 Constant:
|
||||
0:90 0.000000
|
||||
0:91 Function Call: overloadC(vf2;vf2; (2-component vector of float)
|
||||
0:91 Constant:
|
||||
0:91 1 (const int)
|
||||
0:91 1 (const int)
|
||||
0:91 Constant:
|
||||
0:91 2.000000
|
||||
0:91 2.000000
|
||||
0:93 Function Call: overloadD(i1;f1; (3-component vector of float)
|
||||
0:93 'i' (int)
|
||||
0:93 'f' (float)
|
||||
0:94 Function Call: overloadD(f1;i1; (3-component vector of float)
|
||||
0:94 'f' (float)
|
||||
0:94 'i' (int)
|
||||
0:96 Constant:
|
||||
0:96 0.000000
|
||||
0:97 Function Call: texture2D(s21;vf2; (4-component vector of float)
|
||||
0:97 's2D' (uniform sampler2D)
|
||||
0:97 Constant:
|
||||
0:97 0 (const int)
|
||||
0:97 0 (const int)
|
||||
0:98 clamp (4-component vector of float)
|
||||
0:98 'attv4' (in 4-component vector of float)
|
||||
0:98 Constant:
|
||||
0:98 0 (const int)
|
||||
0:95 Function Call: overloadD(f1;i1; (3-component vector of float)
|
||||
0:95 'i' (int)
|
||||
0:95 'i' (int)
|
||||
0:98 Function Call: overloadB(f1;f1; (2-component vector of float)
|
||||
0:98 Constant:
|
||||
0:98 1 (const int)
|
||||
0:99 clamp (4-component vector of float)
|
||||
0:99 Convert float to int (4-component vector of int)
|
||||
0:99 'attv4' (in 4-component vector of float)
|
||||
0:99 Constant:
|
||||
0:99 0 (const int)
|
||||
0:99 Constant:
|
||||
0:99 1 (const int)
|
||||
0:102 Constant:
|
||||
0:102 0.000000
|
||||
0:103 Constant:
|
||||
0:103 0.000000
|
||||
0:104 Constant:
|
||||
0:104 0.000000
|
||||
0:105 Function Call: overloadE(vf2; (3-component vector of float)
|
||||
0:105 Constant:
|
||||
0:105 3.300000
|
||||
0:105 3.300000
|
||||
0:106 Function Call: overloadE(mf22; (3-component vector of float)
|
||||
0:106 Constant:
|
||||
0:106 0.500000
|
||||
0:106 0.000000
|
||||
0:106 0.000000
|
||||
0:106 0.500000
|
||||
0:98 'i' (int)
|
||||
0:100 Constant:
|
||||
0:100 0.000000
|
||||
0:101 Function Call: texture2D(s21;vf2; (4-component vector of float)
|
||||
0:101 's2D' (uniform sampler2D)
|
||||
0:101 Constant:
|
||||
0:101 0 (const int)
|
||||
0:101 0 (const int)
|
||||
0:102 clamp (4-component vector of float)
|
||||
0:102 'attv4' (in 4-component vector of float)
|
||||
0:102 Constant:
|
||||
0:102 0 (const int)
|
||||
0:102 Constant:
|
||||
0:102 1 (const int)
|
||||
0:103 clamp (4-component vector of float)
|
||||
0:103 Convert float to int (4-component vector of int)
|
||||
0:103 'attv4' (in 4-component vector of float)
|
||||
0:103 Constant:
|
||||
0:103 0 (const int)
|
||||
0:103 Constant:
|
||||
0:103 1 (const int)
|
||||
0:106 Constant:
|
||||
0:106 0.000000
|
||||
0:107 Constant:
|
||||
0:107 0.000000
|
||||
0:108 Function Call: overloadE(vf2; (3-component vector of float)
|
||||
0:108 Constant:
|
||||
0:108 1 (const int)
|
||||
0:108 1 (const int)
|
||||
0:111 Function Call: overloadE(f1[2]; (3-component vector of float)
|
||||
0:111 'b' (2-element array of float)
|
||||
0:108 Constant:
|
||||
0:108 0.000000
|
||||
0:109 Function Call: overloadE(vf2; (3-component vector of float)
|
||||
0:109 Constant:
|
||||
0:109 3.300000
|
||||
0:109 3.300000
|
||||
0:110 Function Call: overloadE(mf22; (3-component vector of float)
|
||||
0:110 Constant:
|
||||
0:110 0.500000
|
||||
0:110 0.000000
|
||||
0:110 0.000000
|
||||
0:110 0.500000
|
||||
0:111 Constant:
|
||||
0:111 0.000000
|
||||
0:112 Function Call: overloadE(vf2; (3-component vector of float)
|
||||
0:112 Constant:
|
||||
0:112 1 (const int)
|
||||
0:112 1 (const int)
|
||||
0:115 Function Call: overloadE(f1[2]; (3-component vector of float)
|
||||
0:115 'b' (2-element array of float)
|
||||
0:117 Constant:
|
||||
0:117 0.000000
|
||||
0:118 Function Call: overloadF(i1; (3-component vector of float)
|
||||
0:118 Constant:
|
||||
0:118 1 (const int)
|
||||
0:? Linker Objects
|
||||
0:? 'i' (in 4-component vector of float)
|
||||
0:? 'o' (smooth out 4-component vector of float)
|
||||
|
||||
@@ -240,7 +240,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile)
|
||||
}
|
||||
|
||||
// Switch to a new pool
|
||||
TPoolAllocator& savedGPA = GetThreadPoolAllocator();
|
||||
TPoolAllocator& previousAllocator = GetThreadPoolAllocator();
|
||||
TPoolAllocator* builtInPoolAllocator = new TPoolAllocator();
|
||||
SetThreadPoolAllocator(*builtInPoolAllocator);
|
||||
|
||||
@@ -282,7 +282,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile)
|
||||
delete stageTables[stage];
|
||||
|
||||
delete builtInPoolAllocator;
|
||||
SetThreadPoolAllocator(savedGPA);
|
||||
SetThreadPoolAllocator(previousAllocator);
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
}
|
||||
@@ -915,9 +915,8 @@ public:
|
||||
virtual bool compile(TIntermNode* root, int version = 0, EProfile profile = ENoProfile) { return true; }
|
||||
};
|
||||
|
||||
|
||||
TShader::TShader(EShLanguage s)
|
||||
: stage(s)
|
||||
: pool(0), stage(s)
|
||||
{
|
||||
infoSink = new TInfoSink;
|
||||
compiler = new TDeferredCompiler(stage, *infoSink);
|
||||
@@ -929,6 +928,7 @@ TShader::~TShader()
|
||||
delete infoSink;
|
||||
delete compiler;
|
||||
delete intermediate;
|
||||
delete pool;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -936,9 +936,13 @@ TShader::~TShader()
|
||||
//
|
||||
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages)
|
||||
{
|
||||
return CompileDeferred(compiler, strings, numStrings, 0, EShOptNone, builtInResources, defaultVersion, forwardCompatible, messages, *intermediate);
|
||||
if (! InitThread())
|
||||
return false;
|
||||
|
||||
pool = new TPoolAllocator();
|
||||
SetThreadPoolAllocator(*pool);
|
||||
|
||||
// TODO: memory: pool needs to be popped
|
||||
return CompileDeferred(compiler, strings, numStrings, 0, EShOptNone, builtInResources, defaultVersion, forwardCompatible, messages, *intermediate);
|
||||
}
|
||||
|
||||
const char* TShader::getInfoLog()
|
||||
@@ -951,7 +955,7 @@ const char* TShader::getInfoDebugLog()
|
||||
return infoSink->debug.c_str();
|
||||
}
|
||||
|
||||
TProgram::TProgram()
|
||||
TProgram::TProgram() : pool(0)
|
||||
{
|
||||
infoSink = new TInfoSink;
|
||||
for (int s = 0; s < EShLangCount; ++s)
|
||||
@@ -963,6 +967,8 @@ TProgram::~TProgram()
|
||||
delete infoSink;
|
||||
for (int s = 0; s < EShLangCount; ++s)
|
||||
delete intermediate[s];
|
||||
|
||||
delete pool;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -973,6 +979,9 @@ bool TProgram::link(EShMessages messages)
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
pool = new TPoolAllocator();
|
||||
SetThreadPoolAllocator(*pool);
|
||||
|
||||
for (int s = 0; s < EShLangCount; ++s) {
|
||||
if (! linkStage((EShLanguage)s, messages))
|
||||
error = true;
|
||||
|
||||
@@ -265,6 +265,7 @@ namespace glslang {
|
||||
|
||||
class TIntermediate;
|
||||
class TProgram;
|
||||
class TPoolAllocator;
|
||||
|
||||
class TShader {
|
||||
public:
|
||||
@@ -276,6 +277,7 @@ public:
|
||||
const char* getInfoDebugLog();
|
||||
|
||||
protected:
|
||||
TPoolAllocator* pool;
|
||||
EShLanguage stage;
|
||||
TCompiler* compiler;
|
||||
TIntermediate* intermediate;
|
||||
@@ -301,6 +303,7 @@ protected:
|
||||
bool linkStage(EShLanguage, EShMessages);
|
||||
|
||||
protected:
|
||||
TPoolAllocator* pool;
|
||||
std::list<TShader*> stages[EShLangCount];
|
||||
TIntermediate* intermediate[EShLangCount];
|
||||
TInfoSink* infoSink;
|
||||
|
||||
Reference in New Issue
Block a user