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.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/slang/slang-ir-layout.cpp b/source/slang/slang-ir-layout.cpp
index 41b004372..ed3fff2c0 100644
--- a/source/slang/slang-ir-layout.cpp
+++ b/source/slang/slang-ir-layout.cpp
@@ -77,6 +77,12 @@ static Result _calcNaturalArraySizeAndAlignment(
return SLANG_OK;
}
+IRIntegerValue getIntegerValueFromInst(IRInst* inst)
+{
+ SLANG_ASSERT(inst->op == kIROp_IntLit);
+ return as<IRIntLit>(inst)->value.intVal;
+}
+
static Result _calcNaturalSizeAndAlignment(
TargetRequest* target,
IRType* type,
@@ -192,6 +198,24 @@ static Result _calcNaturalSizeAndAlignment(
}
break;
+ case kIROp_MatrixType:
+ {
+ auto matType = cast<IRMatrixType>(type);
+ auto rowCount = getIntegerValueFromInst(matType->getRowCount());
+ auto colCount = getIntegerValueFromInst(matType->getColumnCount());
+ SharedIRBuilder sharedBuilder;
+ sharedBuilder.module = type->getModule();
+ sharedBuilder.session = sharedBuilder.module->getSession();
+
+ IRBuilder builder;
+ builder.sharedBuilder = &sharedBuilder;
+
+ return _calcNaturalArraySizeAndAlignment(
+ target, matType->getElementType(),
+ builder.getIntValue(builder.getUIntType(), rowCount * colCount),
+ outSizeAndAlignment);
+ }
+ break;
default:
break;
}