Remove getActualType.

Now that getType no longer needs it, this was only used to see if two
types matched (modulo precision).

Change-Id: Icdf507573f03a8caf2b202465a83e50359eb6446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530570
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Commit-Queue: Arman Uguray <armansito@google.com>
This commit is contained in:
John Stiles 2022-04-15 17:22:34 -04:00 committed by SkCQ
parent 123d29701b
commit 21ca05d8bf
2 changed files with 13 additions and 29 deletions

View File

@ -926,30 +926,6 @@ SpvId SPIRVCodeGenerator::writeStruct(const Type& type, const MemoryLayout& memo
return resultId;
}
const Type& SPIRVCodeGenerator::getActualType(const Type& type) {
if (type.isFloat()) {
return *fContext.fTypes.fFloat;
}
if (type.isSigned()) {
return *fContext.fTypes.fInt;
}
if (type.isUnsigned()) {
return *fContext.fTypes.fUInt;
}
if (type.isMatrix() || type.isVector()) {
if (type.componentType().matches(*fContext.fTypes.fHalf)) {
return fContext.fTypes.fFloat->toCompound(fContext, type.columns(), type.rows());
}
if (type.componentType().matches(*fContext.fTypes.fShort)) {
return fContext.fTypes.fInt->toCompound(fContext, type.columns(), type.rows());
}
if (type.componentType().matches(*fContext.fTypes.fUShort)) {
return fContext.fTypes.fUInt->toCompound(fContext, type.columns(), type.rows());
}
}
return type;
}
SpvId SPIRVCodeGenerator::getType(const Type& type) {
return this->getType(type, fDefaultLayout);
}
@ -1952,7 +1928,7 @@ SpvId SPIRVCodeGenerator::writeCompositeConstructor(const AnyConstructor& c, Out
SpvId SPIRVCodeGenerator::writeConstructorScalarCast(const ConstructorScalarCast& c,
OutputStream& out) {
const Type& type = c.type();
if (this->getActualType(type).matches(this->getActualType(c.argument()->type()))) {
if (type.componentType().numberKind() == c.argument()->type().componentType().numberKind()) {
return this->writeExpression(*c.argument(), out);
}
@ -1969,7 +1945,7 @@ SpvId SPIRVCodeGenerator::writeConstructorCompoundCast(const ConstructorCompound
// Write the composite that we are casting. If the actual type matches, we are done.
SpvId compositeId = this->writeExpression(*c.argument(), out);
if (this->getActualType(ctorType).matches(this->getActualType(argType))) {
if (ctorType.componentType().numberKind() == argType.componentType().numberKind()) {
return compositeId;
}
@ -2579,6 +2555,16 @@ SpvId SPIRVCodeGenerator::writeScalarToMatrixSplat(const Type& matrixType,
return this->writeOpCompositeConstruct(matrixType, matArguments, out);
}
static bool types_match(const Type& a, const Type& b) {
if (a.matches(b)) {
return true;
}
return (a.typeKind() == b.typeKind()) &&
(a.isScalar() || a.isVector() || a.isMatrix()) &&
(a.columns() == b.columns() && a.rows() == b.rows()) &&
a.componentType().numberKind() == b.componentType().numberKind();
}
SpvId SPIRVCodeGenerator::writeBinaryExpression(const Type& leftType, SpvId lhs, Operator op,
const Type& rightType, SpvId rhs,
const Type& resultType, OutputStream& out) {
@ -2588,7 +2574,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const Type& leftType, SpvId lhs,
}
// overall type we are operating on: float2, int, uint4...
const Type* operandType;
if (this->getActualType(leftType).matches(this->getActualType(rightType))) {
if (types_match(leftType, rightType)) {
operandType = &leftType;
} else {
// IR allows mismatched types in expressions (e.g. float2 * float), but they need special

View File

@ -161,8 +161,6 @@ private:
SpvId nextId(Precision precision);
const Type& getActualType(const Type& type);
SpvId getType(const Type& type);
SpvId getType(const Type& type, const MemoryLayout& layout);