HLSL: vector shape conversions for all ops: Fix #839. Fix #653. Fix #631.

This commit is contained in:
John Kessenich
2017-04-18 21:07:05 -06:00
parent 2aa12b1c05
commit d5d9ffbdfd
5 changed files with 330 additions and 67 deletions

View File

@@ -2087,7 +2087,7 @@ TIntermNode* HlslParseContext::handleReturnValue(const TSourceLoc& loc, TIntermT
} else if (*currentFunctionType != value->getType()) {
value = intermediate.addConversion(EOpReturn, *currentFunctionType, value);
if (value && *currentFunctionType != value->getType())
value = intermediate.addShapeConversion(EOpReturn, *currentFunctionType, value);
value = intermediate.addUniShapeConversion(EOpReturn, *currentFunctionType, value);
if (value == nullptr) {
error(loc, "type does not match, or is not convertible to, the function's return type", "return", "");
return value;
@@ -4105,7 +4105,7 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
// convert to the correct type.
TIntermTyped* convArg = intermediate.addConversion(EOpFunctionCall, *function[i].type, arg);
if (convArg != nullptr)
convArg = intermediate.addShapeConversion(EOpFunctionCall, *function[i].type, convArg);
convArg = intermediate.addUniShapeConversion(EOpFunctionCall, *function[i].type, convArg);
if (convArg != nullptr)
setArg(i, convArg);
else
@@ -6439,7 +6439,7 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm
initializer = intermediate.addConversion(EOpAssign, variable->getType(), initializer);
if (initializer != nullptr && variable->getType() != initializer->getType())
initializer = intermediate.addShapeConversion(EOpAssign, variable->getType(), initializer);
initializer = intermediate.addUniShapeConversion(EOpAssign, variable->getType(), initializer);
if (initializer == nullptr || !initializer->getAsConstantUnion() ||
variable->getType() != initializer->getType()) {
error(loc, "non-matching or non-convertible constant type for const initializer",