]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/generate.h
Automatically determine array sizes in GLSL if possible
[libs/gl.git] / source / glsl / generate.h
index 73b933bfb63b0f04155c80ab2bb7e484f2529f03..a4ab75719e29b2416ad36e3be6918ace0beeddd1 100644 (file)
@@ -63,6 +63,32 @@ private:
        virtual void visit(Passthrough &);
 };
 
+/**
+Assigns sizes to arrays which don't have a size.  Geometry shader inputs are
+sized by topology.  Other arrays are sized by their use with literal indices.
+*/
+class ArraySizer: private TraversingVisitor
+{
+private:
+       std::map<VariableDeclaration *, int> max_indices;
+       unsigned input_size = 0;
+       VariableDeclaration *r_declaration;
+
+public:
+       void apply(Stage &);
+
+private:
+       virtual void visit(VariableReference &);
+       virtual void visit(MemberAccess &);
+       virtual void visit(Swizzle &);
+       virtual void visit(UnaryExpression&);
+       virtual void visit(BinaryExpression &);
+       virtual void visit(TernaryExpression &);
+       virtual void visit(FunctionCall &);
+       virtual void visit(InterfaceLayout &);
+       virtual void visit(VariableDeclaration &);
+};
+
 } // namespace SL
 } // namespace GL
 } // namespace Msp