]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/compiler.cpp
Refactor a common part in LocationAllocator into a function
[libs/gl.git] / source / glsl / compiler.cpp
index 9ddafcff403c9369b72a76828c366e59077ed3f8..e676fcc87233764cc529fe98203bc5d8b666df0f 100644 (file)
@@ -4,7 +4,6 @@
 #include "builtin.h"
 #include "compiler.h"
 #include "debug.h"
-#include "deviceinfo.h"
 #include "error.h"
 #include "finalize.h"
 #include "generate.h"
@@ -24,10 +23,6 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
-Compiler::Compiler():
-       features(DeviceInfo::get_global().glsl_features)
-{ }
-
 Compiler::Compiler(const Features &f):
        features(f)
 { }
@@ -106,6 +101,11 @@ void Compiler::compile(Mode mode)
                        ++i;
        }
 
+       for(Stage &s: module->stages)
+       {
+               StructuralFeatureConverter().apply(s, features);
+               resolve(s, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS);
+       }
        LocationAllocator().apply(*module, features);
        for(Stage &s: module->stages)
                finalize(s, mode);
@@ -329,7 +329,7 @@ void Compiler::resolve(Stage &stage, unsigned flags)
 
 void Compiler::validate(Stage &stage)
 {
-       DeclarationValidator().apply(stage);
+       DeclarationValidator().apply(stage, features);
        IdentifierValidator().apply(stage);
        ReferenceValidator().apply(stage);
        ExpressionValidator().apply(stage);
@@ -394,14 +394,9 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage)
 
 void Compiler::finalize(Stage &stage, Mode mode)
 {
-       if(mode==PROGRAM)
-       {
-               StructuralFeatureConverter().apply(stage, features);
-               QualifierConverter().apply(stage, features);
-               resolve(stage, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS);
-               PrecisionConverter().apply(stage);
-       }
-       else if(mode==SPIRV)
+       QualifierConverter().apply(stage, features);
+       PrecisionConverter().apply(stage);
+       if(mode==SPIRV)
                StructOrganizer().apply(stage);
 
        // Collect bindings from all stages into the shared stage's maps