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/core/SkNormalFlatSource.cpp b/src/core/SkNormalFlatSource.cpp
index 5b7e013..1f7e482 100644
--- a/src/core/SkNormalFlatSource.cpp
+++ b/src/core/SkNormalFlatSource.cpp
@@ -35,7 +35,7 @@
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppendf("%s = half4(0, 0, 1, 0);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(0, 0, 1, 0);", args.fOutputColor);
}
private:
diff --git a/src/core/SkNormalMapSource.cpp b/src/core/SkNormalMapSource.cpp
index bcd4bb6..7822d96 100644
--- a/src/core/SkNormalMapSource.cpp
+++ b/src/core/SkNormalMapSource.cpp
@@ -56,7 +56,7 @@
// If there's no x & y components, return (0, 0, +/- 1) instead to avoid division by 0
fragBuilder->codeAppend( "if (abs(normal.z) > 0.999) {");
- fragBuilder->codeAppendf(" %s = normalize(half4(0.0, 0.0, half(normal.z), 0.0));",
+ fragBuilder->codeAppendf(" %s = normalize(float4(0.0, 0.0, normal.z, 0.0));",
args.fOutputColor);
// Else, Normalizing the transformed X and Y, while keeping constant both Z and the
// vector's angle in the XY plane. This maintains the "slope" for the surface while
@@ -70,9 +70,8 @@
"( (transformed.x * transformed.x) "
"+ (transformed.y * transformed.y) )"
"/(1.0 - (normal.z * normal.z));");
- fragBuilder->codeAppendf(" %s = half4(half2(transformed * "
- "inversesqrt(scalingFactorSquared)),"
- "half(normal.z), 0.0);",
+ fragBuilder->codeAppendf(" %s = float4(transformed*inversesqrt(scalingFactorSquared),"
+ "normal.z, 0.0);",
args.fOutputColor);
fragBuilder->codeAppend( "}");
}
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index 9cb1a30..f5603e4 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -31,7 +31,7 @@
#include "glsl/GrGLSLUniformHandler.h"
GR_FP_SRC_STRING SKSL_ARITHMETIC_SRC = R"(
-in uniform half4 k;
+in uniform float4 k;
layout(key) const in bool enforcePMColor;
in fragmentProcessor child;
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 40bb72f..2b640d5 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -2043,7 +2043,7 @@
};
SkString lightBody;
lightBody.appendf("\thalf3 halfDir = half3(normalize(surfaceToLight + half3(0, 0, 1)));\n");
- lightBody.appendf("\thalf colorScale = half(%s * pow(dot(normal, halfDir), %s));\n",
+ lightBody.appendf("\tfloat colorScale = %s * pow(dot(normal, halfDir), %s);\n",
ks, shininess);
lightBody.appendf("\thalf3 color = lightColor * saturate(colorScale);\n");
lightBody.appendf("\treturn half4(color, max(max(color.r, color.g), color.b));\n");
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index fffbe42..972dff3 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -71,7 +71,7 @@
} else {
// Simulate the integer effect used above using step/mod. For speed, simulates a 4x4
// dither pattern rather than an 8x8 one.
- half4 modValues = mod(half4(x, y, x, y), half4(2.0, 2.0, 4.0, 4.0));
+ half4 modValues = mod(float4(x, y, x, y), half4(2.0, 2.0, 4.0, 4.0));
half4 stepValues = step(modValues, half4(1.0, 1.0, 2.0, 2.0));
value = dot(stepValues, half4(8.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0)) - 15.0 / 32.0;
}
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.
diff --git a/src/gpu/effects/GrAARectEffect.cpp b/src/gpu/effects/GrAARectEffect.cpp
index 2a4acf1a..9ee0ad5 100644
--- a/src/gpu/effects/GrAARectEffect.cpp
+++ b/src/gpu/effects/GrAARectEffect.cpp
@@ -33,10 +33,10 @@
"float4 prevRect = float4(%f, %f, %f, %f);\nhalf alpha;\n@switch (%d) {\n case "
"0:\n case 2:\n alpha = half(all(greaterThan(float4(sk_FragCoord.xy, "
"%s.zw), float4(%s.xy, sk_FragCoord.xy))) ? 1 : 0);\n break;\n "
- "default:\n half xSub, ySub;\n xSub = min(half(sk_FragCoord.x - "
- "%s.x), 0.0);\n xSub += min(half(%s.z - sk_FragCoord.x), 0.0);\n "
- "ySub = min(half(sk_FragCoord.y - %s.y), 0.0);\n ySub += min(half(%s.w - "
- "sk_FragCoord.y), 0.0);\n alpha = (1.0 + ",
+ "default:\n half xSub, ySub;\n xSub = half(min(sk_FragCoord.x - "
+ "%s.x, 0.0));\n xSub += half(min(%s.z - sk_FragCoord.x, 0.0));\n "
+ "ySub = half(min(sk_FragCoord.y - %s.y, 0.0));\n ySub += half(min(%s.w - "
+ "sk_FragCoord.y, 0.0));\n alpha = half((1",
prevRect.left(),
prevRect.top(),
prevRect.right(),
@@ -49,8 +49,8 @@
args.fUniformHandler->getUniformCStr(fRectUniformVar),
args.fUniformHandler->getUniformCStr(fRectUniformVar));
fragBuilder->codeAppendf(
- "max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));\n}\n@if (%d == 2 || %d == 3) {\n "
- "alpha = 1.0 - alpha;\n}\n%s = %s * alpha;\n",
+ ".0 + max(float(xSub), -1.0)) * (1.0 + max(float(ySub), -1.0)));\n}\n@if (%d == 2 "
+ "|| %d == 3) {\n alpha = half(1.0 - float(alpha));\n}\n%s = %s * alpha;\n",
(int)_outer.edgeType(),
(int)_outer.edgeType(),
args.fOutputColor,
diff --git a/src/gpu/effects/GrAARectEffect.fp b/src/gpu/effects/GrAARectEffect.fp
index 856b761..95064dd 100644
--- a/src/gpu/effects/GrAARectEffect.fp
+++ b/src/gpu/effects/GrAARectEffect.fp
@@ -25,10 +25,10 @@
// The amount of coverage removed in x and y by the edges is computed as a pair of
// negative numbers, xSub and ySub.
half xSub, ySub;
- xSub = min(half(sk_FragCoord.x - rectUniform.x), 0.0);
- xSub += min(half(rectUniform.z - sk_FragCoord.x), 0.0);
- ySub = min(half(sk_FragCoord.y - rectUniform.y), 0.0);
- ySub += min(half(rectUniform.w - sk_FragCoord.y), 0.0);
+ xSub = min(sk_FragCoord.x - rectUniform.x, 0.0);
+ xSub += min(rectUniform.z - sk_FragCoord.x, 0.0);
+ ySub = min(sk_FragCoord.y - rectUniform.y, 0.0);
+ ySub += min(rectUniform.w - sk_FragCoord.y, 0.0);
// Now compute coverage in x and y and multiply them to get the fraction of the pixel
// covered.
alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));
diff --git a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp
index 0920905..3a13123 100644
--- a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -43,11 +43,11 @@
kFragment_GrShaderFlag, kHalf_GrSLType, kDefault_GrSLPrecision, "outerThreshold");
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
- "half4 color = %s;\nhalf4 mask_color = texture(%s, %s).%s;\nif (mask_color.w < "
- "0.5) {\n if (color.w > %s) {\n half scale = %s / color.w;\n "
- "color.xyz *= scale;\n color.w = %s;\n }\n} else if (color.w < %s) {\n "
- " half scale = %s / max(0.001, color.w);\n color.xyz *= scale;\n color.w = "
- "%s;\n}\n%s = color;\n",
+ "half4 color = %s;\nhalf4 mask_color = texture(%s, %s).%s;\nif "
+ "(float(mask_color.w) < 0.5) {\n if (color.w > %s) {\n half scale = %s / "
+ "color.w;\n color.xyz *= scale;\n color.w = %s;\n }\n} else if "
+ "(color.w < %s) {\n half scale = float(%s) / max(0.001, float(color.w));\n "
+ "color.xyz *= scale;\n color.w = %s;\n}\n%s = color;\n",
args.fInputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
sk_TransformedCoords2D_0.c_str(),
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 64ffbd2..e42859b 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -103,7 +103,7 @@
// that suffices. Additionally we should assert that the upstream code only lets us get here if
// either float or half provides the required number of bits.
- GrShaderVar edgeAlpha("edgeAlpha", kHalf_GrSLType, 0);
+ GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0);
GrShaderVar dklmdx("dklmdx", kFloat3_GrSLType, 0);
GrShaderVar dklmdy("dklmdy", kFloat3_GrSLType, 0);
GrShaderVar dfdx("dfdx", kFloat_GrSLType, 0);
@@ -142,7 +142,7 @@
fragBuilder->codeAppendf("%s = %s.x*%s.x - %s.y*%s.z;",
func.c_str(), v.fsIn(), v.fsIn(), v.fsIn(), v.fsIn());
fragBuilder->codeAppendf("%s = abs(%s);", func.c_str(), func.c_str());
- fragBuilder->codeAppendf("%s = half(%s / %s);",
+ fragBuilder->codeAppendf("%s = %s / %s;",
edgeAlpha.c_str(), func.c_str(), gFM.c_str());
fragBuilder->codeAppendf("%s = max(1.0 - %s, 0.0);",
edgeAlpha.c_str(), edgeAlpha.c_str());
@@ -171,7 +171,7 @@
gFM.c_str(), gF.c_str(), gF.c_str());
fragBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;",
func.c_str(), v.fsIn(), v.fsIn(), v.fsIn(), v.fsIn());
- fragBuilder->codeAppendf("%s = half(%s / %s);",
+ fragBuilder->codeAppendf("%s = %s / %s;",
edgeAlpha.c_str(), func.c_str(), gFM.c_str());
fragBuilder->codeAppendf("%s = saturate(0.5 - %s);",
edgeAlpha.c_str(), edgeAlpha.c_str());
@@ -180,9 +180,9 @@
break;
}
case GrClipEdgeType::kFillBW: {
- fragBuilder->codeAppendf("%s = half(%s.x * %s.x - %s.y * %s.z);",
+ fragBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;",
edgeAlpha.c_str(), v.fsIn(), v.fsIn(), v.fsIn(), v.fsIn());
- fragBuilder->codeAppendf("%s = half(%s < 0.0);",
+ fragBuilder->codeAppendf("%s = float(%s < 0.0);",
edgeAlpha.c_str(), edgeAlpha.c_str());
break;
}
@@ -197,7 +197,7 @@
kFloat_GrSLType,
"Coverage",
&coverageScale);
- fragBuilder->codeAppendf("%s = half4(half(%s) * %s);",
+ fragBuilder->codeAppendf("%s = half4(%s * %s);",
args.fOutputCoverage, coverageScale, edgeAlpha.c_str());
} else {
fragBuilder->codeAppendf("%s = half4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
@@ -354,12 +354,12 @@
switch (fEdgeType) {
case GrClipEdgeType::kHairlineAA: {
- fragBuilder->codeAppendf("half2 duvdx = half2(dFdx(%s.xy));", v.fsIn());
- fragBuilder->codeAppendf("half2 duvdy = half2(dFdy(%s.xy));", v.fsIn());
+ fragBuilder->codeAppendf("half2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("half2 duvdy = dFdy(%s.xy);", v.fsIn());
fragBuilder->codeAppendf("half2 gF = half2(2.0 * %s.x * duvdx.x - duvdx.y,"
" 2.0 * %s.x * duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
- fragBuilder->codeAppendf("edgeAlpha = half(%s.x * %s.x - %s.y);",
+ fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
v.fsIn(), v.fsIn(), v.fsIn());
fragBuilder->codeAppend("edgeAlpha = sqrt(edgeAlpha * edgeAlpha / dot(gF, gF));");
fragBuilder->codeAppend("edgeAlpha = max(1.0 - edgeAlpha, 0.0);");
@@ -368,12 +368,12 @@
break;
}
case GrClipEdgeType::kFillAA: {
- fragBuilder->codeAppendf("half2 duvdx = half2(dFdx(%s.xy));", v.fsIn());
- fragBuilder->codeAppendf("half2 duvdy = half2(dFdy(%s.xy));", v.fsIn());
+ fragBuilder->codeAppendf("half2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("half2 duvdy = dFdy(%s.xy);", v.fsIn());
fragBuilder->codeAppendf("half2 gF = half2(2.0 * %s.x * duvdx.x - duvdx.y,"
" 2.0 * %s.x * duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
- fragBuilder->codeAppendf("edgeAlpha = half(%s.x * %s.x - %s.y);",
+ fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
v.fsIn(), v.fsIn(), v.fsIn());
fragBuilder->codeAppend("edgeAlpha = edgeAlpha / sqrt(dot(gF, gF));");
fragBuilder->codeAppend("edgeAlpha = saturate(0.5 - edgeAlpha);");
@@ -382,7 +382,7 @@
break;
}
case GrClipEdgeType::kFillBW: {
- fragBuilder->codeAppendf("edgeAlpha = half(%s.x * %s.x - %s.y);",
+ fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
v.fsIn(), v.fsIn(), v.fsIn());
fragBuilder->codeAppend("edgeAlpha = half(edgeAlpha < 0.0);");
break;
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index b3bd5e2..a320b2e 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -75,8 +75,8 @@
// starting coords are near a texel boundary and accumulations of imgInc would cause us to skip/
// double hit a texel.
fragBuilder->codeAppendf("coord /= %s;", imgInc);
- fragBuilder->codeAppend("half2 f = half2(fract(coord));");
- fragBuilder->codeAppendf("coord = (coord - f + half2(0.5)) * %s;", imgInc);
+ fragBuilder->codeAppend("float2 f = fract(coord);");
+ fragBuilder->codeAppendf("coord = (coord - f + float2(0.5)) * %s;", imgInc);
fragBuilder->codeAppend("half4 wx = kMitchellCoefficients * half4(1.0, f.x, f.x * f.x, f.x * f.x * f.x);");
fragBuilder->codeAppend("half4 wy = kMitchellCoefficients * half4(1.0, f.y, f.y * f.y, f.y * f.y * f.y);");
fragBuilder->codeAppend("half4 rowColors[4];");
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
index 6406e4e..eb5762e 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
@@ -26,9 +26,10 @@
auto mode = _outer.mode();
(void)mode;
fragBuilder->codeAppendf(
- "half factor = 1.0 - %s.w;\n@switch (%d) {\n case 0:\n factor = "
- "exp((-factor * factor) * 4.0) - 0.017999999999999999;\n break;\n case "
- "1:\n factor = smoothstep(1.0, 0.0, factor);\n break;\n}\n%s = "
+ "half factor = half(1.0 - float(%s.w));\n@switch (%d) {\n case 0:\n "
+ "factor = half(exp(float(float(-factor * factor) * 4.0)) - "
+ "0.017999999999999999);\n break;\n case 1:\n factor = "
+ "half(smoothstep(1.0, 0.0, float(factor)));\n break;\n}\n%s = "
"half4(factor);\n",
args.fInputColor, (int)_outer.mode(), args.fOutputColor);
}
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
index 6126c7d..14b29e6 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
@@ -16,7 +16,7 @@
half factor = 1.0 - sk_InColor.a;
@switch (mode) {
case Mode::kGaussian:
- factor = half(exp(-factor * factor * 4.0) - 0.018);
+ factor = exp(-factor * factor * 4.0) - 0.018;
break;
case Mode::kSmoothStep:
factor = smoothstep(1.0, 0.0, factor);
diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp
index bce42f8..3770c0d 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp
@@ -274,8 +274,9 @@
kDefault_GrSLPrecision, "circleData");
fragBuilder->codeAppendf(
"half2 vec = half2(half((sk_FragCoord.x - float(%s.x)) * float(%s.w)), "
- "half((sk_FragCoord.y - float(%s.y)) * float(%s.w)));\nhalf dist = length(vec) + "
- "(0.5 - %s.z) * %s.w;\n%s = %s * texture(%s, float2(half2(dist, 0.5))).%s.w;\n",
+ "half((sk_FragCoord.y - float(%s.y)) * float(%s.w)));\nhalf dist = "
+ "float(length(vec)) + (0.5 - float(%s.z)) * float(%s.w);\n%s = %s * texture(%s, "
+ "float2(half2(dist, 0.5))).%s.w;\n",
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
index 6e3d0b3..eac7304 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
@@ -278,8 +278,8 @@
void main() {
// We just want to compute "(length(vec) - circleData.z + 0.5) * circleData.w" but need to
// rearrange for precision.
- half2 vec = half2(half((sk_FragCoord.x - circleData.x) * circleData.w),
- half((sk_FragCoord.y - circleData.y) * circleData.w));
+ half2 vec = half2((sk_FragCoord.x - circleData.x) * circleData.w,
+ (sk_FragCoord.y - circleData.y) * circleData.w);
half dist = length(vec) + (0.5 - circleData.z) * circleData.w;
sk_OutColor = sk_InColor * texture(blurProfileSampler, half2(dist, 0.5)).a;
}
diff --git a/src/gpu/effects/GrCircleEffect.cpp b/src/gpu/effects/GrCircleEffect.cpp
index ddc81b8..30b81cc 100644
--- a/src/gpu/effects/GrCircleEffect.cpp
+++ b/src/gpu/effects/GrCircleEffect.cpp
@@ -33,11 +33,11 @@
kDefault_GrSLPrecision, "circle");
fragBuilder->codeAppendf(
"half2 prevCenter;\nhalf prevRadius = %f;\nhalf d;\n@if (%d == 2 || %d == 3) {\n "
- " d = half((length((float2(%s.xy) - sk_FragCoord.xy) * float(%s.w)) - 1.0) * "
- "float(%s.z));\n} else {\n d = half((1.0 - length((float2(%s.xy) - "
- "sk_FragCoord.xy) * float(%s.w))) * float(%s.z));\n}\n@if ((%d == 1 || %d == 3) || "
- "%d == 4) {\n d = clamp(d, 0.0, 1.0);\n} else {\n d = d > 0.5 ? 1.0 : "
- "0.0;\n}\n%s = %s * d;\n",
+ " d = (float(length((%s.xy - half2(sk_FragCoord.xy)) * %s.w)) - 1.0) * %s.z;\n} "
+ "else {\n d = half((1.0 - float(length((%s.xy - half2(sk_FragCoord.xy)) * "
+ "%s.w))) * float(%s.z));\n}\n@if ((%d == 1 || %d == 3) || %d == 4) {\n d = "
+ "half(clamp(float(d), 0.0, 1.0));\n} else {\n d = half(float(d) > 0.5 ? 1.0 : "
+ "0.0);\n}\n%s = %s * d;\n",
prevRadius, (int)_outer.edgeType(), (int)_outer.edgeType(),
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar),
diff --git a/src/gpu/effects/GrCircleEffect.fp b/src/gpu/effects/GrCircleEffect.fp
index 1053d4d..64932da 100644
--- a/src/gpu/effects/GrCircleEffect.fp
+++ b/src/gpu/effects/GrCircleEffect.fp
@@ -53,9 +53,9 @@
half d;
@if (edgeType == GrClipEdgeType::kInverseFillBW ||
edgeType == GrClipEdgeType::kInverseFillAA) {
- d = half((length((circle.xy - sk_FragCoord.xy) * circle.w) - 1.0) * circle.z);
+ d = (length((circle.xy - sk_FragCoord.xy) * circle.w) - 1.0) * circle.z;
} else {
- d = half((1.0 - length((circle.xy - sk_FragCoord.xy) * circle.w)) * circle.z);
+ d = (1.0 - length((circle.xy - sk_FragCoord.xy) * circle.w)) * circle.z;
}
@if (edgeType == GrClipEdgeType::kFillAA ||
edgeType == GrClipEdgeType::kInverseFillAA ||
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 158ff90..6493fcb 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -27,10 +27,11 @@
fragBuilder->forceHighPrecision();
fragBuilder->codeAppendf(
- "%s = floor(%s * 255.0 + 0.5) / 255.0;\n@switch (%d) {\n case 0:\n "
- "%s.xyz = floor((%s.xyz * %s.w) * 255.0 + 0.5) / 255.0;\n break;\n case "
- "1:\n %s.xyz = %s.w <= 0.0 ? half3(0.0) : floor((%s.xyz / %s.w) * 255.0 + "
- "0.5) / 255.0;\n break;\n}\n",
+ "%s = half4(floor(float4(float4(%s * 255.0) + 0.5)) / 255.0);\n@switch (%d) {\n "
+ "case 0:\n %s.xyz = half3(floor(float3(float3((%s.xyz * %s.w) * 255.0) + "
+ "0.5)) / 255.0);\n break;\n case 1:\n %s.xyz = float(%s.w) <= 0.0 "
+ "? half3(0.0) : half3(floor(float3(float3((%s.xyz / %s.w) * 255.0) + 0.5)) / "
+ "255.0);\n break;\n}\n",
args.fOutputColor, args.fInputColor, (int)_outer.pmConversion(), args.fOutputColor,
args.fOutputColor, args.fOutputColor, args.fOutputColor, args.fOutputColor,
args.fOutputColor, args.fOutputColor);
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 625427a..4751fec 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -50,9 +50,8 @@
fragBuilder->codeAppend("\t\thalf alpha = 1.0;\n");
fragBuilder->codeAppend("\t\thalf edge;\n");
for (int i = 0; i < cpe.getEdgeCount(); ++i) {
- fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], half3(half(sk_FragCoord.x), "
- "half(sk_FragCoord.y), "
- "1));\n",
+ fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], half3(sk_FragCoord.x, sk_FragCoord.y, "
+ "1));\n",
edgeArrayName, i);
if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
fragBuilder->codeAppend("\t\tedge = saturate(edge);\n");
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 57afe95..b0ddd91 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -103,12 +103,12 @@
// this gives us a smooth step across approximately one fragment
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor
- "*half(dFdx(%s.x)));", st.fsIn());
+ fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor "*dFdx(%s.x));",
+ st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor
- "*half(dFdy(%s.y)));", st.fsIn());
+ fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor "*dFdy(%s.y));",
+ st.fsIn());
#endif
} else if (isSimilarity) {
// For similarity transform, we adjust the effect of the transformation on the distance
@@ -118,29 +118,28 @@
// this gives us a smooth step across approximately one fragment
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("half st_grad_len = length(half2(dFdx(%s)));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = length(dFdx(%s));", st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("half st_grad_len = length(half2(dFdy(%s)));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = length(dFdy(%s));", st.fsIn());
#endif
fragBuilder->codeAppend("afwidth = abs(" SK_DistanceFieldAAFactor "*st_grad_len);");
} else {
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("half2 dist_grad = half2(float2(dFdx(distance), "
- "dFdy(distance)));");
+ fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance), dFdy(distance));");
// the length of the gradient may be 0, so we need to check for this
// this also compensates for the Adreno, which likes to drop tiles on division by 0
fragBuilder->codeAppend("half dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
- fragBuilder->codeAppend("dist_grad = dist_grad*half(inversesqrt(dg_len2));");
+ fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("half2 Jdx = half2(dFdx(%s));", st.fsIn());
- fragBuilder->codeAppendf("half2 Jdy = half2(dFdy(%s));", st.fsIn());
+ fragBuilder->codeAppendf("half2 Jdx = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppendf("half2 Jdy = dFdy(%s);", st.fsIn());
fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
@@ -405,12 +404,12 @@
// this gives us a smooth step across approximately one fragment
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor
- "*half(dFdx(%s.x)));", st.fsIn());
+ fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor "*dFdx(%s.x));",
+ st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor
- "*half(dFdy(%s.y)));", st.fsIn());
+ fragBuilder->codeAppendf("afwidth = abs(" SK_DistanceFieldAAFactor "*dFdy(%s.y));",
+ st.fsIn());
#endif
} else if (isSimilarity) {
// For similarity transform, we adjust the effect of the transformation on the distance
@@ -429,19 +428,18 @@
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance), "
- "dFdy(distance));");
+ fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance), dFdy(distance));");
// the length of the gradient may be 0, so we need to check for this
// this also compensates for the Adreno, which likes to drop tiles on division by 0
fragBuilder->codeAppend("half dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
- fragBuilder->codeAppend("dist_grad = dist_grad*half(inversesqrt(dg_len2));");
+ fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("half2 Jdx = half2(dFdx(%s));", st.fsIn());
- fragBuilder->codeAppendf("half2 Jdy = half2(dFdy(%s));", st.fsIn());
+ fragBuilder->codeAppendf("half2 Jdx = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppendf("half2 Jdy = dFdy(%s);", st.fsIn());
fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
@@ -679,33 +677,32 @@
if (isUniformScale) {
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("half st_grad_len = half(abs(dFdx(%s.x)));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = abs(dFdx(%s.x));", st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("half st_grad_len = half(abs(dFdy(%s.y)));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = abs(dFdy(%s.y));", st.fsIn());
#endif
- fragBuilder->codeAppendf("half2 offset = half2(half(st_grad_len*%s), 0.0);",
- delta.fsIn());
+ fragBuilder->codeAppendf("half2 offset = half2(st_grad_len*%s, 0.0);", delta.fsIn());
} else if (isSimilarity) {
// For a similarity matrix with rotation, the gradient will not be aligned
// with the texel coordinate axes, so we need to calculate it.
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("half2 st_grad = half2(dFdx(%s));", st.fsIn());
- fragBuilder->codeAppendf("half2 offset = half(%s)*st_grad;", delta.fsIn());
+ fragBuilder->codeAppendf("half2 st_grad = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppendf("half2 offset = %s*st_grad;", delta.fsIn());
#else
// We use dFdy because of a Mali 400 bug, and rotate -90 degrees to
// get the gradient in the x direction.
- fragBuilder->codeAppendf("half2 st_grad = half2(dFdy(%s));", st.fsIn());
- fragBuilder->codeAppendf("half2 offset = half2(%s*float2(st_grad.y, -st_grad.x));",
+ fragBuilder->codeAppendf("half2 st_grad = dFdy(%s);", st.fsIn());
+ fragBuilder->codeAppendf("half2 offset = %s*half2(st_grad.y, -st_grad.x);",
delta.fsIn());
#endif
fragBuilder->codeAppend("half st_grad_len = length(st_grad);");
} else {
- fragBuilder->codeAppendf("half2 st = half2(%s);\n", st.fsIn());
+ fragBuilder->codeAppendf("half2 st = %s;\n", st.fsIn());
- fragBuilder->codeAppend("half2 Jdx = half2(dFdx(st));");
- fragBuilder->codeAppend("half2 Jdy = half2(dFdy(st));");
- fragBuilder->codeAppendf("half2 offset = half2(half(%s))*Jdx;", delta.fsIn());
+ fragBuilder->codeAppend("half2 Jdx = dFdx(st);");
+ fragBuilder->codeAppend("half2 Jdy = dFdy(st);");
+ fragBuilder->codeAppendf("half2 offset = %s*Jdx;", delta.fsIn());
}
// sample the texture by index
@@ -717,12 +714,12 @@
fragBuilder->codeAppend("half3 distance;");
fragBuilder->codeAppend("distance.y = texColor.r;");
// red is distance to left offset
- fragBuilder->codeAppend("half2 uv_adjusted = half2(uv) - offset;");
+ fragBuilder->codeAppend("half2 uv_adjusted = uv - offset;");
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
texIdx, "uv_adjusted", "texColor");
fragBuilder->codeAppend("distance.x = texColor.r;");
// blue is distance to right offset
- fragBuilder->codeAppend("uv_adjusted = half2(uv) + offset;");
+ fragBuilder->codeAppend("uv_adjusted = uv + offset;");
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
texIdx, "uv_adjusted", "texColor");
fragBuilder->codeAppend("distance.z = texColor.r;");
@@ -753,15 +750,14 @@
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("half2 dist_grad = half2(half(dFdx(distance.r)), "
- "half(dFdy(distance.r)));");
+ fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance.r), dFdy(distance.r));");
// the length of the gradient may be 0, so we need to check for this
// this also compensates for the Adreno, which likes to drop tiles on division by 0
fragBuilder->codeAppend("half dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
- fragBuilder->codeAppend("dist_grad = dist_grad*half(inversesqrt(dg_len2));");
+ fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
diff --git a/src/gpu/effects/GrEllipseEffect.cpp b/src/gpu/effects/GrEllipseEffect.cpp
index 7372571..566e504 100644
--- a/src/gpu/effects/GrEllipseEffect.cpp
+++ b/src/gpu/effects/GrEllipseEffect.cpp
@@ -42,8 +42,8 @@
"%s.y;\n}\nfloat2 Z = d * %s.zw;\nfloat implicit = dot(Z, d) - 1.0;\nfloat "
"grad_dot = 4.0 * dot(Z, Z);\ngrad_dot = max(grad_dot, 0.0001);\nfloat approx_dist "
"= implicit * inversesqrt(grad_dot);\n@if (useScale) {\n approx_dist *= "
- "%s.x;\n}\nhalf alpha;\n@switch (%d) {\n case 0:\n alpha = approx_dist > "
- "0.0 ? 0.0 : 1.0;\n break;\n case 1:\n alph",
+ "%s.x;\n}\nhalf alpha;\n@switch (%d) {\n case 0:\n alpha = "
+ "half(approx_dist > 0.0 ? 0.0 : 1.0);\n break;\n case 1:\n ",
prevRadii.fX, prevRadii.fY, (useScale ? "true" : "false"),
args.fUniformHandler->getUniformCStr(fEllipseVar),
fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "float2(0)",
@@ -51,10 +51,10 @@
fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "float2(0)",
(int)_outer.edgeType());
fragBuilder->codeAppendf(
- "a = clamp(0.5 - half(approx_dist), 0.0, 1.0);\n break;\n case 2:\n "
- " alpha = approx_dist > 0.0 ? 1.0 : 0.0;\n break;\n case 3:\n "
- "alpha = clamp(0.5 + half(approx_dist), 0.0, 1.0);\n break;\n default:\n "
- " discard;\n}\n%s = %s * alpha;\n",
+ " alpha = half(clamp(0.5 - approx_dist, 0.0, 1.0));\n break;\n case "
+ "2:\n alpha = half(approx_dist > 0.0 ? 1.0 : 0.0);\n break;\n "
+ "case 3:\n alpha = half(clamp(0.5 + approx_dist, 0.0, 1.0));\n "
+ "break;\n default:\n discard;\n}\n%s = %s * alpha;\n",
args.fOutputColor, args.fInputColor);
}
diff --git a/src/gpu/effects/GrEllipseEffect.fp b/src/gpu/effects/GrEllipseEffect.fp
index e50a451..00a4c7d 100644
--- a/src/gpu/effects/GrEllipseEffect.fp
+++ b/src/gpu/effects/GrEllipseEffect.fp
@@ -91,13 +91,13 @@
alpha = approx_dist > 0.0 ? 0.0 : 1.0;
break;
case GrClipEdgeType::kFillAA:
- alpha = saturate(0.5 - half(approx_dist));
+ alpha = saturate(0.5 - approx_dist);
break;
case GrClipEdgeType::kInverseFillBW:
alpha = approx_dist > 0.0 ? 1.0 : 0.0;
break;
case GrClipEdgeType::kInverseFillAA:
- alpha = saturate(0.5 + half(approx_dist));
+ alpha = saturate(0.5 + approx_dist);
break;
default:
// hairline not supported
diff --git a/src/gpu/effects/GrMagnifierEffect.cpp b/src/gpu/effects/GrMagnifierEffect.cpp
index 8042613..b709c48 100644
--- a/src/gpu/effects/GrMagnifierEffect.cpp
+++ b/src/gpu/effects/GrMagnifierEffect.cpp
@@ -48,13 +48,13 @@
kFragment_GrShaderFlag, kHalf2_GrSLType, kDefault_GrSLPrecision, "offset");
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
- "float2 coord = %s;\nfloat2 zoom_coord = float2(%s) + coord * float2(%s, "
- "%s);\nfloat2 delta = (coord - %s.xy) * %s.zw;\ndelta = min(delta, "
- "float2(half2(1.0, 1.0)) - delta);\ndelta *= float2(%s, %s);\nfloat weight = "
- "0.0;\nif (delta.x < 2.0 && delta.y < 2.0) {\n delta = float2(half2(2.0, 2.0)) "
- "- delta;\n float dist = length(delta);\n dist = max(2.0 - dist, 0.0);\n "
- "weight = min(dist * dist, 1.0);\n} else {\n float2 delta_squared = delta * "
- "delta;\n weight = min(min(delta_squared.x, delta_square",
+ "float2 coord = %s;\nfloat2 zoom_coord = float2(%s + half2(coord * "
+ "float2(half2(half(%s), half(%s)))));\nfloat2 delta = (coord - %s.xy) * "
+ "%s.zw;\ndelta = min(delta, float2(half2(1.0, 1.0) - half2(delta)));\ndelta *= "
+ "float2(half2(half(%s), half(%s)));\nhalf weight = 0.0;\nif (delta.x < 2.0 && "
+ "delta.y < 2.0) {\n delta = float2(half2(2.0, 2.0) - half2(delta));\n half "
+ "dist = half(length(delta));\n dist = half(max(2.0 - float(dist), 0.0));\n "
+ "weight = half(min(float(dist * dist), 1.0));\n} else {\n ",
sk_TransformedCoords2D_0.c_str(),
args.fUniformHandler->getUniformCStr(fOffsetVar),
args.fUniformHandler->getUniformCStr(fXInvZoomVar),
@@ -64,7 +64,9 @@
args.fUniformHandler->getUniformCStr(fXInvInsetVar),
args.fUniformHandler->getUniformCStr(fYInvInsetVar));
fragBuilder->codeAppendf(
- "d.y), 1.0);\n}\n%s = texture(%s, mix(coord, zoom_coord, weight)).%s;\n",
+ "float2 delta_squared = delta * delta;\n weight = half(min(min(delta_squared.x, "
+ "delta_squared.y), 1.0));\n}\n%s = texture(%s, mix(coord, zoom_coord, "
+ "float(weight))).%s;\n",
args.fOutputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
diff --git a/src/gpu/effects/GrMagnifierEffect.fp b/src/gpu/effects/GrMagnifierEffect.fp
index 7e32457..53245bb 100644
--- a/src/gpu/effects/GrMagnifierEffect.fp
+++ b/src/gpu/effects/GrMagnifierEffect.fp
@@ -22,15 +22,15 @@
void main() {
float2 coord = sk_TransformedCoords2D[0];
- float2 zoom_coord = offset + coord * float2(xInvZoom, yInvZoom);
+ float2 zoom_coord = offset + coord * half2(xInvZoom, yInvZoom);
float2 delta = (coord - boundsUniform.xy) * boundsUniform.zw;
delta = min(delta, half2(1.0, 1.0) - delta);
- delta *= float2(xInvInset, yInvInset);
+ delta *= half2(xInvInset, yInvInset);
- float weight = 0.0;
+ half weight = 0.0;
if (delta.s < 2.0 && delta.t < 2.0) {
delta = half2(2.0, 2.0) - delta;
- float dist = length(delta);
+ half dist = length(delta);
dist = max(2.0 - dist, 0.0);
weight = min(dist * dist, 1.0);
} else {
diff --git a/src/gpu/effects/GrRRectBlurEffect.cpp b/src/gpu/effects/GrRRectBlurEffect.cpp
index e84fae2..fa85ea5 100644
--- a/src/gpu/effects/GrRRectBlurEffect.cpp
+++ b/src/gpu/effects/GrRRectBlurEffect.cpp
@@ -67,30 +67,30 @@
(void)rect;
auto cornerRadius = _outer.cornerRadius();
(void)cornerRadius;
- fCornerRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
+ fCornerRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat_GrSLType,
kDefault_GrSLPrecision, "cornerRadius");
fProxyRectVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
kDefault_GrSLPrecision, "proxyRect");
fBlurRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
kDefault_GrSLPrecision, "blurRadius");
fragBuilder->codeAppendf(
- "\nhalf2 translatedFragPos = half2(sk_FragCoord.xy - %s.xy);\nhalf threshold = %s "
- "+ 2.0 * %s;\nhalf2 middle = half2((%s.zw - %s.xy) - float(2.0 * threshold));\nif "
- "(translatedFragPos.x >= threshold && translatedFragPos.x < middle.x + threshold) "
- "{\n translatedFragPos.x = threshold;\n} else if (translatedFragPos.x >= "
- "middle.x + threshold) {\n translatedFragPos.x -= middle.x - 1.0;\n}\nif "
- "(translatedFragPos.y > threshold && translatedFragPos.y < middle.y + threshold) "
- "{\n translatedFragPos.y = threshold;",
+ "\nhalf2 translatedFragPos = half2(sk_FragCoord.xy - %s.xy);\nhalf threshold = "
+ "half(%s + 2.0 * float(%s));\nhalf2 middle = half2((%s.zw - %s.xy) - 2.0 * "
+ "float(threshold));\nif (translatedFragPos.x >= threshold && translatedFragPos.x < "
+ "middle.x + threshold) {\n translatedFragPos.x = threshold;\n} else if "
+ "(translatedFragPos.x >= middle.x + threshold) {\n translatedFragPos.x -= "
+ "float(middle.x) - 1.0;\n}\nif (translatedFragPos.y > threshold && "
+ "translatedFragPos.y < middle.y + threshold) {\n translatedFr",
args.fUniformHandler->getUniformCStr(fProxyRectVar),
args.fUniformHandler->getUniformCStr(fCornerRadiusVar),
args.fUniformHandler->getUniformCStr(fBlurRadiusVar),
args.fUniformHandler->getUniformCStr(fProxyRectVar),
args.fUniformHandler->getUniformCStr(fProxyRectVar));
fragBuilder->codeAppendf(
- "\n} else if (translatedFragPos.y >= middle.y + threshold) {\n "
- "translatedFragPos.y -= middle.y - 1.0;\n}\nhalf2 proxyDims = half2(2.0 * "
- "threshold + 1.0);\nhalf2 texCoord = translatedFragPos / proxyDims;\n%s = %s * "
- "texture(%s, float2(texCoord)).%s;\n",
+ "agPos.y = threshold;\n} else if (translatedFragPos.y >= middle.y + threshold) {\n "
+ " translatedFragPos.y -= float(middle.y) - 1.0;\n}\nhalf2 proxyDims = "
+ "half2(half(2.0 * float(threshold) + 1.0));\nhalf2 texCoord = translatedFragPos / "
+ "proxyDims;\n%s = %s * texture(%s, float2(texCoord)).%s;\n",
args.fOutputColor, args.fInputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp
index 698851b..7bbd0a5 100644
--- a/src/gpu/effects/GrRRectBlurEffect.fp
+++ b/src/gpu/effects/GrRRectBlurEffect.fp
@@ -7,7 +7,7 @@
in float sigma;
layout(ctype=SkRect) in float4 rect;
-in uniform half cornerRadius;
+in uniform float cornerRadius;
in uniform sampler2D ninePatchSampler;
layout(ctype=SkRect) uniform float4 proxyRect;
uniform half blurRadius;
@@ -169,10 +169,10 @@
void main() {
// warp the fragment position to the appropriate part of the 9patch blur texture
- half2 rectCenter = half2((proxyRect.xy + proxyRect.zw) / 2.0);
- half2 translatedFragPos = half2(sk_FragCoord.xy - proxyRect.xy);
+ half2 rectCenter = (proxyRect.xy + proxyRect.zw) / 2.0;
+ half2 translatedFragPos = sk_FragCoord.xy - proxyRect.xy;
half threshold = cornerRadius + 2.0 * blurRadius;
- half2 middle = half2(proxyRect.zw - proxyRect.xy - 2.0 * threshold);
+ half2 middle = proxyRect.zw - proxyRect.xy - 2.0 * threshold;
if (translatedFragPos.x >= threshold && translatedFragPos.x < (middle.x + threshold)) {
translatedFragPos.x = threshold;
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 66aed33..5cd54b7 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -166,10 +166,10 @@
// If we're on a device where float != fp32 then the length calculation could overflow.
SkString clampedCircleDistance;
if (!args.fShaderCaps->floatIs32Bits()) {
- clampedCircleDistance.printf("saturate(%s.x * (1.0 - length(dxy * %s.y)))",
+ clampedCircleDistance.printf("saturate(%s.x * (1.0 - length(dxy * %s.y)));",
radiusPlusHalfName, radiusPlusHalfName);
} else {
- clampedCircleDistance.printf("saturate(%s.x - length(dxy))", radiusPlusHalfName);
+ clampedCircleDistance.printf("saturate(%s.x - length(dxy));", radiusPlusHalfName);
}
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -193,84 +193,84 @@
fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
fragBuilder->codeAppend("float2 dxy = max(max(dxy0, dxy1), 0.0);");
- fragBuilder->codeAppendf("half alpha = half(%s);", clampedCircleDistance.c_str());
+ fragBuilder->codeAppendf("half alpha = %s;", clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTopLeft_CornerFlag:
fragBuilder->codeAppendf("float2 dxy = max(%s.xy - sk_FragCoord.xy, 0.0);",
rectName);
- fragBuilder->codeAppendf("half rightAlpha = half(saturate(%s.z - sk_FragCoord.x));",
+ fragBuilder->codeAppendf("half rightAlpha = saturate(%s.z - sk_FragCoord.x);",
rectName);
- fragBuilder->codeAppendf("half bottomAlpha = half(saturate(%s.w - sk_FragCoord.y));",
+ fragBuilder->codeAppendf("half bottomAlpha = saturate(%s.w - sk_FragCoord.y);",
rectName);
- fragBuilder->codeAppendf("half alpha = bottomAlpha * rightAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = bottomAlpha * rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTopRight_CornerFlag:
fragBuilder->codeAppendf("float2 dxy = max(float2(sk_FragCoord.x - %s.z, "
"%s.y - sk_FragCoord.y), 0.0);",
rectName, rectName);
- fragBuilder->codeAppendf("half leftAlpha = half(saturate(sk_FragCoord.x - %s.x));",
+ fragBuilder->codeAppendf("half leftAlpha = saturate(sk_FragCoord.x - %s.x);",
rectName);
- fragBuilder->codeAppendf("half bottomAlpha = half(saturate(%s.w - sk_FragCoord.y));",
+ fragBuilder->codeAppendf("half bottomAlpha = saturate(%s.w - sk_FragCoord.y);",
rectName);
- fragBuilder->codeAppendf("half alpha = bottomAlpha * leftAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = bottomAlpha * leftAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomRight_CornerFlag:
fragBuilder->codeAppendf("float2 dxy = max(sk_FragCoord.xy - %s.zw, 0.0);",
rectName);
- fragBuilder->codeAppendf("half leftAlpha = half(saturate(sk_FragCoord.x - %s.x));",
+ fragBuilder->codeAppendf("half leftAlpha = saturate(sk_FragCoord.x - %s.x);",
rectName);
- fragBuilder->codeAppendf("half topAlpha = half(saturate(sk_FragCoord.y - %s.y));",
+ fragBuilder->codeAppendf("half topAlpha = saturate(sk_FragCoord.y - %s.y);",
rectName);
- fragBuilder->codeAppendf("half alpha = topAlpha * leftAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = topAlpha * leftAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomLeft_CornerFlag:
fragBuilder->codeAppendf("float2 dxy = max(float2(%s.x - sk_FragCoord.x, "
"sk_FragCoord.y - %s.w), 0.0);",
rectName, rectName);
- fragBuilder->codeAppendf("half rightAlpha = half(saturate(%s.z - sk_FragCoord.x));",
+ fragBuilder->codeAppendf("half rightAlpha = saturate(%s.z - sk_FragCoord.x);",
rectName);
- fragBuilder->codeAppendf("half topAlpha = half(saturate(sk_FragCoord.y - %s.y));",
+ fragBuilder->codeAppendf("half topAlpha = saturate(sk_FragCoord.y - %s.y);",
rectName);
- fragBuilder->codeAppendf("half alpha = topAlpha * rightAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = topAlpha * rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kLeft_CornerFlags:
fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
fragBuilder->codeAppendf("float dy1 = sk_FragCoord.y - %s.w;", rectName);
fragBuilder->codeAppend("float2 dxy = max(float2(dxy0.x, max(dxy0.y, dy1)), 0.0);");
- fragBuilder->codeAppendf("half rightAlpha = half(saturate(%s.z - sk_FragCoord.x));",
+ fragBuilder->codeAppendf("half rightAlpha = saturate(%s.z - sk_FragCoord.x);",
rectName);
- fragBuilder->codeAppendf("half alpha = rightAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTop_CornerFlags:
fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
fragBuilder->codeAppendf("float dx1 = sk_FragCoord.x - %s.z;", rectName);
fragBuilder->codeAppend("float2 dxy = max(float2(max(dxy0.x, dx1), dxy0.y), 0.0);");
- fragBuilder->codeAppendf("half bottomAlpha = half(saturate(%s.w - sk_FragCoord.y));",
+ fragBuilder->codeAppendf("half bottomAlpha = saturate(%s.w - sk_FragCoord.y);",
rectName);
- fragBuilder->codeAppendf("half alpha = bottomAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = bottomAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kRight_CornerFlags:
fragBuilder->codeAppendf("float dy0 = %s.y - sk_FragCoord.y;", rectName);
fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
fragBuilder->codeAppend("float2 dxy = max(float2(dxy1.x, max(dy0, dxy1.y)), 0.0);");
- fragBuilder->codeAppendf("half leftAlpha = half(saturate(sk_FragCoord.x - %s.x));",
+ fragBuilder->codeAppendf("half leftAlpha = saturate(sk_FragCoord.x - %s.x);",
rectName);
- fragBuilder->codeAppendf("half alpha = leftAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = leftAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottom_CornerFlags:
fragBuilder->codeAppendf("float dx0 = %s.x - sk_FragCoord.x;", rectName);
fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
fragBuilder->codeAppend("float2 dxy = max(float2(max(dx0, dxy1.x), dxy1.y), 0.0);");
- fragBuilder->codeAppendf("half topAlpha = half(saturate(sk_FragCoord.y - %s.y));",
+ fragBuilder->codeAppendf("half topAlpha = saturate(sk_FragCoord.y - %s.y);",
rectName);
- fragBuilder->codeAppendf("half alpha = topAlpha * half(%s);",
+ fragBuilder->codeAppendf("half alpha = topAlpha * %s;",
clampedCircleDistance.c_str());
break;
}
@@ -570,12 +570,12 @@
SK_ABORT("RRect should always be simple or nine-patch.");
}
// implicit is the evaluation of (x/a)^2 + (y/b)^2 - 1.
- fragBuilder->codeAppend("half implicit = half(dot(Z, dxy) - 1.0);");
+ fragBuilder->codeAppend("float implicit = dot(Z, dxy) - 1.0;");
// grad_dot is the squared length of the gradient of the implicit.
- fragBuilder->codeAppend("half grad_dot = half(4.0 * dot(Z, Z));");
+ fragBuilder->codeAppend("float grad_dot = 4.0 * dot(Z, Z);");
// avoid calling inversesqrt on zero.
fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fragBuilder->codeAppend("half approx_dist = implicit * half(inversesqrt(grad_dot));");
+ fragBuilder->codeAppend("float approx_dist = implicit * inversesqrt(grad_dot);");
if (scaleName) {
fragBuilder->codeAppendf("approx_dist *= %s.x;", scaleName);
}
diff --git a/src/gpu/effects/GrRectBlurEffect.cpp b/src/gpu/effects/GrRectBlurEffect.cpp
index e0cf0d7..aa74f61 100644
--- a/src/gpu/effects/GrRectBlurEffect.cpp
+++ b/src/gpu/effects/GrRectBlurEffect.cpp
@@ -49,10 +49,10 @@
"/* key */ bool highPrecision = %s;\n@if (highPrecision) {\n float2 "
"translatedPos = sk_FragCoord.xy - %s.xy;\n float width = %s.z - %s.x;\n "
"float height = %s.w - %s.y;\n float2 smallDims = float2(width - float(%s), "
- "height - float(%s));\n float center = float(2.0 * floor(%s / 2.0 + 0.25) - "
- "1.0);\n float2 wh = smallDims - float2(center, center);\n half hcoord = "
- "half((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / float(%s));\n half "
- "hlookup = texture(%s, float2(float(hcoord), 0.5)).",
+ "height - float(%s));\n float center = 2.0 * floor(float(float(%s / 2.0) + "
+ "0.25)) - 1.0;\n float2 wh = smallDims - float2(center, center);\n half "
+ "hcoord = half((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / float(%s));\n "
+ " half hlookup = texture(%s, float2(float(hcoord), ",
(highPrecision ? "true" : "false"), args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
@@ -64,13 +64,13 @@
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str());
fragBuilder->codeAppendf(
- "%s.w;\n half vcoord = half((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) "
- "/ float(%s));\n half vlookup = texture(%s, float2(float(vcoord), 0.5)).%s.w;\n "
- " %s = (%s * hlookup) * vlookup;\n} else {\n half2 translatedPos = "
- "half2(sk_FragCoord.xy - %s.xy);\n half width = half(%s.z - %s.x);\n half "
- "height = half(%s.w - %s.y);\n half2 smallDims = half2(width - %s, height - "
- "%s);\n half center = 2.0 * floor(%s / 2.0 + 0.25) - 1.0;\n half2 wh = "
- "smallDims - half2(center, center);\n half ",
+ "0.5)).%s.w;\n half vcoord = half((abs(translatedPos.y - 0.5 * height) - 0.5 * "
+ "wh.y) / float(%s));\n half vlookup = texture(%s, float2(float(vcoord), "
+ "0.5)).%s.w;\n %s = (%s * hlookup) * vlookup;\n} else {\n half2 "
+ "translatedPos = half2(sk_FragCoord.xy - %s.xy);\n half width = half(%s.z - "
+ "%s.x);\n half height = half(%s.w - %s.y);\n half2 smallDims = half2(width - "
+ "%s, height - %s);\n half center = half(2.0 * floor(float(float(%s / 2.0) + "
+ "0.25)) - 1.0);\n half2 wh = smallDims - half2(f",
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
@@ -84,9 +84,11 @@
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar));
fragBuilder->codeAppendf(
- "hcoord = (abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / %s;\n half "
- "hlookup = texture(%s, float2(float(hcoord), 0.5)).%s.w;\n half vcoord = "
- "(abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) / %s;\n half vlookup = "
+ "loat2(float(center), float(center)));\n half hcoord = "
+ "half((abs(float(float(translatedPos.x) - 0.5 * float(width))) - 0.5 * "
+ "float(wh.x)) / float(%s));\n half hlookup = texture(%s, float2(float(hcoord), "
+ "0.5)).%s.w;\n half vcoord = half((abs(float(float(translatedPos.y) - 0.5 * "
+ "float(height))) - 0.5 * float(wh.y)) / float(%s));\n half vlookup = "
"texture(%s, float2(float(vcoord), 0.5)).%s.w;\n %s = (%s * hlookup) * "
"vlookup;\n}\n",
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp
index 5fda20c..814dedb 100644
--- a/src/gpu/effects/GrRectBlurEffect.fp
+++ b/src/gpu/effects/GrRectBlurEffect.fp
@@ -123,21 +123,21 @@
float2 smallDims = float2(width - profileSize, height - profileSize);
float center = 2 * floor(profileSize / 2 + 0.25) - 1;
float2 wh = smallDims - float2(center, center);
- half hcoord = half(((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x)) / profileSize);
+ half hcoord = ((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x)) / profileSize;
half hlookup = texture(blurProfile, float2(hcoord, 0.5)).a;
- half vcoord = half(((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y)) / profileSize);
+ half vcoord = ((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y)) / profileSize;
half vlookup = texture(blurProfile, float2(vcoord, 0.5)).a;
sk_OutColor = sk_InColor * hlookup * vlookup;
} else {
- half2 translatedPos = half2(sk_FragCoord.xy - rect.xy);
- half width = half(rect.z - rect.x);
- half height = half(rect.w - rect.y);
+ half2 translatedPos = sk_FragCoord.xy - rect.xy;
+ half width = rect.z - rect.x;
+ half height = rect.w - rect.y;
half2 smallDims = half2(width - profileSize, height - profileSize);
half center = 2 * floor(profileSize / 2 + 0.25) - 1;
- half2 wh = smallDims - half2(center, center);
- half hcoord = ((half(abs(translatedPos.x - 0.5 * width)) - 0.5 * wh.x)) / profileSize;
+ half2 wh = smallDims - float2(center, center);
+ half hcoord = ((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x)) / profileSize;
half hlookup = texture(blurProfile, float2(hcoord, 0.5)).a;
- half vcoord = ((half(abs(translatedPos.y - 0.5 * height)) - 0.5 * wh.y)) / profileSize;
+ half vcoord = ((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y)) / profileSize;
half vlookup = texture(blurProfile, float2(vcoord, 0.5)).a;
sk_OutColor = sk_InColor * hlookup * vlookup;
}
diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp
index 3338361..68680d1 100644
--- a/src/gpu/effects/GrSRGBEffect.cpp
+++ b/src/gpu/effects/GrSRGBEffect.cpp
@@ -45,7 +45,7 @@
// Mali Bifrost uses fp16 for mediump. Making the intermediate color variable highp causes
// calculations to be performed with sufficient precision.
- fragBuilder->codeAppendf("half4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
if (srgbe.alpha() == GrSRGBEffect::Alpha::kPremul) {
fragBuilder->codeAppendf("half nonZeroAlpha = max(color.a, 0.00001);");
fragBuilder->codeAppendf("color = half4(color.rgb / nonZeroAlpha, color.a);");
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 3cc2a1f..c710245 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -151,15 +151,15 @@
// pixel coordinate. This will then be clamped to 1.f if it's greater than the control
// parameter, which simulates kNearest and kBilerp behavior depending on if it's 0 or 1.
if (decalX && decalY) {
- builder->codeAppendf("half err = max(half(abs(clampedCoord.x - origCoord.x) * %s.x), "
- "half(abs(clampedCoord.y - origCoord.y) * %s.y));",
+ builder->codeAppendf("half err = max(abs(clampedCoord.x - origCoord.x) * %s.x, "
+ "abs(clampedCoord.y - origCoord.y) * %s.y);",
fDecalName.c_str(), fDecalName.c_str());
} else if (decalX) {
- builder->codeAppendf("half err = half(abs(clampedCoord.x - origCoord.x) * %s.x);",
+ builder->codeAppendf("half err = abs(clampedCoord.x - origCoord.x) * %s.x;",
fDecalName.c_str());
} else {
SkASSERT(decalY);
- builder->codeAppendf("half err = half(abs(clampedCoord.y - origCoord.y) * %s.y);",
+ builder->codeAppendf("half err = abs(clampedCoord.y - origCoord.y) * %s.y;",
fDecalName.c_str());
}
@@ -427,7 +427,7 @@
kHalf4_GrSLType,
"scaleAndTranslate",
&scaleAndTranslateName);
- args.fFragBuilder->codeAppendf("half2 coords = half2(sk_FragCoord.xy * %s.xy + %s.zw);",
+ args.fFragBuilder->codeAppendf("half2 coords = sk_FragCoord.xy * %s.xy + %s.zw;",
scaleAndTranslateName, scaleAndTranslateName);
fGLDomain.sampleTexture(args.fFragBuilder,
args.fUniformHandler,
diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp
index cf4c941..b2b45bf 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.cpp
+++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp
@@ -119,7 +119,7 @@
static const char kChannelToChar[4] = { 'x', 'y', 'z', 'w' };
fragBuilder->codeAppendf(
- "half4 yuvOne = half4(half(tmp%d.%c), half(tmp%d.%c), half(tmp%d.%c), 1.0) * %s;",
+ "half4 yuvOne = half4(tmp%d.%c, tmp%d.%c, tmp%d.%c, 1.0) * %s;",
_outer.yuvaIndex(0).fIndex, kChannelToChar[(int)_outer.yuvaIndex(0).fChannel],
_outer.yuvaIndex(1).fIndex, kChannelToChar[(int)_outer.yuvaIndex(1).fChannel],
_outer.yuvaIndex(2).fIndex, kChannelToChar[(int)_outer.yuvaIndex(2).fChannel],
@@ -128,12 +128,12 @@
if (_outer.yuvaIndex(3).fIndex >= 0) {
fragBuilder->codeAppendf(
- "half a = tmp%d.%c;", _outer.yuvaIndex(3).fIndex,
+ "float a = tmp%d.%c;", _outer.yuvaIndex(3).fIndex,
kChannelToChar[(int)_outer.yuvaIndex(3).fChannel]);
// premultiply alpha
fragBuilder->codeAppend("yuvOne *= a;");
} else {
- fragBuilder->codeAppendf("half a = 1.0;");
+ fragBuilder->codeAppendf("float a = 1.0;");
}
fragBuilder->codeAppendf("%s = half4(yuvOne.xyz, a);", args.fOutputColor);
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index a22df4f..77a7972 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3358,7 +3358,7 @@
vshaderTxt.append(
"// Copy Program VS\n"
"void main() {"
- " v_texCoord = half2(a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw);"
+ " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw;"
" sk_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
" sk_Position.zw = half2(0, 1);"
"}"
diff --git a/src/gpu/glsl/GrGLSLBlend.cpp b/src/gpu/glsl/GrGLSLBlend.cpp
index 7ec73fd..c08fe36 100644
--- a/src/gpu/glsl/GrGLSLBlend.cpp
+++ b/src/gpu/glsl/GrGLSLBlend.cpp
@@ -146,7 +146,7 @@
GrShaderVar getLumArgs[] = {
GrShaderVar("color", kHalf3_GrSLType),
};
- SkString getLumBody("return dot(half3(0.3, 0.59, 0.11), color);");
+ SkString getLumBody("return dot(float3(0.3, 0.59, 0.11), color);");
fsBuilder->emitFunction(kHalf_GrSLType,
"luminance",
SK_ARRAY_COUNT(getLumArgs), getLumArgs,
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp
index 012fce7..99862e2 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -70,7 +70,7 @@
&dstCoordScaleName);
fragBuilder->codeAppend("// Read color from copy of the destination.\n");
- fragBuilder->codeAppendf("half2 _dstTexCoord = (half2(sk_FragCoord.xy) - %s) * %s;",
+ fragBuilder->codeAppendf("half2 _dstTexCoord = (sk_FragCoord.xy - %s) * %s;",
dstTopLeftName, dstCoordScaleName);
if (flipY) {
diff --git a/src/gpu/gradients/GrClampedGradientEffect.cpp b/src/gpu/gradients/GrClampedGradientEffect.cpp
index 13da0ea..21a5b1c 100644
--- a/src/gpu/gradients/GrClampedGradientEffect.cpp
+++ b/src/gpu/gradients/GrClampedGradientEffect.cpp
@@ -39,7 +39,7 @@
this->emitChild(1, &_child1, args);
fragBuilder->codeAppendf(
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else if (t.x < "
- "0.0) {\n %s = %s;\n} else if (t.x > 1.0) {\n %s = %s;\n} else {",
+ "0.0) {\n %s = %s;\n} else if (float(t.x) > 1.0) {\n %s = %s;\n} else {",
_child1.c_str(),
(_outer.childProcessor(1).preservesOpaqueInput() ? "true" : "false"),
args.fOutputColor, args.fOutputColor,
diff --git a/src/gpu/gradients/GrDualIntervalGradientColorizer.fp b/src/gpu/gradients/GrDualIntervalGradientColorizer.fp
index 602b075..3674233 100644
--- a/src/gpu/gradients/GrDualIntervalGradientColorizer.fp
+++ b/src/gpu/gradients/GrDualIntervalGradientColorizer.fp
@@ -29,7 +29,7 @@
bias = bias23;
}
- sk_OutColor = half4(t * scale + bias);
+ sk_OutColor = t * scale + bias;
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/gradients/GrLinearGradientLayout.fp b/src/gpu/gradients/GrLinearGradientLayout.fp
index d12ee6c..3a187f3 100644
--- a/src/gpu/gradients/GrLinearGradientLayout.fp
+++ b/src/gpu/gradients/GrLinearGradientLayout.fp
@@ -12,7 +12,7 @@
}
void main() {
- half t = half(sk_TransformedCoords2D[0].x);
+ half t = sk_TransformedCoords2D[0].x;
sk_OutColor = half4(t, 1, 0, 0); // y = 1 for always valid
}
diff --git a/src/gpu/gradients/GrRadialGradientLayout.fp b/src/gpu/gradients/GrRadialGradientLayout.fp
index 6d186e5..24269b8 100644
--- a/src/gpu/gradients/GrRadialGradientLayout.fp
+++ b/src/gpu/gradients/GrRadialGradientLayout.fp
@@ -12,7 +12,7 @@
}
void main() {
- half t = half(length(sk_TransformedCoords2D[0]));
+ half t = length(sk_TransformedCoords2D[0]);
sk_OutColor = half4(t, 1, 0, 0); // y = 1 for always valid
}
diff --git a/src/gpu/gradients/GrSweepGradientLayout.cpp b/src/gpu/gradients/GrSweepGradientLayout.cpp
index 2269e25..fad89cd 100644
--- a/src/gpu/gradients/GrSweepGradientLayout.cpp
+++ b/src/gpu/gradients/GrSweepGradientLayout.cpp
@@ -36,8 +36,8 @@
fragBuilder->codeAppendf(
"half angle;\nif (sk_Caps.atan2ImplementedAsAtanYOverX) {\n angle = half(2.0 * "
"atan(-%s.y, length(%s) - %s.x));\n} else {\n angle = half(atan(-%s.y, "
- "-%s.x));\n}\nhalf t = ((angle * 0.15915494309180001 + 0.5) + %s) * %s;\n%s = "
- "half4(t, 1.0, 0.0, 0.0);\n",
+ "-%s.x));\n}\nhalf t = ((float(float(angle) * 0.15915494309180001) + 0.5) + %s) * "
+ "%s;\n%s = half4(t, 1.0, 0.0, 0.0);\n",
sk_TransformedCoords2D_0.c_str(), sk_TransformedCoords2D_0.c_str(),
sk_TransformedCoords2D_0.c_str(), sk_TransformedCoords2D_0.c_str(),
sk_TransformedCoords2D_0.c_str(), args.fUniformHandler->getUniformCStr(fBiasVar),
diff --git a/src/gpu/gradients/GrSweepGradientLayout.fp b/src/gpu/gradients/GrSweepGradientLayout.fp
index 4f98612..127ef78 100644
--- a/src/gpu/gradients/GrSweepGradientLayout.fp
+++ b/src/gpu/gradients/GrSweepGradientLayout.fp
@@ -22,10 +22,10 @@
// using atan instead.
half angle;
if (sk_Caps.atan2ImplementedAsAtanYOverX) {
- angle = half(2 * atan(-sk_TransformedCoords2D[0].y,
- length(sk_TransformedCoords2D[0]) - sk_TransformedCoords2D[0].x));
+ angle = 2 * atan(-sk_TransformedCoords2D[0].y,
+ length(sk_TransformedCoords2D[0]) - sk_TransformedCoords2D[0].x);
} else {
- angle = half(atan(-sk_TransformedCoords2D[0].y, -sk_TransformedCoords2D[0].x));
+ angle = atan(-sk_TransformedCoords2D[0].y, -sk_TransformedCoords2D[0].x);
}
// 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi]
diff --git a/src/gpu/gradients/GrTiledGradientEffect.cpp b/src/gpu/gradients/GrTiledGradientEffect.cpp
index 0657cad..8789d4c 100644
--- a/src/gpu/gradients/GrTiledGradientEffect.cpp
+++ b/src/gpu/gradients/GrTiledGradientEffect.cpp
@@ -32,10 +32,12 @@
this->emitChild(1, &_child1, args);
fragBuilder->codeAppendf(
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else {\n @if "
- "(%s) {\n half t_1 = t.x - 1.0;\n half tiled_t = (t_1 - 2.0 * "
- "floor(t_1 * 0.5)) - 1.0;\n if (sk_Caps.mustDoOpBetweenFloorAndAbs) {\n "
- " tiled_t = clamp(tiled_t, -1.0, 1.0);\n }\n t.x = "
- "abs(tiled_t);\n } else {\n t.x = fract(t.x);\n }",
+ "(%s) {\n half t_1 = t.x - 1.0;\n half tiled_t = (float(t_1) - 2.0 * "
+ "floor(float(float(t_1) * 0.5))) - 1.0;\n if "
+ "(sk_Caps.mustDoOpBetweenFloorAndAbs) {\n tiled_t = "
+ "half(clamp(float(tiled_t), -1.0, 1.0));\n }\n t.x = "
+ "half(abs(float(tiled_t)));\n } else {\n t.x = "
+ "half(fract(float(t.x)));\n }",
_child1.c_str(),
(_outer.childProcessor(1).preservesOpaqueInput() ? "true" : "false"),
args.fOutputColor, (_outer.mirror() ? "true" : "false"));
diff --git a/src/gpu/gradients/GrTwoPointConicalGradientLayout.cpp b/src/gpu/gradients/GrTwoPointConicalGradientLayout.cpp
index f268e16..418399b 100644
--- a/src/gpu/gradients/GrTwoPointConicalGradientLayout.cpp
+++ b/src/gpu/gradients/GrTwoPointConicalGradientLayout.cpp
@@ -44,24 +44,24 @@
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
"float2 p = %s;\nfloat t = -1.0;\nhalf v = 1.0;\n@switch (%d) {\n case 1:\n "
- " {\n half r0_2 = %s.y;\n t = float(r0_2) - p.y * p.y;\n "
- " if (t >= 0.0) {\n t = p.x + sqrt(t);\n } else "
- "{\n v = -1.0;\n }\n }\n break;\n case "
- "0:\n {\n half r0 = %s.x;\n @if (%s) {\n "
- " t = length(p) - float(r0);\n } else {\n t = "
- "-length(p) - float(r0);\n ",
+ " {\n half r0_2 = %s.y;\n t = float(float(r0_2) - p.y * "
+ "p.y);\n if (t >= 0.0) {\n t = p.x + sqrt(t);\n "
+ " } else {\n v = -1.0;\n }\n }\n break;\n "
+ " case 0:\n {\n half r0 = %s.x;\n @if (%s) {\n "
+ " t = length(p) - float(r0);\n } else {\n t = "
+ "-length(p) - float(r0);\n",
sk_TransformedCoords2D_0.c_str(), (int)_outer.type(),
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
(_outer.isRadiusIncreasing() ? "true" : "false"));
fragBuilder->codeAppendf(
- " }\n }\n break;\n case 2:\n {\n half invR1 "
- "= %s.x;\n half fx = %s.y;\n float x_t = -1.0;\n "
- "@if (%s) {\n x_t = dot(p, p) / p.x;\n } else if (%s) "
- "{\n x_t = length(p) - p.x * float(invR1);\n } else {\n "
- " float temp = p.x * p.x - p.y * p.y;\n if (temp >= "
- "0.0) {\n @if (%s || !%s) {\n x_t = "
- "-sqrt(temp) - p.x * float(invR1)",
+ " }\n }\n break;\n case 2:\n {\n "
+ "half invR1 = %s.x;\n half fx = %s.y;\n float x_t = -1.0;\n "
+ " @if (%s) {\n x_t = dot(p, p) / p.x;\n } else "
+ "if (%s) {\n x_t = length(p) - p.x * float(invR1);\n } "
+ "else {\n float temp = p.x * p.x - p.y * p.y;\n if "
+ "(temp >= 0.0) {\n @if (%s || !%s) {\n "
+ "x_t = -sqrt(temp) - p.x * float",
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
(_outer.isFocalOnCircle() ? "true" : "false"),
@@ -69,19 +69,19 @@
(_outer.isSwapped() ? "true" : "false"),
(_outer.isRadiusIncreasing() ? "true" : "false"));
fragBuilder->codeAppendf(
- ";\n } else {\n x_t = sqrt(temp) - p.x * "
- "float(invR1);\n }\n }\n }\n "
- " @if (!%s) {\n if (x_t <= 0.0) {\n v = -1.0;\n "
- " }\n }\n @if (%s) {\n @if (%s) "
- "{\n t = x_t;\n } else {\n t "
- "= x_t + float(fx);\n }\n } else {\n @if "
- "(%s) {\n ",
+ "(invR1);\n } else {\n x_t = sqrt(temp) "
+ "- p.x * float(invR1);\n }\n }\n }\n "
+ " @if (!%s) {\n if (x_t <= 0.0) {\n v = "
+ "-1.0;\n }\n }\n @if (%s) {\n "
+ "@if (%s) {\n t = x_t;\n } else {\n "
+ " t = x_t + float(fx);\n }\n } else {\n "
+ " @if (%s) {\n ",
(_outer.isWellBehaved() ? "true" : "false"),
(_outer.isRadiusIncreasing() ? "true" : "false"),
(_outer.isNativelyFocal() ? "true" : "false"),
(_outer.isNativelyFocal() ? "true" : "false"));
fragBuilder->codeAppendf(
- " t = -x_t;\n } else {\n t = -x_t + "
+ " t = -x_t;\n } else {\n t = -x_t + "
"float(fx);\n }\n }\n @if (%s) {\n "
" t = 1.0 - t;\n }\n }\n break;\n}\n%s = "
"half4(half(t), v, 0.0, 0.0);\n",
diff --git a/src/gpu/gradients/GrTwoPointConicalGradientLayout.fp b/src/gpu/gradients/GrTwoPointConicalGradientLayout.fp
index 1c6ff67..dbc0fb7 100644
--- a/src/gpu/gradients/GrTwoPointConicalGradientLayout.fp
+++ b/src/gpu/gradients/GrTwoPointConicalGradientLayout.fp
@@ -119,7 +119,7 @@
break;
}
- sk_OutColor = half4(half(t), v, 0, 0);
+ sk_OutColor = half4(t, v, 0, 0);
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/gradients/GrUnrolledBinaryGradientColorizer.fp b/src/gpu/gradients/GrUnrolledBinaryGradientColorizer.fp
index d5d7053..8c9ab64 100644
--- a/src/gpu/gradients/GrUnrolledBinaryGradientColorizer.fp
+++ b/src/gpu/gradients/GrUnrolledBinaryGradientColorizer.fp
@@ -104,7 +104,7 @@
}
}
- sk_OutColor = half4(t * scale + bias);
+ sk_OutColor = t * scale + bias;
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 98537df..39a8d5f 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -571,8 +571,8 @@
fragBuilder->codeAppendf("half edgeAlpha;");
// keep the derivative instructions outside the conditional
- fragBuilder->codeAppendf("half2 duvdx = half2(dFdx(%s.xy));", v.fsIn());
- fragBuilder->codeAppendf("half2 duvdy = half2(dFdy(%s.xy));", v.fsIn());
+ fragBuilder->codeAppendf("half2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("half2 duvdy = dFdy(%s.xy);", v.fsIn());
fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(), v.fsIn());
// today we know z and w are in device space. We could use derivatives
fragBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);", v.fsIn(),
diff --git a/src/gpu/ops/GrAAFillRRectOp.cpp b/src/gpu/ops/GrAAFillRRectOp.cpp
index 464462f..3954523 100644
--- a/src/gpu/ops/GrAAFillRRectOp.cpp
+++ b/src/gpu/ops/GrAAFillRRectOp.cpp
@@ -405,7 +405,7 @@
f->codeAppendf("float x_plus_1=%s.x, y=%s.y;", arcCoord.fsIn(), arcCoord.fsIn());
f->codeAppendf("half coverage;");
f->codeAppendf("if (0 == x_plus_1) {");
- f->codeAppendf( "coverage = half(y);"); // We are a non-arc pixel (i.e., linear coverage).
+ f->codeAppendf( "coverage = y;"); // We are a non-arc pixel (i.e., linear coverage).
f->codeAppendf("} else {");
f->codeAppendf( "float fn = x_plus_1 * (x_plus_1 - 2);"); // fn = (x+1)*(x-1) = x^2-1
f->codeAppendf( "fn = fma(y,y, fn);"); // fn = x^2 + y^2 - 1
@@ -416,7 +416,7 @@
f->codeAppendf("float gx=%s.z, gy=%s.w;", arcCoord.fsIn(), arcCoord.fsIn());
f->codeAppendf("float fnwidth = abs(gx) + abs(gy);");
}
- f->codeAppendf( "half d = half(fn/fnwidth);");
+ f->codeAppendf( "half d = fn/fnwidth;");
f->codeAppendf( "coverage = clamp(.5 - d, 0, 1);");
f->codeAppendf("}");
f->codeAppendf("%s = half4(coverage);", args.fOutputCoverage);
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index e334c72..1cc378c 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -860,11 +860,10 @@
args.fFPCoordTransformHandler);
// transforms all points so that we can compare them to our test circle
- fragBuilder->codeAppendf("half xShifted = half(%s.x - floor(%s.x / %s.z) * %s.z);",
+ fragBuilder->codeAppendf("half xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
dashParams.fsIn(), dashParams.fsIn(), dashParams.fsIn(),
dashParams.fsIn());
- fragBuilder->codeAppendf("half2 fragPosShifted = half2(xShifted, half(%s.y));",
- dashParams.fsIn());
+ fragBuilder->codeAppendf("half2 fragPosShifted = half2(xShifted, %s.y);", dashParams.fsIn());
fragBuilder->codeAppendf("half2 center = half2(%s.y, 0.0);", circleParams.fsIn());
fragBuilder->codeAppend("half dist = length(center - fragPosShifted);");
if (dce.aaMode() != AAMode::kNone) {
@@ -1060,23 +1059,18 @@
args.fFPCoordTransformHandler);
// transforms all points so that we can compare them to our test rect
- fragBuilder->codeAppendf("half xShifted = half(%s.x - floor(%s.x / %s.z) * %s.z);",
+ fragBuilder->codeAppendf("half xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(),
inDashParams.fsIn());
- fragBuilder->codeAppendf("half2 fragPosShifted = half2(xShifted, half(%s.y));",
- inDashParams.fsIn());
+ fragBuilder->codeAppendf("half2 fragPosShifted = half2(xShifted, %s.y);", inDashParams.fsIn());
if (de.aaMode() == AAMode::kCoverage) {
// The amount of coverage removed in x and y by the edges is computed as a pair of negative
// numbers, xSub and ySub.
fragBuilder->codeAppend("half xSub, ySub;");
- fragBuilder->codeAppendf("xSub = half(min(fragPosShifted.x - %s.x, 0.0));",
- inRectParams.fsIn());
- fragBuilder->codeAppendf("xSub += half(min(%s.z - fragPosShifted.x, 0.0));",
- inRectParams.fsIn());
- fragBuilder->codeAppendf("ySub = half(min(fragPosShifted.y - %s.y, 0.0));",
- inRectParams.fsIn());
- fragBuilder->codeAppendf("ySub += half(min(%s.w - fragPosShifted.y, 0.0));",
- inRectParams.fsIn());
+ fragBuilder->codeAppendf("xSub = min(fragPosShifted.x - %s.x, 0.0);", inRectParams.fsIn());
+ fragBuilder->codeAppendf("xSub += min(%s.z - fragPosShifted.x, 0.0);", inRectParams.fsIn());
+ fragBuilder->codeAppendf("ySub = min(fragPosShifted.y - %s.y, 0.0);", inRectParams.fsIn());
+ fragBuilder->codeAppendf("ySub += min(%s.w - fragPosShifted.y, 0.0);", inRectParams.fsIn());
// Now compute coverage in x and y and multiply them to get the fraction of the pixel
// covered.
fragBuilder->codeAppendf(
@@ -1085,10 +1079,8 @@
// For MSAA, we don't modulate the alpha by the Y distance, since MSAA coverage will handle
// AA on the the top and bottom edges. The shader is only responsible for intra-dash alpha.
fragBuilder->codeAppend("half xSub;");
- fragBuilder->codeAppendf("xSub = half(min(fragPosShifted.x - %s.x, 0.0));",
- inRectParams.fsIn());
- fragBuilder->codeAppendf("xSub += half(min(%s.z - fragPosShifted.x, 0.0));",
- inRectParams.fsIn());
+ fragBuilder->codeAppendf("xSub = min(fragPosShifted.x - %s.x, 0.0);", inRectParams.fsIn());
+ fragBuilder->codeAppendf("xSub += min(%s.z - fragPosShifted.x, 0.0);", inRectParams.fsIn());
// Now compute coverage in x to get the fraction of the pixel covered.
fragBuilder->codeAppendf("half alpha = (1.0 + max(xSub, -1.0));");
} else {
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 53e776b..c840cfc 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -157,28 +157,28 @@
args.fFPCoordTransformHandler);
fragBuilder->codeAppend("float d = length(circleEdge.xy);");
- fragBuilder->codeAppend("half distanceToOuterEdge = half(circleEdge.z * (1.0 - d));");
+ fragBuilder->codeAppend("half distanceToOuterEdge = circleEdge.z * (1.0 - d);");
fragBuilder->codeAppend("half edgeAlpha = saturate(distanceToOuterEdge);");
if (cgp.fStroke) {
fragBuilder->codeAppend(
- "half distanceToInnerEdge = half(circleEdge.z * (d - circleEdge.w));");
+ "half distanceToInnerEdge = circleEdge.z * (d - circleEdge.w);");
fragBuilder->codeAppend("half innerAlpha = saturate(distanceToInnerEdge);");
fragBuilder->codeAppend("edgeAlpha *= innerAlpha;");
}
if (cgp.fInClipPlane.isInitialized()) {
fragBuilder->codeAppend(
- "half clip = half(saturate(circleEdge.z * dot(circleEdge.xy, "
- "clipPlane.xy) + clipPlane.z));");
+ "half clip = saturate(circleEdge.z * dot(circleEdge.xy, clipPlane.xy) + "
+ "clipPlane.z);");
if (cgp.fInIsectPlane.isInitialized()) {
fragBuilder->codeAppend(
- "clip *= half(saturate(circleEdge.z * dot(circleEdge.xy, "
- "isectPlane.xy) + isectPlane.z));");
+ "clip *= saturate(circleEdge.z * dot(circleEdge.xy, isectPlane.xy) + "
+ "isectPlane.z);");
}
if (cgp.fInUnionPlane.isInitialized()) {
fragBuilder->codeAppend(
- "clip = saturate(clip + half(saturate(circleEdge.z * dot(circleEdge.xy,"
- " unionPlane.xy) + unionPlane.z)));");
+ "clip = saturate(clip + saturate(circleEdge.z * dot(circleEdge.xy, "
+ "unionPlane.xy) + unionPlane.z));");
}
fragBuilder->codeAppend("edgeAlpha *= clip;");
if (cgp.fInRoundCapCenters.isInitialized()) {
@@ -186,10 +186,10 @@
// by the clip planes. The inverse of the clip planes is applied so that there
// is no double counting.
fragBuilder->codeAppendf(
- "half dcap1 = half(circleEdge.z * (%s - length(circleEdge.xy - "
- " roundCapCenters.xy)));"
- "half dcap2 = half(circleEdge.z * (%s - length(circleEdge.xy - "
- " roundCapCenters.zw)));"
+ "half dcap1 = circleEdge.z * (%s - length(circleEdge.xy - "
+ " roundCapCenters.xy));"
+ "half dcap2 = circleEdge.z * (%s - length(circleEdge.xy - "
+ " roundCapCenters.zw));"
"half capAlpha = (1 - clip) * (max(dcap1, 0) + max(dcap2, 0));"
"edgeAlpha = min(edgeAlpha + capAlpha, 1.0);",
capRadius.fsIn(), capRadius.fsIn());
@@ -327,10 +327,10 @@
// The two boundary dash intervals are stored in wrapDashes.xy and .zw and fed
// to the fragment shader as a varying.
float4 wrapDashes;
- half lastIntervalLength = mod(6.28318530718, half(dashParams.y));
+ half lastIntervalLength = mod(6.28318530718, dashParams.y);
// We can happen to be perfectly divisible.
if (0 == lastIntervalLength) {
- lastIntervalLength = half(dashParams.y);
+ lastIntervalLength = dashParams.y;
}
// Let 'l' be the last interval before reaching 2 pi.
// Based on the phase determine whether (l-1)th, l-th, or (l+1)th interval's
@@ -338,9 +338,9 @@
// interval.
half offset = 0;
if (-dashParams.w >= lastIntervalLength) {
- offset = half(-dashParams.y);
+ offset = -dashParams.y;
} else if (dashParams.w > dashParams.y - lastIntervalLength) {
- offset = half(dashParams.y);
+ offset = dashParams.y;
}
wrapDashes.x = -lastIntervalLength + offset - dashParams.w;
// The end of this dash may be beyond the 2 pi and therefore clipped. Hence the
@@ -351,9 +351,9 @@
// "corresponding" dash appears in the 0th interval and is closest to l.
offset = 0;
if (dashParams.w >= dashParams.x) {
- offset = half(dashParams.y);
+ offset = dashParams.y;
} else if (-dashParams.w > dashParams.y - dashParams.x) {
- offset = half(-dashParams.y);
+ offset = -dashParams.y;
}
wrapDashes.z = lastIntervalLength + offset - dashParams.w;
wrapDashes.w = wrapDashes.z + dashParams.x;
@@ -361,7 +361,7 @@
// circle.
wrapDashes.z = max(wrapDashes.z, lastIntervalLength);
)");
- vertBuilder->codeAppendf("%s = half4(wrapDashes);", wrapDashes.vsOut());
+ vertBuilder->codeAppendf("%s = wrapDashes;", wrapDashes.vsOut());
vertBuilder->codeAppendf("%s = lastIntervalLength;", lastIntervalLength.vsOut());
fragBuilder->codeAppendf("half4 wrapDashes = %s;", wrapDashes.fsIn());
fragBuilder->codeAppendf("half lastIntervalLength = %s;", lastIntervalLength.fsIn());
@@ -398,30 +398,27 @@
float d = length(circleEdge.xy) * circleEdge.z;
// Compute coverage from outer/inner edges of the stroke.
- half distanceToOuterEdge = half(circleEdge.z - d);
+ half distanceToOuterEdge = circleEdge.z - d;
half edgeAlpha = saturate(distanceToOuterEdge);
- half distanceToInnerEdge = half(d - circleEdge.z * circleEdge.w);
+ half distanceToInnerEdge = d - circleEdge.z * circleEdge.w;
half innerAlpha = saturate(distanceToInnerEdge);
edgeAlpha *= innerAlpha;
- half angleFromStart = half(atan(circleEdge.y, circleEdge.x) - dashParams.z);
+ half angleFromStart = atan(circleEdge.y, circleEdge.x) - dashParams.z;
angleFromStart = mod(angleFromStart, 6.28318530718);
float x = mod(angleFromStart, dashParams.y);
// Convert the radial distance from center to pixel into a diameter.
d *= 2;
- half2 currDash = half2(half(-dashParams.w), half(dashParams.x) -
- half(dashParams.w));
- half2 nextDash = half2(half(dashParams.y) - half(dashParams.w),
- half(dashParams.y) + half(dashParams.x) -
- half(dashParams.w));
- half2 prevDash = half2(half(-dashParams.y) - half(dashParams.w),
- half(-dashParams.y) + half(dashParams.x) -
- half(dashParams.w));
+ half2 currDash = half2(-dashParams.w, dashParams.x - dashParams.w);
+ half2 nextDash = half2(dashParams.y - dashParams.w,
+ dashParams.y + dashParams.x - dashParams.w);
+ half2 prevDash = half2(-dashParams.y - dashParams.w,
+ -dashParams.y + dashParams.x - dashParams.w);
half dashAlpha = 0;
)");
fragBuilder->codeAppendf(R"(
if (angleFromStart - x + dashParams.y >= 6.28318530718) {
- dashAlpha += half(%s(x - wrapDashes.z, d) * %s(wrapDashes.w - x, d));
+ dashAlpha += %s(x - wrapDashes.z, d) * %s(wrapDashes.w - x, d);
currDash.y = min(currDash.y, lastIntervalLength);
if (nextDash.x >= lastIntervalLength) {
// The next dash is outside the 0..2pi range, throw it away
@@ -434,7 +431,7 @@
)", fnName.c_str(), fnName.c_str());
fragBuilder->codeAppendf(R"(
if (angleFromStart - x - dashParams.y < -0.01) {
- dashAlpha += half(%s(x - wrapDashes.x, d) * %s(wrapDashes.y - x, d));
+ dashAlpha += %s(x - wrapDashes.x, d) * %s(wrapDashes.y - x, d);
currDash.x = max(currDash.x, 0);
if (prevDash.y <= 0) {
// The previous dash is outside the 0..2pi range, throw it away
@@ -446,9 +443,9 @@
}
)", fnName.c_str(), fnName.c_str());
fragBuilder->codeAppendf(R"(
- dashAlpha += half(%s(x - currDash.x, d) * %s(currDash.y - x, d));
- dashAlpha += half(%s(x - nextDash.x, d) * %s(nextDash.y - x, d));
- dashAlpha += half(%s(x - prevDash.x, d) * %s(prevDash.y - x, d));
+ dashAlpha += %s(x - currDash.x, d) * %s(currDash.y - x, d);
+ dashAlpha += %s(x - nextDash.x, d) * %s(nextDash.y - x, d);
+ dashAlpha += %s(x - prevDash.x, d) * %s(prevDash.y - x, d);
dashAlpha = min(dashAlpha, 1);
edgeAlpha *= dashAlpha;
)", fnName.c_str(), fnName.c_str(), fnName.c_str(), fnName.c_str(), fnName.c_str(),
@@ -584,7 +581,7 @@
// avoid calling inversesqrt on zero.
fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fragBuilder->codeAppend("half invlen = half(inversesqrt(grad_dot));");
+ fragBuilder->codeAppend("half invlen = inversesqrt(grad_dot);");
fragBuilder->codeAppend("half edgeAlpha = saturate(0.5-test*invlen);");
// for inner curve
@@ -593,7 +590,7 @@
ellipseRadii.fsIn());
fragBuilder->codeAppend("test = dot(offset, offset) - 1.0;");
fragBuilder->codeAppendf("grad = 2.0*offset*%s.zw;", ellipseRadii.fsIn());
- fragBuilder->codeAppend("invlen = half(inversesqrt(dot(grad, grad)));");
+ fragBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));");
fragBuilder->codeAppend("edgeAlpha *= saturate(0.5+test*invlen);");
}
@@ -723,8 +720,8 @@
// for outer curve
fragBuilder->codeAppendf("half2 scaledOffset = %s.xy;", offsets0.fsIn());
fragBuilder->codeAppend("half test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("half2 duvdx = half2(dFdx(%s));", offsets0.fsIn());
- fragBuilder->codeAppendf("half2 duvdy = half2(dFdy(%s));", offsets0.fsIn());
+ fragBuilder->codeAppendf("half2 duvdx = dFdx(%s);", offsets0.fsIn());
+ fragBuilder->codeAppendf("half2 duvdy = dFdy(%s);", offsets0.fsIn());
fragBuilder->codeAppendf(
"half2 grad = half2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
" 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
@@ -733,7 +730,7 @@
fragBuilder->codeAppend("half grad_dot = dot(grad, grad);");
// avoid calling inversesqrt on zero.
fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fragBuilder->codeAppend("half invlen = half(inversesqrt(grad_dot));");
+ fragBuilder->codeAppend("half invlen = inversesqrt(grad_dot);");
if (DIEllipseStyle::kHairline == diegp.fStyle) {
// can probably do this with one step
fragBuilder->codeAppend("half edgeAlpha = saturate(1.0-test*invlen);");
@@ -746,13 +743,13 @@
if (DIEllipseStyle::kStroke == diegp.fStyle) {
fragBuilder->codeAppendf("scaledOffset = %s.xy;", offsets1.fsIn());
fragBuilder->codeAppend("test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("duvdx = half2(dFdx(%s));", offsets1.fsIn());
- fragBuilder->codeAppendf("duvdy = half2(dFdy(%s));", offsets1.fsIn());
+ fragBuilder->codeAppendf("duvdx = dFdx(%s);", offsets1.fsIn());
+ fragBuilder->codeAppendf("duvdy = dFdy(%s);", offsets1.fsIn());
fragBuilder->codeAppendf(
"grad = half2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
" 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
offsets1.fsIn(), offsets1.fsIn(), offsets1.fsIn(), offsets1.fsIn());
- fragBuilder->codeAppend("invlen = half(inversesqrt(dot(grad, grad)));");
+ fragBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));");
fragBuilder->codeAppend("edgeAlpha *= saturate(0.5+test*invlen);");
}
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.cpp b/src/gpu/ops/GrQuadPerEdgeAA.cpp
index 70caf55..9329bc4 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.cpp
+++ b/src/gpu/ops/GrQuadPerEdgeAA.cpp
@@ -659,12 +659,12 @@
coverage.vsOut(), gp.fPosition.name());
}
- args.fFragBuilder->codeAppendf("%s = half4(half(%s));",
+ args.fFragBuilder->codeAppendf("%s = float4(%s);",
args.fOutputCoverage, coverage.fsIn());
} else {
// Set coverage to 1, since it's either non-AA or the coverage was already
// folded into the output color
- args.fFragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
+ args.fFragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
}
}
GrGLSLColorSpaceXformHelper fTextureColorSpaceXformHelper;
diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp
index 6ecd6ba..a41d2b6 100644
--- a/src/gpu/vk/GrVkCopyManager.cpp
+++ b/src/gpu/vk/GrVkCopyManager.cpp
@@ -55,7 +55,7 @@
"// Copy Program VS\n"
"void main() {"
- "vTexCoord = half2(inPosition * uTexCoordXform.xy + uTexCoordXform.zw);"
+ "vTexCoord = inPosition * uTexCoordXform.xy + uTexCoordXform.zw;"
"sk_Position.xy = inPosition * uPosXform.xy + uPosXform.zw;"
"sk_Position.zw = half2(0, 1);"
"}"
diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp
index 8dffe4c..a86804b 100644
--- a/src/gpu/vk/GrVkUtil.cpp
+++ b/src/gpu/vk/GrVkUtil.cpp
@@ -204,7 +204,6 @@
SkSL::String(shaderString),
settings);
if (!program) {
- printf("%s\n", shaderString);
SkDebugf("SkSL error:\n%s\n", gpu->shaderCompiler()->errorText().c_str());
SkASSERT(false);
}
diff --git a/src/shaders/SkLightingShader.cpp b/src/shaders/SkLightingShader.cpp
index 8318980..95c20e8 100644
--- a/src/shaders/SkLightingShader.cpp
+++ b/src/shaders/SkLightingShader.cpp
@@ -168,33 +168,32 @@
kFloat3_GrSLType, kDefault_GrSLPrecision,
"AmbientColor", &ambientColorUniName);
- fragBuilder->codeAppendf("half4 diffuseColor = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 diffuseColor = %s;", args.fInputColor);
SkString dstNormalName("dstNormal");
this->emitChild(0, &dstNormalName, args);
fragBuilder->codeAppendf("float3 normal = %s.xyz;", dstNormalName.c_str());
- fragBuilder->codeAppend( "half3 result = half3(0.0);");
+ fragBuilder->codeAppend( "float3 result = float3(0.0);");
// diffuse light
if (lightingFP.fDirectionalLights.count() != 0) {
fragBuilder->codeAppendf("for (int i = 0; i < %d; i++) {",
lightingFP.fDirectionalLights.count());
// TODO: modulate the contribution from each light based on the shadow map
- fragBuilder->codeAppendf(" half NdotL = saturate(half(dot(normal, %s[i])));",
+ fragBuilder->codeAppendf(" float NdotL = saturate(dot(normal, %s[i]));",
lightDirsUniName);
- fragBuilder->codeAppendf(" result += half3(%s[i])*diffuseColor.rgb*NdotL;",
+ fragBuilder->codeAppendf(" result += %s[i]*diffuseColor.rgb*NdotL;",
lightColorsUniName);
fragBuilder->codeAppend("}");
}
// ambient light
- fragBuilder->codeAppendf("result += half3(%s) * diffuseColor.rgb;",
- ambientColorUniName);
+ fragBuilder->codeAppendf("result += %s * diffuseColor.rgb;", ambientColorUniName);
// Clamping to alpha (equivalent to an unpremul'd clamp to 1.0)
- fragBuilder->codeAppendf("%s = half4(clamp(result.rgb, 0.0, diffuseColor.a), "
+ fragBuilder->codeAppendf("%s = float4(clamp(result.rgb, 0.0, diffuseColor.a), "
"diffuseColor.a);", args.fOutputColor);
}
diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp
index 5dd8090..011ced8 100644
--- a/src/shaders/SkPerlinNoiseShader.cpp
+++ b/src/shaders/SkPerlinNoiseShader.cpp
@@ -1015,7 +1015,7 @@
}
// There are rounding errors if the floor operation is not performed here
- fragBuilder->codeAppendf("\n\t\thalf2 %s = half2(floor(%s.xy) * %s);",
+ fragBuilder->codeAppendf("\n\t\thalf2 %s = floor(%s.xy) * %s;",
noiseVec, vCoords.c_str(), baseFrequencyUni);
// Clear the color accumulator
@@ -1292,10 +1292,10 @@
GrShaderVar("p", kHalf3_GrSLType)
};
SkString gradFuncName;
- SkString gradCode("return half(dot(");
+ SkString gradCode("return dot(");
fragBuilder->appendTextureLookup(&gradCode, args.fTexSamplers[1], "float2(fract(x / 16.0), 0.0)",
kHalf2_GrSLType);
- gradCode.append(".rgb * 255.0 - float3(1.0), p));");
+ gradCode.append(".rgb * 255.0 - float3(1.0), p);");
fragBuilder->emitFunction(kHalf_GrSLType, "grad", SK_ARRAY_COUNT(gradArgs), gradArgs,
gradCode.c_str(), &gradFuncName);
@@ -1363,7 +1363,7 @@
fragBuilder->emitFunction(kHalf_GrSLType, "noiseOctaves", SK_ARRAY_COUNT(noiseOctavesArgs),
noiseOctavesArgs, noiseOctavesCode.c_str(), &noiseOctavesFuncName);
- fragBuilder->codeAppendf("half2 coords = half2(%s * %s);", vCoords.c_str(), baseFrequencyUni);
+ fragBuilder->codeAppendf("half2 coords = %s * %s;", vCoords.c_str(), baseFrequencyUni);
fragBuilder->codeAppendf("half r = %s(half3(coords, %s));", noiseOctavesFuncName.c_str(),
zUni);
fragBuilder->codeAppendf("half g = %s(half3(coords, %s + 0000.0));",
diff --git a/src/sksl/SkSLContext.h b/src/sksl/SkSLContext.h
index b8c68c2..225f65d 100644
--- a/src/sksl/SkSLContext.h
+++ b/src/sksl/SkSLContext.h
@@ -21,25 +21,23 @@
Context()
: fInvalid_Type(new Type("<INVALID>"))
, fVoid_Type(new Type("void"))
- , fFloatLiteral_Type(new Type("$floatLiteral", Type::kFloat_NumberKind, 3))
- , fIntLiteral_Type(new Type("$intLiteral", Type::kSigned_NumberKind, 1))
- , fDouble_Type(new Type("double", Type::kFloat_NumberKind, 6))
+ , fDouble_Type(new Type("double", Type::kFloat_NumberKind, 4))
, fDouble2_Type(new Type("double2", *fDouble_Type, 2))
, fDouble3_Type(new Type("double3", *fDouble_Type, 3))
, fDouble4_Type(new Type("double4", *fDouble_Type, 4))
- , fFloat_Type(new Type("float", Type::kFloat_NumberKind, 5))
+ , fFloat_Type(new Type("float", Type::kFloat_NumberKind, 3))
, fFloat2_Type(new Type("float2", *fFloat_Type, 2))
, fFloat3_Type(new Type("float3", *fFloat_Type, 3))
, fFloat4_Type(new Type("float4", *fFloat_Type, 4))
- , fHalf_Type(new Type("half", Type::kFloat_NumberKind, 4))
+ , fHalf_Type(new Type("half", Type::kFloat_NumberKind, 2))
, fHalf2_Type(new Type("half2", *fHalf_Type, 2))
, fHalf3_Type(new Type("half3", *fHalf_Type, 3))
, fHalf4_Type(new Type("half4", *fHalf_Type, 4))
- , fUInt_Type(new Type("uint", Type::kUnsigned_NumberKind, 2))
+ , fUInt_Type(new Type("uint", Type::kUnsigned_NumberKind, 1))
, fUInt2_Type(new Type("uint2", *fUInt_Type, 2))
, fUInt3_Type(new Type("uint3", *fUInt_Type, 3))
, fUInt4_Type(new Type("uint4", *fUInt_Type, 4))
- , fInt_Type(new Type("int", Type::kSigned_NumberKind, 2))
+ , fInt_Type(new Type("int", Type::kSigned_NumberKind, 1))
, fInt2_Type(new Type("int2", *fInt_Type, 2))
, fInt3_Type(new Type("int3", *fInt_Type, 3))
, fInt4_Type(new Type("int4", *fInt_Type, 4))
@@ -208,8 +206,6 @@
const std::unique_ptr<Type> fInvalid_Type;
const std::unique_ptr<Type> fVoid_Type;
- const std::unique_ptr<Type> fFloatLiteral_Type;
- const std::unique_ptr<Type> fIntLiteral_Type;
const std::unique_ptr<Type> fDouble_Type;
const std::unique_ptr<Type> fDouble2_Type;
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 090c7ba..751947a 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -90,10 +90,14 @@
else if (component == *fContext.fDouble_Type) {
result = "dvec";
}
- else if (component.isSigned()) {
+ else if (component == *fContext.fInt_Type ||
+ component == *fContext.fShort_Type ||
+ component == *fContext.fByte_Type) {
result = "ivec";
}
- else if (component.isUnsigned()) {
+ else if (component == *fContext.fUInt_Type ||
+ component == *fContext.fUShort_Type ||
+ component == *fContext.fUByte_Type) {
result = "uvec";
}
else if (component == *fContext.fBool_Type) {
@@ -699,9 +703,7 @@
void GLSLCodeGenerator::writeConstructor(const Constructor& c, Precedence parentPrecedence) {
if (c.fArguments.size() == 1 &&
- (this->getTypeName(c.fType) == this->getTypeName(c.fArguments[0]->fType) ||
- (c.fType.kind() == Type::kScalar_Kind &&
- c.fArguments[0]->fType == *fContext.fFloatLiteral_Type))) {
+ this->getTypeName(c.fType) == this->getTypeName(c.fArguments[0]->fType)) {
// in cases like half(float), they're different types as far as SkSL is concerned but the
// same type as far as GLSL is concerned. We avoid a redundant float(float) by just writing
// out the inner expression here.
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index bf017ad..f8e2499 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -188,9 +188,6 @@
case ASTStatement::kExpression_Kind: {
std::unique_ptr<Statement> result =
this->convertExpressionStatement((ASTExpressionStatement&) statement);
- if (!result) {
- return nullptr;
- }
if (fRTAdjust && Program::kGeometry_Kind == fKind) {
SkASSERT(result->fKind == Statement::kExpression_Kind);
Expression& expr = *((ExpressionStatement&) *result).fExpression;
@@ -1104,17 +1101,8 @@
if (type.kind() == Type::kScalar_Kind) {
std::vector<std::unique_ptr<Expression>> args;
args.push_back(std::move(expr));
- std::unique_ptr<Expression> ctor;
- if (type == *fContext.fFloatLiteral_Type) {
- ctor = this->convertIdentifier(ASTIdentifier(-1, "float"));
- } else if (type == *fContext.fIntLiteral_Type) {
- ctor = this->convertIdentifier(ASTIdentifier(-1, "int"));
- } else {
- ctor = this->convertIdentifier(ASTIdentifier(-1, type.fName));
- }
- if (!ctor) {
- printf("error, null identifier: %s\n", String(type.fName).c_str());
- }
+ ASTIdentifier id(-1, type.fName);
+ std::unique_ptr<Expression> ctor = this->convertIdentifier(id);
SkASSERT(ctor);
return this->call(-1, std::move(ctor), std::move(args));
}
@@ -1417,7 +1405,8 @@
default: return nullptr;
}
}
- if (left.fType.kind() == Type::kVector_Kind && left.fType.componentType().isFloat() &&
+ if (left.fType.kind() == Type::kVector_Kind &&
+ left.fType.componentType() == *fContext.fFloat_Type &&
left.fType == right.fType) {
SkASSERT(left.fKind == Expression::kConstructor_Kind);
SkASSERT(right.fKind == Expression::kConstructor_Kind);
@@ -1492,8 +1481,8 @@
!Compiler::IsAssignment(expression.fOperator))) {
fErrors.error(expression.fOffset, String("type mismatch: '") +
Compiler::OperatorName(expression.fOperator) +
- "' cannot operate on '" + left->fType.description() +
- "', '" + right->fType.description() + "'");
+ "' cannot operate on '" + left->fType.fName +
+ "', '" + right->fType.fName + "'");
return nullptr;
}
if (Compiler::IsAssignment(expression.fOperator)) {
@@ -1539,8 +1528,8 @@
if (!determine_binary_type(fContext, Token::EQEQ, ifTrue->fType, ifFalse->fType, &trueType,
&falseType, &resultType, true) || trueType != falseType) {
fErrors.error(expression.fOffset, "ternary operator result mismatch: '" +
- ifTrue->fType.description() + "', '" +
- ifFalse->fType.description() + "'");
+ ifTrue->fType.fName + "', '" +
+ ifFalse->fType.fName + "'");
return nullptr;
}
ifTrue = this->coerce(std::move(ifTrue), *trueType);
@@ -1818,14 +1807,18 @@
}
switch (expression.fOperator) {
case Token::PLUS:
- if (!base->fType.isNumber() && base->fType.kind() != Type::kVector_Kind &&
- base->fType != *fContext.fFloatLiteral_Type) {
+ if (!base->fType.isNumber() && base->fType.kind() != Type::kVector_Kind) {
fErrors.error(expression.fOffset,
"'+' cannot operate on '" + base->fType.description() + "'");
return nullptr;
}
return base;
case Token::MINUS:
+ if (!base->fType.isNumber() && base->fType.kind() != Type::kVector_Kind) {
+ fErrors.error(expression.fOffset,
+ "'-' cannot operate on '" + base->fType.description() + "'");
+ return nullptr;
+ }
if (base->fKind == Expression::kIntLiteral_Kind) {
return std::unique_ptr<Expression>(new IntLiteral(fContext, base->fOffset,
-((IntLiteral&) *base).fValue));
@@ -1835,11 +1828,6 @@
return std::unique_ptr<Expression>(new FloatLiteral(fContext, base->fOffset,
value));
}
- if (!base->fType.isNumber() && base->fType.kind() != Type::kVector_Kind) {
- fErrors.error(expression.fOffset,
- "'-' cannot operate on '" + base->fType.description() + "'");
- return nullptr;
- }
return std::unique_ptr<Expression>(new PrefixExpression(Token::MINUS, std::move(base)));
case Token::PLUSPLUS:
if (!base->fType.isNumber()) {
diff --git a/src/sksl/SkSLMetalCodeGenerator.cpp b/src/sksl/SkSLMetalCodeGenerator.cpp
index 13c171a..9009665 100644
--- a/src/sksl/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/SkSLMetalCodeGenerator.cpp
@@ -357,7 +357,8 @@
if (t1.columns() > 1) {
return this->canCoerce(t1.componentType(), t2.componentType());
}
- return t1.isFloat() && t2.isFloat();
+ return ((t1 == *fContext.fFloat_Type || t1 == *fContext.fHalf_Type) &&
+ (t2 == *fContext.fFloat_Type || t2 == *fContext.fHalf_Type));
}
void MetalCodeGenerator::writeConstructor(const Constructor& c, Precedence parentPrecedence) {
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index daafe30..b5aa618 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -433,13 +433,13 @@
}
Type SPIRVCodeGenerator::getActualType(const Type& type) {
- if (type.isFloat()) {
+ if (type == *fContext.fHalf_Type) {
return *fContext.fFloat_Type;
}
- if (type.isSigned()) {
+ if (type == *fContext.fShort_Type || type == *fContext.fByte_Type) {
return *fContext.fInt_Type;
}
- if (type.isUnsigned()) {
+ if (type == *fContext.fUShort_Type || type == *fContext.fUByte_Type) {
return *fContext.fUInt_Type;
}
if (type.kind() == Type::kMatrix_Kind || type.kind() == Type::kVector_Kind) {
@@ -472,13 +472,11 @@
case Type::kScalar_Kind:
if (type == *fContext.fBool_Type) {
this->writeInstruction(SpvOpTypeBool, result, fConstantBuffer);
- } else if (type == *fContext.fInt_Type || type == *fContext.fShort_Type ||
- type == *fContext.fIntLiteral_Type) {
+ } else if (type == *fContext.fInt_Type) {
this->writeInstruction(SpvOpTypeInt, result, 32, 1, fConstantBuffer);
- } else if (type == *fContext.fUInt_Type || type == *fContext.fUShort_Type) {
+ } else if (type == *fContext.fUInt_Type) {
this->writeInstruction(SpvOpTypeInt, result, 32, 0, fConstantBuffer);
- } else if (type == *fContext.fFloat_Type || type == *fContext.fHalf_Type ||
- type == *fContext.fFloatLiteral_Type) {
+ } else if (type == *fContext.fFloat_Type) {
this->writeInstruction(SpvOpTypeFloat, result, 32, fConstantBuffer);
} else if (type == *fContext.fDouble_Type) {
this->writeInstruction(SpvOpTypeFloat, result, 64, fConstantBuffer);
@@ -2045,8 +2043,7 @@
}
return result;
} else {
- ABORT("unsupported binary expression: %s (%s, %s)", b.description().c_str(),
- b.fLeft->fType.description().c_str(), b.fRight->fType.description().c_str());
+ ABORT("unsupported binary expression: %s", b.description().c_str());
}
} else {
tmp = this->getActualType(b.fLeft->fType);
@@ -2476,7 +2473,7 @@
}
SpvId SPIRVCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
- if (f.fType != *fContext.fDouble_Type) {
+ if (f.fType == *fContext.fFloat_Type || f.fType == *fContext.fHalf_Type) {
float value = (float) f.fValue;
auto entry = fFloatConstants.find(value);
if (entry == fFloatConstants.end()) {
@@ -2491,6 +2488,7 @@
}
return entry->second;
} else {
+ SkASSERT(f.fType == *fContext.fDouble_Type);
auto entry = fDoubleConstants.find(f.fValue);
if (entry == fDoubleConstants.end()) {
SpvId result = this->nextId();
diff --git a/src/sksl/ir/SkSLConstructor.h b/src/sksl/ir/SkSLConstructor.h
index 1070a0c..145e117 100644
--- a/src/sksl/ir/SkSLConstructor.h
+++ b/src/sksl/ir/SkSLConstructor.h
@@ -32,13 +32,15 @@
std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,
const DefinitionMap& definitions) override {
if (fArguments.size() == 1 && fArguments[0]->fKind == Expression::kIntLiteral_Kind) {
- if (fType.isFloat()) {
+ if (fType == *irGenerator.fContext.fFloat_Type ||
+ fType == *irGenerator.fContext.fHalf_Type) {
// promote float(1) to 1.0
int64_t intValue = ((IntLiteral&) *fArguments[0]).fValue;
return std::unique_ptr<Expression>(new FloatLiteral(irGenerator.fContext,
fOffset,
intValue));
- } else if (fType.isInteger()) {
+ } else if (fType == *irGenerator.fContext.fUInt_Type ||
+ fType == *irGenerator.fContext.fUShort_Type) {
// promote uint(1) to 1u
int64_t intValue = ((IntLiteral&) *fArguments[0]).fValue;
return std::unique_ptr<Expression>(new IntLiteral(fOffset,
@@ -105,10 +107,10 @@
const FloatLiteral fzero(context, -1, 0);
const IntLiteral izero(context, -1, 0);
const Expression* zero;
- if (fType.componentType().isFloat()) {
+ if (fType.componentType() == *context.fFloat_Type) {
zero = &fzero;
} else {
- SkASSERT(fType.componentType().isInteger());
+ SkASSERT(fType.componentType() == *context.fInt_Type);
zero = &izero;
}
for (int col = 0; col < fType.columns(); col++) {
diff --git a/src/sksl/ir/SkSLFloatLiteral.h b/src/sksl/ir/SkSLFloatLiteral.h
index f0f93fd..e995e4c 100644
--- a/src/sksl/ir/SkSLFloatLiteral.h
+++ b/src/sksl/ir/SkSLFloatLiteral.h
@@ -18,7 +18,7 @@
*/
struct FloatLiteral : public Expression {
FloatLiteral(const Context& context, int offset, double value)
- : INHERITED(offset, kFloatLiteral_Kind, *context.fFloatLiteral_Type)
+ : INHERITED(offset, kFloatLiteral_Kind, *context.fFloat_Type)
, fValue(value) {}
FloatLiteral(int offset, double value, const Type* type)
@@ -37,13 +37,6 @@
return true;
}
- int coercionCost(const Type& target) const override {
- if (target.isFloat()) {
- return 0;
- }
- return INHERITED::coercionCost(target);
- }
-
bool compareConstant(const Context& context, const Expression& other) const override {
FloatLiteral& f = (FloatLiteral&) other;
return fValue == f.fValue;
diff --git a/src/sksl/ir/SkSLIntLiteral.h b/src/sksl/ir/SkSLIntLiteral.h
index 9291c97..116796c 100644
--- a/src/sksl/ir/SkSLIntLiteral.h
+++ b/src/sksl/ir/SkSLIntLiteral.h
@@ -45,7 +45,7 @@
}
int coercionCost(const Type& target) const override {
- if (target.isSigned() || target.isUnsigned() || target.isFloat()) {
+ if (target.isUnsigned()) {
return 0;
}
return INHERITED::coercionCost(target);
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h
index 0702866..412ed90 100644
--- a/src/sksl/ir/SkSLSwizzle.h
+++ b/src/sksl/ir/SkSLSwizzle.h
@@ -106,13 +106,13 @@
if (fBase->fKind == Expression::kConstructor_Kind && fBase->isConstant()) {
// we're swizzling a constant vector, e.g. float4(1).x. Simplify it.
SkASSERT(fBase->fKind == Expression::kConstructor_Kind);
- if (fType.isInteger()) {
+ if (fType == *irGenerator.fContext.fInt_Type) {
SkASSERT(fComponents.size() == 1);
int64_t value = ((Constructor&) *fBase).getIVecComponent(fComponents[0]);
return std::unique_ptr<Expression>(new IntLiteral(irGenerator.fContext,
-1,
value));
- } else if (fType.isFloat()) {
+ } else if (fType == *irGenerator.fContext.fFloat_Type) {
SkASSERT(fComponents.size() == 1);
double value = ((Constructor&) *fBase).getFVecComponent(fComponents[0]);
return std::unique_ptr<Expression>(new FloatLiteral(irGenerator.fContext,
diff --git a/src/sksl/ir/SkSLType.cpp b/src/sksl/ir/SkSLType.cpp
index 691ff7b..eb3a64f 100644
--- a/src/sksl/ir/SkSLType.cpp
+++ b/src/sksl/ir/SkSLType.cpp
@@ -26,8 +26,17 @@
}
return INT_MAX;
}
- if (this->isNumber() && other.isNumber() && other.priority() > this->priority()) {
- return other.priority() - this->priority();
+ if (this->isNumber() && other.isFloat()) {
+ return 1;
+ }
+ if (this->isSigned() && other.isSigned()) {
+ return 1;
+ }
+ if (this->isUnsigned() && other.isUnsigned()) {
+ return 1;
+ }
+ if (this->isUnsigned() && other.isSigned() && other.priority() > priority()) {
+ return 1;
}
for (size_t i = 0; i < fCoercibleTypes.size(); i++) {
if (*fCoercibleTypes[i] == other) {
@@ -42,7 +51,7 @@
if (columns == 1 && rows == 1) {
return *this;
}
- if (*this == *context.fFloat_Type || *this == *context.fFloatLiteral_Type) {
+ if (*this == *context.fFloat_Type) {
switch (rows) {
case 1:
switch (columns) {
@@ -138,7 +147,7 @@
}
default: ABORT("unsupported row count (%d)", rows);
}
- } else if (*this == *context.fInt_Type || *this == *context.fIntLiteral_Type) {
+ } else if (*this == *context.fInt_Type) {
switch (rows) {
case 1:
switch (columns) {
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index ba97e63..e368c1a 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -197,12 +197,6 @@
}
String description() const override {
- if (fNameString == "$floatLiteral") {
- return "float";
- }
- if (fNameString == "$intLiteral") {
- return "int";
- }
return fNameString;
}
diff --git a/src/sksl/sksl.inc b/src/sksl/sksl.inc
index 79a9cc3..7e03616 100644
--- a/src/sksl/sksl.inc
+++ b/src/sksl/sksl.inc
@@ -22,68 +22,35 @@
$genType exp2($genType x);
$genType log2($genType x);
$genType sqrt($genType x);
-$genHType radians($genHType degrees);
-$genHType sin($genHType angle);
-$genHType cos($genHType angle);
-$genHType tan($genHType angle);
-$genHType asin($genHType x);
-$genHType acos($genHType x);
-$genHType atan($genHType y, $genHType x);
-$genHType atan($genHType y_over_x);
-$genHType sinh($genHType x);
-$genHType cosh($genHType x);
-$genHType tanh($genHType x);
-$genHType asinh($genHType x);
-$genHType acosh($genHType x);
-$genHType atanh($genHType x);
-$genHType pow($genHType x, $genHType y);
-$genHType exp($genHType x);
-$genHType log($genHType x);
-$genHType exp2($genHType x);
-$genHType log2($genHType x);
-$genHType sqrt($genHType x);
//$genDType sqrt($genDType x);
$genType inversesqrt($genType x);
//$genDType inversesqrt($genDType x);
$genType abs($genType x);
-$genHType abs($genHType x);
$genIType abs($genIType x);
//$genDType abs($genDType x);
$genType sign($genType x);
-$genHType sign($genHType x);
$genIType sign($genIType x);
//$genDType sign($genDType x);
$genType floor($genType x);
-$genHType floor($genHType x);
//$genDType floor($genDType x);
$genType trunc($genType x);
-$genHType trunc($genHType x);
//$genDType trunc($genDType x);
$genType round($genType x);
-$genHType round($genHType x);
//$genDType round($genDType x);
$genType roundEven($genType x);
-$genHType roundEven($genHType x);
//$genDType roundEven($genDType x);
$genType ceil($genType x);
-$genHType ceil($genHType x);
//$genDType ceil($genDType x);
$genType fract($genType x);
-$genHType fract($genHType x);
//$genDType fract($genDType x);
$genType mod($genType x, float y);
$genType mod($genType x, $genType y);
-$genHType mod($genHType x, half y);
-$genHType mod($genHType x, $genType y);
//$genDType mod($genDType x, double y);
//$genDType mod($genDType x, $genDType y);
$genType modf($genType x, out $genType i);
-$genHType modf($genHType x, out $genHType i);
//$genDType modf($genDType x, out $genDType i);
$genType min($genType x, $genType y);
$genType min($genType x, float y);
-$genHType min($genHType x, $genHType y);
-$genHType min($genHType x, half y);
//$genDType min($genDType x, $genDType y);
//$genDType min($genDType x, double y);
$genIType min($genIType x, $genIType y);
@@ -92,8 +59,6 @@
//$genUType min($genUType x, uint y);
$genType max($genType x, $genType y);
$genType max($genType x, float y);
-$genHType max($genHType x, $genHType y);
-$genHType max($genHType x, half y);
//$genDType max($genDType x, $genDType y);
//$genDType max($genDType x, double y);
$genIType max($genIType x, $genIType y);
@@ -102,8 +67,6 @@
//$genUType max($genUType x, uint y);
$genType clamp($genType x, $genType minVal, $genType maxVal);
$genType clamp($genType x, float minVal, float maxVal);
-$genHType clamp($genHType x, $genHType minVal, $genHType maxVal);
-$genHType clamp($genHType x, half minVal, half maxVal);
//$genDType clamp($genDType x, $genDType minVal, $genDType maxVal);
//$genDType clamp($genDType x, double minVal, double maxVal);
$genIType clamp($genIType x, $genIType minVal, $genIType maxVal);
@@ -111,11 +74,8 @@
//$genUType clamp($genUType x, $genUType minVal, $genUType maxVal);
//$genUType clamp($genUType x, uint minVal, uint maxVal);
$genType saturate($genType x);
-$genHType saturate($genHType x);
$genType mix($genType x, $genType y, $genType a);
$genType mix($genType x, $genType y, float a);
-$genHType mix($genHType x, $genHType y, $genHType a);
-$genHType mix($genHType x, $genHType y, half a);
//$genDType mix($genDType x, $genDType y, $genDType a);
//$genDType mix($genDType x, $genDType y, double a);
$genType mix($genType x, $genType y, $genBType a);
@@ -125,14 +85,10 @@
$genBType mix($genBType x, $genBType y, $genBType a);
$genType step($genType edge, $genType x);
$genType step(float edge, $genType x);
-$genHType step($genHType edge, $genHType x);
-$genHType step(half edge, $genHType x);
//$genDType step($genDType edge, $genDType x);
//$genDType step(double edge, $genDType x);
$genType smoothstep($genType edge0, $genType edge1, $genType x);
$genType smoothstep(float edge0, float edge1, $genType x);
-$genHType smoothstep($genHType edge0, $genHType edge1, $genHType x);
-$genHType smoothstep(half edge0, half edge1, $genHType x);
//$genDType smoothstep($genDType edge0, $genDType edge1, $genDType x);
//$genDType smoothstep(double edge0, double edge1, $genDType x);
$genBType isnan($genType x);
@@ -198,15 +154,6 @@
float4x2 outerProduct(float2 c, float4 r);
float3x4 outerProduct(float4 c, float3 r);
float4x3 outerProduct(float3 c, float4 r);
-half2x2 outerProduct(half2 c, half2 r);
-half3x3 outerProduct(half3 c, half3 r);
-half4x3 outerProduct(half4 c, half4 r);
-half2x3 outerProduct(half3 c, half2 r);
-half3x2 outerProduct(half2 c, half3 r);
-half2x4 outerProduct(half4 c, half2 r);
-half4x2 outerProduct(half2 c, half4 r);
-half3x4 outerProduct(half4 c, half3 r);
-half4x3 outerProduct(half3 c, half4 r);
float2x2 transpose(float2x2 m);
float3x3 transpose(float3x3 m);
float4x4 transpose(float4x4 m);
@@ -216,27 +163,12 @@
float4x2 transpose(float2x4 m);
float3x4 transpose(float4x3 m);
float4x3 transpose(float3x4 m);
-half2x2 transpose(half2x2 m);
-half3x3 transpose(half3x3 m);
-half4x4 transpose(half4x4 m);
-half2x3 transpose(half3x2 m);
-half3x2 transpose(half2x3 m);
-half2x4 transpose(half4x2 m);
-half4x2 transpose(half2x4 m);
-half3x4 transpose(half4x3 m);
-half4x3 transpose(half3x4 m);
float determinant(float2x2 m);
float determinant(float3x3 m);
float determinant(float4x4 m);
-half determinant(half2x2 m);
-half determinant(half3x3 m);
-half determinant(half4x4 m);
float2x2 inverse(float2x2 m);
float3x3 inverse(float3x3 m);
float4x4 inverse(float4x4 m);
-half2x2 inverse(half2x2 m);
-half3x3 inverse(half3x3 m);
-half4x4 inverse(half4x4 m);
$bvec lessThan($vec x, $vec y);
$bvec lessThan($hvec x, $hvec y);
$bvec lessThan($dvec x, $dvec y);
@@ -604,10 +536,7 @@
int4 imageLoad(iimage2D image, int2 P);
$genType dFdx($genType p);
$genType dFdy($genType p);
-$genHType dFdx($genHType p);
-$genHType dFdy($genHType p);
$genType fwidth($genType p);
-$genHType fwidth($genHType p);
float interpolateAtSample(float interpolant, int sample);
float2 interpolateAtSample(float2 interpolant, int sample);
float3 interpolateAtSample(float3 interpolant, int sample);