Restore 'medPrecision' label in ellipse effect FP.
This was removed in http://review.skia.org/377842 to allow compilation
without control-flow analysis. We now support const bools in @if
statements (as of http://review.skia.org/379063) and can relax this
restriction a bit.
Change-Id: If3e8018c599d765075568a90af94fb4e4cb25118
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379797
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/effects/GrEllipseEffect.fp b/src/gpu/effects/GrEllipseEffect.fp
index f2fd9dc..1c9a17f 100644
--- a/src/gpu/effects/GrEllipseEffect.fp
+++ b/src/gpu/effects/GrEllipseEffect.fp
@@ -81,7 +81,8 @@
// that is normalized by the larger radius or 128, whichever is smaller. The scale uniform will
// be scale, 1/scale. The inverse squared radii uniform values are already in this normalized space.
// The center is not.
- @if (!sk_Caps.floatIs32Bits) {
+ const bool medPrecision = !sk_Caps.floatIs32Bits;
+ @if (medPrecision) {
d *= scale.y;
}
float2 Z = d * ellipse.zw;
@@ -90,13 +91,13 @@
// grad_dot is the squared length of the gradient of the implicit.
float grad_dot = 4 * dot(Z, Z);
// Avoid calling inversesqrt on zero.
- @if (!sk_Caps.floatIs32Bits) {
+ @if (medPrecision) {
grad_dot = max(grad_dot, 6.1036e-5);
} else {
grad_dot = max(grad_dot, 1.1755e-38);
}
float approx_dist = implicit * inversesqrt(grad_dot);
- @if (!sk_Caps.floatIs32Bits) {
+ @if (medPrecision) {
approx_dist *= scale.x;
}
diff --git a/src/gpu/effects/generated/GrEllipseEffect.cpp b/src/gpu/effects/generated/GrEllipseEffect.cpp
index 3c10b32..75e6f90 100644
--- a/src/gpu/effects/generated/GrEllipseEffect.cpp
+++ b/src/gpu/effects/generated/GrEllipseEffect.cpp
@@ -41,19 +41,20 @@
R"SkSL(float2 prevCenter;
float2 prevRadii = float2(%f, %f);
float2 d = sk_FragCoord.xy - %s.xy;
-@if (!sk_Caps.floatIs32Bits) {
+const bool medPrecision = !sk_Caps.floatIs32Bits;
+@if (medPrecision) {
d *= %s.y;
}
float2 Z = d * %s.zw;
float implicit = dot(Z, d) - 1.0;
float grad_dot = 4.0 * dot(Z, Z);
-@if (!sk_Caps.floatIs32Bits) {
+@if (medPrecision) {
grad_dot = max(grad_dot, 6.1036000261083245e-05);
} else {
grad_dot = max(grad_dot, 1.1754999560161448e-38);
}
float approx_dist = implicit * inversesqrt(grad_dot);
-@if (!sk_Caps.floatIs32Bits) {
+@if (medPrecision) {
approx_dist *= %s.x;
}
half alpha;
diff --git a/src/sksl/SkSLAnalysis.cpp b/src/sksl/SkSLAnalysis.cpp
index cfc05ed..98d993e 100644
--- a/src/sksl/SkSLAnalysis.cpp
+++ b/src/sksl/SkSLAnalysis.cpp
@@ -947,6 +947,10 @@
case Expression::Kind::kFloatLiteral:
return false;
+ // ... settings can appear in fragment processors; they will resolve when compiled
+ case Expression::Kind::kSetting:
+ return false;
+
// ... a global or local variable qualified as 'const', excluding function parameters.
// ... loop indices as defined in section 4. [constant-index-expression]
case Expression::Kind::kVariableReference: {
@@ -981,7 +985,6 @@
case Expression::Kind::kDefined:
case Expression::Kind::kExternalFunctionReference:
case Expression::Kind::kFunctionReference:
- case Expression::Kind::kSetting:
case Expression::Kind::kTypeReference:
default:
SkDEBUGFAIL("Unexpected expression type");