]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix GLSL member access index calculation
authorMikko Rasa <tdb@tdb.fi>
Tue, 6 Apr 2021 09:46:48 +0000 (12:46 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 6 Apr 2021 09:57:39 +0000 (12:57 +0300)
Also show it in debug output

source/glsl/debug.cpp
source/glsl/resolve.cpp

index 2be5bce4ee2a97d5a31408af182c19c3571c0701..bd3404e56f0fae10addb22fb90f3aec2f234560c 100644 (file)
@@ -162,7 +162,7 @@ void DumpTree::visit(MemberAccess &memacc)
        string text = "Member access:";
        if(memacc.declaration)
                text += format(" %%%d", get_label(*memacc.declaration));
        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);
 }
        append(memacc, text);
        append_subtree(*memacc.left);
 }
index bf32326f249defc16224efb11b10ed3a5a6c7244..3201ea1bb2a70665507dd64469916fb0b09daa5c 100644 (file)
@@ -293,6 +293,7 @@ void VariableResolver::visit(MemberAccess &memacc)
                if(i!=strct->members.variables.end())
                {
                        declaration = i->second;
                if(i!=strct->members.variables.end())
                {
                        declaration = i->second;
+                       index = 0;
                        for(NodeList<Statement>::const_iterator j=strct->members.body.begin(); (j!=strct->members.body.end() && j->get()!=i->second); ++j)
                                ++index;
 
                        for(NodeList<Statement>::const_iterator j=strct->members.body.begin(); (j!=strct->members.body.end() && j->get()!=i->second); ++j)
                                ++index;