Add support for GLSL interpolation qualifiers
authorMikko Rasa <tdb@tdb.fi>
Tue, 3 Jul 2018 23:26:02 +0000 (02:26 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 3 Jul 2018 23:26:02 +0000 (02:26 +0300)
source/programcompiler.cpp
source/programparser.cpp
source/programparser.h
source/programsyntax.h

index 5bb84269f30abe4fcd38198cef0b6a2ae416b2f8..1ba898ec4d373f63e019610206dcce5762248063 100644 (file)
@@ -460,6 +460,8 @@ void ProgramCompiler::Formatter::visit(VariableDeclaration &var)
        }
        if(var.constant)
                formatted += "const ";
+       if(!var.interpolation.empty())
+               formatted += format("%s ", var.interpolation);
        if(!var.sampling.empty())
                formatted += format("%s ", var.sampling);
        if(!var.interface.empty() && var.interface!=block_interface)
index 80917ba39834720b7711810b0844d3f4800e0e01..b3a226fc98c55d2d9ceed2f39e9e498b4c68a71a 100644 (file)
@@ -318,6 +318,11 @@ bool ProgramParser::is_sampling_qualifier(const string &token)
        return token=="centroid";
 }
 
+bool ProgramParser::is_interpolation_qualifier(const string &token)
+{
+       return (token=="smooth" || token=="flat" || token=="noperspective");
+}
+
 bool ProgramParser::is_precision_qualifier(const string &token)
 {
        return (token=="highp" || token=="mediump" || token=="lowp");
@@ -325,7 +330,11 @@ bool ProgramParser::is_precision_qualifier(const string &token)
 
 bool ProgramParser::is_qualifier(const string &token)
 {
-       return (token=="const" || is_interface_qualifier(token) || is_sampling_qualifier(token) || is_precision_qualifier(token));
+       return (token=="const" ||
+               is_interface_qualifier(token) ||
+               is_sampling_qualifier(token) ||
+               is_interpolation_qualifier(token) ||
+               is_precision_qualifier(token));
 }
 
 bool ProgramParser::is_builtin_type(const string &token)
@@ -725,6 +734,8 @@ RefPtr<VariableDeclaration> ProgramParser::parse_variable_declaration()
                        var->interface = token;
                else if(is_sampling_qualifier(token))
                        var->sampling = token;
+               else if(is_interpolation_qualifier(token))
+                       var->interpolation = token;
                else if(is_precision_qualifier(token))
                        var->precision = token;
                else if(token=="const")
index fa37118de262efe46c02ad0c6c13dcdf43b4517c..903e58346f7a425a365cccfcf162f56caa75fa6e 100644 (file)
@@ -78,6 +78,7 @@ private:
 
        static bool is_interface_qualifier(const std::string &);
        static bool is_sampling_qualifier(const std::string &);
+       static bool is_interpolation_qualifier(const std::string &);
        static bool is_precision_qualifier(const std::string &);
        static bool is_qualifier(const std::string &);
        static bool is_builtin_type(const std::string &);
index b0ad02b394c480708d1b871173b37cff3c3df6fd..5e107a33a096232f2e3b3a0f93ed70ea36fe3b66 100644 (file)
@@ -226,6 +226,7 @@ struct VariableDeclaration: Node
 {
        bool constant;
        std::string sampling;
+       std::string interpolation;
        std::string interface;
        std::string precision;
        std::string type;