X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fdebug.cpp;h=bd3404e56f0fae10addb22fb90f3aec2f234560c;hb=631872e13c2670f7dece44512ed55af50b77f399;hp=2e8433f28287713ca215c0a33e0df669cd6b1f55;hpb=aa834c69698b5f0804a19fee4ec2e632a51e38c2;p=libs%2Fgl.git diff --git a/source/glsl/debug.cpp b/source/glsl/debug.cpp index 2e8433f2..bd3404e5 100644 --- a/source/glsl/debug.cpp +++ b/source/glsl/debug.cpp @@ -8,24 +8,17 @@ namespace Msp { namespace GL { namespace SL { -const std::string &DumpTree::apply(Stage &stage) +std::string DumpTree::apply(Stage &stage) { formatted = format("Stage: %s\n", Stage::get_stage_name(stage.type)); - tree.push_back(BRANCH); + begin_sub(); append(format("Version: %d.%02d", stage.required_features.glsl_version.major, stage.required_features.glsl_version.minor)); for(std::map::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i) append(format("Type: %%%d %s", get_label(*i->second), i->first)); - set seen_interfaces; for(std::map::const_iterator i=stage.interface_blocks.begin(); i!=stage.interface_blocks.end(); ++i) - if(seen_interfaces.insert(i->second).second) - { - string text = format("Interface block: %%%d %s %s", get_label(*i->second), i->second->interface, i->second->block_name); - if(!i->second->instance_name.empty()) - text += format(" %s", i->second->instance_name); - append(text); - } + append(format("Interface block: %%%d %s", get_label(*i->second), i->first)); for(std::map::const_iterator i=stage.functions.begin(); i!=stage.functions.end(); ++i) append(format("Function: %%%d %s", get_label(*i->second), i->first)); @@ -85,7 +78,8 @@ void DumpTree::append_subtree(Node &node) void DumpTree::begin_sub() { - tree.back() = (tree.back()==BRANCH_LAST ? EMPTY : STRAIGHT); + if(!tree.empty()) + tree.back() = (tree.back()==BRANCH_LAST ? EMPTY : STRAIGHT); tree.push_back(BRANCH); } @@ -97,7 +91,7 @@ void DumpTree::last_branch() void DumpTree::end_sub() { tree.pop_back(); - if(tree.back()==STRAIGHT) + if(!tree.empty() && tree.back()==STRAIGHT) tree.back() = BRANCH; } @@ -168,7 +162,7 @@ void DumpTree::visit(MemberAccess &memacc) string text = "Member access:"; if(memacc.declaration) text += format(" %%%d", get_label(*memacc.declaration)); - text += format(" .%s -> %s", memacc.member, format_type(memacc.type)); + text += format(" .%s (%d) -> %s", memacc.member, memacc.index, format_type(memacc.type)); append(memacc, text); append_subtree(*memacc.left); } @@ -379,10 +373,7 @@ void DumpTree::visit(VariableDeclaration &var) void DumpTree::visit(InterfaceBlock &iface) { - string head; - if(!iface.instance_name.empty()) - head += format("%%%d ", get_label(iface)); - head += format("%s %s", iface.interface, iface.block_name); + string head = format("%%%d %s %s", get_label(iface), iface.interface, iface.block_name); if(!iface.instance_name.empty()) head += format(" %s", iface.instance_name); if(iface.array) @@ -395,7 +386,7 @@ void DumpTree::visit(InterfaceBlock &iface) vector branches; if(iface.type_declaration) - append(format("Type: %%%d %s", get_label(*iface.type_declaration), iface.type_declaration->name)); + branches.push_back(format("Type: %%%d %s", get_label(*iface.type_declaration), iface.type_declaration->name)); if(iface.layout) branches.push_back(iface.layout.get()); if(iface.members)