Revert "SkSL is now pickier about type conversions"
This reverts commit 91c1d08bc391c997418512b9599f3acd3b2c985d.
Reason for revert: breaking everything
Original change's description:
> SkSL is now pickier about type conversions
>
> Bug: skia:
> Change-Id: I4e8b8f229f4e4344f160b0dbb41832764d0b75bd
> Reviewed-on: https://skia-review.googlesource.com/c/188311
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com,ethannicholas@google.com
Change-Id: I670fa9215d3ca0ce738edc24e832b6d968599cb1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/189642
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/ccpr/GrCCConicShader.cpp b/src/gpu/ccpr/GrCCConicShader.cpp
index 8b136e9..9b67470 100644
--- a/src/gpu/ccpr/GrCCConicShader.cpp
+++ b/src/gpu/ccpr/GrCCConicShader.cpp
@@ -74,10 +74,10 @@
const char* outputCoverage) const {
this->calcHullCoverage(&AccessCodeString(f), fKLM_fWind.fsIn(), fGrad_fCorner.fsIn(),
outputCoverage);
- f->codeAppendf("%s *= half(%s.w);", outputCoverage, fKLM_fWind.fsIn()); // Wind.
+ f->codeAppendf("%s *= %s.w;", outputCoverage, fKLM_fWind.fsIn()); // Wind.
if (kFloat4_GrSLType == fGrad_fCorner.type()) {
- f->codeAppendf("%s = fma(half(%s.z), half(%s.w), %s);", // Attenuated corner coverage.
+ f->codeAppendf("%s = %s.z * %s.w + %s;", // Attenuated corner coverage.
outputCoverage, fGrad_fCorner.fsIn(), fGrad_fCorner.fsIn(),
outputCoverage);
}
@@ -88,9 +88,7 @@
code->appendf("float k = %s.x, l = %s.y, m = %s.z;", klm, klm, klm);
code->append ("float f = k*k - l*m;");
code->appendf("float fwidth = abs(%s.x) + abs(%s.y);", grad, grad);
- code->appendf("float curve_coverage = min(0.5 - f/fwidth, 1);");
- // K doubles as the flat opposite edge's AA.
- code->append ("float edge_coverage = min(k - 0.5, 0);");
- // Total hull coverage.
- code->appendf("%s = max(half(curve_coverage + edge_coverage), 0);", outputCoverage);
+ code->appendf("%s = min(0.5 - f/fwidth, 1);", outputCoverage); // Curve coverage.
+ code->append ("half d = min(k - 0.5, 0);"); // K doubles as the flat opposite edge's AA.
+ code->appendf("%s = max(%s + d, 0);", outputCoverage, outputCoverage); // Total hull coverage.
}
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor.cpp b/src/gpu/ccpr/GrCCCoverageProcessor.cpp
index f72ccf9..cb6bf0c 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor.cpp
@@ -66,12 +66,11 @@
// if the max effect it can have on any single pixel is <~ 1/1024, or 1/4 of a bit in 8888.
s->codeAppend ("float2 bbox_size = max(abs(a), abs(b));");
s->codeAppend ("float basewidth = max(bbox_size.x + bbox_size.y, 1);");
- s->codeAppendf("%s = (abs(area_x2 * 1024) > basewidth) ? sign(half(area_x2)) : 0;",
- outputWind);
+ s->codeAppendf("%s = (abs(area_x2 * 1024) > basewidth) ? sign(area_x2) : 0;", outputWind);
} else {
// We already converted nearly-flat curves to lines on the CPU, so no need to worry about
// thin curve hulls at this point.
- s->codeAppendf("%s = sign(half(area_x2));", outputWind);
+ s->codeAppendf("%s = sign(area_x2);", outputWind);
}
}
@@ -120,8 +119,7 @@
s->codeAppendf("float t = dot(%s, n);", rasterVertexDir);
// The below conditional guarantees we get exactly 1 on the divide when nwidth=t (in case the
// GPU divides by multiplying by the reciprocal?) It also guards against NaN when nwidth=0.
- s->codeAppendf("%s = half(abs(t) != nwidth ? t / nwidth : sign(t)) * -.5 - .5;",
- outputCoverage);
+ s->codeAppendf("%s = (abs(t) != nwidth ? t / nwidth : sign(t)) * -.5 - .5;", outputCoverage);
}
void GrCCCoverageProcessor::Shader::CalcEdgeCoveragesAtBloatVertices(GrGLSLVertexGeoBuilder* s,
@@ -136,7 +134,7 @@
s->codeAppend ("float nwidth = abs(n.x) + abs(n.y);");
s->codeAppendf("float2 t = n * float2x2(%s, %s);", bloatDir1, bloatDir2);
s->codeAppendf("for (int i = 0; i < 2; ++i) {");
- s->codeAppendf( "%s[i] = half(abs(t[i]) != nwidth ? t[i] / nwidth : sign(t[i])) * -.5 - .5;",
+ s->codeAppendf( "%s[i] = (abs(t[i]) != nwidth ? t[i] / nwidth : sign(t[i])) * -.5 - .5;",
outputCoverages);
s->codeAppendf("}");
}
@@ -149,14 +147,13 @@
//
// NOTE: leftDir and rightDir are normalized and point in the same direction the path was
// defined with, i.e., leftDir points into the corner and rightDir points away from the corner.
- s->codeAppendf("half obtuseness = max(half(dot(%s, %s)), 0);", leftDir, rightDir);
+ s->codeAppendf("half obtuseness = max(dot(%s, %s), 0);", leftDir, rightDir);
// axis_alignedness = 1 - tan(angle_to_nearest_axis_from_corner_bisector)
// (i.e., 1 when the corner bisector is aligned with the x- or y-axis
// 0 when the corner bisector falls on a 45 degree angle
// 0..1 when the corner bisector falls somewhere in between
- s->codeAppendf("half2 abs_bisect_maybe_transpose = abs((0 == obtuseness) ? half2(%s - %s) : "
- "half2(%s + %s));",
+ s->codeAppendf("half2 abs_bisect_maybe_transpose = abs((0 == obtuseness) ? %s - %s : %s + %s);",
leftDir, rightDir, leftDir, rightDir);
s->codeAppend ("half axis_alignedness = "
"1 - min(abs_bisect_maybe_transpose.y, abs_bisect_maybe_transpose.x) / "
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp b/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
index 79ee1af..e3fbb74 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
@@ -62,7 +62,7 @@
if (PrimitiveType::kWeightedTriangles == proc.fPrimitiveType) {
SkASSERT(3 == numInputPoints);
SkASSERT(kFloat4_GrVertexAttribType == proc.fVertexAttribute.cpuType());
- g->codeAppendf("%s *= half(sk_in[0].sk_Position.w);", wind.c_str());
+ g->codeAppendf("%s *= sk_in[0].sk_Position.w;", wind.c_str());
}
SkString emitVertexFn;
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
index 4162ee0..38b1435 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
@@ -268,8 +268,7 @@
SkASSERT(3 == numInputPoints);
SkASSERT(kFloat4_GrVertexAttribType ==
proc.fInstanceAttributes[kInstanceAttribIdx_X].cpuType());
- v->codeAppendf("wind *= half(%s.w);",
- proc.fInstanceAttributes[kInstanceAttribIdx_X].name());
+ v->codeAppendf("wind *= %s.w;", proc.fInstanceAttributes[kInstanceAttribIdx_X].name());
}
float bloat = kAABloatRadius;
diff --git a/src/gpu/ccpr/GrCCCubicShader.cpp b/src/gpu/ccpr/GrCCCubicShader.cpp
index 7336bb0..f869c73 100644
--- a/src/gpu/ccpr/GrCCCubicShader.cpp
+++ b/src/gpu/ccpr/GrCCCubicShader.cpp
@@ -128,7 +128,7 @@
// Wind is the sign of both L and/or M. Take the sign of whichever has the larger magnitude.
// (In reality, either would be fine because we chop cubics with more than a half pixel of
// padding around the L & M lines, so neither should approach zero.)
- f->codeAppend ("half wind = sign(half(l + m));");
+ f->codeAppend ("half wind = sign(l + m);");
f->codeAppendf("%s *= wind;", outputCoverage);
if (fCornerCoverage.fsIn()) {
@@ -144,9 +144,7 @@
code->append ("float f = k*k*k - l*m;");
code->appendf("float2 grad = %s.xy * k + %s.zw;", gradMatrix, gradMatrix);
code->append ("float fwidth = abs(grad.x) + abs(grad.y);");
- code->appendf("float curve_coverage = min(0.5 - f/fwidth, 1);");
- // Flat edge opposite the curve.
- code->appendf("float edge_coverage = min(%s.w, 0);", klmAndEdge);
- // Total hull coverage.
- code->appendf("%s = max(half(curve_coverage + edge_coverage), 0);", outputCoverage);
+ code->appendf("%s = min(0.5 - f/fwidth, 1);", outputCoverage); // Curve coverage.
+ code->appendf("half d = min(%s.w, 0);", klmAndEdge); // Flat edge opposite the curve.
+ code->appendf("%s = max(%s + d, 0);", outputCoverage, outputCoverage); // Total hull coverage.
}
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index 06e6435..e397516 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -198,9 +198,8 @@
// NOTE: If we were just drawing a rect, ceil/floor would be enough. But since there are also
// diagonals in the octagon that cross through pixel centers, we need to outset by another
// quarter px to ensure those pixels get rasterized.
- v->codeAppend ("half2 bloatdir = (0 != N[0].x) "
- "? half2(half(N[0].x), half(N[1].y))"
- ": half2(half(N[1].x), half(N[0].y));");
+ v->codeAppend ("float2 bloatdir = (0 != N[0].x) "
+ "? half2(N[0].x, N[1].y) : half2(N[1].x, N[0].y);");
v->codeAppend ("octocoord = (ceil(octocoord * bloatdir - 1e-4) + 0.25) * bloatdir;");
gpArgs->fPositionVar.set(kFloat2_GrSLType, "octocoord");
@@ -233,7 +232,7 @@
// Scale coverage count by .5. Make it negative for even-odd paths and positive for winding
// ones. Clamp winding coverage counts at 1.0 (i.e. min(coverage/2, .5)).
- f->codeAppendf("coverage = min(abs(coverage) * half(%s.z), .5);", texcoord.fsIn());
+ f->codeAppendf("coverage = min(abs(coverage) * %s.z, .5);", texcoord.fsIn());
// For negative values, this finishes the even-odd sawtooth function. Since positive (winding)
// values were clamped at "coverage/2 = .5", this only undoes the previous multiply by .5.
diff --git a/src/gpu/ccpr/GrCCQuadraticShader.cpp b/src/gpu/ccpr/GrCCQuadraticShader.cpp
index 4f248cb..bd79be3 100644
--- a/src/gpu/ccpr/GrCCQuadraticShader.cpp
+++ b/src/gpu/ccpr/GrCCQuadraticShader.cpp
@@ -69,10 +69,10 @@
this->calcHullCoverage(&AccessCodeString(f), fCoord_fGrad.fsIn(),
SkStringPrintf("%s.x", fEdge_fWind_fCorner.fsIn()).c_str(),
outputCoverage);
- f->codeAppendf("%s *= half(%s.y);", outputCoverage, fEdge_fWind_fCorner.fsIn()); // Wind.
+ f->codeAppendf("%s *= %s.y;", outputCoverage, fEdge_fWind_fCorner.fsIn()); // Wind.
if (kFloat4_GrSLType == fEdge_fWind_fCorner.type()) {
- f->codeAppendf("%s = half(%s.z * %s.w) + %s;",// Attenuated corner coverage.
+ f->codeAppendf("%s = %s.z * %s.w + %s;",// Attenuated corner coverage.
outputCoverage, fEdge_fWind_fCorner.fsIn(), fEdge_fWind_fCorner.fsIn(),
outputCoverage);
}
@@ -84,9 +84,7 @@
code->appendf("float2 grad = %s.zw;", coordAndGrad);
code->append ("float f = x*x - y;");
code->append ("float fwidth = abs(grad.x) + abs(grad.y);");
- code->appendf("float curve_coverage = min(0.5 - f/fwidth, 1);");
- // Flat edge opposite the curve.
- code->appendf("float edge_coverage = min(%s, 0);", edge);
- // Total hull coverage.
- code->appendf("%s = max(half(curve_coverage + edge_coverage), 0);", outputCoverage);
+ code->appendf("%s = min(0.5 - f/fwidth, 1);", outputCoverage); // Curve coverage.
+ code->appendf("half d = min(%s, 0);", edge); // Flat edge opposite the curve.
+ code->appendf("%s = max(%s + d, 0);", outputCoverage, outputCoverage); // Total hull coverage.
}
diff --git a/src/gpu/ccpr/GrCCStroker.cpp b/src/gpu/ccpr/GrCCStroker.cpp
index e0e1bc3..5293658 100644
--- a/src/gpu/ccpr/GrCCStroker.cpp
+++ b/src/gpu/ccpr/GrCCStroker.cpp
@@ -138,7 +138,7 @@
// Use the 4 edge distances to calculate coverage in the fragment shader.
GrGLSLFPFragmentBuilder* f = args.fFragBuilder;
- f->codeAppendf("half2 coverages = half2(min(%s.xy, .5) + min(%s.zw, .5));",
+ f->codeAppendf("half2 coverages = min(%s.xy, .5) + min(%s.zw, .5);",
edgeDistances.fsIn(), edgeDistances.fsIn());
f->codeAppendf("%s = half4(coverages.x * coverages.y);", args.fOutputColor);
@@ -260,9 +260,9 @@
// Use the 2 edge distances and interpolated butt cap AA to calculate fragment coverage.
GrGLSLFPFragmentBuilder* f = args.fFragBuilder;
- f->codeAppendf("half2 edge_coverages = min(half2(%s.xy), .5);", coverages.fsIn());
+ f->codeAppendf("half2 edge_coverages = min(%s.xy, .5);", coverages.fsIn());
f->codeAppend ("half coverage = edge_coverages.x + edge_coverages.y;");
- f->codeAppendf("coverage *= half(%s.z);", coverages.fsIn()); // Butt cap AA.
+ f->codeAppendf("coverage *= %s.z;", coverages.fsIn()); // Butt cap AA.
// As is common for CCPR, clockwise-winding triangles from the strip emit positive coverage, and
// counter-clockwise triangles emit negative.