summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-14 16:23:19 -0700
committerGitHub <noreply@github.com>2023-08-14 16:23:19 -0700
commit661d6198bbb9857d3fdc6df477e0742ed0b0765c (patch)
tree974a57cfa2e43624e91502e9e652a0cc78105b3a /source/slang/slang-check-decl.cpp
parent0403e0556b470f6b316153caea2dc6f5c314da5b (diff)
Support per field matrix layout (#3101)
* Support per field matrix layout * Fix warnings. * Fix. * Fix tests. * Fix spiv gen. * Fix. * More test fixes. * Fix. * Run only GPU tests on self-hosted servers. * Remove -use-glsl-matrix-layout-modifier. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 4e8a00907..6385e5f57 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1069,6 +1069,23 @@ namespace Slang
validateArraySizeForVariable(varDecl);
}
+ // If there is a matrix layout modifier, we will modify the matrix type now.
+ if (auto matrixType = as<MatrixExpressionType>(varDecl->type.type))
+ {
+ if (auto matrixLayoutModifier = varDecl->findModifier<MatrixLayoutModifier>())
+ {
+ auto matrixLayout = as<ColumnMajorLayoutModifier>(matrixLayoutModifier) ? SLANG_MATRIX_LAYOUT_COLUMN_MAJOR : SLANG_MATRIX_LAYOUT_ROW_MAJOR;
+ auto newMatrixType = getASTBuilder()->getMatrixType(
+ matrixType->getElementType(),
+ matrixType->getRowCount(),
+ matrixType->getColumnCount(),
+ getASTBuilder()->getIntVal(getASTBuilder()->getIntType(), matrixLayout));
+ varDecl->type.type = newMatrixType;
+ if (varDecl->initExpr)
+ varDecl->initExpr = coerce(CoercionSite::Initializer, varDecl->type, varDecl->initExpr);
+ }
+ }
+
checkMeshOutputDecl(varDecl);
// The NVAPI library allows user code to express extended operations