summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-layout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-layout.cpp')
-rw-r--r--source/slang/slang-ir-layout.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang-ir-layout.cpp b/source/slang/slang-ir-layout.cpp
index a6684c7b1..9bbdb1aef 100644
--- a/source/slang/slang-ir-layout.cpp
+++ b/source/slang/slang-ir-layout.cpp
@@ -152,10 +152,18 @@ case kIROp_##TYPE##Type: \
auto structType = cast<IRStructType>(type);
IRSizeAndAlignment structLayout;
IRIntegerValue offset = 0;
+ bool seenFinalUnsizedArrayField = false;
for (auto field : structType->getFields())
{
+ // If we failed to catch an unsized array earlier in the pipeline,
+ // this will pick it up before generating nonsense results for
+ // subsequent offsets
+ SLANG_ASSERT(!seenFinalUnsizedArrayField);
+
IRSizeAndAlignment fieldTypeLayout;
SLANG_RETURN_ON_FAIL(getSizeAndAlignment(target, rules, field->getFieldType(), &fieldTypeLayout));
+ seenFinalUnsizedArrayField = fieldTypeLayout.size == IRSizeAndAlignment::kIndeterminateSize;
+
structLayout.size = align(offset, fieldTypeLayout.alignment);
structLayout.alignment = std::max(structLayout.alignment, fieldTypeLayout.alignment);
@@ -202,6 +210,15 @@ case kIROp_##TYPE##Type: \
}
break;
+ case kIROp_UnsizedArrayType:
+ {
+ auto unsizedArrayType = cast<IRUnsizedArrayType>(type);
+ getSizeAndAlignment(target, rules, unsizedArrayType->getElementType(), outSizeAndAlignment);
+ outSizeAndAlignment->size = IRSizeAndAlignment::kIndeterminateSize;
+ return SLANG_OK;
+ }
+ break;
+
case kIROp_VectorType:
{
auto vecType = cast<IRVectorType>(type);