Use high precision vertex attributes.
Specifying vertex attributes and the view matrix as mediump causes bad artifacts on Mali T6XX.
Covered by the bigmatrix GM in msaa4 mode.
BUG:skia=3545,3771
Review URL: https://codereview.chromium.org/1145273002
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 5534888..6e2ea06 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -193,7 +193,8 @@
bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_GPType);
bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLocalCoord_GPType);
bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCoverage_GPType);
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
if (hasColor) {
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
}
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index fe223f0..5c231bd 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -183,7 +183,8 @@
, fLocalMatrix(localMatrix)
, fUsesLocalCoords(usesLocalCoords) {
this->initClassID<CircleEdgeEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge",
kVec4f_GrVertexAttribType));
fStroke = stroke;
@@ -556,7 +557,8 @@
, fViewMatrix(viewMatrix)
, fUsesLocalCoords(usesLocalCoords) {
this->initClassID<DIEllipseEdgeEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0",
kVec2f_GrVertexAttribType));
fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1",
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index 2e25bdb..4147b74 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -126,13 +126,16 @@
: fName(NULL)
, fType(kFloat_GrVertexAttribType)
, fOffset(0) {}
- Attribute(const char* name, GrVertexAttribType type)
+ Attribute(const char* name, GrVertexAttribType type,
+ GrSLPrecision precision = kDefault_GrSLPrecision)
: fName(name)
, fType(type)
- , fOffset(SkAlign4(GrVertexAttribTypeSize(type))) {}
+ , fOffset(SkAlign4(GrVertexAttribTypeSize(type)))
+ , fPrecision(precision) {}
const char* fName;
GrVertexAttribType fType;
size_t fOffset;
+ GrSLPrecision fPrecision;
};
int numAttribs() const { return fNumAttribs; }
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 5825580..840645e 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -200,7 +200,8 @@
, fCoverageScale(coverage)
, fEdgeType(edgeType) {
this->initClassID<GrConicEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
fInConicCoeffs = &this->addVertexAttrib(Attribute("inConicCoeffs",
kVec4f_GrVertexAttribType));
}
@@ -401,7 +402,8 @@
, fCoverageScale(coverage)
, fEdgeType(edgeType) {
this->initClassID<GrQuadEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
fInHairQuadEdge = &this->addVertexAttrib(Attribute("inHairQuadEdge",
kVec4f_GrVertexAttribType));
}
@@ -614,7 +616,8 @@
, fViewMatrix(viewMatrix)
, fEdgeType(edgeType) {
this->initClassID<GrCubicEffect>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
fInCubicCoeffs = &this->addVertexAttrib(Attribute("inCubicCoeffs",
kVec4f_GrVertexAttribType));
}
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 1e454a0..92fe0a4 100755
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -205,7 +205,8 @@
, fUsesLocalCoords(usesLocalCoords) {
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
this->initClassID<GrDistanceFieldA8TextGeoProc>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
if (flags & kColorAttr_DistanceFieldEffectFlag) {
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
}
@@ -420,7 +421,8 @@
, fUsesLocalCoords(usesLocalCoords) {
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
this->initClassID<GrDistanceFieldPathGeoProc>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
if (flags & kColorAttr_DistanceFieldEffectFlag) {
fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexAttribType));
}
@@ -674,7 +676,8 @@
, fUsesLocalCoords(usesLocalCoords) {
SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag));
this->initClassID<GrDistanceFieldLCDTextGeoProc>();
- fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
+ fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision));
fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords",
kVec2s_GrVertexAttribType));
this->addTextureAccess(&fTextureAccess);
diff --git a/src/gpu/gl/GrGLPrimitiveProcessor.cpp b/src/gpu/gl/GrGLPrimitiveProcessor.cpp
index d719774..893e556 100644
--- a/src/gpu/gl/GrGLPrimitiveProcessor.cpp
+++ b/src/gpu/gl/GrGLPrimitiveProcessor.cpp
@@ -47,7 +47,7 @@
void GrGLPrimitiveProcessor::addUniformViewMatrix(GrGLGPBuilder* pb) {
fViewMatrixUniform = pb->addUniform(GrGLProgramBuilder::kVertex_Visibility,
- kMat33f_GrSLType, kDefault_GrSLPrecision,
+ kMat33f_GrSLType, kHigh_GrSLPrecision,
"uViewM",
&fViewMatrixName);
}
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.h b/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
index 7f7471d..f684189 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
@@ -23,7 +23,9 @@
void addAttribute(const GrGeometryProcessor::Attribute* attr) {
this->addAttribute(GrShaderVar(attr->fName,
GrVertexAttribTypeToSLType(attr->fType),
- GrShaderVar::kAttribute_TypeModifier));
+ GrShaderVar::kAttribute_TypeModifier,
+ GrShaderVar::kNonArray,
+ attr->fPrecision));
}
private: