X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fdebug.cpp;h=700acbf9cd50a66c8db4e98c54343d8696a332ce;hb=3a1fe833ea04df75449706f1d773f6e65521a392;hp=ed604fffa94849b49efeb34e722b4399f2a88cda;hpb=ed3bfcde8987c646157f5450a24c2f5368b3ec9a;p=libs%2Fgl.git diff --git a/source/glsl/debug.cpp b/source/glsl/debug.cpp index ed604fff..700acbf9 100644 --- a/source/glsl/debug.cpp +++ b/source/glsl/debug.cpp @@ -165,7 +165,7 @@ void DumpTree::visit(InterfaceBlockReference &iface) string text; if(iface.declaration) text += format("%%%d ", get_label(*iface.declaration)); - text += format("%s (iface)", iface.name); + text += format("%s (iface) -> %s", iface.name, format_type(iface.type)); append(text); } @@ -178,6 +178,16 @@ void DumpTree::visit(MemberAccess &memacc) annotated_branch(text, *memacc.left); } +void DumpTree::visit(Swizzle &swizzle) +{ + static const char components[4] = { 'x', 'y', 'z', 'w' }; + string text = "Swizzle: ."; + for(unsigned i=0; i %s", format_type(swizzle.type)); + annotated_branch(text, *swizzle.left); +} + void DumpTree::visit(UnaryExpression &unary) { string text = format("Unary: %s, %sfix -> %s", unary.oper->token, (unary.oper->type==Operator::PREFIX ? "pre" : "post"), format_type(unary.type)); @@ -198,14 +208,49 @@ void DumpTree::visit(Assignment &assign) { append(format("Assignment: %s%s -> %s", assign.oper->token, (assign.self_referencing ? " (self-referencing)" : ""), format_type(assign.type))); begin_sub(); - if(assign.target_declaration) - append(format("Target: %%%d %s %s", get_label(*assign.target_declaration), assign.target_declaration->type, assign.target_declaration->name)); + if(assign.target.declaration) + { + string text = format("Target: %%%d", get_label(*assign.target.declaration)); + + static const char swizzle[4] = { 'x', 'y', 'z', 'w' }; + for(unsigned i=0; i(component&0xC0)) + { + case Assignment::Target::MEMBER: + text += format(" .%d", component&0x3F); + break; + case Assignment::Target::SWIZZLE: + text += " ."; + for(unsigned j=0; j<4; ++j) + if(component&(1<visit(*this); last_branch(); assign.right->visit(*this); end_sub(); } +void DumpTree::visit(TernaryExpression &ternary) +{ + append(format("Ternary: %s -> %s", (ternary.oper->token[0]=='?' ? "?:" : ternary.oper->token), format_type(ternary.type))); + begin_sub(); + ternary.condition->visit(*this); + ternary.true_expr->visit(*this); + last_branch(); + ternary.false_expr->visit(*this); + end_sub(); +} + void DumpTree::visit(FunctionCall &call) { string head = "Function call: "; @@ -332,26 +377,34 @@ void DumpTree::visit(VariableDeclaration &var) append_subtree(branches); } -void DumpTree::visit(InterfaceBlock &block) +void DumpTree::visit(InterfaceBlock &iface) { string head; - if(!block.instance_name.empty()) - head += format("%%%d ", get_label(block)); - head += format("%s %s", block.interface, block.name); - if(!block.instance_name.empty()) - head += format(" %s", block.instance_name); - if(block.array) + if(!iface.instance_name.empty()) + head += format("%%%d ", get_label(iface)); + head += format("%s %s", iface.interface, iface.name); + if(!iface.instance_name.empty()) + head += format(" %s", iface.instance_name); + if(iface.array) head += "[]"; - if(block.source==BUILTIN_SOURCE) + if(iface.source==BUILTIN_SOURCE) head += " (builtin)"; - else if(block.linked_block) + else if(iface.linked_block) head += " (linked)"; - annotated_branch(head, block.members); + append(head); + + begin_sub(); + last_branch(); + if(iface.type_declaration) + append(format("Type: %%%d %s", get_label(*iface.type_declaration), iface.type_declaration->name)); + else if(iface.members) + iface.members->visit(*this); + end_sub(); } void DumpTree::visit(FunctionDeclaration &func) { - string text = format("%%%d %s %s", get_label(func), func.return_type, func.name); + string text = format("%%%d %s %s%s", get_label(func), func.return_type, func.name, (func.signature.empty() ? "(?)" : func.signature)); if(func.source==BUILTIN_SOURCE) text += " (builtin)"; else if(!func.definition) @@ -359,6 +412,8 @@ void DumpTree::visit(FunctionDeclaration &func) append(text); begin_sub(); + if(func.return_type_declaration) + append(format("Return type: %%%d %s", get_label(*func.return_type_declaration), func.return_type_declaration->name)); for(NodeArray::const_iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) (*i)->visit(*this); last_branch();