From ac9ac60a1e98aa9c2c3874d6b0b78532045f0a18 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Sat, 14 Sep 2024 18:20:57 +0200 Subject: [PATCH] GlslWriter: Fix structs in array wrongly omitted --- src/NZSL/GlslWriter.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/NZSL/GlslWriter.cpp b/src/NZSL/GlslWriter.cpp index 8e30711..793c62e 100644 --- a/src/NZSL/GlslWriter.cpp +++ b/src/NZSL/GlslWriter.cpp @@ -126,6 +126,20 @@ namespace nzsl RegisterPrecisionQualifiers(std::get(type).containedType->type); } + void RegisterStructType(const Ast::ExpressionType& type) + { + if (IsStorageType(type)) + usedStructs.UnboundedSet(std::get(type).containedType.structIndex); + else if (IsUniformType(type)) + usedStructs.UnboundedSet(std::get(type).containedType.structIndex); + else if (IsStructType(type)) + usedStructs.UnboundedSet(std::get(type).structIndex); + else if (IsArrayType(type)) + RegisterStructType(std::get(type).containedType->type); + else if (IsDynArrayType(type)) + RegisterStructType(std::get(type).containedType->type); + } + void Resolve() { usedStructs.Resize(bufferStructs.GetSize()); @@ -253,26 +267,14 @@ namespace nzsl structs[node.structIndex.value()] = &node.description; for (const auto& member : node.description.members) - { - const Ast::ExpressionType& type = member.type.GetResultingValue(); - if (IsStorageType(type)) - usedStructs.UnboundedSet(std::get(type).containedType.structIndex); - else if (IsUniformType(type)) - usedStructs.UnboundedSet(std::get(type).containedType.structIndex); - } + RegisterStructType(member.type.GetResultingValue()); RecursiveVisitor::Visit(node); } void Visit(Ast::DeclareVariableStatement& node) override { - const Ast::ExpressionType& type = node.varType.GetResultingValue(); - if (IsStorageType(type)) - usedStructs.UnboundedSet(std::get(type).containedType.structIndex); - else if (IsUniformType(type)) - usedStructs.UnboundedSet(std::get(type).containedType.structIndex); - else if (IsStructType(type)) - usedStructs.UnboundedSet(std::get(type).structIndex); + RegisterStructType(node.varType.GetResultingValue()); RecursiveVisitor::Visit(node); }