diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2025-01-30 00:59:49 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 00:59:49 -0800 |
| commit | ba9b2785c69c1b8c6d2b4103267b5281815f9f23 (patch) | |
| tree | e4ba4ca76c6592b90764a0a7ac32502639dc93aa /source/slang/slang-check-conversion.cpp | |
| parent | 2ae194d51e15c064c3d905e628f7335de7504e32 (diff) | |
Support cooperative vector (#6223)
* Support cooperative vector without Vulkan-header update
Adding a Slang support for cooperative vector.
But this commit doesn't have Vulkan-header update.
Diffstat (limited to 'source/slang/slang-check-conversion.cpp')
| -rw-r--r-- | source/slang/slang-check-conversion.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index 248c83fe5..db8548dce 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -34,6 +34,8 @@ BuiltinConversionKind SemanticsVisitor::getImplicitConversionBuiltinKind(Decl* d bool SemanticsVisitor::isEffectivelyScalarForInitializerLists(Type* type) { + if (as<CoopVectorExpressionType>(type)) + return false; if (as<ArrayExpressionType>(type)) return false; if (as<VectorExpressionType>(type)) @@ -282,6 +284,50 @@ bool SemanticsVisitor::_readAggregateValueFromInitializerList( } } } + else if (auto toCoopVectorType = as<CoopVectorExpressionType>(toType)) + { + auto toElementCount = toCoopVectorType->getElementCount(); + auto toElementType = toCoopVectorType->getElementType(); + + UInt elementCount = 0; + if (auto constElementCount = as<ConstantIntVal>(toElementCount)) + { + elementCount = (UInt)constElementCount->getValue(); + } + else + { + // We don't know the element count statically, + // so what are we supposed to be doing? + // + if (outToExpr) + { + getSink()->diagnose( + fromInitializerListExpr, + Diagnostics::cannotUseInitializerListForCoopVectorOfUnknownSize, + toElementCount); + } + return false; + } + + for (UInt ee = 0; ee < elementCount; ++ee) + { + Expr* coercedArg = nullptr; + bool argResult = _readValueFromInitializerList( + toElementType, + outToExpr ? &coercedArg : nullptr, + fromInitializerListExpr, + ioArgIndex); + + // No point in trying further if any argument fails + if (!argResult) + return false; + + if (coercedArg) + { + coercedArgs.add(coercedArg); + } + } + } else if (auto toArrayType = as<ArrayExpressionType>(toType)) { // TODO(tfoley): If we can compute the size of the array statically, |
