From: Mikko Rasa Date: Wed, 10 Mar 2021 10:03:24 +0000 (+0200) Subject: Check for existence of required version in Formatter X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=cfee1ea700d860db170fd1621f3716bc47b677f8;p=libs%2Fgl.git Check for existence of required version in Formatter This way it doesn't depend on whether get_combined_glsl or get_stage_glsl was called. --- diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index c5f0a9a3..3516048c 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -108,7 +108,7 @@ string Compiler::get_combined_glsl() const for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) { glsl += format("#pragma MSP stage(%s)\n", Stage::get_stage_name(i->type)); - glsl += Formatter().apply(*i, MODULE); + glsl += Formatter().apply(*i); glsl += '\n'; } @@ -128,7 +128,7 @@ string Compiler::get_stage_glsl(Stage::Type stage_type) const { for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) if(i->type==stage_type) - return Formatter().apply(*i, PROGRAM); + return Formatter().apply(*i); throw key_error(Stage::get_stage_name(stage_type)); } diff --git a/source/glsl/output.cpp b/source/glsl/output.cpp index b277ba8e..43f337ca 100644 --- a/source/glsl/output.cpp +++ b/source/glsl/output.cpp @@ -10,16 +10,14 @@ namespace SL { Formatter::Formatter(): stage(0), - mode(Compiler::PROGRAM), source_index(0), source_line(1), indent(0), parameter_list(false) { } -const string &Formatter::apply(Stage &s, Compiler::Mode m) +const string &Formatter::apply(Stage &s) { - mode = m; stage = &s; const Version &ver = s.required_features.glsl_version; @@ -73,7 +71,7 @@ void Formatter::set_source(unsigned index, unsigned line) else { unsigned l = line; - if(mode==Compiler::PROGRAM && stage && stage->required_features.glsl_versionrequired_features.glsl_version && stage->required_features.glsl_versionrequired_features.glsl_versionrequired_features.glsl_version && stage->required_features.glsl_versiontype==Stage::VERTEX && var.interface=="in") interface = "attribute"; diff --git a/source/glsl/output.h b/source/glsl/output.h index 61c02caa..58983fca 100644 --- a/source/glsl/output.h +++ b/source/glsl/output.h @@ -14,7 +14,6 @@ class Formatter: private TraversingVisitor { private: Stage *stage; - Compiler::Mode mode; std::string formatted; unsigned source_index; unsigned source_line; @@ -24,7 +23,7 @@ private: public: Formatter(); - const std::string &apply(Stage &, Compiler::Mode); + const std::string &apply(Stage &); const std::string &apply(Node &n) { n.visit(*this); return formatted; } private: