Commit c999ba28 by John Kessenich

Complete hook up all the compile/link errors to the command-line exit status.…

Complete hook up all the compile/link errors to the command-line exit status. (Also, an updated test left from the last check-in.) git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23961 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent b0a7eb59
...@@ -92,12 +92,16 @@ ShBinding FixedAttributeBindings[] = { ...@@ -92,12 +92,16 @@ ShBinding FixedAttributeBindings[] = {
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings }; ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
EShLanguage FindLanguage(const std::string& name); EShLanguage FindLanguage(const std::string& name);
bool CompileFile(const char *fileName, ShHandle); void CompileFile(const char *fileName, ShHandle);
void usage(); void usage();
void FreeFileData(char** data); void FreeFileData(char** data);
char** ReadFileData(const char* fileName); char** ReadFileData(const char* fileName);
void InfoLogMsg(const char* msg, const char* name, const int num); void InfoLogMsg(const char* msg, const char* name, const int num);
// Globally track if any compile or link failure.
bool CompileFailed = false;
bool LinkFailed = false;
// Use to test breaking up a single shader file into multiple strings. // Use to test breaking up a single shader file into multiple strings.
int NumShaderStrings; int NumShaderStrings;
...@@ -511,6 +515,9 @@ void SetMessageOptions(EShMessages& messages) ...@@ -511,6 +515,9 @@ void SetMessageOptions(EShMessages& messages)
} }
// Thread entry point, for non-linking asynchronous mode. // Thread entry point, for non-linking asynchronous mode.
//
// Return 0 for failure, 1 for success.
//
unsigned int unsigned int
#ifdef _WIN32 #ifdef _WIN32
__stdcall __stdcall
...@@ -521,7 +528,7 @@ CompileShaders(void*) ...@@ -521,7 +528,7 @@ CompileShaders(void*)
while (Worklist.remove(workItem)) { while (Worklist.remove(workItem)) {
ShHandle compiler = ShConstructCompiler(FindLanguage(workItem->name), Options); ShHandle compiler = ShConstructCompiler(FindLanguage(workItem->name), Options);
if (compiler == 0) if (compiler == 0)
return false; return 0;
CompileFile(workItem->name.c_str(), compiler); CompileFile(workItem->name.c_str(), compiler);
...@@ -567,7 +574,8 @@ void CompileAndLinkShaders() ...@@ -567,7 +574,8 @@ void CompileAndLinkShaders()
shader->setStrings(shaderStrings, 1); shader->setStrings(shaderStrings, 1);
shader->parse(&Resources, 100, false, messages); if (! shader->parse(&Resources, 100, false, messages))
CompileFailed = true;
program.addShader(shader); program.addShader(shader);
...@@ -584,7 +592,9 @@ void CompileAndLinkShaders() ...@@ -584,7 +592,9 @@ void CompileAndLinkShaders()
// Program-level processing... // Program-level processing...
// //
program.link(messages); if (! program.link(messages))
LinkFailed = true;
if (! (Options & EOptionSuppressInfolog)) { if (! (Options & EOptionSuppressInfolog)) {
puts(program.getInfoLog()); puts(program.getInfoLog());
puts(program.getInfoDebugLog()); puts(program.getInfoDebugLog());
...@@ -608,9 +618,6 @@ void CompileAndLinkShaders() ...@@ -608,9 +618,6 @@ void CompileAndLinkShaders()
int C_DECL main(int argc, char* argv[]) int C_DECL main(int argc, char* argv[])
{ {
bool compileFailed = false;
bool linkFailed = false;
if (! ProcessArguments(argc, argv)) { if (! ProcessArguments(argc, argv)) {
usage(); usage();
return EFailUsage; return EFailUsage;
...@@ -654,10 +661,8 @@ int C_DECL main(int argc, char* argv[]) ...@@ -654,10 +661,8 @@ int C_DECL main(int argc, char* argv[])
} }
} }
glslang::OS_WaitForAllThreads(threads, NumThreads); glslang::OS_WaitForAllThreads(threads, NumThreads);
} else { } else
if (! CompileShaders(0)) CompileShaders(0);
compileFailed = true;
}
// Print out all the resulting infologs // Print out all the resulting infologs
for (int w = 0; w < NumWorkItems; ++w) { for (int w = 0; w < NumWorkItems; ++w) {
...@@ -675,9 +680,9 @@ int C_DECL main(int argc, char* argv[]) ...@@ -675,9 +680,9 @@ int C_DECL main(int argc, char* argv[])
if (Delay) if (Delay)
glslang::OS_Sleep(1000000); glslang::OS_Sleep(1000000);
if (compileFailed) if (CompileFailed)
return EFailCompile; return EFailCompile;
if (linkFailed) if (LinkFailed)
return EFailLink; return EFailLink;
return 0; return 0;
...@@ -724,13 +729,14 @@ EShLanguage FindLanguage(const std::string& name) ...@@ -724,13 +729,14 @@ EShLanguage FindLanguage(const std::string& name)
// Read a file's data into a string, and compile it using the old interface ShCompile, // Read a file's data into a string, and compile it using the old interface ShCompile,
// for non-linkable results. // for non-linkable results.
// //
bool CompileFile(const char *fileName, ShHandle compiler) void CompileFile(const char *fileName, ShHandle compiler)
{ {
int ret; int ret;
char** shaderStrings = ReadFileData(fileName); char** shaderStrings = ReadFileData(fileName);
if (! shaderStrings) { if (! shaderStrings) {
usage(); usage();
return false; CompileFailed = true;
return;
} }
int* lengths = new int[NumShaderStrings]; int* lengths = new int[NumShaderStrings];
...@@ -739,8 +745,10 @@ bool CompileFile(const char *fileName, ShHandle compiler) ...@@ -739,8 +745,10 @@ bool CompileFile(const char *fileName, ShHandle compiler)
for (int s = 0; s < NumShaderStrings; ++s) for (int s = 0; s < NumShaderStrings; ++s)
lengths[s] = strlen(shaderStrings[s]); lengths[s] = strlen(shaderStrings[s]);
if (! shaderStrings) if (! shaderStrings) {
return false; CompileFailed = true;
return;
}
EShMessages messages = EShMsgDefault; EShMessages messages = EShMsgDefault;
SetMessageOptions(messages); SetMessageOptions(messages);
...@@ -763,7 +771,8 @@ bool CompileFile(const char *fileName, ShHandle compiler) ...@@ -763,7 +771,8 @@ bool CompileFile(const char *fileName, ShHandle compiler)
delete [] lengths; delete [] lengths;
FreeFileData(shaderStrings); FreeFileData(shaderStrings);
return ret ? true : false; if (ret == 0)
CompileFailed = true;
} }
// //
......
...@@ -40,7 +40,7 @@ vec4 gl_Color; // ERROR, storage ...@@ -40,7 +40,7 @@ vec4 gl_Color; // ERROR, storage
#extension GL_ARB_texture_gather : warn #extension GL_ARB_texture_gather : warn
void bar() void bar2()
{ {
vec4 s = textureGather(sampC, vec3(0.2)); vec4 s = textureGather(sampC, vec3(0.2));
} }
...@@ -3,9 +3,8 @@ ERROR: 0:25: 'texture gather function' : not supported for this version or the e ...@@ -3,9 +3,8 @@ ERROR: 0:25: 'texture gather function' : not supported for this version or the e
ERROR: 0:35: 'redeclaration' : cannot change the type of gl_Color ERROR: 0:35: 'redeclaration' : cannot change the type of gl_Color
ERROR: 0:38: 'gl_Color' : redeclaring non-array as array ERROR: 0:38: 'gl_Color' : redeclaring non-array as array
ERROR: 0:39: 'redeclaration' : cannot change storage, memory, or auxiliary qualification of gl_Color ERROR: 0:39: 'redeclaration' : cannot change storage, memory, or auxiliary qualification of gl_Color
ERROR: 0:43: 'bar' : function already has a body
WARNING: 0:45: extension GL_ARB_texture_gather is being used for texture gather function WARNING: 0:45: extension GL_ARB_texture_gather is being used for texture gather function
ERROR: 5 compilation errors. No code generated. ERROR: 4 compilation errors. No code generated.
ERROR: node is still EOpNull! ERROR: node is still EOpNull!
0:16 Function Definition: main( (void) 0:16 Function Definition: main( (void)
...@@ -42,7 +41,7 @@ ERROR: node is still EOpNull! ...@@ -42,7 +41,7 @@ ERROR: node is still EOpNull!
0:32 0.200000 0:32 0.200000
0:32 0.200000 0:32 0.200000
0:32 0.200000 0:32 0.200000
0:43 Function Definition: bar( (void) 0:43 Function Definition: bar2( (void)
0:43 Function Parameters: 0:43 Function Parameters:
0:45 Sequence 0:45 Sequence
0:45 Sequence 0:45 Sequence
......
...@@ -947,6 +947,8 @@ TShader::~TShader() ...@@ -947,6 +947,8 @@ TShader::~TShader()
// //
// Turn the shader strings into a parse tree in the TIntermediate. // Turn the shader strings into a parse tree in the TIntermediate.
// //
// Returns true for success.
//
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages) bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages)
{ {
if (! InitThread()) if (! InitThread())
...@@ -993,6 +995,8 @@ TProgram::~TProgram() ...@@ -993,6 +995,8 @@ TProgram::~TProgram()
// Merge the compilation units within each stage into a single TIntermediate. // Merge the compilation units within each stage into a single TIntermediate.
// All starting compilation units need to be the result of calling TShader::parse(). // All starting compilation units need to be the result of calling TShader::parse().
// //
// Return true for success.
//
bool TProgram::link(EShMessages messages) bool TProgram::link(EShMessages messages)
{ {
if (linked) if (linked)
...@@ -1011,9 +1015,14 @@ bool TProgram::link(EShMessages messages) ...@@ -1011,9 +1015,14 @@ bool TProgram::link(EShMessages messages)
// TODO: Link: cross-stage error checking // TODO: Link: cross-stage error checking
return error; return ! error;
} }
//
// Merge the compilation units within the given stage into a single TIntermediate.
//
// Return true for success.
//
bool TProgram::linkStage(EShLanguage stage, EShMessages messages) bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
{ {
if (stages[stage].size() == 0) if (stages[stage].size() == 0)
...@@ -1043,7 +1052,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages) ...@@ -1043,7 +1052,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
intermediate[stage]->errorCheck(*infoSink); intermediate[stage]->errorCheck(*infoSink);
return intermediate[stage]->getNumErrors() > 0; return intermediate[stage]->getNumErrors() == 0;
} }
const char* TProgram::getInfoLog() const char* TProgram::getInfoLog()
......
...@@ -163,8 +163,8 @@ SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); // one per un ...@@ -163,8 +163,8 @@ SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); // one per un
SH_IMPORT_EXPORT void ShDestruct(ShHandle); SH_IMPORT_EXPORT void ShDestruct(ShHandle);
// //
// The return value of ShCompile is boolean, indicating // The return value of ShCompile is boolean, non-zero indicating
// success or failure. // success.
// //
// The info-log should be written by ShCompile into // The info-log should be written by ShCompile into
// ShHandle, so it can answer future queries. // ShHandle, so it can answer future queries.
......
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