зеркало из https://github.com/stride3d/xkslang.git
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
This commit is contained in:
Родитель
b0a7eb599b
Коммит
c999ba2816
|
@ -92,12 +92,16 @@ ShBinding FixedAttributeBindings[] = {
|
|||
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
|
||||
|
||||
EShLanguage FindLanguage(const std::string& name);
|
||||
bool CompileFile(const char *fileName, ShHandle);
|
||||
void CompileFile(const char *fileName, ShHandle);
|
||||
void usage();
|
||||
void FreeFileData(char** data);
|
||||
char** ReadFileData(const char* fileName);
|
||||
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.
|
||||
int NumShaderStrings;
|
||||
|
||||
|
@ -511,6 +515,9 @@ void SetMessageOptions(EShMessages& messages)
|
|||
}
|
||||
|
||||
// Thread entry point, for non-linking asynchronous mode.
|
||||
//
|
||||
// Return 0 for failure, 1 for success.
|
||||
//
|
||||
unsigned int
|
||||
#ifdef _WIN32
|
||||
__stdcall
|
||||
|
@ -521,7 +528,7 @@ CompileShaders(void*)
|
|||
while (Worklist.remove(workItem)) {
|
||||
ShHandle compiler = ShConstructCompiler(FindLanguage(workItem->name), Options);
|
||||
if (compiler == 0)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
CompileFile(workItem->name.c_str(), compiler);
|
||||
|
||||
|
@ -567,7 +574,8 @@ void CompileAndLinkShaders()
|
|||
|
||||
shader->setStrings(shaderStrings, 1);
|
||||
|
||||
shader->parse(&Resources, 100, false, messages);
|
||||
if (! shader->parse(&Resources, 100, false, messages))
|
||||
CompileFailed = true;
|
||||
|
||||
program.addShader(shader);
|
||||
|
||||
|
@ -584,7 +592,9 @@ void CompileAndLinkShaders()
|
|||
// Program-level processing...
|
||||
//
|
||||
|
||||
program.link(messages);
|
||||
if (! program.link(messages))
|
||||
LinkFailed = true;
|
||||
|
||||
if (! (Options & EOptionSuppressInfolog)) {
|
||||
puts(program.getInfoLog());
|
||||
puts(program.getInfoDebugLog());
|
||||
|
@ -608,9 +618,6 @@ void CompileAndLinkShaders()
|
|||
|
||||
int C_DECL main(int argc, char* argv[])
|
||||
{
|
||||
bool compileFailed = false;
|
||||
bool linkFailed = false;
|
||||
|
||||
if (! ProcessArguments(argc, argv)) {
|
||||
usage();
|
||||
return EFailUsage;
|
||||
|
@ -654,10 +661,8 @@ int C_DECL main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
glslang::OS_WaitForAllThreads(threads, NumThreads);
|
||||
} else {
|
||||
if (! CompileShaders(0))
|
||||
compileFailed = true;
|
||||
}
|
||||
} else
|
||||
CompileShaders(0);
|
||||
|
||||
// Print out all the resulting infologs
|
||||
for (int w = 0; w < NumWorkItems; ++w) {
|
||||
|
@ -675,9 +680,9 @@ int C_DECL main(int argc, char* argv[])
|
|||
if (Delay)
|
||||
glslang::OS_Sleep(1000000);
|
||||
|
||||
if (compileFailed)
|
||||
if (CompileFailed)
|
||||
return EFailCompile;
|
||||
if (linkFailed)
|
||||
if (LinkFailed)
|
||||
return EFailLink;
|
||||
|
||||
return 0;
|
||||
|
@ -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,
|
||||
// for non-linkable results.
|
||||
//
|
||||
bool CompileFile(const char *fileName, ShHandle compiler)
|
||||
void CompileFile(const char *fileName, ShHandle compiler)
|
||||
{
|
||||
int ret;
|
||||
char** shaderStrings = ReadFileData(fileName);
|
||||
if (! shaderStrings) {
|
||||
usage();
|
||||
return false;
|
||||
CompileFailed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int* lengths = new int[NumShaderStrings];
|
||||
|
@ -739,8 +745,10 @@ bool CompileFile(const char *fileName, ShHandle compiler)
|
|||
for (int s = 0; s < NumShaderStrings; ++s)
|
||||
lengths[s] = strlen(shaderStrings[s]);
|
||||
|
||||
if (! shaderStrings)
|
||||
return false;
|
||||
if (! shaderStrings) {
|
||||
CompileFailed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
EShMessages messages = EShMsgDefault;
|
||||
SetMessageOptions(messages);
|
||||
|
@ -763,7 +771,8 @@ bool CompileFile(const char *fileName, ShHandle compiler)
|
|||
delete [] lengths;
|
||||
FreeFileData(shaderStrings);
|
||||
|
||||
return ret ? true : false;
|
||||
if (ret == 0)
|
||||
CompileFailed = true;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -40,7 +40,7 @@ vec4 gl_Color; // ERROR, storage
|
|||
|
||||
#extension GL_ARB_texture_gather : warn
|
||||
|
||||
void bar()
|
||||
void bar2()
|
||||
{
|
||||
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
|
|||
ERROR: 0:35: 'redeclaration' : cannot change the type of gl_Color
|
||||
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:43: 'bar' : function already has a body
|
||||
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!
|
||||
0:16 Function Definition: main( (void)
|
||||
|
@ -42,7 +41,7 @@ ERROR: node is still EOpNull!
|
|||
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:45 Sequence
|
||||
0:45 Sequence
|
||||
|
|
|
@ -947,6 +947,8 @@ TShader::~TShader()
|
|||
//
|
||||
// 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)
|
||||
{
|
||||
if (! InitThread())
|
||||
|
@ -993,6 +995,8 @@ TProgram::~TProgram()
|
|||
// Merge the compilation units within each stage into a single TIntermediate.
|
||||
// All starting compilation units need to be the result of calling TShader::parse().
|
||||
//
|
||||
// Return true for success.
|
||||
//
|
||||
bool TProgram::link(EShMessages messages)
|
||||
{
|
||||
if (linked)
|
||||
|
@ -1011,9 +1015,14 @@ bool TProgram::link(EShMessages messages)
|
|||
|
||||
// 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)
|
||||
{
|
||||
if (stages[stage].size() == 0)
|
||||
|
@ -1043,7 +1052,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
|
|||
|
||||
intermediate[stage]->errorCheck(*infoSink);
|
||||
|
||||
return intermediate[stage]->getNumErrors() > 0;
|
||||
return intermediate[stage]->getNumErrors() == 0;
|
||||
}
|
||||
|
||||
const char* TProgram::getInfoLog()
|
||||
|
|
|
@ -163,8 +163,8 @@ SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); // one per un
|
|||
SH_IMPORT_EXPORT void ShDestruct(ShHandle);
|
||||
|
||||
//
|
||||
// The return value of ShCompile is boolean, indicating
|
||||
// success or failure.
|
||||
// The return value of ShCompile is boolean, non-zero indicating
|
||||
// success.
|
||||
//
|
||||
// The info-log should be written by ShCompile into
|
||||
// ShHandle, so it can answer future queries.
|
||||
|
|
Загрузка…
Ссылка в новой задаче