Revert "more relaxed precision decorations for SPIR-V output"
This reverts commit 3215f1a5cab750311abf816a92ed76373f0271ab.
Reason for revert: breaking big_rrect_elliptical_corner_aa_effect on Adreno
Original change's description:
> more relaxed precision decorations for SPIR-V output
>
> Bug: skia:
> Change-Id: Ib840187fc5ded2d00e42a8fb675e9dcf606574bb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201984
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
TBR=egdaniel@google.com,ethannicholas@google.com
Change-Id: Id3368edf8442ec62300bb0e4ee639bcbec8dc33f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202202
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 27787bb..c1675be 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -926,7 +926,6 @@
// Flipping Y also negates the Y derivatives.
SpvId flipped = this->nextId();
this->writeInstruction(SpvOpFNegate, this->getType(c.fType), flipped, result, out);
- this->writePrecisionModifier(c.fType, flipped);
return flipped;
}
break;
@@ -980,7 +979,7 @@
return this->writeIntrinsicCall(c, out);
}
// stores (variable, type, lvalue) pairs to extract and save after the function call is complete
- std::vector<std::tuple<SpvId, const Type*, std::unique_ptr<LValue>>> lvalues;
+ std::vector<std::tuple<SpvId, SpvId, std::unique_ptr<LValue>>> lvalues;
std::vector<SpvId> arguments;
for (size_t i = 0; i < c.fArguments.size(); i++) {
// id of temporary variable that we will use to hold this argument, or 0 if it is being
@@ -1000,7 +999,8 @@
// update the lvalue.
tmpValueId = lv->load(out);
tmpVar = this->nextId();
- lvalues.push_back(std::make_tuple(tmpVar, &c.fArguments[i]->fType, std::move(lv)));
+ lvalues.push_back(std::make_tuple(tmpVar, this->getType(c.fArguments[i]->fType),
+ std::move(lv)));
}
} else {
// see getFunctionType for an explanation of why we're always using pointer parameters
@@ -1028,9 +1028,7 @@
// arguments
for (const auto& tuple : lvalues) {
SpvId load = this->nextId();
- this->writeInstruction(SpvOpLoad, getType(*std::get<1>(tuple)), load, std::get<0>(tuple),
- out);
- this->writePrecisionModifier(*std::get<1>(tuple), load);
+ this->writeInstruction(SpvOpLoad, std::get<1>(tuple), load, std::get<0>(tuple), out);
std::get<2>(tuple)->store(load, out);
}
return result;
@@ -1527,12 +1525,10 @@
class PointerLValue : public SPIRVCodeGenerator::LValue {
public:
- PointerLValue(SPIRVCodeGenerator& gen, SpvId pointer, SpvId type,
- SPIRVCodeGenerator::Precision precision)
+ PointerLValue(SPIRVCodeGenerator& gen, SpvId pointer, SpvId type)
: fGen(gen)
, fPointer(pointer)
- , fType(type)
- , fPrecision(precision) {}
+ , fType(type) {}
virtual SpvId getPointer() override {
return fPointer;
@@ -1541,7 +1537,6 @@
virtual SpvId load(OutputStream& out) override {
SpvId result = fGen.nextId();
fGen.writeInstruction(SpvOpLoad, fType, result, fPointer, out);
- fGen.writePrecisionModifier(fPrecision, result);
return result;
}
@@ -1553,20 +1548,17 @@
SPIRVCodeGenerator& fGen;
const SpvId fPointer;
const SpvId fType;
- const SPIRVCodeGenerator::Precision fPrecision;
};
class SwizzleLValue : public SPIRVCodeGenerator::LValue {
public:
SwizzleLValue(SPIRVCodeGenerator& gen, SpvId vecPointer, const std::vector<int>& components,
- const Type& baseType, const Type& swizzleType,
- SPIRVCodeGenerator::Precision precision)
+ const Type& baseType, const Type& swizzleType)
: fGen(gen)
, fVecPointer(vecPointer)
, fComponents(components)
, fBaseType(baseType)
- , fSwizzleType(swizzleType)
- , fPrecision(precision) {}
+ , fSwizzleType(swizzleType) {}
virtual SpvId getPointer() override {
return 0;
@@ -1575,7 +1567,6 @@
virtual SpvId load(OutputStream& out) override {
SpvId base = fGen.nextId();
fGen.writeInstruction(SpvOpLoad, fGen.getType(fBaseType), base, fVecPointer, out);
- fGen.writePrecisionModifier(fPrecision, base);
SpvId result = fGen.nextId();
fGen.writeOpCode(SpvOpVectorShuffle, 5 + (int32_t) fComponents.size(), out);
fGen.writeWord(fGen.getType(fSwizzleType), out);
@@ -1585,7 +1576,6 @@
for (int component : fComponents) {
fGen.writeWord(component, out);
}
- fGen.writePrecisionModifier(fPrecision, result);
return result;
}
@@ -1624,7 +1614,6 @@
}
fGen.writeWord(offset, out);
}
- fGen.writePrecisionModifier(fPrecision, shuffle);
fGen.writeInstruction(SpvOpStore, fVecPointer, shuffle, out);
}
@@ -1634,12 +1623,10 @@
const std::vector<int>& fComponents;
const Type& fBaseType;
const Type& fSwizzleType;
- const SPIRVCodeGenerator::Precision fPrecision;
};
std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const Expression& expr,
OutputStream& out) {
- Precision precision = expr.fType.highPrecision() ? Precision::kHigh : Precision::kLow;
switch (expr.fKind) {
case Expression::kVariableReference_Kind: {
SpvId type;
@@ -1654,8 +1641,7 @@
SkASSERT(entry != fVariableMap.end());
return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue(*this,
entry->second,
- type,
- precision));
+ type));
}
case Expression::kIndex_Kind: // fall through
case Expression::kFieldAccess_Kind: {
@@ -1670,8 +1656,7 @@
return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue(
*this,
member,
- this->getType(expr.fType),
- precision));
+ this->getType(expr.fType)));
}
case Expression::kSwizzle_Kind: {
Swizzle& swizzle = (Swizzle&) expr;
@@ -1691,16 +1676,14 @@
return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue(
*this,
member,
- this->getType(expr.fType),
- precision));
+ this->getType(expr.fType)));
} else {
return std::unique_ptr<SPIRVCodeGenerator::LValue>(new SwizzleLValue(
*this,
base,
swizzle.fComponents,
swizzle.fBase->fType,
- expr.fType,
- precision));
+ expr.fType));
}
}
case Expression::kTernary_Kind: {
@@ -1726,8 +1709,7 @@
return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue(
*this,
result,
- this->getType(expr.fType),
- precision));
+ this->getType(expr.fType)));
}
default:
// expr isn't actually an lvalue, create a dummy variable for it. This case happens due
@@ -1742,8 +1724,7 @@
return std::unique_ptr<SPIRVCodeGenerator::LValue>(new PointerLValue(
*this,
result,
- this->getType(expr.fType),
- precision));
+ this->getType(expr.fType)));
}
}
@@ -1753,7 +1734,6 @@
SkASSERT(entry != fVariableMap.end());
SpvId var = entry->second;
this->writeInstruction(SpvOpLoad, this->getType(ref.fVariable.fType), result, var, out);
- this->writePrecisionModifier(ref.fVariable.fType, result);
if (ref.fVariable.fModifiers.fLayout.fBuiltin == SK_FRAGCOORD_BUILTIN &&
fProgram.fSettings.fFlipY) {
// need to remap to a top-left coordinate system
@@ -2407,7 +2387,6 @@
this->writeLabel(end, out);
SpvId result = this->nextId();
this->writeInstruction(SpvOpLoad, this->getType(t.fType), result, var, out);
- this->writePrecisionModifier(t.fType, result);
return result;
}
@@ -2434,7 +2413,6 @@
} else {
ABORT("unsupported prefix expression %s", p.description().c_str());
}
- this->writePrecisionModifier(p.fType, result);
return result;
}
switch (p.fOperator) {
@@ -2740,11 +2718,7 @@
}
void SPIRVCodeGenerator::writePrecisionModifier(const Type& type, SpvId id) {
- this->writePrecisionModifier(type.highPrecision() ? Precision::kHigh : Precision::kLow, id);
-}
-
-void SPIRVCodeGenerator::writePrecisionModifier(Precision precision, SpvId id) {
- if (precision == Precision::kLow) {
+ if (!type.highPrecision()) {
this->writeInstruction(SpvOpDecorate, id, SpvDecorationRelaxedPrecision, fDecorationBuffer);
}
}
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.h b/src/sksl/SkSLSPIRVCodeGenerator.h
index 422c0e7..3681cfe 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.h
+++ b/src/sksl/SkSLSPIRVCodeGenerator.h
@@ -101,11 +101,6 @@
kTexture_SpecialIntrinsic,
};
- enum class Precision {
- kLow,
- kHigh,
- };
-
void setupIntrinsics();
SpvId nextId();
@@ -125,8 +120,6 @@
SpvId getPointerType(const Type& type, const MemoryLayout& layout,
SpvStorageClass_ storageClass);
- void writePrecisionModifier(Precision precision, SpvId id);
-
void writePrecisionModifier(const Type& type, SpvId id);
std::vector<SpvId> getAccessChain(const Expression& expr, OutputStream& out);