summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-12 19:31:25 -0700
committerGitHub <noreply@github.com>2024-03-12 19:31:25 -0700
commit6f7c8271710b43349d34b8f7569ceb6957400548 (patch)
tree288c18bb4b9a2cf32de7e400c1fe8b56385b727e /source/slang/slang-check-expr.cpp
parenteef7e208bf7436a4f111a9290f37204e3220d82b (diff)
Fix `sessionDesc.defaultMatrixLayoutMode` being ineffective. (#3753)
* Fix `sessionDesc.defaultMatrixLayoutMode` being ineffective. * Fix matrix layout in buffer pointer. * Attempt to fix. * Fix buffer element type lowering for buffer pointers. * Add comment. * Fix test. * Fix member lookup in `Ref<T>`. * Fix validation error. * Enhance test.
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index ea6afdc1d..995b5e888 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -4164,15 +4164,39 @@ namespace Slang
List<Val*> modifierVals;
for( auto modifier : expr->modifiers )
{
+ if (auto matrixLayoutModifier = as<MatrixLayoutModifier>(modifier))
+ {
+ if (auto matrixType = as<MatrixExpressionType>(baseType))
+ {
+ if (as<ColumnMajorLayoutModifier>(matrixLayoutModifier))
+ {
+ baseType = m_astBuilder->getMatrixType(matrixType->getElementType(), matrixType->getRowCount(), matrixType->getColumnCount(),
+ m_astBuilder->getIntVal(m_astBuilder->getIntType(), kMatrixLayoutMode_ColumnMajor));
+ }
+ else
+ {
+ baseType = m_astBuilder->getMatrixType(matrixType->getElementType(), matrixType->getRowCount(), matrixType->getColumnCount(),
+ m_astBuilder->getIntVal(m_astBuilder->getIntType(), kMatrixLayoutMode_RowMajor));
+ }
+ expr->type = m_astBuilder->getTypeType(baseType);
+ }
+ else
+ {
+ getSink()->diagnose(matrixLayoutModifier, Diagnostics::matrixLayoutModifierOnNonMatrixType, baseType);
+ }
+ continue;
+ }
auto modifierVal = checkTypeModifier(modifier, baseType);
if(!modifierVal)
continue;
modifierVals.add(modifierVal);
}
- auto modifiedType = m_astBuilder->getModifiedType(baseType, modifierVals);
- expr->type = m_astBuilder->getTypeType(modifiedType);
-
+ if (modifierVals.getCount())
+ {
+ auto modifiedType = m_astBuilder->getModifiedType(baseType, modifierVals);
+ expr->type = m_astBuilder->getTypeType(modifiedType);
+ }
return expr;
}