Remove vertex-shader perspective divide
The new fill rect op seems to be the first op that sends 3D local coordinates, so
this wasn't encountered before. Prior ops specifically do not apply a perspective
matrix on the CPU so that the local coords remain 2D until after the transform.
Performing the perspective divide in the VS and then interpolating the 2D results
is basically the same as using non-perspective interpolation on the position
attribute.
Bug: skia:
Change-Id: Ib5bed8230b69040aafb100b34a69acb9309a0547
Reviewed-on: https://skia-review.googlesource.com/c/167387
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index 9a768c2..d7dc7cc 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -77,7 +77,8 @@
strUniName.c_str(),
&uniName).toIndex();
GrSLType varyingType = kFloat2_GrSLType;
- if (localMatrix.hasPerspective() || coordTransform->getMatrix().hasPerspective()) {
+ if (localMatrix.hasPerspective() || coordTransform->getMatrix().hasPerspective()
+ || threeComponentLocalCoords) {
varyingType = kFloat3_GrSLType;
}
SkString strVaryingName;
@@ -89,9 +90,6 @@
if (kFloat2_GrSLType == varyingType) {
vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), uniName, localCoords.c_str());
- if (threeComponentLocalCoords) {
- vb->codeAppendf("%s /= %s.z;", v.vsOut(), localCoords.c_str());
- }
} else {
vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, localCoords.c_str());
}