summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-constraint.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-09 20:11:09 -0700
committerGitHub <noreply@github.com>2023-08-09 20:11:09 -0700
commitf875d3f5ba9c1ddc6aa9a0960efd5ab27ae4e4c9 (patch)
tree42dae9fd6c260dfdafe7ce4a1ffc392e799c855d /source/slang/slang-check-constraint.cpp
parent03a5bb4bc0391e2de3c2dfb9ff3213bc0ccd9664 (diff)
Support implciit casted swizzled lvalue. (#3077)
* Support implciit casted swizzled lvalue. * Fix warnings. * Fix. * fix comment. * Prefer mangled linkage name for global params. * Update tests. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-constraint.cpp')
-rw-r--r--source/slang/slang-check-constraint.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp
index b9d33a1c1..d66bf35cc 100644
--- a/source/slang/slang-check-constraint.cpp
+++ b/source/slang/slang-check-constraint.cpp
@@ -186,20 +186,15 @@ namespace Slang
{
if (auto rightBasic = as<BasicExpressionType>(right))
{
- auto leftFlavor = leftBasic->getBaseType();
- auto rightFlavor = rightBasic->getBaseType();
+ auto costConvertRightToLeft = getConversionCost(leftBasic, rightBasic);
+ auto costConvertLeftToRight = getConversionCost(rightBasic, leftBasic);
- // TODO(tfoley): Need a special-case rule here that if
- // either operand is of type `half`, then we promote
- // to at least `float`
-
- // Return the one that had higher rank...
- if (leftFlavor > rightFlavor)
- return left;
+ // Return the one that had lower conversion cost.
+ if (costConvertRightToLeft > costConvertLeftToRight)
+ return right;
else
{
- SLANG_ASSERT(rightFlavor > leftFlavor); // equality was handles at the top of this function
- return right;
+ return left;
}
}