]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/compiler.cpp
Give declaration nodes to all GLSL types.
[libs/gl.git] / source / glsl / compiler.cpp
index d5ee6691ff83cd3d877c845431ab9a29698c1edb..f5540139e3391cffd1afd1b9f2f8e709fa4b99d5 100644 (file)
@@ -206,13 +206,6 @@ void Compiler::append_stage(Stage &stage)
                target = &*i;
        }
 
-       if(target->content.body.empty())
-       {
-               Stage *builtins = get_builtins(stage.type);
-               if(builtins && builtins!=&stage)
-                       append_stage(*builtins);
-       }
-
        if(stage.required_features.glsl_version>target->required_features.glsl_version)
                target->required_features.glsl_version = stage.required_features.glsl_version;
        for(NodeList<Statement>::iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i)
@@ -239,16 +232,23 @@ void Compiler::generate(Stage &stage, Mode mode)
        stage.required_features.gl_api = features.gl_api;
        if(module->shared.required_features.glsl_version>stage.required_features.glsl_version)
                stage.required_features.glsl_version = module->shared.required_features.glsl_version;
+
        inject_block(stage.content, module->shared.content);
+       if(const Stage *builtins = get_builtins(stage.type))
+               inject_block(stage.content, builtins->content);
+       if(const Stage *builtins = get_builtins(Stage::SHARED))
+               inject_block(stage.content, builtins->content);
 
        // Initial resolving pass
        BlockHierarchyResolver().apply(stage);
+       TypeResolver().apply(stage);
        FunctionResolver().apply(stage);
        VariableResolver().apply(stage);
 
        /* All variables local to a stage have been resolved.  Resolve non-local
        variables through interfaces. */
        InterfaceGenerator().apply(stage);
+       TypeResolver().apply(stage);
        VariableResolver().apply(stage);
 
        FunctionResolver().apply(stage);
@@ -276,6 +276,7 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage)
        any_inlined |= ExpressionInliner().apply(stage);
        if(any_inlined)
        {
+               TypeResolver().apply(stage);
                VariableResolver().apply(stage);
                FunctionResolver().apply(stage);
        }