From: Mikko Rasa Date: Tue, 3 Jul 2018 23:26:02 +0000 (+0300) Subject: Add support for GLSL interpolation qualifiers X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=11520b2b95f4242b3ca4d2d3d14a0f2b5c1623f1;p=libs%2Fgl.git Add support for GLSL interpolation qualifiers --- diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index 5bb84269..1ba898ec 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -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) diff --git a/source/programparser.cpp b/source/programparser.cpp index 80917ba3..b3a226fc 100644 --- a/source/programparser.cpp +++ b/source/programparser.cpp @@ -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 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") diff --git a/source/programparser.h b/source/programparser.h index fa37118d..903e5834 100644 --- a/source/programparser.h +++ b/source/programparser.h @@ -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 &); diff --git a/source/programsyntax.h b/source/programsyntax.h index b0ad02b3..5e107a33 100644 --- a/source/programsyntax.h +++ b/source/programsyntax.h @@ -226,6 +226,7 @@ struct VariableDeclaration: Node { bool constant; std::string sampling; + std::string interpolation; std::string interface; std::string precision; std::string type;