ccpr: Avoid inline array definitions
MoltenVK currently has an issue translating these to MSL:
https://github.com/KhronosGroup/SPIRV-Cross/issues/558
Bug: skia:
Change-Id: Id210780672f8ec3920f8087bd60a9108e8fb0256
Reviewed-on: https://skia-review.googlesource.com/124525
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/ccpr/GrCCConicShader.cpp b/src/gpu/ccpr/GrCCConicShader.cpp
index 01568de..9b67470 100644
--- a/src/gpu/ccpr/GrCCConicShader.cpp
+++ b/src/gpu/ccpr/GrCCConicShader.cpp
@@ -37,10 +37,11 @@
// De Casteljau's algorithm.
s->codeAppendf("float2 p1w = %s[1]*w;", pts);
s->codeAppend ("float r = 1 / (1 + w);");
- s->codeAppendf("float2 conic_hull[4] = float2[4](%s[0], "
- "(%s[0] + p1w) * r, "
- "(p1w + %s[2]) * r, "
- "%s[2]);", pts, pts, pts, pts);
+ s->codeAppend ("float2 conic_hull[4];");
+ s->codeAppendf("conic_hull[0] = %s[0];", pts);
+ s->codeAppendf("conic_hull[1] = (%s[0] + p1w) * r;", pts);
+ s->codeAppendf("conic_hull[2] = (p1w + %s[2]) * r;", pts);
+ s->codeAppendf("conic_hull[3] = %s[2];", pts);
*outHull4 = "conic_hull";
}
}
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index 4841ed2..55cbcab 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -179,14 +179,14 @@
// N[0] is the normal for the edge we are intersecting from the regular bounding box, pointing
// out of the octagon.
- v->codeAppendf("float2 refpt = float2[2](%s.xy, %s.zw)[sk_VertexID >> 2];",
+ v->codeAppendf("float2 refpt = (0 == sk_VertexID >> 2) ? %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("float2 refpt45 = float2[2](%s.xy, %s.zw)[((sk_VertexID + 1) >> 2) & 1];",
+ v->codeAppendf("float2 refpt45 = (0 == ((sk_VertexID + 1) & (1 << 2))) ? %s.xy : %s.zw;",
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName,
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName);
v->codeAppendf("refpt45 *= float2x2(.5,.5,-.5,.5);"); // transform back to device space.
diff --git a/src/gpu/ccpr/GrCCQuadraticShader.cpp b/src/gpu/ccpr/GrCCQuadraticShader.cpp
index 00e16ce..bd79be3 100644
--- a/src/gpu/ccpr/GrCCQuadraticShader.cpp
+++ b/src/gpu/ccpr/GrCCQuadraticShader.cpp
@@ -28,11 +28,11 @@
// Clip the bezier triangle by the tangent line at maximum height. Quadratics have the nice
// property that maximum height always occurs at T=.5. This is a simple application for
// De Casteljau's algorithm.
- s->codeAppendf("float2 quadratic_hull[4] = float2[4](%s[0], "
- "(%s[0] + %s[1]) * .5, "
- "(%s[1] + %s[2]) * .5, "
- "%s[2]);",
- pts, pts, pts, pts, pts, pts);
+ s->codeAppend ("float2 quadratic_hull[4];");
+ s->codeAppendf("quadratic_hull[0] = %s[0];", pts);
+ s->codeAppendf("quadratic_hull[1] = (%s[0] + %s[1]) * .5;", pts, pts);
+ s->codeAppendf("quadratic_hull[2] = (%s[1] + %s[2]) * .5;", pts, pts);
+ s->codeAppendf("quadratic_hull[3] = %s[2];", pts);
*outHull4 = "quadratic_hull";
}
}