]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/debug.cpp
Give declaration nodes to all GLSL types.
[libs/gl.git] / source / glsl / debug.cpp
index 06bf1925cea7e4102015f999cd198d3b67f4615c..d49b9a5f142e8a09b29bcc304e7c29056b87f412 100644 (file)
@@ -14,7 +14,7 @@ const std::string &DumpTree::apply(Stage &stage)
        tree.push_back(BRANCH);
        append(format("Version: %d.%02d", stage.required_features.glsl_version.major, stage.required_features.glsl_version.minor));
 
-       for(std::map<string, StructDeclaration *>::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i)
+       for(std::map<string, TypeDeclaration *>::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i)
                append(format("Type: %%%d %s", get_label(*i->second), i->first));
 
        set<InterfaceBlock *> seen_interfaces;
@@ -236,6 +236,45 @@ void DumpTree::visit(InterfaceLayout &layout)
        annotated_branch(format("Layout: %s", layout.interface), layout.layout);
 }
 
+void DumpTree::visit(BasicTypeDeclaration &type)
+{
+       append(format("%%%d typedef %s", get_label(type), type.name));
+       begin_sub();
+       if(type.kind!=BasicTypeDeclaration::VECTOR && type.kind!=BasicTypeDeclaration::MATRIX)
+               last_branch();
+       if(type.base_type)
+               append(format("%s: %%%d %s", (type.kind==BasicTypeDeclaration::ALIAS ? "Alias of" : "Base"), get_label(*type.base_type), type.base_type->name));
+
+       last_branch();
+       if(type.kind==BasicTypeDeclaration::VECTOR)
+               append(format("Vector: %d", type.size));
+       else if(type.kind==BasicTypeDeclaration::MATRIX)
+               append(format("Matrix: %dx%d", type.size&0xFFFF, type.size>>16));
+       end_sub();
+}
+
+void DumpTree::visit(ImageTypeDeclaration &type)
+{
+       append(format("%%%d typedef %s", get_label(type), type.name));
+       begin_sub();
+
+       if(!type.shadow && !type.base_type)
+               last_branch();
+       static const char *dims[] = { "1D", "2D", "3D", "Cube" };
+       append(format("Dimensions: %s%s", dims[type.dimensions-1], (type.array ? " array" : "")));
+
+       if(!type.shadow)
+               last_branch();
+       if(type.base_type)
+               append(format("Element type: %%%d %s", get_label(*type.base_type), type.base_type->name));
+
+       last_branch();
+       if(type.shadow)
+               append("Shadow");
+
+       end_sub();
+}
+
 void DumpTree::visit(StructDeclaration &strct)
 {
        annotated_branch(format("%%%d struct %s", get_label(strct), strct.name), strct.members);
@@ -262,6 +301,11 @@ void DumpTree::visit(VariableDeclaration &var)
        append(decl);
 
        begin_sub();
+       if(!var.layout && !var.array && !var.init_expression)
+               last_branch();
+       if(var.type_declaration)
+               append(format("Type: %%%d %s", get_label(*var.type_declaration), var.type_declaration->name));
+
        if(!var.array && !var.init_expression)
                last_branch();
        if(var.layout)