X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=c5f0a9a3d05b6fd640f9afe5a5cba5a05e0ec5ab;hb=a1ba04add302e7712d127b46d8d11386987a0aea;hp=ccfbe691195eefd91aa4314281db6afc1bb97c97;hpb=041ba4b1acd55337239c5ce24cc310118c621206;p=libs%2Fgl.git diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index ccfbe691..c5f0a9a3 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -282,7 +282,7 @@ void Compiler::resolve(Stage &stage, unsigned flags) else if(resolve(stage, flags, RESOLVE_FUNCTIONS)) flags |= RESOLVE_EXPRESSIONS; else if(resolve(stage, flags, RESOLVE_EXPRESSIONS)) - flags |= RESOLVE_VARIABLES; + flags |= RESOLVE_VARIABLES|RESOLVE_FUNCTIONS; } } @@ -293,6 +293,8 @@ bool Compiler::validate(Stage &stage) ReferenceValidator().apply(stage); ExpressionValidator().apply(stage); + stable_sort(stage.diagnostics, &diagnostic_line_order); + for(vector::const_iterator i=stage.diagnostics.begin(); i!=stage.diagnostics.end(); ++i) if(i->severity==Diagnostic::ERR) return false; @@ -300,6 +302,21 @@ bool Compiler::validate(Stage &stage) return true; } +bool Compiler::diagnostic_line_order(const Diagnostic &diag1, const Diagnostic &diag2) +{ + if(diag1.provoking_source!=diag2.provoking_source) + { + // Sort builtins first and imported modules according to import order. + if(diag1.provoking_source<=BUILTIN_SOURCE) + return diag1.provoking_sourcediag2.provoking_source; + } + return diag1.provoking_line