X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=332dd331f69b6bc6e287e89306e2e21eeff52e72;hb=4c6f1a526ed949f6c9f4c3a57c036b3cdb1aaa91;hp=e46e5401a8fbe452e8175cc622545d7f52caf6f7;hpb=a60a60fe29850ef8a5dc291ed70741eeb95d9e0b;p=libs%2Fgl.git diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index e46e5401..332dd331 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -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