renamed SkSL types in preparation for killing precision modifiers
Bug: skia:
Change-Id: Iff0289e25355a89cdc289a0892ed755dd1b1c900
Reviewed-on: https://skia-review.googlesource.com/27703
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index ec79053..c94c47a 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -86,7 +86,7 @@
varyingHandler->addVarying("color", &varying);
// There are several optional steps to process the color. Start with the attribute:
- vertBuilder->codeAppendf("vec4 color = %s;", gp.inColor()->fName);
+ vertBuilder->codeAppendf("float4 color = %s;", gp.inColor()->fName);
// Linearize
if (gp.linearizeColor()) {
@@ -101,7 +101,7 @@
"return (x <= 0.04045) ? (x / 12.92) "
": pow((x + 0.055) / 1.055, 2.4);",
&srgbFuncName);
- vertBuilder->codeAppendf("color = vec4(%s(%s.r), %s(%s.g), %s(%s.b), %s.a);",
+ vertBuilder->codeAppendf("color = float4(%s(%s.r), %s(%s.g), %s(%s.b), %s.a);",
srgbFuncName.c_str(), gp.inColor()->fName,
srgbFuncName.c_str(), gp.inColor()->fName,
srgbFuncName.c_str(), gp.inColor()->fName,
@@ -110,7 +110,7 @@
// For SkColor, do a red/blue swap and premul
if (gp.fFlags & kColorAttributeIsSkColor_GPFlag) {
- vertBuilder->codeAppend("color = vec4(color.a * color.bgr, color.a);");
+ vertBuilder->codeAppend("color = float4(color.a * color.bgr, color.a);");
}
// Do color-correction to destination gamut
@@ -163,9 +163,9 @@
if (gp.hasVertexCoverage()) {
fragBuilder->codeAppendf("float alpha = 1.0;");
varyingHandler->addPassThroughAttribute(gp.inCoverage(), "alpha");
- fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
} else if (gp.coverage() == 0xff) {
- fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
} else {
const char* fragCoverage;
fCoverageUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
@@ -173,7 +173,7 @@
kDefault_GrSLPrecision,
"Coverage",
&fragCoverage);
- fragBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, fragCoverage);
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, fragCoverage);
}
}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 78319c7..9c60808 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -18,7 +18,7 @@
class GrShaderCaps;
class GrSwizzle;
-/** Provides custom fragment shader code. Fragment processors receive an input color (vec4f) and
+/** Provides custom fragment shader code. Fragment processors receive an input color (float4) and
produce an output color. They may reference textures and uniforms. They may use
GrCoordTransforms to receive a transformation of the local coordinates that map from local space
to the fragment being processed.
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp
index 39d418b..42668bc 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -44,7 +44,7 @@
fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, stagedLocalVarName);
// setup constant solid coverage
- fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
}
void emitTransforms(GrGLSLVaryingHandler* varyingHandler,
diff --git a/src/gpu/GrTextureStripAtlas.h b/src/gpu/GrTextureStripAtlas.h
index 8957aa3..a67438b 100644
--- a/src/gpu/GrTextureStripAtlas.h
+++ b/src/gpu/GrTextureStripAtlas.h
@@ -65,11 +65,11 @@
*
* If a regular texture access without using the atlas looks like:
*
- * texture2D(sampler, vec2(x, y))
+ * texture2D(sampler, float2(x, y))
*
* Then when using the atlas we'd replace it with:
*
- * texture2D(sampler, vec2(x, yOffset + y * scaleFactor))
+ * texture2D(sampler, float2(x, yOffset + y * scaleFactor))
*
* Where yOffset, returned by getYOffset(), is the offset to the start of the row within the
* atlas and scaleFactor, returned by getNormalizedTexelHeight, is the normalized height of
diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
index 85b989b..332a64c 100644
--- a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
@@ -122,7 +122,8 @@
const TexelBufferHandle& pointsBuffer,
const char* rtAdjust, GrGPArgs* gpArgs) const {
v->codeAppendf("int packedoffset = %s.w;", proc.instanceAttrib());
- v->codeAppend ("highp vec2 atlasoffset = vec2((packedoffset<<16) >> 16, packedoffset >> 16);");
+ v->codeAppend ("highp float2 atlasoffset = float2((packedoffset<<16) >> 16, "
+ "packedoffset >> 16);");
this->onEmitVertexShader(proc, v, pointsBuffer, "atlasoffset", rtAdjust, gpArgs);
}
@@ -150,12 +151,12 @@
fnBody.appendf("%s = %s * %s;",
fFragCoverageTimesWind.gsOut(), coverage, fGeomWind.c_str());
}
- fnBody.append ("gl_Position = vec4(position, 0, 1);");
+ fnBody.append ("gl_Position = float4(position, 0, 1);");
fnBody.append ("EmitVertex();");
return fnBody;
}().c_str(), &emitVertexFn);
- g->codeAppendf("highp vec2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
+ g->codeAppendf("highp float2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
#ifdef SK_DEBUG
if (proc.debugVisualizations()) {
@@ -172,7 +173,7 @@
SkASSERT(numSides >= 3);
if (!insetPts) {
- g->codeAppendf("highp vec2 centroidpt = %s * vec%i(%f);",
+ g->codeAppendf("highp float2 centroidpt = %s * float%i(%f);",
polygonPts, numSides, 1.0 / numSides);
}
@@ -180,44 +181,44 @@
"nextidx = (%s + 1) %% %i;",
wedgeIdx, numSides - 1, numSides, wedgeIdx, numSides);
- g->codeAppendf("highp vec2 self = %s[%s];"
+ g->codeAppendf("highp float2 self = %s[%s];"
"highp int leftidx = %s > 0 ? previdx : nextidx;"
"highp int rightidx = %s > 0 ? nextidx : previdx;",
polygonPts, wedgeIdx, fGeomWind.c_str(), fGeomWind.c_str());
// Which quadrant does the vector from self -> right fall into?
- g->codeAppendf("highp vec2 right = %s[rightidx];", polygonPts);
+ g->codeAppendf("highp float2 right = %s[rightidx];", polygonPts);
if (3 == numSides) {
// TODO: evaluate perf gains.
- g->codeAppend ("highp vec2 qsr = sign(right - self);");
+ g->codeAppend ("highp float2 qsr = sign(right - self);");
} else {
SkASSERT(4 == numSides);
- g->codeAppendf("highp vec2 diag = %s[(%s + 2) %% 4];", polygonPts, wedgeIdx);
- g->codeAppend ("highp vec2 qsr = sign((right != self ? right : diag) - self);");
+ g->codeAppendf("highp float2 diag = %s[(%s + 2) %% 4];", polygonPts, wedgeIdx);
+ g->codeAppend ("highp float2 qsr = sign((right != self ? right : diag) - self);");
}
// Which quadrant does the vector from left -> self fall into?
- g->codeAppendf("highp vec2 qls = sign(self - %s[leftidx]);", polygonPts);
+ g->codeAppendf("highp float2 qls = sign(self - %s[leftidx]);", polygonPts);
// d2 just helps us reduce triangle counts with orthogonal, axis-aligned lines.
// TODO: evaluate perf gains.
const char* dr2 = "dr";
if (3 == numSides) {
// TODO: evaluate perf gains.
- g->codeAppend ("highp vec2 dr = vec2(qsr.y != 0 ? +qsr.y : +qsr.x, "
+ g->codeAppend ("highp float2 dr = float2(qsr.y != 0 ? +qsr.y : +qsr.x, "
"qsr.x != 0 ? -qsr.x : +qsr.y);");
- g->codeAppend ("highp vec2 dr2 = vec2(qsr.y != 0 ? +qsr.y : -qsr.x, "
+ g->codeAppend ("highp float2 dr2 = float2(qsr.y != 0 ? +qsr.y : -qsr.x, "
"qsr.x != 0 ? -qsr.x : -qsr.y);");
- g->codeAppend ("highp vec2 dl = vec2(qls.y != 0 ? +qls.y : +qls.x, "
+ g->codeAppend ("highp float2 dl = float2(qls.y != 0 ? +qls.y : +qls.x, "
"qls.x != 0 ? -qls.x : +qls.y);");
dr2 = "dr2";
} else {
- g->codeAppend ("highp vec2 dr = vec2(qsr.y != 0 ? +qsr.y : 1, "
+ g->codeAppend ("highp float2 dr = float2(qsr.y != 0 ? +qsr.y : 1, "
"qsr.x != 0 ? -qsr.x : 1);");
- g->codeAppend ("highp vec2 dl = (qls == vec2(0)) ? dr : vec2(qls.y != 0 ? +qls.y : 1, "
- "qls.x != 0 ? -qls.x : 1);");
+ g->codeAppend ("highp float2 dl = (qls == float2(0)) ? dr : "
+ "float2(qls.y != 0 ? +qls.y : 1, qls.x != 0 ? -qls.x : 1);");
}
- g->codeAppendf("bvec2 dnotequal = notEqual(%s, dl);", dr2);
+ g->codeAppendf("bool2 dnotequal = notEqual(%s, dl);", dr2);
// Emit one third of what is the convex hull of pixel-size boxes centered on the vertices.
// Each invocation emits a different third.
@@ -235,7 +236,7 @@
g->codeAppendf( "%s(self + bloat * dl, 1);", emitVertexFn);
g->codeAppend ("}");
g->codeAppend ("if (all(dnotequal)) {");
- g->codeAppendf( "%s(self + bloat * vec2(-dl.y, dl.x), 1);", emitVertexFn);
+ g->codeAppendf( "%s(self + bloat * float2(-dl.y, dl.x), 1);", emitVertexFn);
g->codeAppend ("}");
g->codeAppend ("EndPrimitive();");
@@ -246,18 +247,18 @@
const char* leftPt, const char* rightPt,
const char* distanceEquation) const {
if (!distanceEquation) {
- this->emitEdgeDistanceEquation(g, leftPt, rightPt, "highp vec3 edge_distance_equation");
+ this->emitEdgeDistanceEquation(g, leftPt, rightPt, "highp float3 edge_distance_equation");
distanceEquation = "edge_distance_equation";
}
// qlr is defined in emitEdgeDistanceEquation.
- g->codeAppendf("highp mat2 endpts = mat2(%s - bloat * qlr, %s + bloat * qlr);",
+ g->codeAppendf("highp float2x2 endpts = float2x2(%s - bloat * qlr, %s + bloat * qlr);",
leftPt, rightPt);
- g->codeAppendf("mediump vec2 endpts_coverage = %s.xy * endpts + %s.z;",
+ g->codeAppendf("mediump float2 endpts_coverage = %s.xy * endpts + %s.z;",
distanceEquation, distanceEquation);
// d1 is defined in emitEdgeDistanceEquation.
- g->codeAppend ("highp vec2 d2 = d1;");
+ g->codeAppend ("highp float2 d2 = d1;");
g->codeAppend ("bool aligned = qlr.x == 0 || qlr.y == 0;");
g->codeAppend ("if (aligned) {");
g->codeAppend ( "d1 -= qlr;");
@@ -286,16 +287,17 @@
const char* leftPt, const char* rightPt,
const char* outputDistanceEquation) const {
// Which quadrant does the vector from left -> right fall into?
- g->codeAppendf("highp vec2 qlr = sign(%s - %s);", rightPt, leftPt);
- g->codeAppend ("highp vec2 d1 = vec2(qlr.y, -qlr.x);");
+ g->codeAppendf("highp float2 qlr = sign(%s - %s);", rightPt, leftPt);
+ g->codeAppend ("highp float2 d1 = float2(qlr.y, -qlr.x);");
- g->codeAppendf("highp vec2 n = vec2(%s.y - %s.y, %s.x - %s.x);",
+ g->codeAppendf("highp float2 n = float2(%s.y - %s.y, %s.x - %s.x);",
rightPt, leftPt, leftPt, rightPt);
- g->codeAppendf("highp vec2 kk = n * mat2(%s + bloat * d1, %s - bloat * d1);", leftPt, leftPt);
+ g->codeAppendf("highp float2 kk = n * float2x2(%s + bloat * d1, %s - bloat * d1);",
+ leftPt, leftPt);
// Clamp for when n=0. wind=0 when n=0 so as long as we don't get Inf or NaN we are fine.
g->codeAppendf("highp float scale = 1 / max(kk[0] - kk[1], 1e-30);");
- g->codeAppendf("%s = vec3(-n, kk[1]) * scale;", outputDistanceEquation);
+ g->codeAppendf("%s = float3(-n, kk[1]) * scale;", outputDistanceEquation);
}
void PrimitiveProcessor::emitCoverage(const GrCCPRCoverageProcessor& proc, GrGLSLFragmentBuilder* f,
@@ -314,11 +316,11 @@
break;
}
- f->codeAppendf("%s = vec4(1);", outputCoverage);
+ f->codeAppendf("%s = float4(1);", outputCoverage);
#ifdef SK_DEBUG
if (proc.debugVisualizations()) {
- f->codeAppendf("%s = vec4(-%s.a, %s.a, 0, 1);", outputColor, outputColor, outputColor);
+ f->codeAppendf("%s = float4(-%s.a, %s.a, 0, 1);", outputColor, outputColor, outputColor);
}
#endif
}
@@ -327,17 +329,17 @@
const char* samplesName) const {
// Standard DX11 sample locations.
#if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS)
- f->defineConstant("highp vec2[8]", samplesName, "vec2[8]("
- "vec2(+1, -3)/16, vec2(-1, +3)/16, vec2(+5, +1)/16, vec2(-3, -5)/16, "
- "vec2(-5, +5)/16, vec2(-7, -1)/16, vec2(+3, +7)/16, vec2(+7, -7)/16."
+ f->defineConstant("highp float2[8]", samplesName, "float2[8]("
+ "float2(+1, -3)/16, float2(-1, +3)/16, float2(+5, +1)/16, float2(-3, -5)/16, "
+ "float2(-5, +5)/16, float2(-7, -1)/16, float2(+3, +7)/16, float2(+7, -7)/16."
")");
return 8;
#else
- f->defineConstant("highp vec2[16]", samplesName, "vec2[16]("
- "vec2(+1, +1)/16, vec2(-1, -3)/16, vec2(-3, +2)/16, vec2(+4, -1)/16, "
- "vec2(-5, -2)/16, vec2(+2, +5)/16, vec2(+5, +3)/16, vec2(+3, -5)/16, "
- "vec2(-2, +6)/16, vec2( 0, -7)/16, vec2(-4, -6)/16, vec2(-6, +4)/16, "
- "vec2(-8, 0)/16, vec2(+7, -4)/16, vec2(+6, +7)/16, vec2(-7, -8)/16."
+ f->defineConstant("highp float2[16]", samplesName, "float2[16]("
+ "float2(+1, +1)/16, float2(-1, -3)/16, float2(-3, +2)/16, float2(+4, -1)/16, "
+ "float2(-5, -2)/16, float2(+2, +5)/16, float2(+5, +3)/16, float2(+3, -5)/16, "
+ "float2(-2, +6)/16, float2( 0, -7)/16, float2(-4, -6)/16, float2(-6, +4)/16, "
+ "float2(-8, 0)/16, float2(+7, -4)/16, float2(+6, +7)/16, float2(-7, -8)/16."
")");
return 16;
#endif
diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.h b/src/gpu/ccpr/GrCCPRCoverageProcessor.h
index 574cf4a..befa1a9 100644
--- a/src/gpu/ccpr/GrCCPRCoverageProcessor.h
+++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.h
@@ -215,13 +215,13 @@
int emitEdgeGeometry(GrGLSLGeometryBuilder*, const char* emitVertexFn, const char* leftPt,
const char* rightPt, const char* distanceEquation = nullptr) const;
- // Defines an equation ("dot(vec3(pt, 1), distance_equation)") that is -1 on the outside border
- // of a conservative raster edge and 0 on the inside (see emitEdgeGeometry).
+ // Defines an equation ("dot(float3(pt, 1), distance_equation)") that is -1 on the outside
+ // border of a conservative raster edge and 0 on the inside (see emitEdgeGeometry).
void emitEdgeDistanceEquation(GrGLSLGeometryBuilder*, const char* leftPt, const char* rightPt,
const char* outputDistanceEquation) const;
- // Defines a global vec2 array that contains MSAA sample locations as offsets from pixel center.
- // Subclasses can use this for software multisampling.
+ // Defines a global float2 array that contains MSAA sample locations as offsets from pixel
+ // center. Subclasses can use this for software multisampling.
//
// Returns the number of samples.
int defineSoftSampleLocations(GrGLSLFragmentBuilder*, const char* samplesName) const;
diff --git a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
index 9dfa8e1..5f6f759 100644
--- a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
@@ -24,10 +24,10 @@
#endif
// Fetch all 4 cubic bezier points.
- v->codeAppendf("ivec4 indices = ivec4(%s.y, %s.x, %s.x + 1, %s.y + 1);",
+ v->codeAppendf("int4 indices = int4(%s.y, %s.x, %s.x + 1, %s.y + 1);",
proc.instanceAttrib(), proc.instanceAttrib(), proc.instanceAttrib(),
proc.instanceAttrib());
- v->codeAppend ("highp mat4x2 bezierpts = mat4x2(");
+ v->codeAppend ("highp float4x2 bezierpts = float4x2(");
v->appendTexelFetch(pointsBuffer, "indices[sk_VertexID]");
v->codeAppend (".xy, ");
v->appendTexelFetch(pointsBuffer, "indices[(sk_VertexID + 1) % 4]");
@@ -38,24 +38,24 @@
v->codeAppend (".xy);");
// Find the corner of the inset geometry that corresponds to this bezier vertex (bezierpts[0]).
- v->codeAppend ("highp mat2 N = mat2(bezierpts[3].y - bezierpts[0].y, "
- "bezierpts[0].x - bezierpts[3].x, "
- "bezierpts[1].y - bezierpts[0].y, "
- "bezierpts[0].x - bezierpts[1].x);");
- v->codeAppend ("highp mat2 P = mat2(bezierpts[3], bezierpts[1]);");
+ v->codeAppend ("highp float2x2 N = float2x2(bezierpts[3].y - bezierpts[0].y, "
+ "bezierpts[0].x - bezierpts[3].x, "
+ "bezierpts[1].y - bezierpts[0].y, "
+ "bezierpts[0].x - bezierpts[1].x);");
+ v->codeAppend ("highp float2x2 P = float2x2(bezierpts[3], bezierpts[1]);");
v->codeAppend ("if (abs(determinant(N)) < 2) {"); // Area of [pts[3], pts[0], pts[1]] < 1px.
// The inset corner doesn't exist because we are effectively colinear with
// both neighbor vertices. Just duplicate a neighbor's inset corner.
v->codeAppend ( "int smallidx = (dot(N[0], N[0]) > dot(N[1], N[1])) ? 1 : 0;");
- v->codeAppend ( "N[smallidx] = vec2(bezierpts[2].y - bezierpts[3 - smallidx * 2].y, "
- "bezierpts[3 - smallidx * 2].x - bezierpts[2].x);");
+ v->codeAppend ( "N[smallidx] = float2(bezierpts[2].y - bezierpts[3 - smallidx * 2].y, "
+ "bezierpts[3 - smallidx * 2].x - bezierpts[2].x);");
v->codeAppend ( "P[smallidx] = bezierpts[2];");
v->codeAppend ("}");
v->codeAppend ("N[0] *= sign(dot(N[0], P[1] - P[0]));");
v->codeAppend ("N[1] *= sign(dot(N[1], P[0] - P[1]));");
- v->codeAppendf("highp vec2 K = vec2(dot(N[0], P[0] + %f * sign(N[0])), "
- "dot(N[1], P[1] + %f * sign(N[1])));", inset, inset);
+ v->codeAppendf("highp float2 K = float2(dot(N[0], P[0] + %f * sign(N[0])), "
+ "dot(N[1], P[1] + %f * sign(N[1])));", inset, inset);
v->codeAppendf("%s.xy = K * inverse(N) + %s;", fInset.vsOut(), atlasOffset);
v->codeAppendf("%s.xy = %s.xy * %s.xz + %s.yw;",
fInset.vsOut(), fInset.vsOut(), rtAdjust, rtAdjust);
@@ -71,14 +71,15 @@
v->codeAppend ("[sk_VertexID % 2];");
// Emit the vertex position.
- v->codeAppendf("highp vec2 self = bezierpts[0] + %s;", atlasOffset);
+ v->codeAppendf("highp float2 self = bezierpts[0] + %s;", atlasOffset);
gpArgs->fPositionVar.set(kVec2f_GrSLType, "self");
}
void GrCCPRCubicProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdjust,
const char* outputWind) const {
// We will define bezierpts in onEmitGeometryShader.
- g->codeAppend ("highp float area_times_2 = determinant(mat3(1, bezierpts[0], "
+ g->codeAppend ("highp float area_times_2 = "
+ "determinant(float3x3(1, bezierpts[0], "
"1, bezierpts[2], "
"0, bezierpts[3] - bezierpts[1]));");
// Drop curves that are nearly flat. The KLM math becomes unstable in this case.
@@ -97,13 +98,13 @@
void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const char* emitVertexFn,
const char* wind, const char* rtAdjust) const {
// Prepend bezierpts at the start of the shader.
- g->codePrependf("highp mat4x2 bezierpts = mat4x2(sk_in[0].gl_Position.xy, "
+ g->codePrependf("highp float4x2 bezierpts = float4x2(sk_in[0].gl_Position.xy, "
"sk_in[1].gl_Position.xy, "
"sk_in[2].gl_Position.xy, "
"sk_in[3].gl_Position.xy);");
// Evaluate the cubic at t=.5 for an approximate midpoint.
- g->codeAppendf("highp vec2 midpoint = bezierpts * vec4(.125, .375, .375, .125);");
+ g->codeAppendf("highp float2 midpoint = bezierpts * float4(.125, .375, .375, .125);");
// Finish finding the inset geometry we started in the vertex shader. The z component tells us
// how "sharp" an inset corner is. And the vertex shader already skips one corner if it is
@@ -111,9 +112,9 @@
// geometry is all empty (it should never be non-convex because the curve gets chopped into
// convex segments ahead of time).
g->codeAppendf("bool isempty = "
- "any(lessThan(vec4(%s[0].z, %s[1].z, %s[2].z, %s[3].z) * %s, vec4(2)));",
+ "any(lessThan(float4(%s[0].z, %s[1].z, %s[2].z, %s[3].z) * %s, float4(2)));",
fInset.gsIn(), fInset.gsIn(), fInset.gsIn(), fInset.gsIn(), wind);
- g->codeAppendf("highp vec2 inset[4];");
+ g->codeAppendf("highp float2 inset[4];");
g->codeAppend ("for (int i = 0; i < 4; ++i) {");
g->codeAppendf( "inset[i] = isempty ? midpoint : %s[i].xy;", fInset.gsIn());
g->codeAppend ("}");
@@ -127,8 +128,8 @@
g->codeAppend ("lowp int numbackwards = 0;");
g->codeAppend ("for (int i = 0; i < 4; ++i) {");
g->codeAppend ( "lowp int j = (i + 1) % 4;");
- g->codeAppendf( "highp vec2 inner = inset[j] - inset[i];");
- g->codeAppendf( "highp vec2 outer = sk_in[j].gl_Position.xy - sk_in[i].gl_Position.xy;");
+ g->codeAppendf( "highp float2 inner = inset[j] - inset[i];");
+ g->codeAppendf( "highp float2 outer = sk_in[j].gl_Position.xy - sk_in[i].gl_Position.xy;");
g->codeAppendf( "backwards[i] = sign(dot(outer, inner));");
g->codeAppendf( "numbackwards += backwards[i] < 0 ? 1 : 0;");
g->codeAppend ("}");
@@ -137,16 +138,16 @@
// dropped on the floor later.
g->codeAppend ("lowp int x = (backwards[0] != backwards[2]) ? 1 : 0;");
g->codeAppend ("lowp int x3 = (x + 3) % 4;");
- g->codeAppend ("highp mat2 X = mat2(inset[x].y - inset[x+1].y, "
- "inset[x+1].x - inset[x].x, "
- "inset[x+2].y - inset[x3].y, "
- "inset[x3].x - inset[x+2].x);");
- g->codeAppend ("highp vec2 KK = vec2(dot(X[0], inset[x]), dot(X[1], inset[x+2]));");
- g->codeAppend ("highp vec2 crossoverpoint = KK * inverse(X);");
+ g->codeAppend ("highp float2x2 X = float2x2(inset[x].y - inset[x+1].y, "
+ "inset[x+1].x - inset[x].x, "
+ "inset[x+2].y - inset[x3].y, "
+ "inset[x3].x - inset[x+2].x);");
+ g->codeAppend ("highp float2 KK = float2(dot(X[0], inset[x]), dot(X[1], inset[x+2]));");
+ g->codeAppend ("highp float2 crossoverpoint = KK * inverse(X);");
// Determine what point backwards edges should collapse into. If there is one backwards edge,
// it should collapse to the crossover point. If >1, they should all collapse to the midpoint.
- g->codeAppend ("highp vec2 collapsepoint = numbackwards == 1 ? crossoverpoint : midpoint;");
+ g->codeAppend ("highp float2 collapsepoint = numbackwards == 1 ? crossoverpoint : midpoint;");
// Collapse backwards egdes to the "collapse" point.
g->codeAppend ("for (int i = 0; i < 4; ++i) {");
@@ -157,46 +158,46 @@
// Calculate the KLM matrix.
g->declareGlobal(fKLMMatrix);
- g->codeAppend ("highp vec4 K, L, M;");
+ g->codeAppend ("highp float4 K, L, M;");
if (Type::kSerpentine == fType) {
- g->codeAppend ("highp vec2 l,m;");
- g->codeAppendf("l.ts = vec2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppendf("m.ts = vec2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppend ("K = vec4(0, l.s * m.s, -l.t * m.s - m.t * l.s, l.t * m.t);");
- g->codeAppend ("L = vec4(-1,3,-3,1) * l.ssst * l.sstt * l.sttt;");
- g->codeAppend ("M = vec4(-1,3,-3,1) * m.ssst * m.sstt * m.sttt;");
+ g->codeAppend ("highp float2 l,m;");
+ g->codeAppendf("l.ts = float2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppendf("m.ts = float2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppend ("K = float4(0, l.s * m.s, -l.t * m.s - m.t * l.s, l.t * m.t);");
+ g->codeAppend ("L = float4(-1,3,-3,1) * l.ssst * l.sstt * l.sttt;");
+ g->codeAppend ("M = float4(-1,3,-3,1) * m.ssst * m.sstt * m.sttt;");
} else {
- g->codeAppend ("highp vec2 d,e;");
- g->codeAppendf("d.ts = vec2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppendf("e.ts = vec2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppend ("highp vec4 dxe = vec4(d.s * e.s, d.s * e.t, d.t * e.s, d.t * e.t);");
- g->codeAppend ("K = vec4(0, dxe.x, -dxe.y - dxe.z, dxe.w);");
- g->codeAppend ("L = vec4(-1,1,-1,1) * d.sstt * (dxe.xyzw + vec4(0, 2*dxe.zy, 0));");
- g->codeAppend ("M = vec4(-1,1,-1,1) * e.sstt * (dxe.xzyw + vec4(0, 2*dxe.yz, 0));");
+ g->codeAppend ("highp float2 d,e;");
+ g->codeAppendf("d.ts = float2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppendf("e.ts = float2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppend ("highp float4 dxe = float4(d.s * e.s, d.s * e.t, d.t * e.s, d.t * e.t);");
+ g->codeAppend ("K = float4(0, dxe.x, -dxe.y - dxe.z, dxe.w);");
+ g->codeAppend ("L = float4(-1,1,-1,1) * d.sstt * (dxe.xyzw + float4(0, 2*dxe.zy, 0));");
+ g->codeAppend ("M = float4(-1,1,-1,1) * e.sstt * (dxe.xzyw + float4(0, 2*dxe.yz, 0));");
}
- g->codeAppend ("highp mat2x4 C = mat4(-1, 3, -3, 1, "
- " 3, -6, 3, 0, "
- "-3, 3, 0, 0, "
- " 1, 0, 0, 0) * transpose(bezierpts);");
+ g->codeAppend ("highp float2x4 C = float4x4(-1, 3, -3, 1, "
+ " 3, -6, 3, 0, "
+ "-3, 3, 0, 0, "
+ " 1, 0, 0, 0) * transpose(bezierpts);");
- g->codeAppend ("highp vec2 absdet = abs(C[0].xx * C[1].zy - C[1].xx * C[0].zy);");
+ g->codeAppend ("highp float2 absdet = abs(C[0].xx * C[1].zy - C[1].xx * C[0].zy);");
g->codeAppend ("lowp int middlerow = absdet[0] > absdet[1] ? 2 : 1;");
- g->codeAppend ("highp mat3 CI = inverse(mat3(C[0][0], C[0][middlerow], C[0][3], "
- "C[1][0], C[1][middlerow], C[1][3], "
- " 0, 0, 1));");
- g->codeAppendf("%s = CI * mat3(K[0], K[middlerow], K[3], "
- "L[0], L[middlerow], L[3], "
- "M[0], M[middlerow], M[3]);", fKLMMatrix.c_str());
+ g->codeAppend ("highp float3x3 CI = inverse(float3x3(C[0][0], C[0][middlerow], C[0][3], "
+ "C[1][0], C[1][middlerow], C[1][3], "
+ " 0, 0, 1));");
+ g->codeAppendf("%s = CI * float3x3(K[0], K[middlerow], K[3], "
+ "L[0], L[middlerow], L[3], "
+ "M[0], M[middlerow], M[3]);", fKLMMatrix.c_str());
// Orient the KLM matrix so we fill the correct side of the curve.
- g->codeAppendf("lowp vec2 orientation = sign(vec3(midpoint, 1) * mat2x3(%s[1], %s[2]));",
+ g->codeAppendf("lowp float2 orientation = sign(float3(midpoint, 1) * float2x3(%s[1], %s[2]));",
fKLMMatrix.c_str(), fKLMMatrix.c_str());
- g->codeAppendf("%s *= mat3(orientation[0] * orientation[1], 0, 0, "
- "0, orientation[0], 0, "
- "0, 0, orientation[1]);", fKLMMatrix.c_str());
+ g->codeAppendf("%s *= float3x3(orientation[0] * orientation[1], 0, 0, "
+ "0, orientation[0], 0, "
+ "0, 0, orientation[1]);", fKLMMatrix.c_str());
g->declareGlobal(fKLMDerivatives);
g->codeAppendf("%s[0] = %s[0].xy * %s.xz;",
@@ -227,7 +228,7 @@
void GrCCPRCubicInsetProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("highp vec3 klm = vec3(%s, 1) * %s;", position, fKLMMatrix.c_str());
+ fnBody->appendf("highp float3 klm = float3(%s, 1) * %s;", position, fKLMMatrix.c_str());
fnBody->appendf("%s = klm;", fKLM.gsOut());
fnBody->appendf("%s[0] = 3 * klm[0] * %s[0];", fGradMatrix.gsOut(), fKLMDerivatives.c_str());
fnBody->appendf("%s[1] = -klm[1] * %s[2].xy - klm[2] * %s[1].xy;",
@@ -239,7 +240,7 @@
f->codeAppendf("highp float k = %s.x, l = %s.y, m = %s.z;",
fKLM.fsIn(), fKLM.fsIn(), fKLM.fsIn());
f->codeAppend ("highp float f = k*k*k - l*m;");
- f->codeAppendf("highp vec2 grad = %s * vec2(k, 1);", fGradMatrix.fsIn());
+ f->codeAppendf("highp float2 grad = %s * float2(k, 1);", fGradMatrix.fsIn());
f->codeAppend ("highp float d = f * inversesqrt(dot(grad, grad));");
f->codeAppendf("%s = clamp(0.5 - d, 0, 1);", outputCoverage);
}
@@ -250,8 +251,8 @@
// We defined bezierpts in onEmitGeometryShader.
g->declareGlobal(fEdgeDistanceEquation);
g->codeAppendf("int edgeidx0 = %s > 0 ? 3 : 0;", wind);
- g->codeAppendf("highp vec2 edgept0 = bezierpts[edgeidx0];");
- g->codeAppendf("highp vec2 edgept1 = bezierpts[3 - edgeidx0];");
+ g->codeAppendf("highp float2 edgept0 = bezierpts[edgeidx0];");
+ g->codeAppendf("highp float2 edgept1 = bezierpts[3 - edgeidx0];");
this->emitEdgeDistanceEquation(g, "edgept0", "edgept1", fEdgeDistanceEquation.c_str());
g->codeAppendf("%s.z += 0.5;", fEdgeDistanceEquation.c_str()); // outer = -.5, inner = .5
@@ -260,9 +261,9 @@
fEdgeDistanceDerivatives.c_str(), fEdgeDistanceEquation.c_str(), rtAdjust);
g->declareGlobal(fEdgeSpaceTransform);
- g->codeAppend ("highp vec4 edgebbox = vec4(min(bezierpts[0], bezierpts[3]) - bloat, "
+ g->codeAppend ("highp float4 edgebbox = float4(min(bezierpts[0], bezierpts[3]) - bloat, "
"max(bezierpts[0], bezierpts[3]) + bloat);");
- g->codeAppendf("%s.xy = 2 / vec2(edgebbox.zw - edgebbox.xy);", fEdgeSpaceTransform.c_str());
+ g->codeAppendf("%s.xy = 2 / float2(edgebbox.zw - edgebbox.xy);", fEdgeSpaceTransform.c_str());
g->codeAppendf("%s.zw = -1 - %s.xy * edgebbox.xy;",
fEdgeSpaceTransform.c_str(), fEdgeSpaceTransform.c_str());
@@ -277,14 +278,14 @@
void GrCCPRCubicBorderProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("highp vec3 klm = vec3(%s, 1) * %s;", position, fKLMMatrix.c_str());
- fnBody->appendf("highp float d = dot(vec3(%s, 1), %s);",
+ fnBody->appendf("highp float3 klm = float3(%s, 1) * %s;", position, fKLMMatrix.c_str());
+ fnBody->appendf("highp float d = dot(float3(%s, 1), %s);",
position, fEdgeDistanceEquation.c_str());
- fnBody->appendf("%s = vec4(klm, d);", fKLMD.gsOut());
- fnBody->appendf("%s = vec4(%s[0].x, %s[1].x, %s[2].x, %s.x);",
+ fnBody->appendf("%s = float4(klm, d);", fKLMD.gsOut());
+ fnBody->appendf("%s = float4(%s[0].x, %s[1].x, %s[2].x, %s.x);",
fdKLMDdx.gsOut(), fKLMDerivatives.c_str(), fKLMDerivatives.c_str(),
fKLMDerivatives.c_str(), fEdgeDistanceDerivatives.c_str());
- fnBody->appendf("%s = vec4(%s[0].y, %s[1].y, %s[2].y, %s.y);",
+ fnBody->appendf("%s = float4(%s[0].y, %s[1].y, %s[2].y, %s.y);",
fdKLMDdy.gsOut(), fKLMDerivatives.c_str(), fKLMDerivatives.c_str(),
fKLMDerivatives.c_str(), fEdgeDistanceDerivatives.c_str());
fnBody->appendf("%s = position * %s.xy + %s.zw;", fEdgeSpaceCoord.gsOut(),
@@ -302,18 +303,19 @@
// Along the shared edge, we start with distance-to-edge coverage, then subtract out the
// remaining pixel coverage that is still inside the shared edge, but outside the curve.
// Outside the shared edege, we just use standard msaa to count samples inside the curve.
- f->codeAppendf("bool use_edge = all(lessThan(abs(%s), vec2(1)));", fEdgeSpaceCoord.fsIn());
+ f->codeAppendf("bool use_edge = all(lessThan(abs(%s), float2(1)));", fEdgeSpaceCoord.fsIn());
f->codeAppendf("%s = (use_edge ? clamp(%s.w + 0.5, 0, 1) : 0) * %i;",
outputCoverage, fKLMD.fsIn(), sampleCount);
- f->codeAppendf("highp mat2x4 grad_klmd = mat2x4(%s, %s);", fdKLMDdx.fsIn(), fdKLMDdy.fsIn());
+ f->codeAppendf("highp float2x4 grad_klmd = float2x4(%s, %s);", fdKLMDdx.fsIn(),
+ fdKLMDdy.fsIn());
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
- f->codeAppendf( "highp vec4 klmd = grad_klmd * samples[i] + %s;", fKLMD.fsIn());
+ f->codeAppendf( "highp float4 klmd = grad_klmd * samples[i] + %s;", fKLMD.fsIn());
f->codeAppend ( "lowp float f = klmd.y * klmd.z - klmd.x * klmd.x * klmd.x;");
// A sample is inside our cubic sub-section if it is inside the implicit AND L & M are both
// positive. This works because the sections get chopped at the K/L and K/M intersections.
- f->codeAppend ( "bvec4 inside = greaterThan(vec4(f,klmd.yzw), vec4(0));");
+ f->codeAppend ( "bool4 inside = greaterThan(float4(f,klmd.yzw), float4(0));");
f->codeAppend ( "lowp float in_curve = all(inside.xyz) ? 1 : 0;");
f->codeAppend ( "lowp float in_edge = inside.w ? 1 : 0;");
f->codeAppendf( "%s += use_edge ? in_edge * (in_curve - 1) : in_curve;", outputCoverage);
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
index 6efaecf..1292553 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
@@ -136,41 +136,41 @@
// Find the intersections of (bloated) devBounds and devBounds45 in order to come up with an
// octagon that circumscribes the (bloated) path. A vertex is the intersection of two lines:
// one edge from the path's bounding box and one edge from its 45-degree bounding box.
- v->codeAppendf("highp mat2 N = mat2(%s);", proc.getEdgeNormsAttrib().fName);
+ v->codeAppendf("highp float2x2 N = float2x2(%s);", proc.getEdgeNormsAttrib().fName);
// N[0] is the normal for the edge we are intersecting from the regular bounding box, pointing
// out of the octagon.
- v->codeAppendf("highp vec2 refpt = (min(N[0].x, N[0].y) < 0) ? %s.xy : %s.zw;",
+ v->codeAppendf("highp float2 refpt = (min(N[0].x, N[0].y) < 0) ? %s.xy : %s.zw;",
proc.getInstanceAttrib(InstanceAttribs::kDevBounds).fName,
proc.getInstanceAttrib(InstanceAttribs::kDevBounds).fName);
v->codeAppendf("refpt += N[0] * %f;", kAABloatRadius); // bloat for AA.
// N[1] is the normal for the edge we are intersecting from the 45-degree bounding box, pointing
// out of the octagon.
- v->codeAppendf("highp vec2 refpt45 = (N[1].x < 0) ? %s.xy : %s.zw;",
+ v->codeAppendf("highp float2 refpt45 = (N[1].x < 0) ? %s.xy : %s.zw;",
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName,
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName);
- v->codeAppendf("refpt45 *= mat2(.5,.5,-.5,.5);"); // transform back to device space.
+ v->codeAppendf("refpt45 *= float2x2(.5,.5,-.5,.5);"); // transform back to device space.
v->codeAppendf("refpt45 += N[1] * %f;", kAABloatRadius); // bloat for AA.
- v->codeAppend ("highp vec2 K = vec2(dot(N[0], refpt), dot(N[1], refpt45));");
- v->codeAppendf("highp vec2 octocoord = K * inverse(N);");
+ v->codeAppend ("highp float2 K = float2(dot(N[0], refpt), dot(N[1], refpt45));");
+ v->codeAppendf("highp float2 octocoord = K * inverse(N);");
gpArgs->fPositionVar.set(kVec2f_GrSLType, "octocoord");
// Convert to atlas coordinates in order to do our texture lookup.
- v->codeAppendf("highp vec2 atlascoord = octocoord + vec2(%s);",
+ v->codeAppendf("highp float2 atlascoord = octocoord + float2(%s);",
proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).fName);
if (kTopLeft_GrSurfaceOrigin == proc.atlasProxy()->origin()) {
v->codeAppendf("%s = atlascoord * %s;", texcoord.vsOut(), atlasAdjust);
} else {
SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlasProxy()->origin());
- v->codeAppendf("%s = vec2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
+ v->codeAppendf("%s = float2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
texcoord.vsOut(), atlasAdjust, atlasAdjust);
}
// Convert to (local) path cordinates.
- v->codeAppendf("highp vec2 pathcoord = inverse(mat2(%s)) * (octocoord - %s);",
+ v->codeAppendf("highp float2 pathcoord = inverse(float2x2(%s)) * (octocoord - %s);",
proc.getInstanceAttrib(InstanceAttribs::kViewMatrix).fName,
proc.getInstanceAttrib(InstanceAttribs::kViewTranslate).fName);
@@ -185,11 +185,11 @@
f->codeAppend (".a;");
if (SkPath::kWinding_FillType == proc.fillType()) {
- f->codeAppendf("%s = vec4(min(abs(coverage_count), 1));", args.fOutputCoverage);
+ f->codeAppendf("%s = float4(min(abs(coverage_count), 1));", args.fOutputCoverage);
} else {
SkASSERT(SkPath::kEvenOdd_FillType == proc.fillType());
f->codeAppend ("mediump float t = mod(abs(coverage_count), 2);");
- f->codeAppendf("%s = vec4(1 - abs(t - 1));", args.fOutputCoverage);
+ f->codeAppendf("%s = float4(1 - abs(t - 1));", args.fOutputCoverage);
}
}
diff --git a/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp b/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
index 8c58ea2..bc09fea 100644
--- a/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
@@ -16,9 +16,9 @@
const TexelBufferHandle& pointsBuffer,
const char* atlasOffset, const char* rtAdjust,
GrGPArgs* gpArgs) const {
- v->codeAppendf("ivec3 indices = ivec3(%s.y, %s.x, %s.y + 1);",
+ v->codeAppendf("int3 indices = int3(%s.y, %s.x, %s.y + 1);",
proc.instanceAttrib(), proc.instanceAttrib(), proc.instanceAttrib());
- v->codeAppend ("highp vec2 self = ");
+ v->codeAppend ("highp float2 self = ");
v->appendTexelFetch(pointsBuffer, "indices[sk_VertexID]");
v->codeAppendf(".xy + %s;", atlasOffset);
gpArgs->fPositionVar.set(kVec2f_GrSLType, "self");
@@ -27,8 +27,9 @@
void GrCCPRQuadraticProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdjust,
const char* outputWind) const {
// We will define bezierpts in onEmitGeometryShader.
- g->codeAppend ("highp float area_times_2 = determinant(mat2(bezierpts[1] - bezierpts[0], "
- "bezierpts[2] - bezierpts[0]));");
+ g->codeAppend ("highp float area_times_2 = "
+ "determinant(float2x2(bezierpts[1] - bezierpts[0], "
+ "bezierpts[2] - bezierpts[0]));");
// Drop curves that are nearly flat, in favor of the higher quality triangle antialiasing.
g->codeAppendf("if (2 * abs(area_times_2) < length((bezierpts[2] - bezierpts[0]) * %s.zx)) {",
rtAdjust);
@@ -46,21 +47,21 @@
const char* emitVertexFn, const char* wind,
const char* rtAdjust) const {
// Prepend bezierpts at the start of the shader.
- g->codePrependf("highp mat3x2 bezierpts = mat3x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy);");
+ g->codePrependf("highp float3x2 bezierpts = float3x2(sk_in[0].gl_Position.xy, "
+ "sk_in[1].gl_Position.xy, "
+ "sk_in[2].gl_Position.xy);");
g->declareGlobal(fCanonicalMatrix);
- g->codeAppendf("%s = mat3(0.0, 0, 1, "
- "0.5, 0, 1, "
- "1.0, 1, 1) * "
- "inverse(mat3(bezierpts[0], 1, "
- "bezierpts[1], 1, "
- "bezierpts[2], 1));",
+ g->codeAppendf("%s = float3x3(0.0, 0, 1, "
+ "0.5, 0, 1, "
+ "1.0, 1, 1) * "
+ "inverse(float3x3(bezierpts[0], 1, "
+ "bezierpts[1], 1, "
+ "bezierpts[2], 1));",
fCanonicalMatrix.c_str());
g->declareGlobal(fCanonicalDerivatives);
- g->codeAppendf("%s = mat2(%s) * mat2(%s.x, 0, 0, %s.z);",
+ g->codeAppendf("%s = float2x2(%s) * float2x2(%s.x, 0, 0, %s.z);",
fCanonicalDerivatives.c_str(), fCanonicalMatrix.c_str(), rtAdjust, rtAdjust);
this->emitQuadraticGeometry(g, emitVertexFn, wind, rtAdjust);
@@ -69,10 +70,10 @@
void GrCCPRQuadraticProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("%s.xy = (%s * vec3(%s, 1)).xy;",
+ fnBody->appendf("%s.xy = (%s * float3(%s, 1)).xy;",
fCanonicalCoord.gsOut(), fCanonicalMatrix.c_str(), position);
- fnBody->appendf("%s.zw = vec2(2 * %s.x * %s[0].x - %s[0].y, "
- "2 * %s.x * %s[1].x - %s[1].y);",
+ fnBody->appendf("%s.zw = float2(2 * %s.x * %s[0].x - %s[0].y, "
+ "2 * %s.x * %s[1].x - %s[1].y);",
fCanonicalCoord.gsOut(), fCanonicalCoord.gsOut(),
fCanonicalDerivatives.c_str(), fCanonicalDerivatives.c_str(),
fCanonicalCoord.gsOut(), fCanonicalDerivatives.c_str(),
@@ -93,26 +94,26 @@
const char* rtAdjust) const {
// Find the point on the curve whose tangent is halfway between the tangents at the endpionts.
// We defined bezierpts in onEmitGeometryShader.
- g->codeAppend ("highp vec2 n = (normalize(bezierpts[0] - bezierpts[1]) + "
- "normalize(bezierpts[2] - bezierpts[1]));");
+ g->codeAppend ("highp float2 n = (normalize(bezierpts[0] - bezierpts[1]) + "
+ "normalize(bezierpts[2] - bezierpts[1]));");
g->codeAppend ("highp float t = dot(bezierpts[0] - bezierpts[1], n) / "
"dot(bezierpts[2] - 2 * bezierpts[1] + bezierpts[0], n);");
- g->codeAppend ("highp vec2 pt = (1 - t) * (1 - t) * bezierpts[0] + "
- "2 * t * (1 - t) * bezierpts[1] + "
- "t * t * bezierpts[2];");
+ g->codeAppend ("highp float2 pt = (1 - t) * (1 - t) * bezierpts[0] + "
+ "2 * t * (1 - t) * bezierpts[1] + "
+ "t * t * bezierpts[2];");
// Clip the triangle by the tangent line at this halfway point.
- g->codeAppend ("highp mat2 v = mat2(bezierpts[0] - bezierpts[1], "
- "bezierpts[2] - bezierpts[1]);");
- g->codeAppend ("highp vec2 nv = n * v;");
- g->codeAppend ("highp vec2 d = abs(nv[0]) > 0.1 * max(bloat.x, bloat.y) ? "
- "(dot(n, pt - bezierpts[1])) / nv : vec2(0);");
+ g->codeAppend ("highp float2x2 v = float2x2(bezierpts[0] - bezierpts[1], "
+ "bezierpts[2] - bezierpts[1]);");
+ g->codeAppend ("highp float2 nv = n * v;");
+ g->codeAppend ("highp float2 d = abs(nv[0]) > 0.1 * max(bloat.x, bloat.y) ? "
+ "(dot(n, pt - bezierpts[1])) / nv : float2(0);");
// Generate a 4-point hull of the curve from the clipped triangle.
- g->codeAppendf("highp mat4x2 quadratic_hull = mat4x2(bezierpts[0], "
- "bezierpts[1] + d[0] * v[0], "
- "bezierpts[1] + d[1] * v[1], "
- "bezierpts[2]);");
+ g->codeAppendf("highp float4x2 quadratic_hull = float4x2(bezierpts[0], "
+ "bezierpts[1] + d[0] * v[0], "
+ "bezierpts[1] + d[1] * v[1], "
+ "bezierpts[2]);");
int maxVerts = this->emitHullGeometry(g, emitVertexFn, "quadratic_hull", 4, "sk_InvocationID");
@@ -127,9 +128,9 @@
const char* rtAdjust) const {
// We defined bezierpts in onEmitGeometryShader.
g->codeAppendf("int leftidx = %s > 0 ? 2 : 0;", wind);
- g->codeAppendf("highp vec2 left = bezierpts[leftidx];");
- g->codeAppendf("highp vec2 right = bezierpts[2 - leftidx];");
- this->emitEdgeDistanceEquation(g, "left", "right", "highp vec3 edge_distance_equation");
+ g->codeAppendf("highp float2 left = bezierpts[leftidx];");
+ g->codeAppendf("highp float2 right = bezierpts[2 - leftidx];");
+ this->emitEdgeDistanceEquation(g, "left", "right", "highp float3 edge_distance_equation");
g->declareGlobal(fEdgeDistanceDerivatives);
g->codeAppendf("%s = edge_distance_equation.xy * %s.xz;",
@@ -163,16 +164,16 @@
// shared edge, but outside the curve.
int sampleCount = this->defineSoftSampleLocations(f, "samples");
- f->codeAppendf("highp mat2x3 grad_xyd = mat2x3(%s[0],%s.y, %s[1],%s.z);",
+ f->codeAppendf("highp float2x3 grad_xyd = float2x3(%s[0],%s.y, %s[1],%s.z);",
fFragCanonicalDerivatives.fsIn(), fEdgeDistance.fsIn(),
fFragCanonicalDerivatives.fsIn(), fEdgeDistance.fsIn());
- f->codeAppendf("highp vec3 center_xyd = vec3(%s.xy, %s.x);",
+ f->codeAppendf("highp float3 center_xyd = float3(%s.xy, %s.x);",
fCanonicalCoord.fsIn(), fEdgeDistance.fsIn());
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
- f->codeAppend ( "highp vec3 xyd = grad_xyd * samples[i] + center_xyd;");
+ f->codeAppend ( "highp float3 xyd = grad_xyd * samples[i] + center_xyd;");
f->codeAppend ( "lowp float f = xyd.x * xyd.x - xyd.y;"); // f > 0 -> outside curve.
- f->codeAppend ( "bvec2 outside_curve_inside_edge = greaterThan(vec2(f, xyd.z), vec2(0));");
+ f->codeAppend ( "bool2 outside_curve_inside_edge = greaterThan(float2(f, xyd.z), float2(0));");
f->codeAppendf( "%s -= all(outside_curve_inside_edge) ? %f : 0;",
outputCoverage, 1.0 / sampleCount);
f->codeAppendf("}");
diff --git a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
index 23f7b14..77da2cf 100644
--- a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
@@ -16,7 +16,7 @@
const TexelBufferHandle& pointsBuffer,
const char* atlasOffset, const char* rtAdjust,
GrGPArgs* gpArgs) const {
- v->codeAppend ("highp vec2 self = ");
+ v->codeAppend ("highp float2 self = ");
v->appendTexelFetch(pointsBuffer,
SkStringPrintf("%s[sk_VertexID]", proc.instanceAttrib()).c_str());
v->codeAppendf(".xy + %s;", atlasOffset);
@@ -25,16 +25,17 @@
void GrCCPRTriangleProcessor::defineInputVertices(GrGLSLGeometryBuilder* g) const {
// Prepend in_vertices at the start of the shader.
- g->codePrependf("highp mat3x2 in_vertices = mat3x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy);");
+ g->codePrependf("highp float3x2 in_vertices = float3x2(sk_in[0].gl_Position.xy, "
+ "sk_in[1].gl_Position.xy, "
+ "sk_in[2].gl_Position.xy);");
}
void GrCCPRTriangleProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* /*rtAdjust*/,
const char* outputWind) const {
// We will define in_vertices in defineInputVertices.
- g->codeAppendf("%s = sign(determinant(mat2(in_vertices[1] - in_vertices[0], "
- "in_vertices[2] - in_vertices[0])));", outputWind);
+ g->codeAppendf("%s = sign(determinant(float2x2(in_vertices[1] - in_vertices[0], "
+ "in_vertices[2] - in_vertices[0])));",
+ outputWind);
}
void GrCCPRTriangleHullAndEdgeProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
@@ -52,8 +53,8 @@
if (GeometryType::kHulls != fGeometryType) {
g->codeAppend ("int edgeidx0 = sk_InvocationID, "
"edgeidx1 = (edgeidx0 + 1) % 3;");
- g->codeAppendf("highp vec2 edgept0 = in_vertices[%s > 0 ? edgeidx0 : edgeidx1];", wind);
- g->codeAppendf("highp vec2 edgept1 = in_vertices[%s > 0 ? edgeidx1 : edgeidx0];", wind);
+ g->codeAppendf("highp float2 edgept0 = in_vertices[%s > 0 ? edgeidx0 : edgeidx1];", wind);
+ g->codeAppendf("highp float2 edgept1 = in_vertices[%s > 0 ? edgeidx1 : edgeidx0];", wind);
maxOutputVertices += this->emitEdgeGeometry(g, emitVertexFn, "edgept0", "edgept1");
}
@@ -72,16 +73,17 @@
this->INHERITED::onEmitVertexShader(proc, v, pointsBuffer, atlasOffset, rtAdjust, gpArgs);
// Fetch and transform the next point in the triangle.
- v->codeAppend ("highp vec2 next = ");
+ v->codeAppend ("highp float2 next = ");
v->appendTexelFetch(pointsBuffer,
SkStringPrintf("%s[(sk_VertexID+1) %% 3]", proc.instanceAttrib()).c_str());
v->codeAppendf(".xy + %s;", atlasOffset);
// Find the plane that gives distance from the [self -> next] edge, normalized to its AA
// bloat width.
- v->codeAppend ("highp vec2 n = vec2(next.y - self.y, self.x - next.x);");
- v->codeAppendf("highp vec2 d = n * mat2(self + %f * sign(n), "
- "self - %f * sign(n));", kAABloatRadius, kAABloatRadius);
+ v->codeAppend ("highp float2 n = float2(next.y - self.y, self.x - next.x);");
+ v->codeAppendf("highp float2 d = n * float2x2(self + %f * sign(n), "
+ "self - %f * sign(n));",
+ kAABloatRadius, kAABloatRadius);
// Clamp for when n=0. (wind=0 when n=0, so as long as we don't get Inf or NaN we are fine.)
v->codeAppendf("%s.xy = n / max(d[0] - d[1], 1e-30);", fEdgeDistance.vsOut());
@@ -96,11 +98,11 @@
const char* rtAdjust) const {
this->defineInputVertices(g);
- g->codeAppend ("highp vec2 self = in_vertices[sk_InvocationID];");
- g->codeAppendf("%s(self + vec2(-bloat.x, -bloat.y), 1);", emitVertexFn);
- g->codeAppendf("%s(self + vec2(-bloat.x, +bloat.y), 1);", emitVertexFn);
- g->codeAppendf("%s(self + vec2(+bloat.x, -bloat.y), 1);", emitVertexFn);
- g->codeAppendf("%s(self + vec2(+bloat.x, +bloat.y), 1);", emitVertexFn);
+ g->codeAppend ("highp float2 self = in_vertices[sk_InvocationID];");
+ g->codeAppendf("%s(self + float2(-bloat.x, -bloat.y), 1);", emitVertexFn);
+ g->codeAppendf("%s(self + float2(-bloat.x, +bloat.y), 1);", emitVertexFn);
+ g->codeAppendf("%s(self + float2(+bloat.x, -bloat.y), 1);", emitVertexFn);
+ g->codeAppendf("%s(self + float2(+bloat.x, +bloat.y), 1);", emitVertexFn);
g->codeAppend ("EndPrimitive();");
g->configure(GrGLSLGeometryBuilder::InputType::kTriangles,
@@ -116,13 +118,13 @@
fNeighbors.gsOut(), fDevCoord.gsIn());
fnBody->appendf("%s.zw = %s[(sk_InvocationID + 2) %% 3];",
fNeighbors.gsOut(), fDevCoord.gsIn());
- fnBody->appendf("%s = mat3(%s[(sk_InvocationID + 2) %% 3], "
- "%s[sk_InvocationID], "
- "%s[(sk_InvocationID + 1) %% 3]) * %s;",
+ fnBody->appendf("%s = float3x3(%s[(sk_InvocationID + 2) %% 3], "
+ "%s[sk_InvocationID], "
+ "%s[(sk_InvocationID + 1) %% 3]) * %s;",
fEdgeDistances.gsOut(), fEdgeDistance.gsIn(), fEdgeDistance.gsIn(),
fEdgeDistance.gsIn(), wind);
- // Otherwise, fEdgeDistances = mat3(...) * sign(wind * rtAdjust.x * rdAdjust.z).
+ // Otherwise, fEdgeDistances = float3x3(...) * sign(wind * rtAdjust.x * rdAdjust.z).
GR_STATIC_ASSERT(kTopLeft_GrSurfaceOrigin == GrCCPRCoverageProcessor::kAtlasOrigin);
fnBody->appendf("%s = sk_InvocationID;", fCornerIdx.gsOut());
@@ -131,23 +133,23 @@
void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
const char* outputCoverage) const {
// FIXME: Adreno breaks if we don't put the frag coord in an intermediate highp variable.
- f->codeAppendf("highp vec2 fragcoord = sk_FragCoord.xy;");
+ f->codeAppendf("highp float2 fragcoord = sk_FragCoord.xy;");
// Approximate coverage by tracking where 4 horizontal lines enter and leave the triangle.
GrShaderVar samples("samples", kVec4f_GrSLType, GrShaderVar::kNonArray,
kHigh_GrSLPrecision);
f->declareGlobal(samples);
- f->codeAppendf("%s = fragcoord.y + vec4(-0.375, -0.125, 0.125, 0.375);", samples.c_str());
+ f->codeAppendf("%s = fragcoord.y + float4(-0.375, -0.125, 0.125, 0.375);", samples.c_str());
GrShaderVar leftedge("leftedge", kVec4f_GrSLType, GrShaderVar::kNonArray,
kHigh_GrSLPrecision);
f->declareGlobal(leftedge);
- f->codeAppendf("%s = vec4(fragcoord.x - 0.5);", leftedge.c_str());
+ f->codeAppendf("%s = float4(fragcoord.x - 0.5);", leftedge.c_str());
GrShaderVar rightedge("rightedge", kVec4f_GrSLType, GrShaderVar::kNonArray,
kHigh_GrSLPrecision);
f->declareGlobal(rightedge);
- f->codeAppendf("%s = vec4(fragcoord.x + 0.5);", rightedge.c_str());
+ f->codeAppendf("%s = float4(fragcoord.x + 0.5);", rightedge.c_str());
SkString sampleEdgeFn;
GrShaderVar edgeArg("edge_distance", kVec3f_GrSLType, GrShaderVar::kNonArray,
@@ -156,7 +158,7 @@
SkString b;
b.appendf("highp float m = abs(%s.x) < 1e-3 ? 1e18 : -1 / %s.x;",
edgeArg.c_str(), edgeArg.c_str());
- b.appendf("highp vec4 edge = m * (%s.y * samples + %s.z);",
+ b.appendf("highp float4 edge = m * (%s.y * samples + %s.z);",
edgeArg.c_str(), edgeArg.c_str());
b.appendf("if (%s.x <= 1e-3 || (abs(%s.x) < 1e-3 && %s.y > 0)) {",
edgeArg.c_str(), edgeArg.c_str(), edgeArg.c_str());
@@ -168,10 +170,10 @@
}().c_str(), &sampleEdgeFn);
// See if the previous neighbor already handled this pixel.
- f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.zw), vec2(%f)))) {",
+ f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.zw), float2(%f)))) {",
fNeighbors.fsIn(), kAABloatRadius);
// Handle the case where all 3 corners defer to the previous neighbor.
- f->codeAppendf( "if (%s != 0 || !all(lessThan(abs(fragcoord - %s.xy), vec2(%f)))) {",
+ f->codeAppendf( "if (%s != 0 || !all(lessThan(abs(fragcoord - %s.xy), float2(%f)))) {",
fCornerIdx.fsIn(), fNeighbors.fsIn(), kAABloatRadius);
f->codeAppend ( "discard;");
f->codeAppend ( "}");
@@ -179,7 +181,7 @@
// Erase what the hull and two edges wrote at this corner in previous shaders (the two .5's
// for the edges and the -1 for the hull cancel each other out).
- f->codeAppendf("%s = dot(vec3(fragcoord, 1) * mat2x3(%s), vec2(1));",
+ f->codeAppendf("%s = dot(float3(fragcoord, 1) * float2x3(%s), float2(1));",
outputCoverage, fEdgeDistances.fsIn());
// Sample the two edges at this corner.
@@ -187,15 +189,15 @@
f->codeAppendf("%s(%s[1]);", sampleEdgeFn.c_str(), fEdgeDistances.fsIn());
// Handle the opposite edge if the next neighbor will defer to us.
- f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.xy), vec2(%f)))) {",
+ f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.xy), float2(%f)))) {",
fNeighbors.fsIn(), kAABloatRadius);
// Erase the coverage the opposite edge wrote to this corner.
- f->codeAppendf( "%s += dot(%s[2], vec3(fragcoord, 1)) + 0.5;",
+ f->codeAppendf( "%s += dot(%s[2], float3(fragcoord, 1)) + 0.5;",
outputCoverage, fEdgeDistances.fsIn());
// Sample the opposite edge.
f->codeAppendf( "%s(%s[2]);", sampleEdgeFn.c_str(), fEdgeDistances.fsIn());
f->codeAppend ("}");
- f->codeAppendf("highp vec4 widths = max(%s - %s, 0);", rightedge.c_str(), leftedge.c_str());
- f->codeAppendf("%s += dot(widths, vec4(0.25));", outputCoverage);
+ f->codeAppendf("highp float4 widths = max(%s - %s, 0);", rightedge.c_str(), leftedge.c_str());
+ f->codeAppendf("%s += dot(widths, float4(0.25));", outputCoverage);
}
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index d45cd75..50c47e8 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -146,7 +146,7 @@
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str());
- fragBuilder->codeAppendf("%s = vec2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
+ fragBuilder->codeAppendf("%s = float2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
fragBuilder->codeAppendf("%s = sqrt(dot(%s, %s));",
gFM.c_str(), gF.c_str(), gF.c_str());
fragBuilder->codeAppendf("%s = %s.x*%s.x - %s.y*%s.z;",
@@ -175,7 +175,7 @@
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str());
- fragBuilder->codeAppendf("%s = vec2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
+ fragBuilder->codeAppendf("%s = float2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
fragBuilder->codeAppendf("%s = sqrt(dot(%s, %s));",
gFM.c_str(), gF.c_str(), gF.c_str());
fragBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;",
@@ -207,10 +207,10 @@
kHigh_GrSLPrecision,
"Coverage",
&coverageScale);
- fragBuilder->codeAppendf("%s = vec4(%s * %s);",
+ fragBuilder->codeAppendf("%s = float4(%s * %s);",
args.fOutputCoverage, coverageScale, edgeAlpha.c_str());
} else {
- fragBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
}
}
@@ -367,9 +367,9 @@
switch (fEdgeType) {
case kHairlineAA_GrProcessorEdgeType: {
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y,"
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 gF = float2(2.0 * %s.x * duvdx.x - duvdx.y,"
" 2.0 * %s.x * duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
@@ -381,9 +381,9 @@
break;
}
case kFillAA_GrProcessorEdgeType: {
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y,"
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 gF = float2(2.0 * %s.x * duvdx.x - duvdx.y,"
" 2.0 * %s.x * duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
@@ -411,9 +411,9 @@
kDefault_GrSLPrecision,
"Coverage",
&coverageScale);
- fragBuilder->codeAppendf("%s = vec4(%s * edgeAlpha);", args.fOutputCoverage, coverageScale);
+ fragBuilder->codeAppendf("%s = float4(%s * edgeAlpha);", args.fOutputCoverage, coverageScale);
} else {
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
}
@@ -565,7 +565,7 @@
kHigh_GrSLPrecision, "KLM", &devkLMMatrixName);
GrGLSLVertToFrag v(kVec3f_GrSLType);
varyingHandler->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = %s * vec3(%s, 1);",
+ vertBuilder->codeAppendf("%s = %s * float3(%s, 1);",
v.vsOut(), devkLMMatrixName, gpArgs->fPositionVar.c_str());
@@ -574,12 +574,12 @@
varyingHandler->addVarying("GradCoeffs", &gradCoeffs, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("highp float k = %s[0], l = %s[1], m = %s[2];",
v.vsOut(), v.vsOut(), v.vsOut());
- vertBuilder->codeAppendf("highp vec2 gk = vec2(%s[0][0], %s[1][0]), "
- "gl = vec2(%s[0][1], %s[1][1]), "
- "gm = vec2(%s[0][2], %s[1][2]);",
+ vertBuilder->codeAppendf("highp float2 gk = float2(%s[0][0], %s[1][0]), "
+ "gl = float2(%s[0][1], %s[1][1]), "
+ "gm = float2(%s[0][2], %s[1][2]);",
devkLMMatrixName, devkLMMatrixName, devkLMMatrixName,
devkLMMatrixName, devkLMMatrixName, devkLMMatrixName);
- vertBuilder->codeAppendf("%s = vec4(3 * k * gk, -m * gl - l * gm);",
+ vertBuilder->codeAppendf("%s = float4(3 * k * gk, -m * gl - l * gm);",
gradCoeffs.vsOut());
}
@@ -646,7 +646,7 @@
}
- fragBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
}
void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 4095f93..28fcd9e 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -71,26 +71,26 @@
*
* This is GLSL, so the matrix is column-major (transposed from standard matrix notation).
*/
- fragBuilder->codeAppend("mat4 kMitchellCoefficients = mat4("
+ fragBuilder->codeAppend("float4x4 kMitchellCoefficients = float4x4("
" 1.0 / 18.0, 16.0 / 18.0, 1.0 / 18.0, 0.0 / 18.0,"
"-9.0 / 18.0, 0.0 / 18.0, 9.0 / 18.0, 0.0 / 18.0,"
"15.0 / 18.0, -36.0 / 18.0, 27.0 / 18.0, -6.0 / 18.0,"
"-7.0 / 18.0, 21.0 / 18.0, -21.0 / 18.0, 7.0 / 18.0);");
- fragBuilder->codeAppendf("vec2 coord = %s - %s * vec2(0.5);", coords2D.c_str(), imgInc);
+ fragBuilder->codeAppendf("float2 coord = %s - %s * float2(0.5);", coords2D.c_str(), imgInc);
// We unnormalize the coord in order to determine our fractional offset (f) within the texel
// We then snap coord to a texel center and renormalize. The snap prevents cases where the
// 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("vec2 f = fract(coord);");
- fragBuilder->codeAppendf("coord = (coord - f + vec2(0.5)) * %s;", imgInc);
- fragBuilder->codeAppend("vec4 wx = kMitchellCoefficients * vec4(1.0, f.x, f.x * f.x, f.x * f.x * f.x);");
- fragBuilder->codeAppend("vec4 wy = kMitchellCoefficients * vec4(1.0, f.y, f.y * f.y, f.y * f.y * f.y);");
- fragBuilder->codeAppend("vec4 rowColors[4];");
+ fragBuilder->codeAppend("float2 f = fract(coord);");
+ fragBuilder->codeAppendf("coord = (coord - f + float2(0.5)) * %s;", imgInc);
+ fragBuilder->codeAppend("float4 wx = kMitchellCoefficients * float4(1.0, f.x, f.x * f.x, f.x * f.x * f.x);");
+ fragBuilder->codeAppend("float4 wy = kMitchellCoefficients * float4(1.0, f.y, f.y * f.y, f.y * f.y * f.y);");
+ fragBuilder->codeAppend("float4 rowColors[4];");
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {
SkString coord;
- coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1);
+ coord.printf("coord + %s * float2(%d, %d)", imgInc, x - 1, y - 1);
SkString sampleVar;
sampleVar.printf("rowColors[%d]", x);
fDomain.sampleTexture(fragBuilder,
@@ -102,7 +102,7 @@
args.fTexSamplers[0]);
}
fragBuilder->codeAppendf(
- "vec4 s%d = wx.x * rowColors[0] + wx.y * rowColors[1] + wx.z * rowColors[2] + wx.w * rowColors[3];",
+ "float4 s%d = wx.x * rowColors[0] + wx.y * rowColors[1] + wx.z * rowColors[2] + wx.w * rowColors[3];",
y);
}
SkString bicubicColor("(wy.x * s0 + wy.y * s1 + wy.z * s2 + wy.w * s3)");
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 9de3b46..151c529 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -67,7 +67,7 @@
v.fsIn(),
kVec2f_GrSLType);
fragBuilder->codeAppend(";");
- fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
} else {
fragBuilder->codeAppendf("%s = ", args.fOutputCoverage);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], v.fsIn(), kVec2f_GrSLType);
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
index aa39d95..f63422f 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
@@ -28,8 +28,9 @@
"float 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 = "
- "vec4(factor);\n",
- args.fInputColor ? args.fInputColor : "vec4(1)", _outer.mode(), args.fOutputColor);
+ "float4(factor);\n",
+ args.fInputColor ? args.fInputColor : "float4(1)", _outer.mode(),
+ args.fOutputColor);
}
private:
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
index 2c4d5ef..3ff233a 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
@@ -24,5 +24,5 @@
factor = smoothstep(1.0, 0.0, factor);
break;
}
- sk_OutColor = vec4(factor);
+ sk_OutColor = float4(factor);
}
diff --git a/src/gpu/effects/GrCircleEffect.cpp b/src/gpu/effects/GrCircleEffect.cpp
index 638d94d..97bfda4 100644
--- a/src/gpu/effects/GrCircleEffect.cpp
+++ b/src/gpu/effects/GrCircleEffect.cpp
@@ -27,11 +27,11 @@
fCircleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
kDefault_GrSLPrecision, "circle");
fragBuilder->codeAppendf(
- "vec2 prevCenter;\nfloat prevRadius = %f;\nfloat d;\n@if (%d == 2 || %d == 3) {\n "
- " d = (length((%s.xy - sk_FragCoord.xy) * %s.w) - 1.0) * %s.z;\n} else {\n d = "
- "(1.0 - length((%s.xy - sk_FragCoord.xy) * %s.w)) * %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",
+ "float2 prevCenter;\nfloat prevRadius = %f;\nfloat d;\n@if (%d == 2 || %d == 3) "
+ "{\n d = (length((%s.xy - sk_FragCoord.xy) * %s.w) - 1.0) * %s.z;\n} else {\n "
+ " d = (1.0 - length((%s.xy - sk_FragCoord.xy) * %s.w)) * %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",
prevRadius, _outer.edgeType(), _outer.edgeType(),
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar),
@@ -40,7 +40,7 @@
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar), _outer.edgeType(),
_outer.edgeType(), _outer.edgeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrCircleEffect.fp b/src/gpu/effects/GrCircleEffect.fp
index 74973ca..884112e 100644
--- a/src/gpu/effects/GrCircleEffect.fp
+++ b/src/gpu/effects/GrCircleEffect.fp
@@ -6,14 +6,14 @@
*/
layout(key) in int edgeType;
-in vec2 center;
+in float2 center;
in float radius;
-vec2 prevCenter;
+float2 prevCenter;
float prevRadius = -1;
// The circle uniform is (center.x, center.y, radius + 0.5, 1 / (radius + 0.5)) for regular
// fills and (..., radius - 0.5, 1 / (radius - 0.5)) for inverse fills.
-uniform vec4 circle;
+uniform float4 circle;
@optimizationFlags { kCompatibleWithCoverageAsAlpha_OptimizationFlag }
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index d83e82d..8806481 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -25,12 +25,12 @@
if (nullptr == args.fInputColor) {
// could optimize this case, but we aren't for now.
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
// Aggressively round to the nearest exact (N / 255) floating point value. This lets us
// find a round-trip preserving pair on some GPUs that do odd byte to float conversion.
- fragBuilder->codeAppendf("vec4 color = floor(%s * 255.0 + 0.5) / 255.0;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = floor(%s * 255.0 + 0.5) / 255.0;", args.fInputColor);
switch (cce.pmConversion()) {
case GrConfigConversionEffect::kToPremul_PMConversion:
@@ -40,7 +40,7 @@
case GrConfigConversionEffect::kToUnpremul_PMConversion:
fragBuilder->codeAppend(
- "color.rgb = color.a <= 0.0 ? vec3(0,0,0) : floor(color.rgb / color.a * 255.0 + 0.5) / 255.0;");
+ "color.rgb = color.a <= 0.0 ? float3(0,0,0) : floor(color.rgb / color.a * 255.0 + 0.5) / 255.0;");
break;
default:
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 7dba3de..bb61cc1 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -199,7 +199,7 @@
fragBuilder->codeAppend("\t\tfloat alpha = 1.0;\n");
fragBuilder->codeAppend("\t\tfloat edge;\n");
for (int i = 0; i < cpe.getEdgeCount(); ++i) {
- fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(sk_FragCoord.x, sk_FragCoord.y, "
+ fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], float3(sk_FragCoord.x, sk_FragCoord.y, "
"1));\n",
edgeArrayName, i);
if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp
index 14464f7..2d66e1e 100644
--- a/src/gpu/effects/GrDisableColorXP.cpp
+++ b/src/gpu/effects/GrDisableColorXP.cpp
@@ -53,7 +53,7 @@
// you do not give gl_FragColor a value, the gl context is lost and we end up drawing
// nothing. So this fix just sets the gl_FragColor arbitrarily to 0.
GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder;
- fragBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
+ fragBuilder->codeAppendf("%s = float4(0);", args.fOutputPrimary);
}
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index c8dd4eb..0dfb315 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -89,12 +89,12 @@
GrGLSLVertToFrag st(kVec2f_GrSLType);
varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
+ vertBuilder->codeAppendf("%s = float2(%d, %d) * %s;", st.vsOut(),
atlas->width(), atlas->height(),
dfTexEffect.inTextureCoords()->fName);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp vec2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
fragBuilder->codeAppend("\tfloat texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
@@ -141,19 +141,19 @@
// 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("vec2 dist_grad = vec2(dFdx(distance), dFdy(distance));");
+ fragBuilder->codeAppend("float2 dist_grad = float2(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("float dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("vec2 Jdx = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppendf("vec2 Jdy = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppendf("float2 Jdx = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppendf("float2 Jdy = dFdy(%s);", st.fsIn());
+ fragBuilder->codeAppend("float2 grad = float2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -172,7 +172,7 @@
fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -352,7 +352,7 @@
"TextureSize", &textureSizeUniName);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp vec2 uv = %s;", v.fsIn());
+ fragBuilder->codeAppendf("highp float2 uv = %s;", v.fsIn());
fragBuilder->codeAppend("float texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
@@ -362,7 +362,7 @@
fragBuilder->codeAppend("float distance = "
SK_DistanceFieldMultiplier "*(texColor - " SK_DistanceFieldThreshold ");");
- fragBuilder->codeAppendf("highp vec2 st = uv*%s;", textureSizeUniName);
+ fragBuilder->codeAppendf("highp float2 st = uv*%s;", textureSizeUniName);
fragBuilder->codeAppend("float afwidth;");
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
kUniformScale_DistanceFieldEffectMask;
@@ -398,19 +398,19 @@
// 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("vec2 dist_grad = vec2(dFdx(distance), dFdy(distance));");
+ fragBuilder->codeAppend("float2 dist_grad = float2(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("float dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("vec2 Jdx = dFdx(st);");
- fragBuilder->codeAppend("vec2 Jdy = dFdy(st);");
- fragBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppend("float2 Jdx = dFdx(st);");
+ fragBuilder->codeAppend("float2 Jdy = dFdy(st);");
+ fragBuilder->codeAppend("float2 grad = float2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -426,7 +426,7 @@
fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -601,7 +601,7 @@
GrGLSLVertToFrag st(kVec2f_GrSLType);
varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
+ vertBuilder->codeAppendf("%s = float2(%d, %d) * %s;", st.vsOut(),
atlas->width(), atlas->height(),
dfTexEffect.inTextureCoords()->fName);
@@ -609,7 +609,7 @@
// create LCD offset adjusted by inverse of transform
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp vec2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
SkScalar lcdDelta = 1.0f / (3.0f * atlas->width());
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
@@ -624,36 +624,36 @@
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
fragBuilder->codeAppendf("float st_grad_len = abs(dFdy(%s.y));", st.fsIn());
#endif
- fragBuilder->codeAppend("vec2 offset = vec2(st_grad_len*delta, 0.0);");
+ fragBuilder->codeAppend("float2 offset = float2(st_grad_len*delta, 0.0);");
} 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("vec2 st_grad = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppend("vec2 offset = delta*st_grad;");
+ fragBuilder->codeAppendf("float2 st_grad = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppend("float2 offset = delta*st_grad;");
#else
// We use dFdy because of a Mali 400 bug, and rotate -90 degrees to
// get the gradient in the x direction.
- fragBuilder->codeAppendf("vec2 st_grad = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("vec2 offset = delta*vec2(st_grad.y, -st_grad.x);");
+ fragBuilder->codeAppendf("float2 st_grad = dFdy(%s);", st.fsIn());
+ fragBuilder->codeAppend("float2 offset = delta*float2(st_grad.y, -st_grad.x);");
#endif
fragBuilder->codeAppend("float st_grad_len = length(st_grad);");
} else {
- fragBuilder->codeAppendf("vec2 st = %s;\n", st.fsIn());
+ fragBuilder->codeAppendf("float2 st = %s;\n", st.fsIn());
- fragBuilder->codeAppend("vec2 Jdx = dFdx(st);");
- fragBuilder->codeAppend("vec2 Jdy = dFdy(st);");
- fragBuilder->codeAppend("vec2 offset = delta*Jdx;");
+ fragBuilder->codeAppend("float2 Jdx = dFdx(st);");
+ fragBuilder->codeAppend("float2 Jdy = dFdy(st);");
+ fragBuilder->codeAppend("float2 offset = delta*Jdx;");
}
// green is distance to uv center
- fragBuilder->codeAppend("\tvec4 texColor = ");
+ fragBuilder->codeAppend("\tfloat4 texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv", kVec2f_GrSLType);
fragBuilder->codeAppend(";\n");
- fragBuilder->codeAppend("\tvec3 distance;\n");
+ fragBuilder->codeAppend("\tfloat3 distance;\n");
fragBuilder->codeAppend("\tdistance.y = texColor.r;\n");
// red is distance to left offset
- fragBuilder->codeAppend("\tvec2 uv_adjusted = uv - offset;\n");
+ fragBuilder->codeAppend("\tfloat2 uv_adjusted = uv - offset;\n");
fragBuilder->codeAppend("\ttexColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv_adjusted", kVec2f_GrSLType);
fragBuilder->codeAppend(";\n");
@@ -666,7 +666,7 @@
fragBuilder->codeAppend("\tdistance.z = texColor.r;\n");
fragBuilder->codeAppend("\tdistance = "
- "vec3(" SK_DistanceFieldMultiplier ")*(distance - vec3(" SK_DistanceFieldThreshold"));");
+ "float3(" SK_DistanceFieldMultiplier ")*(distance - float3(" SK_DistanceFieldThreshold"));");
// adjust width based on gamma
const char* distanceAdjustUniName = nullptr;
@@ -692,16 +692,16 @@
// 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("vec2 dist_grad = vec2(dFdx(distance.r), dFdy(distance.r));");
+ fragBuilder->codeAppend("float2 dist_grad = float2(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("float dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppend("float2 grad = float2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -713,11 +713,11 @@
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppendf("%s = "
- "vec4(clamp((distance + vec3(afwidth)) / vec3(2.0 * afwidth), 0.0, 1.0), 1.0);",
+ "float4(clamp((distance + float3(afwidth)) / float3(2.0 * afwidth), 0.0, 1.0), 1.0);",
args.fOutputCoverage);
} else {
fragBuilder->codeAppendf(
- "%s = vec4(smoothstep(vec3(-afwidth), vec3(afwidth), distance), 1.0);",
+ "%s = float4(smoothstep(float3(-afwidth), float3(afwidth), distance), 1.0);",
args.fOutputCoverage);
}
}
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 73ab181..38e4c77 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -31,13 +31,13 @@
"int x = int(sk_FragCoord.x);\n int y = int(sk_FragCoord.y);\n uint m = "
"uint((((((y & 1) << 5 | (x & 1) << 4) | (y & 2) << 2) | (x & 2) << 1) | (y & 4) "
">> 1) | (x & 4) >> 2);\n value = float(m) / 64.0 - 0.4921875;\n} else {\n "
- "value = fract(sin(dot(sk_FragCoord.xy, vec2(12.989800000000001, "
- "78.233000000000004))) * 43758.545299999998) - 0.5;\n}\n%s = vec4(clamp(%s.xyz + "
+ "value = fract(sin(dot(sk_FragCoord.xy, float2(12.989800000000001, "
+ "78.233000000000004))) * 43758.545299999998) - 0.5;\n}\n%s = float4(clamp(%s.xyz + "
"value * range, 0.0, %s.w), %s.w);\n",
_outer.rangeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)",
- args.fInputColor ? args.fInputColor : "vec4(1)",
- args.fInputColor ? args.fInputColor : "vec4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)",
+ args.fInputColor ? args.fInputColor : "float4(1)",
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrDitherEffect.fp b/src/gpu/effects/GrDitherEffect.fp
index 937efae..f983702 100644
--- a/src/gpu/effects/GrDitherEffect.fp
+++ b/src/gpu/effects/GrDitherEffect.fp
@@ -61,11 +61,11 @@
// the assumption that sin(<big number>) oscillates with high frequency
// and sampling it will generate "randomness". Since we're using this
// for rendering and not cryptography it should be OK.
- value = fract(sin(dot(sk_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453) - .5;
+ value = fract(sin(dot(sk_FragCoord.xy, float2(12.9898, 78.233))) * 43758.5453) - .5;
}
// For each color channel, add the random offset to the channel value and then clamp
// between 0 and alpha to keep the color premultiplied.
- sk_OutColor = vec4(clamp(sk_InColor.rgb + value * range, 0, sk_InColor.a), sk_InColor.a);
+ sk_OutColor = float4(clamp(sk_InColor.rgb + value * range, 0, sk_InColor.a), sk_InColor.a);
}
@test(testData) {
diff --git a/src/gpu/effects/GrEllipseEffect.cpp b/src/gpu/effects/GrEllipseEffect.cpp
index 020c34e..ebc3bf7 100644
--- a/src/gpu/effects/GrEllipseEffect.cpp
+++ b/src/gpu/effects/GrEllipseEffect.cpp
@@ -23,7 +23,7 @@
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrEllipseEffect& _outer = args.fFp.cast<GrEllipseEffect>();
(void)_outer;
- prevRadii = vec2(-1.0);
+ prevRadii = float2(-1.0);
useScale = sk_Caps.floatPrecisionVaries;
fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
kHigh_GrSLPrecision, "ellipse");
@@ -32,23 +32,26 @@
kDefault_GrSLPrecision, "scale");
}
fragBuilder->codeAppendf(
- "vec2 prevCenter;\nvec2 prevRadii = vec2(%f, %f);\nbool useScale = %s;\nvec2 d = "
- "sk_FragCoord.xy - %s.xy;\n@if (useScale) {\n d *= %s.y;\n}\nvec2 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}\nfloat "
- "alpha;\n@switch (%d) {\n case 0:\n alpha = approx_dist > 0.0 ? 0.0 : "
- "1.0;\n break;\n case 1:\n alpha = clamp(0.5 - 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 + approx_dist, 0.0, "
- "1.0);\n break;\n default:\n discard;\n}\n%s = %s * alpha;\n",
+ "float2 prevCenter;\nfloat2 prevRadii = float2(%f, %f);\nbool useScale = "
+ "%s;\nfloat2 d = sk_FragCoord.xy - %s.xy;\n@if (useScale) {\n d *= "
+ "%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}\nfloat alpha;\n@switch (%d) {\n case 0:\n alpha = approx_dist "
+ "> 0.0 ? 0.0 : 1.0;\n break;\n case 1:\n alpha = clamp(0.5 - "
+ "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 + "
+ "approx_dist, 0.0, 1.0);\n break;\n default:\n discard;\n}\n%s = "
+ "%s * alpha;\n",
prevRadii.fX, prevRadii.fY, (useScale ? "true" : "false"),
args.fUniformHandler->getUniformCStr(fEllipseVar),
- fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "vec2(0.0)",
+ fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar)
+ : "float2(0.0)",
args.fUniformHandler->getUniformCStr(fEllipseVar),
- fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "vec2(0.0)",
+ fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar)
+ : "float2(0.0)",
_outer.edgeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrEllipseEffect.fp b/src/gpu/effects/GrEllipseEffect.fp
index 7bf3220..85c4c96 100644
--- a/src/gpu/effects/GrEllipseEffect.fp
+++ b/src/gpu/effects/GrEllipseEffect.fp
@@ -6,17 +6,17 @@
*/
layout(key) in int edgeType;
-in vec2 center;
-in vec2 radii;
+in float2 center;
+in float2 radii;
-vec2 prevCenter;
-vec2 prevRadii = vec2(-1);
+float2 prevCenter;
+float2 prevRadii = float2(-1);
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
// The last two terms can underflow on mediump, so we use highp.
-uniform highp vec4 ellipse;
+uniform highp float4 ellipse;
bool useScale = sk_Caps.floatPrecisionVaries;
-layout(when=useScale) uniform vec2 scale;
+layout(when=useScale) uniform float2 scale;
@optimizationFlags { kCompatibleWithCoverageAsAlpha_OptimizationFlag }
@@ -50,7 +50,7 @@
void main() {
// d is the offset to the ellipse center
- vec2 d = sk_FragCoord.xy - ellipse.xy;
+ float2 d = sk_FragCoord.xy - ellipse.xy;
// If we're on a device with a "real" mediump then we'll do the distance computation in a space
// that is normalized by the larger radius. The scale uniform will be scale, 1/scale. The
// inverse squared radii uniform values are already in this normalized space. The center is
@@ -58,7 +58,7 @@
@if (useScale) {
d *= scale.y;
}
- vec2 Z = d * ellipse.zw;
+ float2 Z = d * ellipse.zw;
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
float implicit = dot(Z, d) - 1;
// grad_dot is the squared length of the gradient of the implicit.
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index ebe86dd..eb6f49f 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -59,13 +59,13 @@
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(0, 0, 0, 0);", args.fOutputColor);
const GrShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
- fragBuilder->codeAppendf("vec2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
- fragBuilder->codeAppend("vec2 coordSampled = vec2(0, 0);");
+ fragBuilder->codeAppendf("float2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
+ fragBuilder->codeAppend("float2 coordSampled = float2(0, 0);");
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
const char* kVecSuffix[4] = {".x", ".y", ".z", ".w"};
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 46dc2d8..9d8e793 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -70,9 +70,9 @@
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);");
- fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
- fragBuilder->codeAppend("vec4 c;");
+ fragBuilder->codeAppend("float4 sum = float4(0, 0, 0, 0);");
+ fragBuilder->codeAppendf("float2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
+ fragBuilder->codeAppend("float4 c;");
const char* kVecSuffix[4] = { ".x", ".y", ".z", ".w" };
for (int y = 0; y < kHeight; y++) {
@@ -83,7 +83,7 @@
fragBuilder->codeAppendf("float k = %s[%d]%s;", kernel, offset / 4,
kVecSuffix[offset & 0x3]);
SkString coord;
- coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc);
+ coord.printf("coord + float2(%d, %d) * %s", x, y, imgInc);
fDomain.sampleTexture(fragBuilder,
uniformHandler,
args.fShaderCaps,
diff --git a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
index d26377b..6ae770b 100644
--- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
+++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
@@ -71,13 +71,13 @@
}
if (nullptr == args.fInputColor) {
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
- fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
// 1: Un-premultiply the input color (if necessary)
fragBuilder->codeAppendf("float nonZeroAlpha = max(color.a, 0.00001);");
- fragBuilder->codeAppendf("color = vec4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
+ fragBuilder->codeAppendf("color = float4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
// 2: Apply src transfer function (to get to linear RGB)
if (srcCoeffsName) {
@@ -89,7 +89,7 @@
// 3: Apply gamut matrix
if (gamutXformName) {
fragBuilder->codeAppendf(
- "color.rgb = (%s * vec4(color.rgb, 1.0)).rgb;", gamutXformName);
+ "color.rgb = (%s * float4(color.rgb, 1.0)).rgb;", gamutXformName);
}
// 4: Apply dst transfer fn
@@ -100,7 +100,7 @@
}
// 5: Premultiply again
- fragBuilder->codeAppendf("%s = vec4(color.rgb * color.a, color.a);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(color.rgb * color.a, color.a);", args.fOutputColor);
}
static inline void GenKey(const GrProcessor& processor, const GrShaderCaps&,
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index ffb91cc..c571b83 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -440,7 +440,7 @@
SkASSERT(inColor);
switch (outputType) {
case BlendFormula::kNone_OutputType:
- fragBuilder->codeAppendf("%s = vec4(0.0);", output);
+ fragBuilder->codeAppendf("%s = float4(0.0);", output);
break;
case BlendFormula::kCoverage_OutputType:
// We can have a coverage formula while not reading coverage if there are mixed samples.
@@ -456,7 +456,7 @@
fragBuilder->codeAppendf("%s = (1.0 - %s.a) * %s;", output, inColor, inCoverage);
break;
case BlendFormula::kISCModulate_OutputType:
- fragBuilder->codeAppendf("%s = (vec4(1.0) - %s) * %s;", output, inColor, inCoverage);
+ fragBuilder->codeAppendf("%s = (float4(1.0) - %s) * %s;", output, inColor, inCoverage);
break;
default:
SkFAIL("Unsupported output type.");
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index edf8eb6..8dde914 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -197,13 +197,13 @@
// alphas together.
switch (crre.getCircularCornerFlags()) {
case CircularRRectEffect::kAll_CornerFlags:
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(max(dxy0, dxy1), 0.0);");
+ 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("float alpha = %s;", clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTopLeft_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(%s.xy - sk_FragCoord.xy, 0.0);",
+ fragBuilder->codeAppendf("float2 dxy = max(%s.xy - sk_FragCoord.xy, 0.0);",
rectName);
fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
rectName);
@@ -213,7 +213,7 @@
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTopRight_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(vec2(sk_FragCoord.x - %s.z, "
+ fragBuilder->codeAppendf("float2 dxy = max(float2(sk_FragCoord.x - %s.z, "
"%s.y - sk_FragCoord.y), 0.0);",
rectName, rectName);
fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
@@ -224,7 +224,7 @@
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomRight_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(sk_FragCoord.xy - %s.zw, 0.0);",
+ fragBuilder->codeAppendf("float2 dxy = max(sk_FragCoord.xy - %s.zw, 0.0);",
rectName);
fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
rectName);
@@ -234,7 +234,7 @@
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomLeft_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(vec2(%s.x - sk_FragCoord.x, sk_FragCoord.y - "
+ fragBuilder->codeAppendf("float2 dxy = max(float2(%s.x - sk_FragCoord.x, sk_FragCoord.y - "
"%s.w), 0.0);",
rectName, rectName);
fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
@@ -245,18 +245,18 @@
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kLeft_CornerFlags:
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
fragBuilder->codeAppendf("float dy1 = sk_FragCoord.y - %s.w;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(dxy0.x, max(dxy0.y, dy1)), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(float2(dxy0.x, max(dxy0.y, dy1)), 0.0);");
fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTop_CornerFlags:
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
fragBuilder->codeAppendf("float dx1 = sk_FragCoord.x - %s.z;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(max(dxy0.x, dx1), dxy0.y), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(float2(max(dxy0.x, dx1), dxy0.y), 0.0);");
fragBuilder->codeAppendf("float bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = bottomAlpha * %s;",
@@ -264,8 +264,8 @@
break;
case CircularRRectEffect::kRight_CornerFlags:
fragBuilder->codeAppendf("float dy0 = %s.y - sk_FragCoord.y;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(dxy1.x, max(dy0, dxy1.y)), 0.0);");
+ 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("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = leftAlpha * %s;",
@@ -273,8 +273,8 @@
break;
case CircularRRectEffect::kBottom_CornerFlags:
fragBuilder->codeAppendf("float dx0 = %s.x - sk_FragCoord.x;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(max(dx0, dxy1.x), dxy1.y), 0.0);");
+ 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("float topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = topAlpha * %s;",
@@ -532,8 +532,8 @@
// The code below is a simplified version of the above that performs maxs on the vector
// components before computing distances and alpha values so that only one distance computation
// need be computed to determine the min alpha.
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
// If we're on a device with a "real" mediump then we'll do the distance computation in a space
// that is normalized by the largest radius. The scale uniform will be scale, 1/scale. The
@@ -554,12 +554,12 @@
kDefault_GrSLPrecision,
"invRadiiXY",
&invRadiiXYSqdName);
- fragBuilder->codeAppend("vec2 dxy = max(max(dxy0, dxy1), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(max(dxy0, dxy1), 0.0);");
if (scaleName) {
fragBuilder->codeAppendf("dxy *= %s.y;", scaleName);
}
// Z is the x/y offsets divided by squared radii.
- fragBuilder->codeAppendf("vec2 Z = dxy * %s.xy;", invRadiiXYSqdName);
+ fragBuilder->codeAppendf("float2 Z = dxy * %s.xy;", invRadiiXYSqdName);
break;
}
case SkRRect::kNinePatch_Type: {
@@ -573,11 +573,11 @@
fragBuilder->codeAppendf("dxy0 *= %s.y;", scaleName);
fragBuilder->codeAppendf("dxy1 *= %s.y;", scaleName);
}
- fragBuilder->codeAppend("vec2 dxy = max(max(dxy0, dxy1), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(max(dxy0, dxy1), 0.0);");
// Z is the x/y offsets divided by squared radii. We only care about the (at most) one
// corner where both the x and y offsets are positive, hence the maxes. (The inverse
// squared radii will always be positive.)
- fragBuilder->codeAppendf("vec2 Z = max(max(dxy0 * %s.xy, dxy1 * %s.zw), 0.0);",
+ fragBuilder->codeAppendf("float2 Z = max(max(dxy0 * %s.xy, dxy1 * %s.zw), 0.0);",
invRadiiLTRBSqdName, invRadiiLTRBSqdName);
break;
diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp
index ed924b3..1cffb9e 100644
--- a/src/gpu/effects/GrSRGBEffect.cpp
+++ b/src/gpu/effects/GrSRGBEffect.cpp
@@ -44,20 +44,20 @@
}
if (nullptr == args.fInputColor) {
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
- fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
if (srgbe.alpha() == GrSRGBEffect::Alpha::kPremul) {
fragBuilder->codeAppendf("float nonZeroAlpha = max(color.a, 0.00001);");
- fragBuilder->codeAppendf("color = vec4(color.rgb / nonZeroAlpha, color.a);");
+ fragBuilder->codeAppendf("color = float4(color.rgb / nonZeroAlpha, color.a);");
}
- fragBuilder->codeAppendf("color = vec4(%s(color.r), %s(color.g), %s(color.b), color.a);",
+ fragBuilder->codeAppendf("color = float4(%s(color.r), %s(color.g), %s(color.b), color.a);",
srgbFuncName.c_str(),
srgbFuncName.c_str(),
srgbFuncName.c_str());
if (srgbe.alpha() == GrSRGBEffect::Alpha::kPremul) {
- fragBuilder->codeAppendf("color = vec4(color.rgb, 1) * color.a;");
+ fragBuilder->codeAppendf("color = float4(color.rgb, 1) * color.a;");
}
fragBuilder->codeAppendf("%s = color;", args.fOutputColor);
}
diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp
index 6ab993a..046240c 100644
--- a/src/gpu/effects/GrShadowGeoProc.cpp
+++ b/src/gpu/effects/GrShadowGeoProc.cpp
@@ -26,7 +26,7 @@
// emit attributes
varyingHandler->emitAttributes(rsgp);
- fragBuilder->codeAppend("vec4 shadowParams;");
+ fragBuilder->codeAppend("float4 shadowParams;");
varyingHandler->addPassThroughAttribute(rsgp.inShadowParams(), "shadowParams");
// setup pass through color
@@ -48,7 +48,7 @@
fragBuilder->codeAppend("float factor = 1.0 - clamp(distance, 0.0, shadowParams.w);");
fragBuilder->codeAppend("factor = exp(-factor * factor * 4.0) - 0.018;");
- fragBuilder->codeAppendf("%s = vec4(factor);",
+ fragBuilder->codeAppendf("%s = float4(factor);",
args.fOutputCoverage);
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index cab078b..bbac5b5 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -27,15 +27,15 @@
SkSL::String sk_TransformedCoords2D_0 =
fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
- "vec4 _tmpVar1;%s = %s * %stexture(%s, %s).%s%s;\n", args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)",
+ "float4 _tmpVar1;%s = %s * %stexture(%s, %s).%s%s;\n", args.fOutputColor,
+ args.fInputColor ? args.fInputColor : "float4(1)",
fColorSpaceHelper.isValid() ? "(_tmpVar1 = " : "",
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
sk_TransformedCoords2D_0.c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
fColorSpaceHelper.isValid()
- ? SkStringPrintf(", vec4(clamp((%s * vec4(_tmpVar1.rgb, 1.0)).rgb, 0.0, "
- "_tmpVar1.a), _tmpVar1.a))",
+ ? SkStringPrintf(", float4(clamp((%s * float4(_tmpVar1.rgb, 1.0)).rgb, "
+ "0.0, _tmpVar1.a), _tmpVar1.a))",
args.fUniformHandler->getUniformCStr(
fColorSpaceHelper.gamutXformUniform()))
.c_str()
diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp
index 2094444..6f7c818 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ b/src/gpu/effects/GrSimpleTextureEffect.fp
@@ -7,7 +7,7 @@
in uniform sampler2D image;
in uniform colorSpaceXform colorXform;
-in mat4 matrix;
+in float4x4 matrix;
@constructorParams {
GrSamplerParams samplerParams
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index fa56058..ee7985c 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -115,8 +115,8 @@
// may return undefined results". This appears to be an issue with
// the 'any' call since even the simple "result=black; if (any())
// result=white;" code fails to compile.
- builder->codeAppend("vec4 outside = vec4(0.0, 0.0, 0.0, 0.0);");
- builder->codeAppend("vec4 inside = ");
+ builder->codeAppend("float4 outside = float4(0.0, 0.0, 0.0, 0.0);");
+ builder->codeAppend("float4 inside = ");
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
kVec2f_GrSLType, colorXformHelper);
builder->codeAppend(";");
@@ -131,12 +131,12 @@
builder->codeAppend("float blend = step(1.0, max(x, y));");
builder->codeAppendf("%s = mix(inside, outside, blend);", outColor);
} else {
- builder->codeAppend("bvec4 outside;\n");
+ builder->codeAppend("bool4 outside;\n");
builder->codeAppendf("outside.xy = lessThan(%s, %s.xy);", inCoords.c_str(),
domain);
builder->codeAppendf("outside.zw = greaterThan(%s, %s.zw);", inCoords.c_str(),
domain);
- builder->codeAppendf("%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0.0) : ",
+ builder->codeAppendf("%s = any(outside) ? float4(0.0, 0.0, 0.0, 0.0) : ",
outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
kVec2f_GrSLType, colorXformHelper);
@@ -385,7 +385,7 @@
kDefault_GrSLPrecision,
"scaleAndTranslate",
&scaleAndTranslateName);
- args.fFragBuilder->codeAppendf("vec2 coords = sk_FragCoord.xy * %s.xy + %s.zw;",
+ args.fFragBuilder->codeAppendf("float2 coords = sk_FragCoord.xy * %s.xy + %s.zw;",
scaleAndTranslateName, scaleAndTranslateName);
fGLDomain.sampleTexture(args.fFragBuilder,
args.fUniformHandler,
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 96bbc23..10c2e56 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -23,7 +23,7 @@
/**
* Limits a texture's lookup coordinates to a domain. Samples outside the domain are either clamped
- * the edge of the domain or result in a vec4 of zeros (decal mode). The domain is clipped to
+ * the edge of the domain or result in a float4 of zeros (decal mode). The domain is clipped to
* normalized texture coords ([0,1]x[0,1] square). Bilinear filtering can cause texels outside the
* domain to affect the read value unless the caller considers this when calculating the domain.
*/
@@ -98,8 +98,8 @@
* Call this from GrGLSLFragmentProcessor::emitCode() to sample the texture W.R.T. the
* domain and mode.
*
- * @param outcolor name of vec4 variable to hold the sampled color.
- * @param inCoords name of vec2 variable containing the coords to be used with the domain.
+ * @param outcolor name of float4 variable to hold the sampled color.
+ * @param inCoords name of float2 variable containing the coords to be used with the domain.
* It is assumed that this is a variable and not an expression.
* @param inModulateColor if non-nullptr the sampled color will be modulated with this
* expression before being written to outColor.
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 80de68f..88a09e6 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -220,7 +220,7 @@
const char* inputColor = nullptr;
if (args.fInputColor) {
inputColor = "inputColor";
- fragBuilder->codeAppendf("vec4 inputColor = vec4(%s.rgb, 1.0);", args.fInputColor);
+ fragBuilder->codeAppendf("float4 inputColor = float4(%s.rgb, 1.0);", args.fInputColor);
}
// declare outputColor and emit the code for each of the two children
@@ -454,7 +454,7 @@
const char* inputColor = args.fInputColor;
// We don't try to optimize for this case at all
if (!inputColor) {
- fragBuilder->codeAppendf("const vec4 ones = vec4(1);");
+ fragBuilder->codeAppendf("const float4 ones = float4(1);");
inputColor = "ones";
}
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 0d7f218..93f268a 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -112,7 +112,7 @@
fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
kMat44f_GrSLType, kDefault_GrSLPrecision,
"ColorSpaceMatrix", &colorSpaceMatrix);
- fragBuilder->codeAppendf("%s = vec4(", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(", args.fOutputColor);
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
args.fTransformedCoords[0].c_str(),
args.fTransformedCoords[0].getType());
@@ -279,7 +279,7 @@
kFragment_GrShaderFlag,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"RGBToYUV", 3, &uniName);
- fragBuilder->codeAppendf("%s = vec4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
+ fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
"dot(rgbColor.rgb, %s[1].rgb) + %s[1].a,"
"dot(rgbColor.rgb, %s[2].rgb) + %s[2].a,"
"rgbColor.a);",
@@ -291,7 +291,7 @@
kFragment_GrShaderFlag,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"RGBToUV", 2, &uniName);
- fragBuilder->codeAppendf("%s = vec4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
+ fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
"dot(rgbColor.rgb, %s[1].rgb) + %s[1].a,"
"0.0,"
"rgbColor.a);",
@@ -304,7 +304,7 @@
kFragment_GrShaderFlag,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"RGBToYUorV", &uniName);
- fragBuilder->codeAppendf("%s = vec4(dot(rgbColor.rgb, %s.rgb) + %s.a);\n",
+ fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s.rgb) + %s.a);\n",
args.fOutputColor, uniName, uniName);
break;
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 3c35def..6247850 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3512,7 +3512,7 @@
"void main() {"
" v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw;"
" gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
- " gl_Position.zw = vec2(0, 1);"
+ " gl_Position.zw = float2(0, 1);"
"}"
);
@@ -3628,27 +3628,27 @@
vshaderTxt.append(
"// Mipmap Program VS\n"
"void main() {"
- " gl_Position.xy = a_vertex * vec2(2, 2) - vec2(1, 1);"
- " gl_Position.zw = vec2(0, 1);"
+ " gl_Position.xy = a_vertex * float2(2, 2) - float2(1, 1);"
+ " gl_Position.zw = float2(0, 1);"
);
// Insert texture coordinate computation:
if (oddWidth && oddHeight) {
vshaderTxt.append(
" v_texCoord0 = a_vertex.xy * u_texCoordXform.yw;"
- " v_texCoord1 = a_vertex.xy * u_texCoordXform.yw + vec2(u_texCoordXform.x, 0);"
- " v_texCoord2 = a_vertex.xy * u_texCoordXform.yw + vec2(0, u_texCoordXform.z);"
+ " v_texCoord1 = a_vertex.xy * u_texCoordXform.yw + float2(u_texCoordXform.x, 0);"
+ " v_texCoord2 = a_vertex.xy * u_texCoordXform.yw + float2(0, u_texCoordXform.z);"
" v_texCoord3 = a_vertex.xy * u_texCoordXform.yw + u_texCoordXform.xz;"
);
} else if (oddWidth) {
vshaderTxt.append(
- " v_texCoord0 = a_vertex.xy * vec2(u_texCoordXform.y, 1);"
- " v_texCoord1 = a_vertex.xy * vec2(u_texCoordXform.y, 1) + vec2(u_texCoordXform.x, 0);"
+ " v_texCoord0 = a_vertex.xy * float2(u_texCoordXform.y, 1);"
+ " v_texCoord1 = a_vertex.xy * float2(u_texCoordXform.y, 1) + float2(u_texCoordXform.x, 0);"
);
} else if (oddHeight) {
vshaderTxt.append(
- " v_texCoord0 = a_vertex.xy * vec2(1, u_texCoordXform.w);"
- " v_texCoord1 = a_vertex.xy * vec2(1, u_texCoordXform.w) + vec2(0, u_texCoordXform.z);"
+ " v_texCoord0 = a_vertex.xy * float2(1, u_texCoordXform.w);"
+ " v_texCoord1 = a_vertex.xy * float2(1, u_texCoordXform.w) + float2(0, u_texCoordXform.z);"
);
} else {
vshaderTxt.append(
@@ -3760,7 +3760,7 @@
vshaderTxt.append(
"// Stencil Clip Clear Program VS\n"
"void main() {"
- " gl_Position = vec4(a_vertex.x, a_vertex.y, 0, 1);"
+ " gl_Position = float4(a_vertex.x, a_vertex.y, 0, 1);"
"}");
SkString fshaderTxt(version);
@@ -3770,7 +3770,7 @@
fshaderTxt.appendf(
"// Stencil Clip Clear Program FS\n"
"void main() {"
- " sk_FragColor = vec4(0);"
+ " sk_FragColor = float4(0);"
"}");
const char* str;
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index d6bde9a..ec32c35 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -68,8 +68,8 @@
}
/**
- * Gets a vec4 that adjusts the position from Skia device coords to GL's normalized device
- * coords. Assuming the transformed position, pos, is a homogeneous vec3, the vec, v, is
+ * Gets a float4 that adjusts the position from Skia device coords to GL's normalized device
+ * coords. Assuming the transformed position, pos, is a homogeneous float3, the vec, v, is
* applied as such:
* pos.x = dot(v.xy, pos.xz)
* pos.y = dot(v.zw, pos.yz)
diff --git a/src/gpu/glsl/GrGLSLBlend.cpp b/src/gpu/glsl/GrGLSLBlend.cpp
index bee5a83..b37169b 100644
--- a/src/gpu/glsl/GrGLSLBlend.cpp
+++ b/src/gpu/glsl/GrGLSLBlend.cpp
@@ -120,14 +120,14 @@
// Adds a function that takes two colors and an alpha as input. It produces a color with the
// hue and saturation of the first color, the luminosity of the second color, and the input
// alpha. It has this signature:
-// vec3 set_luminance(vec3 hueSatColor, float alpha, vec3 lumColor).
+// float3 set_luminance(float3 hueSatColor, float alpha, float3 lumColor).
static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumFunction) {
// Emit a helper that gets the luminance of a color.
SkString getFunction;
GrShaderVar getLumArgs[] = {
GrShaderVar("color", kVec3f_GrSLType),
};
- SkString getLumBody("return dot(vec3(0.3, 0.59, 0.11), color);");
+ SkString getLumBody("return dot(float3(0.3, 0.59, 0.11), color);");
fsBuilder->emitFunction(kFloat_GrSLType,
"luminance",
SK_ARRAY_COUNT(getLumArgs), getLumArgs,
@@ -142,17 +142,17 @@
};
SkString setLumBody;
setLumBody.printf("float diff = %s(lumColor - hueSat);", getFunction.c_str());
- setLumBody.append("vec3 outColor = hueSat + diff;");
+ setLumBody.append("float3 outColor = hueSat + diff;");
setLumBody.appendf("float outLum = %s(outColor);", getFunction.c_str());
setLumBody.append("float minComp = min(min(outColor.r, outColor.g), outColor.b);"
"float maxComp = max(max(outColor.r, outColor.g), outColor.b);"
"if (minComp < 0.0 && outLum != minComp) {"
- "outColor = outLum + ((outColor - vec3(outLum, outLum, outLum)) * outLum) /"
+ "outColor = outLum + ((outColor - float3(outLum, outLum, outLum)) * outLum) /"
"(outLum - minComp);"
"}"
"if (maxComp > alpha && maxComp != outLum) {"
"outColor = outLum +"
- "((outColor - vec3(outLum, outLum, outLum)) * (alpha - outLum)) /"
+ "((outColor - float3(outLum, outLum, outLum)) * (alpha - outLum)) /"
"(maxComp - outLum);"
"}"
"return outColor;");
@@ -165,7 +165,7 @@
// Adds a function that creates a color with the hue and luminosity of one input color and
// the saturation of another color. It will have this signature:
-// float set_saturation(vec3 hueLumColor, vec3 satColor)
+// float set_saturation(float3 hueLumColor, float3 satColor)
static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
// Emit a helper that gets the saturation of a color
SkString getFunction;
@@ -181,7 +181,7 @@
// Emit a helper that sets the saturation given sorted input channels. This used
// to use inout params for min, mid, and max components but that seems to cause
- // problems on PowerVR drivers. So instead it returns a vec3 where r, g ,b are the
+ // problems on PowerVR drivers. So instead it returns a float3 where r, g ,b are the
// adjusted min, mid, and max inputs, respectively.
SkString helperFunction;
GrShaderVar helperArgs[] = {
@@ -191,13 +191,13 @@
GrShaderVar("sat", kFloat_GrSLType),
};
static const char kHelperBody[] = "if (minComp < maxComp) {"
- "vec3 result;"
+ "float3 result;"
"result.r = 0.0;"
"result.g = sat * (midComp - minComp) / (maxComp - minComp);"
"result.b = sat;"
"return result;"
"} else {"
- "return vec3(0, 0, 0);"
+ "return float3(0, 0, 0);"
"}";
fsBuilder->emitFunction(kVec3f_GrSLType,
"set_saturation_helper",
@@ -311,7 +311,7 @@
SkString setSat, setLum;
add_sat_function(fsBuilder, &setSat);
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 dstSrcAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 dstSrcAlpha = %s * %s.a;",
dstColor, srcColor);
fsBuilder->codeAppendf("%s.rgb = %s(%s(%s.rgb * %s.a, dstSrcAlpha.rgb),"
"dstSrcAlpha.a, dstSrcAlpha.rgb);",
@@ -326,7 +326,7 @@
SkString setSat, setLum;
add_sat_function(fsBuilder, &setSat);
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 dstSrcAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 dstSrcAlpha = %s * %s.a;",
dstColor, srcColor);
fsBuilder->codeAppendf("%s.rgb = %s(%s(dstSrcAlpha.rgb, %s.rgb * %s.a),"
"dstSrcAlpha.a, dstSrcAlpha.rgb);",
@@ -340,7 +340,7 @@
// SetLum(S * Da, Sa* Da, D * Sa) + (1 - Sa) * D + (1 - Da) * S
SkString setLum;
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 srcDstAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 srcDstAlpha = %s * %s.a;",
srcColor, dstColor);
fsBuilder->codeAppendf("%s.rgb = %s(srcDstAlpha.rgb, srcDstAlpha.a, %s.rgb * %s.a);",
outputColor, setLum.c_str(), dstColor, srcColor);
@@ -352,7 +352,7 @@
// SetLum(D * Sa, Sa* Da, S * Da) + (1 - Sa) * D + (1 - Da) * S
SkString setLum;
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 srcDstAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 srcDstAlpha = %s * %s.a;",
srcColor, dstColor);
fsBuilder->codeAppendf("%s.rgb = %s(%s.rgb * %s.a, srcDstAlpha.a, srcDstAlpha.rgb);",
outputColor, setLum.c_str(), dstColor, srcColor);
@@ -387,13 +387,13 @@
fsBuilder->codeAppendf(" * %s", srcColorName);
break;
case SkBlendModeCoeff::kISC:
- fsBuilder->codeAppendf(" * (vec4(1.0) - %s)", srcColorName);
+ fsBuilder->codeAppendf(" * (float4(1.0) - %s)", srcColorName);
break;
case SkBlendModeCoeff::kDC:
fsBuilder->codeAppendf(" * %s", dstColorName);
break;
case SkBlendModeCoeff::kIDC:
- fsBuilder->codeAppendf(" * (vec4(1.0) - %s)", dstColorName);
+ fsBuilder->codeAppendf(" * (float4(1.0) - %s)", dstColorName);
break;
case SkBlendModeCoeff::kSA:
fsBuilder->codeAppendf(" * %s.a", srcColorName);
@@ -434,7 +434,7 @@
false);
// append dst blend
if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) {
- fsBuilder->codeAppend("vec4(0, 0, 0, 0)");
+ fsBuilder->codeAppend("float4(0, 0, 0, 0)");
}
if (clamp) {
fsBuilder->codeAppend(", 0, 1);");
@@ -486,7 +486,7 @@
false);
// append dst blend
if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) {
- fsBuilder->codeAppend("vec4(0, 0, 0, 0)");
+ fsBuilder->codeAppend("float4(0, 0, 0, 0)");
}
fsBuilder->codeAppend(";");
}
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
index 006fe58..6f75c16 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
@@ -29,7 +29,7 @@
SkASSERT(outputColor);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
outputColor->append(fragBuilder->getMangleString());
- fragBuilder->codeAppendf("vec4 %s;", outputColor->c_str());
+ fragBuilder->codeAppendf("float4 %s;", outputColor->c_str());
this->internalEmitChild(childIndex, inputColor, outputColor->c_str(), args);
}
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.h b/src/gpu/glsl/GrGLSLFragmentProcessor.h
index 355d490..ed4b71f 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.h
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.h
@@ -86,9 +86,9 @@
@param fp The processor that generated this program stage.
@param key The key that was computed by GenKey() from the generating
GrProcessor.
- @param outputColor A predefined vec4 in the FS in which the stage should place its
+ @param outputColor A predefined float4 in the FS in which the stage should place its
output color (or coverage).
- @param inputColor A vec4 that holds the input color to the stage in the FS. This may
+ @param inputColor A float4 that holds the input color to the stage in the FS. This may
be nullptr in which case the implied input is solid white (all
ones). TODO: Better system for communicating optimization info
(e.g. input color is solid white, trans black, known to be opaque,
@@ -152,7 +152,7 @@
}
inline void emitChild(int childIndex, SkString* outputColor, EmitArgs& parentArgs) {
- this->emitChild(childIndex, "vec4(1.0)", outputColor, parentArgs);
+ this->emitChild(childIndex, "float4(1.0)", outputColor, parentArgs);
}
/** Will emit the code of a child proc in its own scope. Pass in the parent's EmitArgs and
@@ -167,7 +167,7 @@
EmitArgs& parentArgs);
inline void emitChild(int childIndex, EmitArgs& args) {
- this->emitChild(childIndex, "vec4(1.0)", args);
+ this->emitChild(childIndex, "float4(1.0)", args);
}
/** Variation that uses the parent's output color variable to hold the child's output.*/
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index 6c0528e..7f16136 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -119,7 +119,7 @@
SkString coords2D;
coords2D.printf("%s_ensure2D", coords.c_str());
- this->codeAppendf("\tvec2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_str(),
+ this->codeAppendf("\tfloat2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_str(),
coords.c_str());
return coords2D;
}
@@ -199,7 +199,7 @@
fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOut_TypeModifier);
fbFetchColorName = DeclaredColorOutputName();
// Set the dstColor to an intermediate variable so we don't override it with the output
- this->codeAppendf("vec4 %s = %s;", kDstColorName, fbFetchColorName);
+ this->codeAppendf("float4 %s = %s;", kDstColorName, fbFetchColorName);
} else {
return fbFetchColorName;
}
@@ -305,9 +305,9 @@
SkSTArray<16, SkPoint, true> offsets;
offsets.push_back_n(specs.fEffectiveSampleCnt);
m.mapPoints(offsets.begin(), specs.fSampleLocations, specs.fEffectiveSampleCnt);
- this->definitions().appendf("const highp vec2 %s[] = vec2[](", name);
+ this->definitions().appendf("const highp float2 %s[] = float2[](", name);
for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) {
- this->definitions().appendf("vec2(%f, %f)", offsets[i].x(), offsets[i].y());
+ this->definitions().appendf("float2(%f, %f)", offsets[i].x(), offsets[i].y());
this->definitions().append(i + 1 != specs.fEffectiveSampleCnt ? ", " : ");\n");
}
}
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index 9dd1cba..3ab5b68 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -62,9 +62,9 @@
handler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType);
if (kVec2f_GrSLType == varyingType) {
- vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
+ vb->codeAppendf("%s = (%s * float3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
} else {
- vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName, localCoords);
+ vb->codeAppendf("%s = %s * float3(%s, 1);", v.vsOut(), uniName, localCoords);
}
++i;
}
@@ -89,7 +89,7 @@
GrGPArgs* gpArgs,
const char* posName) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
- vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+ vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
}
void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
@@ -100,7 +100,7 @@
UniformHandle* viewMatrixUniform) {
if (mat.isIdentity()) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
- vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+ vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
} else {
const char* viewMatrixName;
*viewMatrixUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
@@ -109,11 +109,11 @@
&viewMatrixName);
if (!mat.hasPerspective()) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
- vertBuilder->codeAppendf("vec2 %s = (%s * vec3(%s, 1)).xy;",
+ vertBuilder->codeAppendf("float2 %s = (%s * float3(%s, 1)).xy;",
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
} else {
gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
- vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
+ vertBuilder->codeAppendf("float3 %s = %s * float3(%s, 1);",
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
}
}
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.h b/src/gpu/glsl/GrGLSLGeometryProcessor.h
index 6777620..10a4aa8 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.h
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.h
@@ -50,7 +50,7 @@
struct GrGPArgs {
// The variable used by a GP to store its position. It can be
- // either a vec2 or a vec3 depending on the presence of perspective.
+ // either a float2 or a float3 depending on the presence of perspective.
GrShaderVar fPositionVar;
};
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
index c2e0ab7..d9d17e5 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
@@ -49,7 +49,7 @@
&stagedLocalVarName);
fragBuilder->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
if (fragBuilder->getProgramBuilder()->shaderCaps()->mustObfuscateUniformColor()) {
- fragBuilder->codeAppendf("%s = max(%s, vec4(0, 0, 0, 0));", outputName, outputName);
+ fragBuilder->codeAppendf("%s = max(%s, float4(0, 0, 0, 0));", outputName, outputName);
}
}
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 5c78c07..a3c20c3 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -239,8 +239,8 @@
this->uniformHandler(),
this->shaderCaps(),
xp,
- colorIn.size() ? colorIn.c_str() : "vec4(1)",
- coverageIn.size() ? coverageIn.c_str() : "vec4(1)",
+ colorIn.size() ? colorIn.c_str() : "float4(1)",
+ coverageIn.size() ? coverageIn.c_str() : "float4(1)",
fFS.getPrimaryColorOutputName(),
fFS.getSecondaryColorOutputName(),
dstTextureSamplerHandle,
@@ -455,7 +455,7 @@
} else {
this->nameVariable(&outName, '\0', baseName);
}
- fFS.codeAppendf("vec4 %s;", outName.c_str());
+ fFS.codeAppendf("float4 %s;", outName.c_str());
*output = outName;
}
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index 542cee6..8f7d23d 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -128,7 +128,7 @@
SkString functionBody;
// Gamut xform, clamp to destination gamut. We only support/have premultiplied textures, so we
// always just clamp to alpha.
- functionBody.append("\tcolor.rgb = clamp((xform * vec4(color.rgb, 1.0)).rgb, 0.0, color.a);\n");
+ functionBody.append("\tcolor.rgb = clamp((xform * float4(color.rgb, 1.0)).rgb, 0.0, color.a);\n");
functionBody.append("\treturn color;");
SkString colorGamutXformFuncName;
this->emitFunction(kVec4f_GrSLType,
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h
index 16e5b86..4906c03 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.h
@@ -47,8 +47,8 @@
/** Does the work of appendTextureLookup and modulates the result by modulation. The result is
- always a vec4. modulation and the swizzle specified by SamplerHandle must both be
- vec4 or float. If modulation is "" or nullptr it this function acts as though
+ always a float4. modulation and the swizzle specified by SamplerHandle must both be
+ float4 or float. If modulation is "" or nullptr it this function acts as though
appendTextureLookup were called. */
void appendTextureLookupAndModulate(const char* modulation,
SamplerHandle,
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
index 627b11d..e06ee2d 100644
--- a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
@@ -20,23 +20,23 @@
if (this->getProgramBuilder()->desc()->header().fSnapVerticesToPixelCenters) {
if (kVec3f_GrSLType == posVar.getType()) {
const char* p = posVar.c_str();
- this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
+ this->codeAppendf("{float2 _posTmp = float2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
} else {
SkASSERT(kVec2f_GrSLType == posVar.getType());
- this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str());
+ this->codeAppendf("{float2 _posTmp = %s;", posVar.c_str());
}
- this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);"
- "gl_Position = vec4(_posTmp.x * %s.x + %s.y,"
- "_posTmp.y * %s.z + %s.w, 0, 1);}",
+ this->codeAppendf("_posTmp = floor(_posTmp) + float2(0.5, 0.5);"
+ "gl_Position = float4(_posTmp.x * %s.x + %s.y,"
+ "_posTmp.y * %s.z + %s.w, 0, 1);}",
rtAdjustName, rtAdjustName, rtAdjustName, rtAdjustName);
} else if (kVec3f_GrSLType == posVar.getType()) {
- this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
+ this->codeAppendf("gl_Position = float4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
posVar.c_str(), rtAdjustName,
posVar.c_str(), rtAdjustName,
posVar.c_str());
} else {
SkASSERT(kVec2f_GrSLType == posVar.getType());
- this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
+ this->codeAppendf("gl_Position = float4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
posVar.c_str(), rtAdjustName, rtAdjustName,
posVar.c_str(), rtAdjustName, rtAdjustName);
}
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp
index 5af0f05..6c2c460 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -52,7 +52,7 @@
// The discard here also helps for batching text draws together which need to read from
// a dst copy for blends. Though this only helps the case where the outer bounding boxes
// of each letter overlap and not two actually parts of the text.
- fragBuilder->codeAppendf("if (all(lessThanEqual(%s.rgb, vec3(0)))) {"
+ fragBuilder->codeAppendf("if (all(lessThanEqual(%s.rgb, float3(0)))) {"
" discard;"
"}", args.fInputCoverage);
}
@@ -72,14 +72,14 @@
&dstCoordScaleName);
fragBuilder->codeAppend("// Read color from copy of the destination.\n");
- fragBuilder->codeAppendf("vec2 _dstTexCoord = (sk_FragCoord.xy - %s) * %s;",
+ fragBuilder->codeAppendf("float2 _dstTexCoord = (sk_FragCoord.xy - %s) * %s;",
dstTopLeftName, dstCoordScaleName);
if (flipY) {
fragBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
}
- fragBuilder->codeAppendf("vec4 %s = ", dstColor);
+ fragBuilder->codeAppendf("float4 %s = ", dstColor);
fragBuilder->appendTextureLookup(args.fDstTextureSamplerHandle, "_dstTexCoord",
kVec2f_GrSLType);
fragBuilder->codeAppend(";");
@@ -91,7 +91,7 @@
if (!needsLocalOutColor) {
outColor = args.fOutputPrimary;
} else {
- fragBuilder->codeAppendf("vec4 %s;", outColor);
+ fragBuilder->codeAppendf("float4 %s;", outColor);
}
this->emitBlendCodeForDstRead(fragBuilder,
@@ -139,7 +139,7 @@
fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
} else {
- fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
+ fragBuilder->codeAppendf("%s = float4(1.0);", outColorSecondary);
}
} else if (srcCoverage) {
if (proc.isLCD()) {
@@ -150,7 +150,7 @@
fragBuilder->codeAppendf("float lerpGreen = mix(%s.a, %s.a, %s.b);",
dstColor, outColor, srcCoverage);
}
- fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
+ fragBuilder->codeAppendf("%s = %s * %s + (float4(1.0) - %s) * %s;",
outColor, srcCoverage, outColor, srcCoverage, dstColor);
if (proc.isLCD()) {
fragBuilder->codeAppendf("%s.a = max(max(lerpRed, lerpBlue), lerpGreen);", outColor);
diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp
index 39c1cf2..28095da 100644
--- a/src/gpu/instanced/InstanceProcessor.cpp
+++ b/src/gpu/instanced/InstanceProcessor.cpp
@@ -232,11 +232,11 @@
}
if (!ip.opInfo().fHasPerspective) {
- v->codeAppendf("mat2x3 shapeMatrix = mat2x3(%s, %s);",
+ v->codeAppendf("float2x3 shapeMatrix = float2x3(%s, %s);",
inputs.attr(Attrib::kShapeMatrixX), inputs.attr(Attrib::kShapeMatrixY));
} else {
v->defineConstantf("int", "PERSPECTIVE_FLAG", "0x%x", kPerspective_InfoFlag);
- v->codeAppendf("mat3 shapeMatrix = mat3(%s, %s, vec3(0, 0, 1));",
+ v->codeAppendf("float3x3 shapeMatrix = float3x3(%s, %s, float3(0, 0, 1));",
inputs.attr(Attrib::kShapeMatrixX), inputs.attr(Attrib::kShapeMatrixY));
v->codeAppendf("if (0 != (%s & PERSPECTIVE_FLAG)) {",
inputs.attr(Attrib::kInstanceInfo));
@@ -303,16 +303,16 @@
inputs.attr(Attrib::kInstanceInfo));
}
// Here we take advantage of the fact that outerRect == localRect in recordDRRect.
- v->codeAppendf("vec4 outer = %s;", inputs.attr(Attrib::kLocalRect));
- v->codeAppend ("vec4 inner = ");
+ v->codeAppendf("float4 outer = %s;", inputs.attr(Attrib::kLocalRect));
+ v->codeAppend ("float4 inner = ");
inputs.fetchNextParam();
v->codeAppend (";");
// outer2Inner is a transform from shape coords to inner shape coords:
// e.g. innerShapeCoords = shapeCoords * outer2Inner.xy + outer2Inner.zw
- v->codeAppend ("vec4 outer2Inner = vec4(outer.zw - outer.xy, "
+ v->codeAppend ("float4 outer2Inner = float4(outer.zw - outer.xy, "
"outer.xy + outer.zw - inner.xy - inner.zw) / "
"(inner.zw - inner.xy).xyxy;");
- v->codeAppendf("vec2 innerShapeCoords = %s * outer2Inner.xy + outer2Inner.zw;",
+ v->codeAppendf("float2 innerShapeCoords = %s * outer2Inner.xy + outer2Inner.zw;",
backend->outShapeCoords());
backend->initInnerShape(varyingHandler, v);
@@ -372,8 +372,8 @@
const char* localCoords = nullptr;
if (ip.opInfo().fUsesLocalCoords) {
localCoords = "localCoords";
- v->codeAppendf("vec2 t = 0.5 * (%s + vec2(1));", backend->outShapeCoords());
- v->codeAppendf("vec2 localCoords = (1.0 - t) * %s.xy + t * %s.zw;",
+ v->codeAppendf("float2 t = 0.5 * (%s + float2(1));", backend->outShapeCoords());
+ v->codeAppendf("float2 localCoords = (1.0 - t) * %s.xy + t * %s.zw;",
inputs.attr(Attrib::kLocalRect), inputs.attr(Attrib::kLocalRect));
}
if (ip.opInfo().fHasLocalMatrix && ip.opInfo().fHasParams) {
@@ -383,20 +383,20 @@
if (!ip.opInfo().fUsesLocalCoords) {
inputs.skipParams(2);
} else {
- v->codeAppendf( "mat2x3 localMatrix;");
+ v->codeAppendf( "float2x3 localMatrix;");
v->codeAppend ( "localMatrix[0] = ");
inputs.fetchNextParam(kVec3f_GrSLType);
v->codeAppend ( ";");
v->codeAppend ( "localMatrix[1] = ");
inputs.fetchNextParam(kVec3f_GrSLType);
v->codeAppend ( ";");
- v->codeAppend ( "localCoords = (vec3(localCoords, 1) * localMatrix).xy;");
+ v->codeAppend ( "localCoords = (float3(localCoords, 1) * localMatrix).xy;");
}
v->codeAppend("}");
}
GrSLType positionType = ip.opInfo().fHasPerspective ? kVec3f_GrSLType : kVec2f_GrSLType;
- v->codeAppendf("%s deviceCoords = vec3(%s, 1) * shapeMatrix;",
+ v->codeAppendf("%s deviceCoords = float3(%s, 1) * shapeMatrix;",
GrGLSLTypeString(positionType), backend->outShapeCoords());
gpArgs->fPositionVar.set(positionType, "deviceCoords");
@@ -409,7 +409,7 @@
void GLSLInstanceProcessor::Backend::init(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
if (fModifiedShapeCoords) {
- v->codeAppendf("vec2 %s = %s;", fModifiedShapeCoords, fInputs.attr(Attrib::kShapeCoords));
+ v->codeAppendf("float2 %s = %s;", fModifiedShapeCoords, fInputs.attr(Attrib::kShapeCoords));
}
this->onInit(varyingHandler, v);
@@ -421,11 +421,11 @@
}
void GLSLInstanceProcessor::Backend::setupRRect(GrGLSLVertexBuilder* v, int* usedShapeDefinitions) {
- v->codeAppendf("uvec2 corner = uvec2(%s & 1, (%s >> 1) & 1);",
+ v->codeAppendf("uint2 corner = uint2(%s & 1, (%s >> 1) & 1);",
fInputs.attr(Attrib::kVertexAttrs), fInputs.attr(Attrib::kVertexAttrs));
- v->codeAppend ("vec2 cornerSign = vec2(corner) * 2.0 - 1.0;");
- v->codeAppendf("vec2 radii%s;", fNeedsNeighborRadii ? ", neighborRadii" : "");
- v->codeAppend ("mat2 p = ");
+ v->codeAppend ("float2 cornerSign = float2(corner) * 2.0 - 1.0;");
+ v->codeAppendf("float2 radii%s;", fNeedsNeighborRadii ? ", neighborRadii" : "");
+ v->codeAppend ("float2x2 p = ");
fInputs.fetchNextParam(kMat22f_GrSLType);
v->codeAppend (";");
uint8_t types = fOpInfo.fShapeTypes & kRRect_ShapesMask;
@@ -467,11 +467,11 @@
this->adjustRRectVertices(v);
if (fArcCoords.vsOut()) {
- v->codeAppendf("%s = (cornerSign * %s + radii - vec2(1)) / radii;",
+ v->codeAppendf("%s = (cornerSign * %s + radii - float2(1)) / radii;",
fArcCoords.vsOut(), fModifiedShapeCoords);
}
if (fTriangleIsArc.vsOut()) {
- v->codeAppendf("%s = int(all(equal(vec2(1), abs(%s))));",
+ v->codeAppendf("%s = int(all(equal(float2(1), abs(%s))));",
fTriangleIsArc.vsOut(), fInputs.attr(Attrib::kShapeCoords));
}
@@ -486,9 +486,9 @@
}
void GLSLInstanceProcessor::Backend::setupNinePatchRadii(GrGLSLVertexBuilder* v) {
- v->codeAppend("radii = vec2(p[0][corner.x], p[1][corner.y]);");
+ v->codeAppend("radii = float2(p[0][corner.x], p[1][corner.y]);");
if (fNeedsNeighborRadii) {
- v->codeAppend("neighborRadii = vec2(p[0][1 - corner.x], p[1][1 - corner.y]);");
+ v->codeAppend("neighborRadii = float2(p[0][1 - corner.x], p[1][1 - corner.y]);");
}
}
@@ -507,13 +507,13 @@
* x2 x4
*
*/
- v->codeAppend("mat2 p2 = ");
+ v->codeAppend("float2x2 p2 = ");
fInputs.fetchNextParam(kMat22f_GrSLType);
v->codeAppend(";");
- v->codeAppend("radii = vec2(p[corner.x][corner.y], p2[corner.y][corner.x]);");
+ v->codeAppend("radii = float2(p[corner.x][corner.y], p2[corner.y][corner.x]);");
if (fNeedsNeighborRadii) {
- v->codeAppend("neighborRadii = vec2(p[1 - corner.x][corner.y], "
- "p2[1 - corner.y][corner.x]);");
+ v->codeAppend("neighborRadii = float2(p[1 - corner.x][corner.y], "
+ "p2[1 - corner.y][corner.x]);");
}
}
@@ -540,10 +540,10 @@
}
void GLSLInstanceProcessor::Backend::setupInnerSimpleRRect(GrGLSLVertexBuilder* v) {
- v->codeAppend("mat2 innerP = ");
+ v->codeAppend("float2x2 innerP = ");
fInputs.fetchNextParam(kMat22f_GrSLType);
v->codeAppend(";");
- v->codeAppend("vec2 innerRadii = innerP[0] * 2.0 / innerP[1];");
+ v->codeAppend("float2 innerRadii = innerP[0] * 2.0 / innerP[1];");
this->onSetupInnerSimpleRRect(v);
}
@@ -554,7 +554,7 @@
fModifiesColor ? outColor : nullptr);
if (outCoverage && !fModifiesCoverage) {
// Even though the subclass doesn't use coverage, we are expected to assign some value.
- f->codeAppendf("%s = vec4(1);", outCoverage);
+ f->codeAppendf("%s = float4(1);", outCoverage);
}
if (!fModifiesColor) {
// The subclass didn't assign a value to the output color.
@@ -621,18 +621,18 @@
void GLSLInstanceProcessor::BackendNonAA::setupInnerRect(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1);", fInnerRRect.vsOut());
}
}
void GLSLInstanceProcessor::BackendNonAA::setupInnerOval(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(0, 0, 1, 1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, 1, 1);", fInnerRRect.vsOut());
}
}
void GLSLInstanceProcessor::BackendNonAA::onSetupInnerSimpleRRect(GrGLSLVertexBuilder* v) {
- v->codeAppendf("%s = vec4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
}
void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
@@ -646,8 +646,8 @@
f->codeAppend ("lowp float covered = 1.0;");
dropFragment = "covered = 0.0";
} else if (fModifiesColor) {
- f->codeAppendf("lowp vec4 color = %s;", fColor.fsIn());
- dropFragment = "color = vec4(0)";
+ f->codeAppendf("lowp float4 color = %s;", fColor.fsIn());
+ dropFragment = "color = float4(0)";
}
if (fTriangleIsArc.fsIn()) {
SkASSERT(dropFragment);
@@ -658,19 +658,19 @@
SkASSERT(dropFragment);
f->codeAppendf("// Inner shape.\n");
if (kRect_ShapeFlag == fOpInfo.fInnerShapeTypes) {
- f->codeAppendf("if (all(lessThanEqual(abs(%s), vec2(1)))) %s;",
+ f->codeAppendf("if (all(lessThanEqual(abs(%s), float2(1)))) %s;",
fInnerShapeCoords.fsIn(), dropFragment);
} else if (kOval_ShapeFlag == fOpInfo.fInnerShapeTypes) {
f->codeAppendf("if ((dot(%s, %s) <= 1.0)) %s;",
fInnerShapeCoords.fsIn(), fInnerShapeCoords.fsIn(), dropFragment);
} else {
- f->codeAppendf("if (all(lessThan(abs(%s), vec2(1)))) {", fInnerShapeCoords.fsIn());
- f->codeAppendf( "vec2 distanceToArcEdge = abs(%s) - %s.xy;",
+ f->codeAppendf("if (all(lessThan(abs(%s), float2(1)))) {", fInnerShapeCoords.fsIn());
+ f->codeAppendf( "float2 distanceToArcEdge = abs(%s) - %s.xy;",
fInnerShapeCoords.fsIn(), fInnerRRect.fsIn());
- f->codeAppend ( "if (any(lessThan(distanceToArcEdge, vec2(0)))) {");
+ f->codeAppend ( "if (any(lessThan(distanceToArcEdge, float2(0)))) {");
f->codeAppendf( "%s;", dropFragment);
f->codeAppend ( "} else {");
- f->codeAppendf( "vec2 rrectCoords = distanceToArcEdge * %s.zw;",
+ f->codeAppendf( "float2 rrectCoords = distanceToArcEdge * %s.zw;",
fInnerRRect.fsIn());
f->codeAppend ( "if (dot(rrectCoords, rrectCoords) <= 1.0) {");
f->codeAppendf( "%s;", dropFragment);
@@ -680,7 +680,7 @@
}
}
if (fModifiesCoverage) {
- f->codeAppendf("%s = vec4(covered);", outCoverage);
+ f->codeAppendf("%s = float4(covered);", outCoverage);
} else if (fModifiesColor) {
f->codeAppendf("%s = color;", outColor);
}
@@ -747,10 +747,10 @@
void GLSLInstanceProcessor::BackendCoverage::onInit(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
- v->codeAppend ("mat2 shapeTransposeMatrix = transpose(mat2(shapeMatrix));");
- v->codeAppend ("vec2 shapeHalfSize = vec2(length(shapeTransposeMatrix[0]), "
+ v->codeAppend ("float2x2 shapeTransposeMatrix = transpose(float2x2(shapeMatrix));");
+ v->codeAppend ("float2 shapeHalfSize = float2(length(shapeTransposeMatrix[0]), "
"length(shapeTransposeMatrix[1]));");
- v->codeAppend ("vec2 bloat = 0.5 / shapeHalfSize;");
+ v->codeAppend ("float2 bloat = 0.5 / shapeHalfSize;");
v->codeAppendf("bloatedShapeCoords = %s * (1.0 + bloat);", fInputs.attr(Attrib::kShapeCoords));
if (kOval_ShapeFlag != fOpInfo.fShapeTypes) {
@@ -779,13 +779,13 @@
void GLSLInstanceProcessor::BackendCoverage::setupRect(GrGLSLVertexBuilder* v) {
// Make the border one pixel wide. Inner vs outer is indicated by coordAttrs.
- v->codeAppendf("vec2 rectBloat = (%s != 0) ? bloat : -bloat;",
+ v->codeAppendf("float2 rectBloat = (%s != 0) ? bloat : -bloat;",
fInputs.attr(Attrib::kVertexAttrs));
// Here we use the absolute value, because when the rect is thinner than a pixel, this makes it
// mark the spot where pixel center is within half a pixel of the *opposite* edge. This,
// combined with the "maxCoverage" logic below gives us mathematically correct coverage even for
// subpixel rectangles.
- v->codeAppendf("bloatedShapeCoords = %s * abs(vec2(1.0 + rectBloat));",
+ v->codeAppendf("bloatedShapeCoords = %s * abs(float2(1.0 + rectBloat));",
fInputs.attr(Attrib::kShapeCoords));
// Determine coverage at the vertex. Coverage naturally ramps from 0 to 1 unless the rect is
@@ -802,9 +802,9 @@
void GLSLInstanceProcessor::BackendCoverage::setupOval(GrGLSLVertexBuilder* v) {
// Offset the inner and outer octagons by one pixel. Inner vs outer is indicated by coordAttrs.
- v->codeAppendf("vec2 ovalBloat = (%s != 0) ? bloat : -bloat;",
+ v->codeAppendf("float2 ovalBloat = (%s != 0) ? bloat : -bloat;",
fInputs.attr(Attrib::kVertexAttrs));
- v->codeAppendf("bloatedShapeCoords = %s * max(vec2(1.0 + ovalBloat), vec2(0));",
+ v->codeAppendf("bloatedShapeCoords = %s * max(float2(1.0 + ovalBloat), float2(0));",
fInputs.attr(Attrib::kShapeCoords));
v->codeAppendf("%s = bloatedShapeCoords * shapeHalfSize;", fEllipseCoords.vsOut());
if (fEllipseName.vsOut()) {
@@ -827,8 +827,8 @@
// We try to let the AA borders line up with the arc edges on their particular side, but we
// can't allow them to get closer than one half pixel to the edge or they might overlap with
// their neighboring border.
- v->codeAppend("vec2 innerEdge = max(1.0 - bloat, vec2(0));");
- v->codeAppend ("vec2 borderEdge = cornerSign * clamp(1.0 - radii, -innerEdge, innerEdge);");
+ v->codeAppend("float2 innerEdge = max(1.0 - bloat, float2(0));");
+ v->codeAppend ("float2 borderEdge = cornerSign * clamp(1.0 - radii, -innerEdge, innerEdge);");
// 0.5 is a special value that indicates this vertex is an arc edge.
v->codeAppendf("if (abs(%s.x) == 0.5)"
"bloatedShapeCoords.x = borderEdge.x;", fInputs.attr(Attrib::kShapeCoords));
@@ -851,7 +851,7 @@
// interior edge of the border will necessarily clamp, and we need to match the AA behavior of
// the arc segments (i.e. distance from bloated edge only; ignoring the fact that the pixel
// actully has less coverage because it's not completely inside the opposite edge.)
- v->codeAppend("vec2 d = shapeHalfSize + 0.5 - abs(bloatedShapeCoords) * shapeHalfSize;");
+ v->codeAppend("float2 d = shapeHalfSize + 0.5 - abs(bloatedShapeCoords) * shapeHalfSize;");
v->codeAppend("rectCoverage = min(d.x, d.y);");
SkASSERT(!fShapeIsCircle);
@@ -859,8 +859,8 @@
// smooth transition from flat edge to arc, we don't allow the radii to be smaller than one half
// pixel. (We don't worry about the transition on the opposite side when a radius is so large
// that the border clamped on that side.)
- v->codeAppendf("vec2 clampedRadii = max(radii, bloat);");
- v->codeAppendf("%s = (cornerSign * bloatedShapeCoords + clampedRadii - vec2(1)) * "
+ v->codeAppendf("float2 clampedRadii = max(radii, bloat);");
+ v->codeAppendf("%s = (cornerSign * bloatedShapeCoords + clampedRadii - float2(1)) * "
"shapeHalfSize;", fEllipseCoords.vsOut());
v->codeAppendf("%s = 1.0 / (clampedRadii * clampedRadii * shapeHalfSize * shapeHalfSize);",
fEllipseName.vsOut());
@@ -868,7 +868,7 @@
void GLSLInstanceProcessor::BackendCoverage::onInitInnerShape(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
- v->codeAppend("vec2 innerShapeHalfSize = shapeHalfSize / outer2Inner.xy;");
+ v->codeAppend("float2 innerShapeHalfSize = shapeHalfSize / outer2Inner.xy;");
if (kOval_ShapeFlag == fOpInfo.fInnerShapeTypes) {
varyingHandler->addVarying("innerEllipseCoords", &fInnerEllipseCoords,
@@ -906,7 +906,7 @@
v->codeAppendf("%s = innerShapeCoords * innerShapeHalfSize;", fInnerEllipseCoords.vsOut());
}
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(0, 0, innerShapeHalfSize);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, innerShapeHalfSize);", fInnerRRect.vsOut());
}
}
@@ -916,7 +916,7 @@
v->codeAppendf("%s = 1.0 / (innerRadii * innerRadii * innerShapeHalfSize * "
"innerShapeHalfSize);",
fInnerEllipseName.vsOut());
- v->codeAppendf("%s = vec4(1.0 - innerRadii, innerShapeHalfSize);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1.0 - innerRadii, innerShapeHalfSize);", fInnerRRect.vsOut());
}
void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
@@ -974,12 +974,12 @@
this->emitInnerRect(f, innerCoverageDecl.c_str());
} else {
f->codeAppendf("%s = 0.0;", innerCoverageDecl.c_str());
- f->codeAppendf("mediump vec2 distanceToArcEdge = abs(%s) - %s.xy;",
+ f->codeAppendf("mediump float2 distanceToArcEdge = abs(%s) - %s.xy;",
fInnerShapeCoords.fsIn(), fInnerRRect.fsIn());
- f->codeAppend ("if (any(lessThan(distanceToArcEdge, vec2(1e-5)))) {");
+ f->codeAppend ("if (any(lessThan(distanceToArcEdge, float2(1e-5)))) {");
this->emitInnerRect(f, "innerCoverage");
f->codeAppend ("} else {");
- f->codeAppendf( "mediump vec2 ellipseCoords = distanceToArcEdge * %s.zw;",
+ f->codeAppendf( "mediump float2 ellipseCoords = distanceToArcEdge * %s.zw;",
fInnerRRect.fsIn());
this->emitArc(f, "ellipseCoords", fInnerEllipseName.fsIn(),
false /*ellipseCoordsNeedClamp*/,
@@ -987,9 +987,9 @@
f->codeAppend ("}");
}
}
- f->codeAppendf("%s = vec4(max(coverage - innerCoverage, 0.0));", outCoverage);
+ f->codeAppendf("%s = float4(max(coverage - innerCoverage, 0.0));", outCoverage);
} else if (!fTweakAlphaForCoverage) {
- f->codeAppendf("%s = vec4(coverage);", outCoverage);
+ f->codeAppendf("%s = float4(coverage);", outCoverage);
}
}
@@ -1029,16 +1029,16 @@
// - To restrict the arcs of rounded rects to their positive quadrants.
// - To avoid inversesqrt(0) in the ellipse formula.
if (ellipseCoordsMayBeNegative) {
- f->codeAppendf("mediump vec2 ellipseClampedCoords = max(abs(%s), vec2(1e-4));",
+ f->codeAppendf("mediump float2 ellipseClampedCoords = max(abs(%s), float2(1e-4));",
ellipseCoords);
} else {
- f->codeAppendf("mediump vec2 ellipseClampedCoords = max(%s, vec2(1e-4));",
+ f->codeAppendf("mediump float2 ellipseClampedCoords = max(%s, float2(1e-4));",
ellipseCoords);
}
ellipseCoords = "ellipseClampedCoords";
}
// ellipseCoords are in pixel space and ellipseName is 1 / rx^2, 1 / ry^2.
- f->codeAppendf("highp vec2 Z = %s * %s;", ellipseCoords, ellipseName);
+ f->codeAppendf("highp float2 Z = %s * %s;", ellipseCoords, ellipseName);
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
f->codeAppendf("highp float implicit = dot(Z, %s) - 1.0;", ellipseCoords);
// gradDot is the squared length of the gradient of the implicit.
@@ -1049,7 +1049,7 @@
void GLSLInstanceProcessor::BackendCoverage::emitInnerRect(GrGLSLPPFragmentBuilder* f,
const char* outCoverage) {
- f->codeAppendf("lowp vec2 c = %s - abs(%s);",
+ f->codeAppendf("lowp float2 c = %s - abs(%s);",
fInnerShapeBloatedHalfSize.fsIn(), fDistanceToInnerEdge.fsIn());
f->codeAppendf("%s = clamp(min(c.x, c.y), 0.0, 1.0);", outCoverage);
}
@@ -1177,9 +1177,9 @@
}
}
if (!fOpInfo.fHasPerspective) {
- v->codeAppend("mat2 shapeInverseMatrix = inverse(mat2(shapeMatrix));");
- v->codeAppend("vec2 fragShapeSpan = abs(vec4(shapeInverseMatrix).xz) + "
- "abs(vec4(shapeInverseMatrix).yw);");
+ v->codeAppend("float2x2 shapeInverseMatrix = inverse(float2x2(shapeMatrix));");
+ v->codeAppend("float2 fragShapeSpan = abs(float4(shapeInverseMatrix).xz) + "
+ "abs(float4(shapeInverseMatrix).yw);");
}
}
@@ -1195,7 +1195,7 @@
}
if (fArcTest.vsOut()) {
// Pick a value that is not > 0.
- v->codeAppendf("%s = vec2(0);", fArcTest.vsOut());
+ v->codeAppendf("%s = float2(0);", fArcTest.vsOut());
}
if (fTriangleIsArc.vsOut()) {
v->codeAppendf("%s = 0;", fTriangleIsArc.vsOut());
@@ -1208,8 +1208,8 @@
void GLSLInstanceProcessor::BackendMultisample::setupOval(GrGLSLVertexBuilder* v) {
v->codeAppendf("%s = abs(%s);", fArcCoords.vsOut(), this->outShapeCoords());
if (fArcInverseMatrix.vsOut()) {
- v->codeAppendf("vec2 s = sign(%s);", this->outShapeCoords());
- v->codeAppendf("%s = shapeInverseMatrix * mat2(s.x, 0, 0 , s.y);",
+ v->codeAppendf("float2 s = sign(%s);", this->outShapeCoords());
+ v->codeAppendf("%s = shapeInverseMatrix * float2x2(s.x, 0, 0 , s.y);",
fArcInverseMatrix.vsOut());
}
if (fFragArcHalfSpan.vsOut()) {
@@ -1217,7 +1217,7 @@
}
if (fArcTest.vsOut()) {
// Pick a value that is > 0.
- v->codeAppendf("%s = vec2(1);", fArcTest.vsOut());
+ v->codeAppendf("%s = float2(1);", fArcTest.vsOut());
}
if (fTriangleIsArc.vsOut()) {
if (!this->isMixedSampled()) {
@@ -1243,13 +1243,13 @@
// For the mixed samples algorithm it's best to bloat the corner triangles a bit so that
// more of the pixels that cross into the arc region are completely inside the shared edges.
// We also snap to a regular rect if the radii shrink smaller than a pixel.
- v->codeAppend ("vec2 midpt = 0.5 * (neighborRadii - radii);");
- v->codeAppend ("vec2 cornerSize = any(lessThan(radii, fragShapeSpan)) ? "
- "vec2(0) : min(radii + 0.5 * fragShapeSpan, 1.0 - midpt);");
+ v->codeAppend ("float2 midpt = 0.5 * (neighborRadii - radii);");
+ v->codeAppend ("float2 cornerSize = any(lessThan(radii, fragShapeSpan)) ? "
+ "float2(0) : min(radii + 0.5 * fragShapeSpan, 1.0 - midpt);");
} else {
// TODO: We could still bloat the corner triangle in the perspective case; we would just
// need to find the screen-space derivative of shape coords at this particular point.
- v->codeAppend ("vec2 cornerSize = any(lessThan(radii, vec2(1e-3))) ? vec2(0) : radii;");
+ v->codeAppend ("float2 cornerSize = any(lessThan(radii, float2(1e-3))) ? float2(0) : radii;");
}
v->codeAppendf("if (abs(%s.x) == 0.5)"
@@ -1271,12 +1271,12 @@
v->codeAppendf("%s = 0.5 * fragShapeSpan;", fFragShapeHalfSpan.vsOut());
}
if (fArcInverseMatrix.vsOut()) {
- v->codeAppend ("vec2 s = cornerSign / radii;");
- v->codeAppendf("%s = shapeInverseMatrix * mat2(s.x, 0, 0, s.y);",
+ v->codeAppend ("float2 s = cornerSign / radii;");
+ v->codeAppendf("%s = shapeInverseMatrix * float2x2(s.x, 0, 0, s.y);",
fArcInverseMatrix.vsOut());
}
if (fFragArcHalfSpan.vsOut()) {
- v->codeAppendf("%s = 0.5 * (abs(vec4(%s).xz) + abs(vec4(%s).yw));",
+ v->codeAppendf("%s = 0.5 * (abs(float4(%s).xz) + abs(float4(%s).yw));",
fFragArcHalfSpan.vsOut(), fArcInverseMatrix.vsOut(),
fArcInverseMatrix.vsOut());
}
@@ -1285,8 +1285,8 @@
// edges of a fan triangle to a point within that triangle. fArcTest is used to check if a
// fragment is too close to either shared edge, in which case we point sample the shape as a
// rect at that point in order to guarantee the mixed samples discard logic works correctly.
- v->codeAppendf("%s = (cornerSize == vec2(0)) ? vec2(0) : "
- "cornerSign * %s * mat2(1, cornerSize.x - 1.0, cornerSize.y - 1.0, 1);",
+ v->codeAppendf("%s = (cornerSize == float2(0)) ? float2(0) : "
+ "cornerSign * %s * float2x2(1, cornerSize.x - 1.0, cornerSize.y - 1.0, 1);",
fArcTest.vsOut(), fModifiedShapeCoords);
if (!fOpInfo.fHasPerspective) {
// Shift the point at which distances to edges are measured from the center of the pixel
@@ -1299,7 +1299,7 @@
}
if (fEarlyAccept.vsOut()) {
SkASSERT(this->isMixedSampled());
- v->codeAppendf("%s = all(equal(vec2(1), abs(%s))) ? 0 : SAMPLE_MASK_ALL;",
+ v->codeAppendf("%s = all(equal(float2(1), abs(%s))) ? 0 : SAMPLE_MASK_ALL;",
fEarlyAccept.vsOut(), fInputs.attr(Attrib::kShapeCoords));
}
}
@@ -1315,7 +1315,7 @@
if (!fOpInfo.fHasPerspective) {
varyingHandler->addFlatVarying("innerShapeInverseMatrix", &fInnerShapeInverseMatrix,
kHigh_GrSLPrecision);
- v->codeAppendf("%s = shapeInverseMatrix * mat2(outer2Inner.x, 0, 0, outer2Inner.y);",
+ v->codeAppendf("%s = shapeInverseMatrix * float2x2(outer2Inner.x, 0, 0, outer2Inner.y);",
fInnerShapeInverseMatrix.vsOut());
varyingHandler->addFlatVarying("fragInnerShapeHalfSpan", &fFragInnerShapeHalfSpan,
kHigh_GrSLPrecision);
@@ -1329,14 +1329,14 @@
// The fragment shader will generalize every inner shape as a round rect. Since this one
// is a rect, we simply emit bogus parameters for the round rect (negative radii) that
// ensure the fragment shader always takes the "sample as rect" codepath.
- v->codeAppendf("%s = vec4(2.0 * (inner.zw - inner.xy) / (outer.zw - outer.xy), vec2(0));",
+ v->codeAppendf("%s = float4(2.0 * (inner.zw - inner.xy) / (outer.zw - outer.xy), float2(0));",
fInnerRRect.vsOut());
}
}
void GLSLInstanceProcessor::BackendMultisample::setupInnerOval(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(0, 0, 1, 1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, 1, 1);", fInnerRRect.vsOut());
}
}
@@ -1345,9 +1345,9 @@
if (fFragInnerShapeHalfSpan.vsOut()) {
v->codeAppendf("innerRadii = max(innerRadii, 2e-1 * %s);", fFragInnerShapeHalfSpan.vsOut());
} else {
- v->codeAppend ("innerRadii = max(innerRadii, vec2(1e-4));");
+ v->codeAppend ("innerRadii = max(innerRadii, float2(1e-4));");
}
- v->codeAppendf("%s = vec4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
}
void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
@@ -1383,7 +1383,7 @@
if (fOpInfo.fHasPerspective && fOpInfo.fInnerShapeTypes) {
// This determines if the fragment should consider the inner shape in its sample mask.
// We take the derivative early in case discards may occur before we get to the inner shape.
- f->codeAppendf("highp vec2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
+ f->codeAppendf("highp float2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
fInnerShapeCoords.fsIn());
}
@@ -1400,7 +1400,7 @@
if (arcTest && fOpInfo.fHasPerspective) {
// The non-perspective version accounts for fwidth() in the vertex shader.
// We make sure to take the derivative here, before a neighbor pixel may early accept.
- f->codeAppendf("highp vec2 arcTest = %s - 0.5 * fwidth(%s);",
+ f->codeAppendf("highp float2 arcTest = %s - 0.5 * fwidth(%s);",
fArcTest.fsIn(), fArcTest.fsIn());
arcTest = "arcTest";
}
@@ -1411,7 +1411,7 @@
if (arcTest) {
// At this point, if the sample mask is all set it means we are inside an arc triangle.
f->codeAppendf("if (gl_SampleMaskIn[0] == SAMPLE_MASK_ALL || "
- "all(greaterThan(%s, vec2(0)))) {", arcTest);
+ "all(greaterThan(%s, float2(0)))) {", arcTest);
this->emitArc(f, arcCoords, false, clampArcCoords, opts);
f->codeAppend ("} else {");
this->emitRect(f, shapeCoords, opts);
@@ -1484,10 +1484,10 @@
}
f->codeAppend ("int rectMask = 0;");
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 pt = ");
+ f->codeAppend ( "highp float2 pt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", coords.fInverseMatrix);
f->codeAppend ( ";");
- f->codeAppend ( "if (all(lessThan(abs(pt), vec2(1)))) rectMask |= (1 << i);");
+ f->codeAppend ( "if (all(lessThan(abs(pt), float2(1)))) rectMask |= (1 << i);");
f->codeAppend ("}");
this->acceptCoverageMask(f, "rectMask", opts);
if (coords.fFragHalfSpan) {
@@ -1503,7 +1503,7 @@
SkString absArcCoords;
absArcCoords.printf(coordsMayBeNegative ? "abs(%s)" : "%s", coords.fVarying->fsIn());
if (clampCoords) {
- f->codeAppendf("if (%s(max(%s + %s, vec2(0))) < 1.0) {",
+ f->codeAppendf("if (%s(max(%s + %s, float2(0))) < 1.0) {",
fSquareFun.c_str(), absArcCoords.c_str(), coords.fFragHalfSpan);
} else {
f->codeAppendf("if (%s(%s + %s) < 1.0) {",
@@ -1511,7 +1511,7 @@
}
// The entire pixel is inside the arc.
this->acceptOrRejectWholeFragment(f, true, opts);
- f->codeAppendf("} else if (%s(max(%s - %s, vec2(0))) >= 1.0) {",
+ f->codeAppendf("} else if (%s(max(%s - %s, float2(0))) >= 1.0) {",
fSquareFun.c_str(), absArcCoords.c_str(), coords.fFragHalfSpan);
// The entire pixel is outside the arc.
this->acceptOrRejectWholeFragment(f, false, opts);
@@ -1519,12 +1519,12 @@
}
f->codeAppend ( "int arcMask = 0;");
f->codeAppend ( "for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 pt = ");
+ f->codeAppend ( "highp float2 pt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", coords.fInverseMatrix);
f->codeAppend ( ";");
if (clampCoords) {
SkASSERT(!coordsMayBeNegative);
- f->codeAppend ( "pt = max(pt, vec2(0));");
+ f->codeAppend ( "pt = max(pt, float2(0));");
}
f->codeAppendf( "if (%s(pt) < 1.0) arcMask |= (1 << i);", fSquareFun.c_str());
f->codeAppend ( "}");
@@ -1538,31 +1538,31 @@
const EmitShapeCoords& coords,
const char* rrect,
const EmitShapeOpts& opts) {
- f->codeAppendf("highp vec2 distanceToArcEdge = abs(%s) - %s.xy;", coords.fVarying->fsIn(),
+ f->codeAppendf("highp float2 distanceToArcEdge = abs(%s) - %s.xy;", coords.fVarying->fsIn(),
rrect);
- f->codeAppend ("if (any(lessThan(distanceToArcEdge, vec2(0)))) {");
+ f->codeAppend ("if (any(lessThan(distanceToArcEdge, float2(0)))) {");
this->emitRect(f, coords, opts);
f->codeAppend ("} else {");
if (coords.fInverseMatrix && coords.fFragHalfSpan) {
- f->codeAppendf("highp vec2 rrectCoords = distanceToArcEdge * %s.zw;", rrect);
- f->codeAppendf("highp vec2 fragRRectHalfSpan = %s * %s.zw;", coords.fFragHalfSpan, rrect);
+ f->codeAppendf("highp float2 rrectCoords = distanceToArcEdge * %s.zw;", rrect);
+ f->codeAppendf("highp float2 fragRRectHalfSpan = %s * %s.zw;", coords.fFragHalfSpan, rrect);
f->codeAppendf("if (%s(rrectCoords + fragRRectHalfSpan) <= 1.0) {", fSquareFun.c_str());
// The entire pixel is inside the round rect.
this->acceptOrRejectWholeFragment(f, true, opts);
- f->codeAppendf("} else if (%s(max(rrectCoords - fragRRectHalfSpan, vec2(0))) >= 1.0) {",
+ f->codeAppendf("} else if (%s(max(rrectCoords - fragRRectHalfSpan, float2(0))) >= 1.0) {",
fSquareFun.c_str());
// The entire pixel is outside the round rect.
this->acceptOrRejectWholeFragment(f, false, opts);
f->codeAppend ("} else {");
- f->codeAppendf( "highp vec2 s = %s.zw * sign(%s);", rrect, coords.fVarying->fsIn());
- f->codeAppendf( "highp mat2 innerRRectInverseMatrix = %s * mat2(s.x, 0, 0, s.y);",
- coords.fInverseMatrix);
+ f->codeAppendf( "highp float2 s = %s.zw * sign(%s);", rrect, coords.fVarying->fsIn());
+ f->codeAppendf( "highp float2x2 innerRRectInverseMatrix = %s * "
+ "float2x2(s.x, 0, 0, s.y);", coords.fInverseMatrix);
f->codeAppend ( "highp int rrectMask = 0;");
f->codeAppend ( "for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 pt = rrectCoords + ");
+ f->codeAppend ( "highp float2 pt = rrectCoords + ");
f->appendOffsetToSample("i", GrGLSLFPFragmentBuilder::kSkiaDevice_Coordinates);
f->codeAppend ( "* innerRRectInverseMatrix;");
- f->codeAppendf( "if (%s(max(pt, vec2(0))) < 1.0) rrectMask |= (1 << i);",
+ f->codeAppendf( "if (%s(max(pt, float2(0))) < 1.0) rrectMask |= (1 << i);",
fSquareFun.c_str());
f->codeAppend ( "}");
this->acceptCoverageMask(f, "rrectMask", opts);
@@ -1570,10 +1570,10 @@
} else {
f->codeAppend ("int rrectMask = 0;");
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 shapePt = ");
+ f->codeAppend ( "highp float2 shapePt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", nullptr);
f->codeAppend ( ";");
- f->codeAppendf( "highp vec2 rrectPt = max(abs(shapePt) - %s.xy, vec2(0)) * %s.zw;",
+ f->codeAppendf( "highp float2 rrectPt = max(abs(shapePt) - %s.xy, float2(0)) * %s.zw;",
rrect, rrect);
f->codeAppendf( "if (%s(rrectPt) < 1.0) rrectMask |= (1 << i);", fSquareFun.c_str());
f->codeAppend ("}");
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 9841f70..22b2b59 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -588,14 +588,14 @@
fragBuilder->codeAppendf("float edgeAlpha;");
// keep the derivative instructions outside the conditional
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 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(),
v.fsIn());
fragBuilder->codeAppendf ("} else {");
- fragBuilder->codeAppendf("vec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,"
+ fragBuilder->codeAppendf("float2 gF = float2(2.0*%s.x*duvdx.x - duvdx.y,"
" 2.0*%s.x*duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
fragBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(),
@@ -603,7 +603,7 @@
fragBuilder->codeAppendf("edgeAlpha = "
"clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);}");
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static inline void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index fdc59a4..7a23b5a 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -789,7 +789,7 @@
* This effect will draw a dotted line (defined as a dashed lined with round caps and no on
* interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo.
* Both of the previous two parameters are in device space. This effect also requires the setting of
- * a vec2 vertex attribute for the the four corners of the bounding rect. This attribute is the
+ * a float2 vertex attribute for the the four corners of the bounding rect. This attribute is the
* "dash position" of each vertex. In other words it is the vertex coords (in device space) if we
* transform the line to be horizontal, with the start of line at the origin then shifted to the
* right by half the off interval. The line then goes in the positive x direction.
@@ -910,8 +910,8 @@
fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
dashParams.fsIn(), dashParams.fsIn(), dashParams.fsIn(),
dashParams.fsIn());
- fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", dashParams.fsIn());
- fragBuilder->codeAppendf("vec2 center = vec2(%s.y, 0.0);", circleParams.fsIn());
+ fragBuilder->codeAppendf("float2 fragPosShifted = float2(xShifted, %s.y);", dashParams.fsIn());
+ fragBuilder->codeAppendf("float2 center = float2(%s.y, 0.0);", circleParams.fsIn());
fragBuilder->codeAppend("float dist = length(center - fragPosShifted);");
if (dce.aaMode() != AAMode::kNone) {
fragBuilder->codeAppendf("float diff = dist - %s.x;", circleParams.fsIn());
@@ -921,7 +921,7 @@
fragBuilder->codeAppendf("float alpha = 1.0;");
fragBuilder->codeAppendf("alpha *= dist < %s.x + 0.5 ? 1.0 : 0.0;", circleParams.fsIn());
}
- fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
}
void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
@@ -998,7 +998,7 @@
/*
* This effect will draw a dashed line. The width of the dash is given by the strokeWidth and the
* length and spacing by the DashInfo. Both of the previous two parameters are in device space.
- * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the
+ * This effect also requires the setting of a float2 vertex attribute for the the four corners of the
* bounding rect. This attribute is the "dash position" of each vertex. In other words it is the
* vertex coords (in device space) if we transform the line to be horizontal, with the start of
* line at the origin then shifted to the right by half the off interval. The line then goes in the
@@ -1114,7 +1114,7 @@
fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(),
inDashParams.fsIn());
- fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", inDashParams.fsIn());
+ fragBuilder->codeAppendf("float2 fragPosShifted = float2(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.
@@ -1143,7 +1143,7 @@
fragBuilder->codeAppendf("alpha *= (%s.z - fragPosShifted.x) >= -0.5 ? 1.0 : 0.0;",
inRectParams.fsIn());
}
- fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
}
void GLDashingLineEffect::setData(const GrGLSLProgramDataManager& pdman,
diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp
index b570a65..f1503fc 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -156,7 +156,7 @@
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
uv.fsIn());
- fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputCoverage);
+ fsBuilder->codeAppendf("%s = float4(1.0);", args.fOutputCoverage);
}
static inline void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 1c80594..770a54f 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -119,21 +119,21 @@
// emit attributes
varyingHandler->emitAttributes(cgp);
- fragBuilder->codeAppend("highp vec4 circleEdge;");
+ fragBuilder->codeAppend("highp float4 circleEdge;");
varyingHandler->addPassThroughAttribute(cgp.fInCircleEdge, "circleEdge",
kHigh_GrSLPrecision);
if (cgp.fInClipPlane) {
- fragBuilder->codeAppend("vec3 clipPlane;");
+ fragBuilder->codeAppend("float3 clipPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInClipPlane, "clipPlane");
}
if (cgp.fInIsectPlane) {
SkASSERT(cgp.fInClipPlane);
- fragBuilder->codeAppend("vec3 isectPlane;");
+ fragBuilder->codeAppend("float3 isectPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInIsectPlane, "isectPlane");
}
if (cgp.fInUnionPlane) {
SkASSERT(cgp.fInClipPlane);
- fragBuilder->codeAppend("vec3 unionPlane;");
+ fragBuilder->codeAppend("float3 unionPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInUnionPlane, "unionPlane");
}
@@ -178,7 +178,7 @@
}
fragBuilder->codeAppend("edgeAlpha *= clip;");
}
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
@@ -301,10 +301,10 @@
args.fFPCoordTransformHandler);
// for outer curve
- fragBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
+ fragBuilder->codeAppendf("float2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
ellipseRadii.fsIn());
fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("vec2 grad = 2.0*scaledOffset*%s.xy;", ellipseRadii.fsIn());
+ fragBuilder->codeAppendf("float2 grad = 2.0*scaledOffset*%s.xy;", ellipseRadii.fsIn());
fragBuilder->codeAppend("float grad_dot = dot(grad, grad);");
// avoid calling inversesqrt on zero.
@@ -322,7 +322,7 @@
fragBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);");
}
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
@@ -445,12 +445,12 @@
args.fFPCoordTransformHandler);
// for outer curve
- fragBuilder->codeAppendf("vec2 scaledOffset = %s.xy;", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 scaledOffset = %s.xy;", offsets0.fsIn());
fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s);", offsets0.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s);", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s);", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s);", offsets0.fsIn());
fragBuilder->codeAppendf(
- "vec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
+ "float2 grad = float2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
" 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn());
@@ -473,14 +473,14 @@
fragBuilder->codeAppendf("duvdx = dFdx(%s);", offsets1.fsIn());
fragBuilder->codeAppendf("duvdy = dFdy(%s);", offsets1.fsIn());
fragBuilder->codeAppendf(
- "grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
+ "grad = float2(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 = inversesqrt(dot(grad, grad));");
fragBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);");
}
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp
index 47c17ab..938596f 100644
--- a/src/gpu/vk/GrVkCopyManager.cpp
+++ b/src/gpu/vk/GrVkCopyManager.cpp
@@ -44,17 +44,17 @@
"#extension GL_ARB_shading_language_420pack : enable\n"
"layout(set = 0, binding = 0) uniform vertexUniformBuffer {"
- "mediump vec4 uPosXform;"
- "mediump vec4 uTexCoordXform;"
+ "mediump float4 uPosXform;"
+ "mediump float4 uTexCoordXform;"
"};"
- "layout(location = 0) in highp vec2 inPosition;"
- "layout(location = 1) out mediump vec2 vTexCoord;"
+ "layout(location = 0) in highp float2 inPosition;"
+ "layout(location = 1) out mediump float2 vTexCoord;"
"// Copy Program VS\n"
"void main() {"
"vTexCoord = inPosition * uTexCoordXform.xy + uTexCoordXform.zw;"
"gl_Position.xy = inPosition * uPosXform.xy + uPosXform.zw;"
- "gl_Position.zw = vec2(0, 1);"
+ "gl_Position.zw = float2(0, 1);"
"}"
);
@@ -66,8 +66,8 @@
"precision mediump float;"
"layout(set = 1, binding = 0) uniform mediump sampler2D uTextureSampler;"
- "layout(location = 1) in mediump vec2 vTexCoord;"
- "layout(location = 0, index = 0) out mediump vec4 fsColorOut;"
+ "layout(location = 1) in mediump float2 vTexCoord;"
+ "layout(location = 0, index = 0) out mediump float4 fsColorOut;"
"// Copy Program FS\n"
"void main() {"
@@ -135,7 +135,7 @@
SkASSERT(fVertexBuffer.get());
fVertexBuffer->updateData(vdata, sizeof(vdata));
- // We use 2 vec4's for uniforms
+ // We use 2 float4's for uniforms
fUniformBuffer.reset(GrVkUniformBuffer::Create(gpu, 8 * sizeof(float)));
SkASSERT(fUniformBuffer.get());
diff --git a/src/gpu/vk/GrVkPipelineState.h b/src/gpu/vk/GrVkPipelineState.h
index 9481aa1..a5d3346 100644
--- a/src/gpu/vk/GrVkPipelineState.h
+++ b/src/gpu/vk/GrVkPipelineState.h
@@ -132,8 +132,8 @@
}
/**
- * Gets a vec4 that adjusts the position from Skia device coords to Vulkans normalized device
- * coords. Assuming the transformed position, pos, is a homogeneous vec3, the vec, v, is
+ * Gets a float4 that adjusts the position from Skia device coords to Vulkans normalized device
+ * coords. Assuming the transformed position, pos, is a homogeneous float3, the vec, v, is
* applied as such:
* pos.x = dot(v.xy, pos.xz)
* pos.y = dot(v.zw, pos.yz)
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index 55fd3d7..f45d795 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -61,7 +61,7 @@
/** Returns the size in bytes taken up in vulkanbuffers for floating point GrSLTypes.
For non floating point type returns 0. Currently this reflects the std140 alignment
- so a mat22 takes up 8 floats. */
+ so a float2x2 takes up 8 floats. */
static inline uint32_t grsltype_to_vk_size(GrSLType type) {
switch(type) {
case kInt_GrSLType: