Got RelaxedPrecision decorations working again in SPIR-V, and removed
no-longer-needed old-style precision handling code.
Bug: skia:8829
Change-Id: I72fc2ee2a305c9c72a3efa92dd44d18239eabaf2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198169
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 1804ecb..c03b1ce 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -1884,9 +1884,14 @@
this->writeInstruction(ifUInt, this->getType(resultType), result, lhs, rhs, out);
} else if (operandType == *fContext.fBool_Type) {
this->writeInstruction(ifBool, this->getType(resultType), result, lhs, rhs, out);
+ return result; // skip RelaxedPrecision check
} else {
ABORT("invalid operandType: %s", operandType.description().c_str());
}
+ if (resultType == operandType && !resultType.highPrecision()) {
+ this->writeInstruction(SpvOpDecorate, result, SpvDecorationRelaxedPrecision,
+ fDecorationBuffer);
+ }
return result;
}
@@ -2712,9 +2717,8 @@
return result;
}
-void SPIRVCodeGenerator::writePrecisionModifier(const Modifiers& modifiers, SpvId id) {
- if ((modifiers.fFlags & Modifiers::kLowp_Flag) |
- (modifiers.fFlags & Modifiers::kMediump_Flag)) {
+void SPIRVCodeGenerator::writePrecisionModifier(const Type& type, SpvId id) {
+ if (!type.highPrecision()) {
this->writeInstruction(SpvOpDecorate, id, SpvDecorationRelaxedPrecision, fDecorationBuffer);
}
}
@@ -2778,7 +2782,7 @@
}
this->writeInstruction(SpvOpVariable, type, id, storageClass, fConstantBuffer);
this->writeInstruction(SpvOpName, id, var->fName, fNameBuffer);
- this->writePrecisionModifier(var->fModifiers, id);
+ this->writePrecisionModifier(var->fType, id);
if (varDecl.fValue) {
SkASSERT(!fCurrentBlock);
fCurrentBlock = -1;