From 661d6198bbb9857d3fdc6df477e0742ed0b0765c Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 14 Aug 2023 16:23:19 -0700 Subject: 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 --- source/slang/slang-check-decl.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/slang/slang-check-decl.cpp') 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(varDecl->type.type)) + { + if (auto matrixLayoutModifier = varDecl->findModifier()) + { + auto matrixLayout = as(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 -- cgit v1.2.3