]> git.tdb.fi Git - libs/gl.git/commitdiff
Some rearranging and comments
authorMikko Rasa <tdb@tdb.fi>
Wed, 10 Mar 2021 11:14:48 +0000 (13:14 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 10 Mar 2021 13:33:38 +0000 (15:33 +0200)
source/glsl/compiler.h
source/glsl/generate.cpp
source/glsl/optimize.cpp
source/glsl/optimize.h

index 5104388870f5a22bbfff775d843ce9ab095f2bbf..a515a326f2b10b21ce866fd4591e65b38558263d 100644 (file)
@@ -131,6 +131,8 @@ private:
        aspects as necessary. */
        void resolve(Stage &, unsigned = RESOLVE_ALL);
 
+       /** Checks the validity of the module.  If the return value is false, the
+       module's diagnostics list will contain additional information of errors. */
        bool validate(Stage &);
 
        static bool diagnostic_line_order(const Diagnostic &, const Diagnostic &);
index 09a776afb7f60bb61d2bdc47d0a8f3fb9e470b3e..158bb4cc91b67b39239358c70bf0237ef5821ed0 100644 (file)
@@ -191,6 +191,9 @@ void TypeResolver::visit(BasicTypeDeclaration &type)
                        if(basic_base->kind==BasicTypeDeclaration::VECTOR)
                        {
                                type.kind = BasicTypeDeclaration::MATRIX;
+                               /* A matrix's base type is its column vector type.  This will put
+                               the column vector's size, i.e. the matrix's row count, in the high
+                               half of the size. */
                                type.size |= basic_base->size<<16;
                        }
 
index 441a73a072e8df7740c27b62f9d3c5cc1f9596b2..9ab8ef70ef94dfc235e08ecee479792f9ae9cf2b 100644 (file)
@@ -809,29 +809,6 @@ void UnusedVariableRemover::visit(InterfaceBlock &iface)
        }
 }
 
-void UnusedVariableRemover::visit(FunctionDeclaration &func)
-{
-       if(func.body.body.empty())
-               return;
-
-       BlockVariableMap saved_vars = variables;
-       // Assignments from other functions should not be visible.
-       for(BlockVariableMap::iterator i=variables.begin(); i!=variables.end(); ++i)
-               i->second.assignments.resize(i->second.initialized);
-       TraversingVisitor::visit(func);
-       swap(variables, saved_vars);
-       merge_variables(saved_vars);
-
-       /* Always treat function parameters as referenced.  Removing unused
-       parameters is not currently supported. */
-       for(NodeArray<VariableDeclaration>::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
-       {
-               BlockVariableMap::iterator j = variables.find(i->get());
-               if(j!=variables.end())
-                       j->second.referenced = true;
-       }
-}
-
 void UnusedVariableRemover::merge_variables(const BlockVariableMap &other_vars)
 {
        for(BlockVariableMap::const_iterator i=other_vars.begin(); i!=other_vars.end(); ++i)
@@ -855,6 +832,29 @@ void UnusedVariableRemover::merge_variables(const BlockVariableMap &other_vars)
        }
 }
 
+void UnusedVariableRemover::visit(FunctionDeclaration &func)
+{
+       if(func.body.body.empty())
+               return;
+
+       BlockVariableMap saved_vars = variables;
+       // Assignments from other functions should not be visible.
+       for(BlockVariableMap::iterator i=variables.begin(); i!=variables.end(); ++i)
+               i->second.assignments.resize(i->second.initialized);
+       TraversingVisitor::visit(func);
+       swap(variables, saved_vars);
+       merge_variables(saved_vars);
+
+       /* Always treat function parameters as referenced.  Removing unused
+       parameters is not currently supported. */
+       for(NodeArray<VariableDeclaration>::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
+       {
+               BlockVariableMap::iterator j = variables.find(i->get());
+               if(j!=variables.end())
+                       j->second.referenced = true;
+       }
+}
+
 void UnusedVariableRemover::visit(Conditional &cond)
 {
        cond.condition->visit(*this);
index 5448ea7c4e8771b8008ec0a6b786349f9386cc90..34c0b2455bd4e4ac60126b72e53586a016d16425 100644 (file)
@@ -227,15 +227,15 @@ private:
        virtual void visit(UnaryExpression &);
        virtual void visit(BinaryExpression &);
        virtual void visit(Assignment &);
-       void record_assignment(const Assignment::Target &, Node &);
        virtual void visit(FunctionCall &);
+       void record_assignment(const Assignment::Target &, Node &);
        virtual void visit(ExpressionStatement &);
        // Ignore structs because their members can't be accessed directly.
        virtual void visit(StructDeclaration &) { }
        virtual void visit(VariableDeclaration &);
        virtual void visit(InterfaceBlock &);
-       virtual void visit(FunctionDeclaration &);
        void merge_variables(const BlockVariableMap &);
+       virtual void visit(FunctionDeclaration &);
        virtual void visit(Conditional &);
        virtual void visit(Iteration &);
 };