From 631872e13c2670f7dece44512ed55af50b77f399 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 6 Apr 2021 12:46:48 +0300 Subject: [PATCH] Fix GLSL member access index calculation Also show it in debug output --- source/glsl/debug.cpp | 2 +- source/glsl/resolve.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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; -- 2.45.2