]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/compiler.cpp
Combine the precision handling visitors and rewrite the logic
[libs/gl.git] / source / glsl / compiler.cpp
index 40dfede3a68688e5ec9ef7a9fb23576af28d393e..d8b060ea4e3873285980373e45974ee1b6b84950 100644 (file)
@@ -2,10 +2,10 @@
 #include <msp/strings/format.h>
 #include <msp/strings/utils.h>
 #include "builtin.h"
-#include "compatibility.h"
 #include "compiler.h"
 #include "debug.h"
 #include "error.h"
+#include "finalize.h"
 #include "generate.h"
 #include "glsl_error.h"
 #include "optimize.h"
@@ -264,11 +264,6 @@ void Compiler::generate(Stage &stage, Mode mode)
        resolve(stage, RESOLVE_BLOCKS|RESOLVE_TYPES|RESOLVE_VARIABLES);
 
        ConstantSpecializer().apply(stage, (mode==PROGRAM && specialized ? &spec_values : 0));
-       if(mode==PROGRAM)
-       {
-               LegacyConverter().apply(stage, features);
-               resolve(stage, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS);
-       }
 }
 
 template<typename T>
@@ -300,7 +295,7 @@ void Compiler::resolve(Stage &stage, unsigned flags)
 
 bool Compiler::validate(Stage &stage)
 {
-       TypeValidator().apply(stage);
+       DeclarationValidator().apply(stage);
        IdentifierValidator().apply(stage);
        ReferenceValidator().apply(stage);
        ExpressionValidator().apply(stage);
@@ -358,10 +353,12 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage)
 
 void Compiler::finalize(Stage &stage, Mode mode)
 {
-       if(get_gl_api()==OPENGL_ES2 && mode==PROGRAM)
-               DefaultPrecisionGenerator().apply(stage);
-       else if(mode==MODULE)
-               PrecisionRemover().apply(stage);
+       if(mode==PROGRAM)
+       {
+               LegacyConverter().apply(stage, features);
+               resolve(stage, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS);
+               PrecisionConverter().apply(stage);
+       }
 }
 
 void Compiler::inject_block(Block &target, const Block &source)