From: Mikko Rasa Date: Tue, 6 Apr 2021 09:46:48 +0000 (+0300) Subject: Fix GLSL member access index calculation X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=631872e13c2670f7dece44512ed55af50b77f399 Fix GLSL member access index calculation Also show it in debug output --- diff --git a/source/glsl/debug.cpp b/source/glsl/debug.cpp index 2be5bce4..bd3404e5 100644 --- a/source/glsl/debug.cpp +++ b/source/glsl/debug.cpp @@ -162,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); } diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index bf32326f..3201ea1b 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -293,6 +293,7 @@ void VariableResolver::visit(MemberAccess &memacc) if(i!=strct->members.variables.end()) { declaration = i->second; + index = 0; for(NodeList::const_iterator j=strct->members.body.begin(); (j!=strct->members.body.end() && j->get()!=i->second); ++j) ++index;