HLSL: allow promotion from 1-vector types to scalars, e.g, float<-float1
Previously, an error was thrown when assigning a float1 to a scalar float, or similar for other basic types. This allows that. Also, this allows calling functions accepting scalars with float1 params, so for example sin(float1) will work. This is a minor change in HlslParseContext::findFunction().
This commit is contained in:
@@ -1271,6 +1271,7 @@ public:
|
||||
virtual TArraySizes& getArraySizes() { assert(arraySizes != nullptr); return *arraySizes; }
|
||||
|
||||
virtual bool isScalar() const { return ! isVector() && ! isMatrix() && ! isStruct() && ! isArray(); }
|
||||
virtual bool isScalarOrVec1() const { return isScalar() || vector1; }
|
||||
virtual bool isVector() const { return vectorSize > 1 || vector1; }
|
||||
virtual bool isMatrix() const { return matrixCols ? true : false; }
|
||||
virtual bool isArray() const { return arraySizes != nullptr; }
|
||||
|
||||
@@ -814,8 +814,10 @@ TIntermTyped* TIntermediate::addShapeConversion(TOperator op, const TType& type,
|
||||
TOperator constructorOp = mapTypeToConstructorOp(type);
|
||||
|
||||
// scalar -> smeared -> vector, or
|
||||
// vec1 -> scalar, or
|
||||
// bigger vector -> smaller vector or scalar
|
||||
if ((type.isVector() && node->getType().isScalar()) ||
|
||||
(node->getType().isVector() && node->getVectorSize() == 1 && type.isScalar()) ||
|
||||
(node->getVectorSize() > type.getVectorSize() && type.isVector()))
|
||||
return setAggregateOperator(makeAggregate(node), constructorOp, type, node->getLoc());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user