X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.cpp;h=947b310ef5e528e026dd53dcbd642de96f4923b3;hb=c701c8787cb19fbb6dc5b0bfae1a94e2b07dd549;hp=c94e2e27042c63a6a7f0b2c91f3d26c5b00f1e30;hpb=03880839dcd2c067061ac5491083159a9fd06611;p=libs%2Fgl.git diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index c94e2e27..947b310e 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -138,14 +138,16 @@ void InterfaceBlockReference::visit(NodeVisitor &visitor) MemberAccess::MemberAccess(): - declaration(0) + declaration(0), + index(-1) { } MemberAccess::MemberAccess(const MemberAccess &other): Expression(other), left(other.left), member(other.member), - declaration(0) + declaration(0), + index(-1) { } void MemberAccess::visit(NodeVisitor &visitor) @@ -369,7 +371,7 @@ InterfaceBlock::InterfaceBlock(): InterfaceBlock::InterfaceBlock(const InterfaceBlock &other): Statement(other), interface(other.interface), - name(other.name), + block_name(other.block_name), members(other.members), instance_name(other.instance_name), array(other.array), @@ -465,13 +467,12 @@ Module::Module(): { } -string get_unused_variable_name(const Block &block, const string &base, const string &prefix_hint) +string get_unused_variable_name(const Block &block, const string &base) { string name = base; - bool prefixed = false; unsigned number = 1; - unsigned size_without_number = name.size(); + unsigned base_size = name.size(); while(1) { bool unused = true; @@ -480,25 +481,27 @@ string get_unused_variable_name(const Block &block, const string &base, const st if(unused) return name; - if(!prefixed && !prefix_hint.empty()) - { - if(name.front()!='_') - name = "_"+name; - name = prefix_hint+name; - if(name.front()!='_') - name = "_"+name; - prefixed = true; - size_without_number = name.size(); - } - else - { - name.erase(size_without_number); - name += format("_%d", number); - ++number; - } + name.erase(base_size); + name += format("_%d", number); + ++number; } } +int get_layout_value(const Layout &layout, const string &name, int def_value) +{ + for(vector::const_iterator i=layout.qualifiers.begin(); i!=layout.qualifiers.end(); ++i) + if(i->name==name) + return i->value; + return def_value; +} + +void add_to_chain(Assignment::Target &target, Assignment::Target::ChainType type, unsigned index) +{ + if(target.chain_len<7) + target.chain[target.chain_len] = type | min(index, 0x3F); + ++target.chain_len; +} + } // namespace SL } // namespace GL } // namespace Msp