aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-09-18 02:41:08 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-18 03:01:47 +0000
commit27185a9b9756d2f5fcc077c6c2c005259d4ba517 (patch)
tree7b1747160cb0fb3fb69ecd61de24f4310ee8cf7b /src/gpu
parent56fbbd65807d1c4ff63b5233764c6e15cba51bb4 (diff)
Revert "Revert "Revert "Switched highp float to highfloat and mediump float to half."""
This reverts commit 05d5a13fea6246648de7e41358ed338d53c85ea2. Reason for revert: looks like it broke filterfastbounds Original change's description: > Revert "Revert "Switched highp float to highfloat and mediump float to half."" > > This reverts commit 1d816b92bb7cf2258007f3f74ffd143b89f25d01. > > Bug: skia: > Change-Id: I388b5e5e9bf619db48297a80c9a80c039f26c9f1 > Reviewed-on: https://skia-review.googlesource.com/46464 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> TBR=bsalomon@google.com,ethannicholas@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia: Change-Id: Iddf6aef2ab084aa73da7ceebdfc303a1d2b80cde Reviewed-on: https://skia-review.googlesource.com/47441 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp23
-rw-r--r--src/gpu/GrFragmentProcessor.cpp5
-rw-r--r--src/gpu/GrFragmentProcessor.h2
-rw-r--r--src/gpu/GrPathProcessor.cpp15
-rw-r--r--src/gpu/GrShaderVar.cpp2
-rw-r--r--src/gpu/GrShaderVar.h13
-rw-r--r--src/gpu/ccpr/GrCCPRCoverageProcessor.cpp108
-rw-r--r--src/gpu/ccpr/GrCCPRCoverageProcessor.h6
-rw-r--r--src/gpu/ccpr/GrCCPRCubicProcessor.cpp128
-rw-r--r--src/gpu/ccpr/GrCCPRCubicProcessor.h16
-rw-r--r--src/gpu/ccpr/GrCCPRPathProcessor.cpp36
-rw-r--r--src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp78
-rw-r--r--src/gpu/ccpr/GrCCPRQuadraticProcessor.h23
-rw-r--r--src/gpu/ccpr/GrCCPRTriangleProcessor.cpp62
-rw-r--r--src/gpu/ccpr/GrCCPRTriangleProcessor.h10
-rw-r--r--src/gpu/effects/GrAtlasedShaderHelpers.h12
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp103
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp21
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp10
-rw-r--r--src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp12
-rw-r--r--src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp4
-rw-r--r--src/gpu/effects/GrCircleEffect.cpp15
-rw-r--r--src/gpu/effects/GrCircleEffect.fp12
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp8
-rw-r--r--src/gpu/effects/GrConstColorProcessor.cpp2
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.cpp18
-rw-r--r--src/gpu/effects/GrDisableColorXP.cpp2
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp144
-rw-r--r--src/gpu/effects/GrDitherEffect.cpp19
-rw-r--r--src/gpu/effects/GrDitherEffect.fp14
-rw-r--r--src/gpu/effects/GrEllipseEffect.cpp39
-rw-r--r--src/gpu/effects/GrEllipseEffect.fp26
-rw-r--r--src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp18
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp25
-rw-r--r--src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp47
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp8
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp133
-rw-r--r--src/gpu/effects/GrSRGBEffect.cpp18
-rw-r--r--src/gpu/effects/GrShadowGeoProc.cpp10
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp8
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.fp2
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp30
-rw-r--r--src/gpu/effects/GrTextureDomain.h4
-rw-r--r--src/gpu/effects/GrXfermodeFragmentProcessor.cpp4
-rw-r--r--src/gpu/effects/GrYUVEffect.cpp5
-rw-r--r--src/gpu/gl/GrGLGpu.cpp55
-rw-r--r--src/gpu/gl/GrGLProgramDataManager.cpp29
-rw-r--r--src/gpu/gl/GrGLUniformHandler.cpp2
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp3
-rw-r--r--src/gpu/glsl/GrGLSL.cpp56
-rw-r--r--src/gpu/glsl/GrGLSLBlend.cpp82
-rw-r--r--src/gpu/glsl/GrGLSLColorSpaceXformHelper.h4
-rw-r--r--src/gpu/glsl/GrGLSLFragmentProcessor.cpp2
-rw-r--r--src/gpu/glsl/GrGLSLFragmentProcessor.h8
-rw-r--r--src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp26
-rw-r--r--src/gpu/glsl/GrGLSLFragmentShaderBuilder.h15
-rw-r--r--src/gpu/glsl/GrGLSLGeometryProcessor.cpp41
-rw-r--r--src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp5
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp7
-rw-r--r--src/gpu/glsl/GrGLSLShaderBuilder.cpp8
-rw-r--r--src/gpu/glsl/GrGLSLShaderBuilder.h10
-rw-r--r--src/gpu/glsl/GrGLSLUniformHandler.h17
-rw-r--r--src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp20
-rw-r--r--src/gpu/glsl/GrGLSLXferProcessor.cpp26
-rw-r--r--src/gpu/instanced/InstanceProcessor.cpp310
-rw-r--r--src/gpu/ops/GrAAConvexPathRenderer.cpp12
-rw-r--r--src/gpu/ops/GrDashOp.cpp40
-rw-r--r--src/gpu/ops/GrMSAAPathRenderer.cpp4
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp70
-rw-r--r--src/gpu/ops/GrTextureOp.cpp8
-rw-r--r--src/gpu/vk/GrVkCopyManager.cpp18
-rw-r--r--src/gpu/vk/GrVkPipelineStateDataManager.cpp23
-rw-r--r--src/gpu/vk/GrVkUniformHandler.cpp64
-rw-r--r--src/gpu/vk/GrVkVaryingHandler.cpp33
74 files changed, 1147 insertions, 1151 deletions
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 58ae2a90ec..659d333899 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -82,26 +82,26 @@ public:
// Setup pass through color
if (gp.hasVertexColor()) {
- GrGLSLVertToFrag varying(kHalf4_GrSLType);
+ GrGLSLVertToFrag varying(kVec4f_GrSLType);
varyingHandler->addVarying("color", &varying);
// There are several optional steps to process the color. Start with the attribute:
- vertBuilder->codeAppendf("half4 color = %s;", gp.inColor()->fName);
+ vertBuilder->codeAppendf("float4 color = %s;", gp.inColor()->fName);
// Linearize
if (gp.linearizeColor()) {
SkString srgbFuncName;
static const GrShaderVar gSrgbArgs[] = {
- GrShaderVar("x", kHalf_GrSLType),
+ GrShaderVar("x", kFloat_GrSLType),
};
- vertBuilder->emitFunction(kHalf_GrSLType,
+ vertBuilder->emitFunction(kFloat_GrSLType,
"srgb_to_linear",
SK_ARRAY_COUNT(gSrgbArgs),
gSrgbArgs,
"return (x <= 0.04045) ? (x / 12.92) "
": pow((x + 0.055) / 1.055, 2.4);",
&srgbFuncName);
- vertBuilder->codeAppendf("color = half4(%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 @@ public:
// For SkColor, do a red/blue swap and premul
if (gp.fFlags & kColorAttributeIsSkColor_GPFlag) {
- vertBuilder->codeAppend("color = half4(color.a * color.bgr, color.a);");
+ vertBuilder->codeAppend("color = float4(color.a * color.bgr, color.a);");
}
// Do color-correction to destination gamut
@@ -161,18 +161,19 @@ public:
// Setup coverage as pass through
if (gp.hasVertexCoverage()) {
- fragBuilder->codeAppendf("half alpha = 1.0;");
+ fragBuilder->codeAppendf("float alpha = 1.0;");
varyingHandler->addPassThroughAttribute(gp.inCoverage(), "alpha");
- fragBuilder->codeAppendf("%s = half4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
} else if (gp.coverage() == 0xff) {
- fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
} else {
const char* fragCoverage;
fCoverageUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf_GrSLType,
+ kFloat_GrSLType,
+ kDefault_GrSLPrecision,
"Coverage",
&fragCoverage);
- fragBuilder->codeAppendf("%s = half4(%s);", args.fOutputCoverage, fragCoverage);
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, fragCoverage);
}
}
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index ca49da860c..060cde5302 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -177,7 +177,7 @@ private:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, args.fInputColor);
- fragBuilder->codeAppendf("half invAlpha = %s.a <= 0.0 ? 0.0 : 1.0 / %s.a;",
+ fragBuilder->codeAppendf("float invAlpha = %s.a <= 0.0 ? 0.0 : 1.0 / %s.a;",
args.fInputColor, args.fInputColor);
fragBuilder->codeAppendf("%s.rgb *= invAlpha;", args.fOutputColor);
}
@@ -387,7 +387,8 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::OverrideInput(
void emitCode(EmitArgs& args) override {
const char* colorName;
fColorUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf4_GrSLType,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
"Color", &colorName);
this->emitChild(0, colorName, args);
}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 0c3efd1dfb..3237684eb3 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -18,7 +18,7 @@ class GrProcessorKeyBuilder;
class GrShaderCaps;
class GrSwizzle;
-/** Provides custom fragment shader code. Fragment processors receive an input color (half4) 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 24326e94a0..42668bcf16 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -37,13 +37,14 @@ public:
// Setup uniform color
const char* stagedLocalVarName;
fColorUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf4_GrSLType,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
"Color",
&stagedLocalVarName);
fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, stagedLocalVarName);
// setup constant solid coverage
- fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
}
void emitTransforms(GrGLSLVaryingHandler* varyingHandler,
@@ -51,8 +52,8 @@ public:
int i = 0;
while (const GrCoordTransform* coordTransform = transformHandler->nextCoordTransform()) {
GrSLType varyingType =
- coordTransform->getMatrix().hasPerspective() ? kHalf3_GrSLType
- : kHalf2_GrSLType;
+ coordTransform->getMatrix().hasPerspective() ? kVec3f_GrSLType
+ : kVec2f_GrSLType;
SkString strVaryingName;
strVaryingName.printf("TransformedCoord_%d", i);
@@ -88,9 +89,9 @@ public:
}
fInstalledTransforms[t].fCurrentValue = m;
- SkASSERT(fInstalledTransforms[t].fType == kHalf2_GrSLType ||
- fInstalledTransforms[t].fType == kHalf3_GrSLType);
- unsigned components = fInstalledTransforms[t].fType == kHalf2_GrSLType ? 2 : 3;
+ SkASSERT(fInstalledTransforms[t].fType == kVec2f_GrSLType ||
+ fInstalledTransforms[t].fType == kVec3f_GrSLType);
+ unsigned components = fInstalledTransforms[t].fType == kVec2f_GrSLType ? 2 : 3;
pd.setPathFragmentInputTransform(fInstalledTransforms[t].fHandle, components, m);
++t;
}
diff --git a/src/gpu/GrShaderVar.cpp b/src/gpu/GrShaderVar.cpp
index fcc05c0f7a..09e98f82c0 100644
--- a/src/gpu/GrShaderVar.cpp
+++ b/src/gpu/GrShaderVar.cpp
@@ -81,7 +81,7 @@ void GrShaderVar::setIOType(GrIOType ioType) {
}
void GrShaderVar::appendDecl(const GrShaderCaps* shaderCaps, SkString* out) const {
- SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeTemporarilyAcceptsPrecision(fType));
+ SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
SkString layout = fLayoutQualifier;
if (!fLayoutQualifier.isEmpty()) {
out->appendf("layout(%s) ", fLayoutQualifier.c_str());
diff --git a/src/gpu/GrShaderVar.h b/src/gpu/GrShaderVar.h
index 5a379b9d77..7f09f8cbf7 100644
--- a/src/gpu/GrShaderVar.h
+++ b/src/gpu/GrShaderVar.h
@@ -37,12 +37,13 @@ public:
};
/**
- * Defaults to a non-arry half with no type modifier or layout qualifier.
+ * Defaults to a non-arry float with no precision specifier, type modifier, or layout qualifier.
*/
GrShaderVar()
- : fType(kHalf_GrSLType)
+ : fType(kFloat_GrSLType)
, fTypeModifier(kNone_TypeModifier)
, fCount(kNonArray)
+ , fPrecision(kDefault_GrSLPrecision)
, fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
}
@@ -115,7 +116,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
@@ -139,7 +140,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
@@ -164,7 +165,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
@@ -189,7 +190,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
fType = type;
fTypeModifier = typeModifier;
fName = name;
diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
index 4aac3d3d02..079f240231 100644
--- a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
@@ -122,8 +122,8 @@ void PrimitiveProcessor::emitVertexShader(const GrCCPRCoverageProcessor& proc,
const TexelBufferHandle& pointsBuffer,
const char* rtAdjust, GrGPArgs* gpArgs) const {
v->codeAppendf("int packedoffset = %s[%i];", proc.instanceAttrib(), proc.atlasOffsetIdx());
- v->codeAppend ("highfloat2 atlasoffset = highfloat2((packedoffset<<16) >> 16, "
- "packedoffset >> 16);");
+ v->codeAppend ("highp float2 atlasoffset = float2((packedoffset<<16) >> 16, "
+ "packedoffset >> 16);");
this->onEmitVertexShader(proc, v, pointsBuffer, "atlasoffset", rtAdjust, gpArgs);
}
@@ -135,10 +135,12 @@ void PrimitiveProcessor::emitGeometryShader(const GrCCPRCoverageProcessor& proc,
SkString emitVertexFn;
SkSTArray<2, GrShaderVar> emitArgs;
- const char* position = emitArgs.emplace_back("position", kHighFloat2_GrSLType,
- GrShaderVar::kNonArray).c_str();
- const char* coverage = emitArgs.emplace_back("coverage", kHighFloat_GrSLType,
- GrShaderVar::kNonArray).c_str();
+ const char* position = emitArgs.emplace_back("position", kVec2f_GrSLType,
+ GrShaderVar::kNonArray,
+ kHigh_GrSLPrecision).c_str();
+ const char* coverage = emitArgs.emplace_back("coverage", kFloat_GrSLType,
+ GrShaderVar::kNonArray,
+ kHigh_GrSLPrecision).c_str();
g->emitFunction(kVoid_GrSLType, "emitVertex", emitArgs.count(), emitArgs.begin(), [&]() {
SkString fnBody;
this->emitPerVertexGeometryCode(&fnBody, position, coverage, fGeomWind.c_str());
@@ -149,12 +151,12 @@ void PrimitiveProcessor::emitGeometryShader(const GrCCPRCoverageProcessor& proc,
fnBody.appendf("%s = %s * %s;",
fFragCoverageTimesWind.gsOut(), coverage, fGeomWind.c_str());
}
- fnBody.append ("gl_Position = highfloat4(position, 0, 1);");
+ fnBody.append ("gl_Position = float4(position, 0, 1);");
fnBody.append ("EmitVertex();");
return fnBody;
}().c_str(), &emitVertexFn);
- g->codeAppendf("highfloat2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
+ g->codeAppendf("highp float2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
#ifdef SK_DEBUG
if (proc.debugVisualizationsEnabled()) {
@@ -171,7 +173,7 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
SkASSERT(numSides >= 3);
if (!midpoint) {
- g->codeAppendf("highfloat2 midpoint = %s * highfloat%i(%f);",
+ g->codeAppendf("highp float2 midpoint = %s * float%i(%f);",
polygonPts, numSides, 1.0 / numSides);
midpoint = "midpoint";
}
@@ -180,42 +182,42 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
"nextidx = (%s + 1) %% %i;",
wedgeIdx, numSides - 1, numSides, wedgeIdx, numSides);
- g->codeAppendf("highfloat2 self = %s[%s];"
- "int leftidx = %s > 0 ? previdx : nextidx;"
- "int rightidx = %s > 0 ? nextidx : previdx;",
+ 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("highfloat2 right = %s[rightidx];", polygonPts);
+ g->codeAppendf("highp float2 right = %s[rightidx];", polygonPts);
if (3 == numSides) {
// TODO: evaluate perf gains.
- g->codeAppend ("highfloat2 qsr = sign(right - self);");
+ g->codeAppend ("highp float2 qsr = sign(right - self);");
} else {
SkASSERT(4 == numSides);
- g->codeAppendf("highfloat2 diag = %s[(%s + 2) %% 4];", polygonPts, wedgeIdx);
- g->codeAppend ("highfloat2 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("highfloat2 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 ("highfloat2 dr = highfloat2(qsr.y != 0 ? +qsr.y : +qsr.x, "
- "qsr.x != 0 ? -qsr.x : +qsr.y);");
- g->codeAppend ("highfloat2 dr2 = highfloat2(qsr.y != 0 ? +qsr.y : -qsr.x, "
- "qsr.x != 0 ? -qsr.x : -qsr.y);");
- g->codeAppend ("highfloat2 dl = highfloat2(qls.y != 0 ? +qls.y : +qls.x, "
- "qls.x != 0 ? -qls.x : +qls.y);");
+ g->codeAppend ("highp float2 dr = float2(qsr.y != 0 ? +qsr.y : +qsr.x, "
+ "qsr.x != 0 ? -qsr.x : +qsr.y);");
+ g->codeAppend ("highp float2 dr2 = float2(qsr.y != 0 ? +qsr.y : -qsr.x, "
+ "qsr.x != 0 ? -qsr.x : -qsr.y);");
+ 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 ("highfloat2 dr = highfloat2(qsr.y != 0 ? +qsr.y : 1, "
- "qsr.x != 0 ? -qsr.x : 1);");
- g->codeAppend ("highfloat2 dl = (qls == highfloat2(0)) ? dr : "
- "highfloat2(qls.y != 0 ? +qls.y : 1, qls.x != 0 ? -qls.x : 1);");
+ g->codeAppend ("highp float2 dr = float2(qsr.y != 0 ? +qsr.y : 1, "
+ "qsr.x != 0 ? -qsr.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("bool2 dnotequal = notEqual(%s, dl);", dr2);
@@ -228,7 +230,7 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
g->codeAppendf( "%s(self + bloat * dl, 1);", emitVertexFn);
g->codeAppend ("}");
g->codeAppend ("if (all(dnotequal)) {");
- g->codeAppendf( "%s(self + bloat * highfloat2(-dl.y, dl.x), 1);", emitVertexFn);
+ g->codeAppendf( "%s(self + bloat * float2(-dl.y, dl.x), 1);", emitVertexFn);
g->codeAppend ("}");
g->codeAppend ("EndPrimitive();");
@@ -239,18 +241,18 @@ int PrimitiveProcessor::emitEdgeGeometry(GrGLSLGeometryBuilder* g, const char* e
const char* leftPt, const char* rightPt,
const char* distanceEquation) const {
if (!distanceEquation) {
- this->emitEdgeDistanceEquation(g, leftPt, rightPt, "highfloat3 edge_distance_equation");
+ this->emitEdgeDistanceEquation(g, leftPt, rightPt, "highp float3 edge_distance_equation");
distanceEquation = "edge_distance_equation";
}
// qlr is defined in emitEdgeDistanceEquation.
- g->codeAppendf("highfloat2x2 endpts = highfloat2x2(%s - bloat * qlr, %s + bloat * qlr);",
+ g->codeAppendf("highp float2x2 endpts = float2x2(%s - bloat * qlr, %s + bloat * qlr);",
leftPt, rightPt);
- g->codeAppendf("half2 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 ("highfloat2 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;");
@@ -279,25 +281,25 @@ void PrimitiveProcessor::emitEdgeDistanceEquation(GrGLSLGeometryBuilder* g,
const char* leftPt, const char* rightPt,
const char* outputDistanceEquation) const {
// Which quadrant does the vector from left -> right fall into?
- g->codeAppendf("highfloat2 qlr = sign(%s - %s);", rightPt, leftPt);
- g->codeAppend ("highfloat2 d1 = highfloat2(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("highfloat2 n = highfloat2(%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("highfloat2 kk = n * highfloat2x2(%s + bloat * d1, %s - bloat * d1);",
+ 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("highfloat scale = 1 / max(kk[0] - kk[1], 1e-30);");
+ g->codeAppendf("highp float scale = 1 / max(kk[0] - kk[1], 1e-30);");
- g->codeAppendf("%s = half3(-n, kk[1]) * scale;", outputDistanceEquation);
+ g->codeAppendf("%s = float3(-n, kk[1]) * scale;", outputDistanceEquation);
}
int PrimitiveProcessor::emitCornerGeometry(GrGLSLGeometryBuilder* g, const char* emitVertexFn,
const char* pt) const {
- g->codeAppendf("%s(%s + highfloat2(-bloat.x, -bloat.y), 1);", emitVertexFn, pt);
- g->codeAppendf("%s(%s + highfloat2(-bloat.x, +bloat.y), 1);", emitVertexFn, pt);
- g->codeAppendf("%s(%s + highfloat2(+bloat.x, -bloat.y), 1);", emitVertexFn, pt);
- g->codeAppendf("%s(%s + highfloat2(+bloat.x, +bloat.y), 1);", emitVertexFn, pt);
+ g->codeAppendf("%s(%s + float2(-bloat.x, -bloat.y), 1);", emitVertexFn, pt);
+ g->codeAppendf("%s(%s + float2(-bloat.x, +bloat.y), 1);", emitVertexFn, pt);
+ g->codeAppendf("%s(%s + float2(+bloat.x, -bloat.y), 1);", emitVertexFn, pt);
+ g->codeAppendf("%s(%s + float2(+bloat.x, +bloat.y), 1);", emitVertexFn, pt);
g->codeAppend ("EndPrimitive();");
return 4;
@@ -313,17 +315,17 @@ void PrimitiveProcessor::emitCoverage(const GrCCPRCoverageProcessor& proc, GrGLS
f->codeAppendf("%s.a = %s;", outputColor, fFragCoverageTimesWind.fsIn());
break;
case CoverageType::kShader:
- f->codeAppendf("half coverage = 0;");
+ f->codeAppendf("mediump float coverage = 0;");
this->emitShaderCoverage(f, "coverage");
f->codeAppendf("%s.a = coverage * %s;", outputColor, fFragWind.fsIn());
break;
}
- f->codeAppendf("%s = half4(1);", outputCoverage);
+ f->codeAppendf("%s = float4(1);", outputCoverage);
#ifdef SK_DEBUG
if (proc.debugVisualizationsEnabled()) {
- f->codeAppendf("%s = half4(-%s.a, %s.a, 0, 1);", outputColor, outputColor, outputColor);
+ f->codeAppendf("%s = float4(-%s.a, %s.a, 0, 1);", outputColor, outputColor, outputColor);
}
#endif
}
@@ -332,17 +334,17 @@ int PrimitiveProcessor::defineSoftSampleLocations(GrGLSLFragmentBuilder* f,
const char* samplesName) const {
// Standard DX11 sample locations.
#if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS)
- f->defineConstant("highfloat2[8]", samplesName, "highfloat2[8]("
- "highfloat2(+1, -3)/16, highfloat2(-1, +3)/16, highfloat2(+5, +1)/16, highfloat2(-3, -5)/16, "
- "highfloat2(-5, +5)/16, highfloat2(-7, -1)/16, highfloat2(+3, +7)/16, highfloat2(+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("highfloat2[16]", samplesName, "highfloat2[16]("
- "highfloat2(+1, +1)/16, highfloat2(-1, -3)/16, highfloat2(-3, +2)/16, highfloat2(+4, -1)/16, "
- "highfloat2(-5, -2)/16, highfloat2(+2, +5)/16, highfloat2(+5, +3)/16, highfloat2(+3, -5)/16, "
- "highfloat2(-2, +6)/16, highfloat2( 0, -7)/16, highfloat2(-4, -6)/16, highfloat2(-6, +4)/16, "
- "highfloat2(-8, 0)/16, highfloat2(+7, -4)/16, highfloat2(+6, +7)/16, highfloat2(-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 8120136fad..b8032d9ec2 100644
--- a/src/gpu/ccpr/GrCCPRCoverageProcessor.h
+++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.h
@@ -133,9 +133,9 @@ protected:
PrimitiveProcessor(CoverageType coverageType)
: fCoverageType(coverageType)
- , fGeomWind("wind", kHalf_GrSLType, GrShaderVar::kNonArray, kLow_GrSLPrecision)
- , fFragWind(kHalf_GrSLType)
- , fFragCoverageTimesWind(kHalf_GrSLType) {}
+ , fGeomWind("wind", kFloat_GrSLType, GrShaderVar::kNonArray, kLow_GrSLPrecision)
+ , fFragWind(kFloat_GrSLType)
+ , fFragCoverageTimesWind(kFloat_GrSLType) {}
// Called before generating shader code. Subclass should add its custom varyings to the handler
// and update its corresponding internal member variables.
diff --git a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
index fcf2076c1c..0ac4517d5f 100644
--- a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
@@ -16,18 +16,18 @@ void GrCCPRCubicProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor& pro
const TexelBufferHandle& pointsBuffer,
const char* atlasOffset, const char* rtAdjust,
GrGPArgs* gpArgs) const {
- v->codeAppend ("highfloat2 self = ");
+ v->codeAppend ("highp float2 self = ");
v->appendTexelFetch(pointsBuffer,
SkStringPrintf("%s.x + sk_VertexID", proc.instanceAttrib()).c_str());
v->codeAppendf(".xy + %s;", atlasOffset);
- gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "self");
+ 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 ("highfloat area_times_2 = "
- "determinant(highfloat3x3(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.
@@ -46,61 +46,61 @@ void GrCCPRCubicProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdju
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("highfloat4x2 bezierpts = highfloat4x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy, "
- "sk_in[3].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 mid-ish point.
- g->codeAppendf("highfloat2 midpoint = bezierpts * highfloat4(.125, .375, .375, .125);");
+ g->codeAppendf("highp float2 midpoint = bezierpts * float4(.125, .375, .375, .125);");
// Find the cubic's power basis coefficients.
- g->codeAppend ("highfloat2x4 C = highfloat4x4(-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);");
// Find the cubic's inflection function.
- g->codeAppend ("highfloat D3 = +determinant(highfloat2x2(C[0].yz, C[1].yz));");
- g->codeAppend ("highfloat D2 = -determinant(highfloat2x2(C[0].xz, C[1].xz));");
- g->codeAppend ("highfloat D1 = +determinant(highfloat2x2(C));");
+ g->codeAppend ("highp float D3 = +determinant(float2x2(C[0].yz, C[1].yz));");
+ g->codeAppend ("highp float D2 = -determinant(float2x2(C[0].xz, C[1].xz));");
+ g->codeAppend ("highp float D1 = +determinant(float2x2(C));");
// Calculate the KLM matrix.
g->declareGlobal(fKLMMatrix);
- g->codeAppend ("highfloat4 K, L, M;");
- g->codeAppend ("highfloat2 l, m;");
- g->codeAppend ("highfloat discr = 3*D2*D2 - 4*D1*D3;");
+ g->codeAppend ("highp float4 K, L, M;");
+ g->codeAppend ("highp float2 l, m;");
+ g->codeAppend ("highp float discr = 3*D2*D2 - 4*D1*D3;");
if (CubicType::kSerpentine == fCubicType) {
// This math also works out for the "cusp" and "cusp at infinity" cases.
- g->codeAppend ("highfloat q = 3*D2 + sign(D2) * sqrt(max(3*discr, 0));");
- g->codeAppend ("l.ts = normalize(highfloat2(q, 6*D1));");
- g->codeAppend ("m.ts = discr <= 0 ? l.ts : normalize(highfloat2(2*D3, q));");
- g->codeAppend ("K = highfloat4(0, l.s * m.s, -l.t * m.s - m.t * l.s, l.t * m.t);");
- g->codeAppend ("L = highfloat4(-1,3,-3,1) * l.ssst * l.sstt * l.sttt;");
- g->codeAppend ("M = highfloat4(-1,3,-3,1) * m.ssst * m.sstt * m.sttt;");
+ g->codeAppend ("highp float q = 3*D2 + sign(D2) * sqrt(max(3*discr, 0));");
+ g->codeAppend ("l.ts = normalize(float2(q, 6*D1));");
+ g->codeAppend ("m.ts = discr <= 0 ? l.ts : normalize(float2(2*D3, q));");
+ 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 ("highfloat q = D2 + sign(D2) * sqrt(max(-discr, 0));");
- g->codeAppend ("l.ts = normalize(highfloat2(q, 2*D1));");
- g->codeAppend ("m.ts = discr >= 0 ? l.ts : normalize(highfloat2(2 * (D2*D2 - D3*D1), D1*q));");
- g->codeAppend ("highfloat4 lxm = highfloat4(l.s * m.s, l.s * m.t, l.t * m.s, l.t * m.t);");
- g->codeAppend ("K = highfloat4(0, lxm.x, -lxm.y - lxm.z, lxm.w);");
- g->codeAppend ("L = highfloat4(-1,1,-1,1) * l.sstt * (lxm.xyzw + highfloat4(0, 2*lxm.zy, 0));");
- g->codeAppend ("M = highfloat4(-1,1,-1,1) * m.sstt * (lxm.xzyw + highfloat4(0, 2*lxm.yz, 0));");
+ g->codeAppend ("highp float q = D2 + sign(D2) * sqrt(max(-discr, 0));");
+ g->codeAppend ("l.ts = normalize(float2(q, 2*D1));");
+ g->codeAppend ("m.ts = discr >= 0 ? l.ts : normalize(float2(2 * (D2*D2 - D3*D1), D1*q));");
+ g->codeAppend ("highp float4 lxm = float4(l.s * m.s, l.s * m.t, l.t * m.s, l.t * m.t);");
+ g->codeAppend ("K = float4(0, lxm.x, -lxm.y - lxm.z, lxm.w);");
+ g->codeAppend ("L = float4(-1,1,-1,1) * l.sstt * (lxm.xyzw + float4(0, 2*lxm.zy, 0));");
+ g->codeAppend ("M = float4(-1,1,-1,1) * m.sstt * (lxm.xzyw + float4(0, 2*lxm.yz, 0));");
}
- g->codeAppend ("short middlerow = abs(D2) > abs(D1) ? 2 : 1;");
- g->codeAppend ("highfloat3x3 CI = inverse(highfloat3x3(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 * highfloat3x3(K[0], K[middlerow], K[3], "
- "L[0], L[middlerow], L[3], "
- "M[0], M[middlerow], M[3]);", fKLMMatrix.c_str());
+ g->codeAppend ("lowp int middlerow = abs(D2) > abs(D1) ? 2 : 1;");
+ 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("half2 orientation = sign(half3(midpoint, 1) * half2x3(%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 *= highfloat3x3(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;",
@@ -112,9 +112,9 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
// Determine the amount of additional coverage to subtract out for the flat edge (P3 -> P0).
g->declareGlobal(fEdgeDistanceEquation);
- g->codeAppendf("short edgeidx0 = %s > 0 ? 3 : 0;", wind);
- g->codeAppendf("highfloat2 edgept0 = bezierpts[edgeidx0];");
- g->codeAppendf("highfloat2 edgept1 = bezierpts[3 - edgeidx0];");
+ g->codeAppendf("int edgeidx0 = %s > 0 ? 3 : 0;", wind);
+ g->codeAppendf("highp float2 edgept0 = bezierpts[edgeidx0];");
+ g->codeAppendf("highp float2 edgept1 = bezierpts[3 - edgeidx0];");
this->emitEdgeDistanceEquation(g, "edgept0", "edgept1", fEdgeDistanceEquation.c_str());
this->emitCubicGeometry(g, emitVertexFn, wind, rtAdjust);
@@ -123,10 +123,10 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
void GrCCPRCubicProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("highfloat3 klm = highfloat3(%s, 1) * %s;", position, fKLMMatrix.c_str());
- fnBody->appendf("highfloat d = dot(float3(%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 = highfloat4(klm, d);", fKLMD.gsOut());
+ fnBody->appendf("%s = float4(klm, d);", fKLMD.gsOut());
this->onEmitPerVertexGeometryCode(fnBody);
}
@@ -150,10 +150,10 @@ void GrCCPRCubicHullProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) con
void GrCCPRCubicHullProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
const char* outputCoverage) const {
- f->codeAppendf("highfloat k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
+ f->codeAppendf("highp float k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn());
- f->codeAppend ("highfloat f = k*k*k - l*m;");
- f->codeAppendf("highfloat2 grad_f = %s * highfloat2(k, 1);", fGradMatrix.fsIn());
+ f->codeAppend ("highp float f = k*k*k - l*m;");
+ f->codeAppendf("highp float2 grad_f = %s * float2(k, 1);", fGradMatrix.fsIn());
f->codeAppendf("%s = clamp(0.5 - f * inversesqrt(dot(grad_f, grad_f)), 0, 1);", outputCoverage);
f->codeAppendf("%s += min(d, 0);", outputCoverage); // Flat closing edge.
}
@@ -166,7 +166,7 @@ void GrCCPRCubicCornerProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
g->codeAppendf("%s = %s.xy * %s.xz;",
fEdgeDistanceDerivatives.c_str(), fEdgeDistanceEquation.c_str(), rtAdjust);
- g->codeAppendf("highfloat2 corner = bezierpts[sk_InvocationID * 3];");
+ g->codeAppendf("highp float2 corner = bezierpts[sk_InvocationID * 3];");
int numVertices = this->emitCornerGeometry(g, emitVertexFn, "corner");
g->configure(GrGLSLGeometryBuilder::InputType::kLinesAdjacency,
@@ -174,10 +174,10 @@ void GrCCPRCubicCornerProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
}
void GrCCPRCubicCornerProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) const {
- fnBody->appendf("%s = highfloat4(%s[0].x, %s[1].x, %s[2].x, %s.x);",
+ 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 = highfloat4(%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());
@@ -187,28 +187,28 @@ void GrCCPRCubicCornerProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) c
void GrCCPRCubicCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
const char* outputCoverage) const {
- f->codeAppendf("highfloat2x4 grad_klmd = highfloat2x4(%s, %s);",
+ f->codeAppendf("highp float2x4 grad_klmd = float2x4(%s, %s);",
fdKLMDdx.fsIn(), fdKLMDdy.fsIn());
// Erase what the previous hull shader wrote. We don't worry about the two corners falling on
// the same pixel because those cases should have been weeded out by this point.
- f->codeAppendf("highfloat k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
+ f->codeAppendf("highp float k = %s.x, l = %s.y, m = %s.z, d = %s.w;",
fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn(), fKLMD.fsIn());
- f->codeAppend ("highfloat f = k*k*k - l*m;");
- f->codeAppend ("highfloat2 grad_f = highfloat3(3*k*k, -m, -l) * highfloat2x3(grad_klmd);");
+ f->codeAppend ("highp float f = k*k*k - l*m;");
+ f->codeAppend ("highp float2 grad_f = float3(3*k*k, -m, -l) * float2x3(grad_klmd);");
f->codeAppendf("%s = -clamp(0.5 - f * inversesqrt(dot(grad_f, grad_f)), 0, 1);",
outputCoverage);
f->codeAppendf("%s -= d;", outputCoverage);
// Use software msaa to estimate actual coverage at the corner pixels.
const int sampleCount = this->defineSoftSampleLocations(f, "samples");
- f->codeAppendf("highfloat4 klmd_center = float4(%s.xyz, %s.w + 0.5);",
+ f->codeAppendf("highp float4 klmd_center = float4(%s.xyz, %s.w + 0.5);",
fKLMD.fsIn(), fKLMD.fsIn());
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
- f->codeAppend ( "highfloat4 klmd = grad_klmd * samples[i] + klmd_center;");
- f->codeAppend ( "half f = klmd.y * klmd.z - klmd.x * klmd.x * klmd.x;");
- f->codeAppendf( "%s += all(greaterThan(half4(f, klmd.y, klmd.z, klmd.w), "
- "half4(0))) ? %f : 0;",
+ f->codeAppend ( "highp float4 klmd = grad_klmd * samples[i] + klmd_center;");
+ f->codeAppend ( "lowp float f = klmd.y * klmd.z - klmd.x * klmd.x * klmd.x;");
+ f->codeAppendf( "%s += all(greaterThan(float4(f, klmd.y, klmd.z, klmd.w), "
+ "float4(0))) ? %f : 0;",
outputCoverage, 1.0 / sampleCount);
f->codeAppend ("}");
}
diff --git a/src/gpu/ccpr/GrCCPRCubicProcessor.h b/src/gpu/ccpr/GrCCPRCubicProcessor.h
index 20ca3f2547..cfee7bfac1 100644
--- a/src/gpu/ccpr/GrCCPRCubicProcessor.h
+++ b/src/gpu/ccpr/GrCCPRCubicProcessor.h
@@ -33,12 +33,12 @@ public:
GrCCPRCubicProcessor(CubicType cubicType)
: INHERITED(CoverageType::kShader)
, fCubicType(cubicType)
- , fKLMMatrix("klm_matrix", kHighFloat3x3_GrSLType, GrShaderVar::kNonArray,
+ , fKLMMatrix("klm_matrix", kMat33f_GrSLType, GrShaderVar::kNonArray,
kHigh_GrSLPrecision)
- , fKLMDerivatives("klm_derivatives", kHighFloat2_GrSLType, 3, kHigh_GrSLPrecision)
- , fEdgeDistanceEquation("edge_distance_equation", kHighFloat3_GrSLType,
+ , fKLMDerivatives("klm_derivatives", kVec2f_GrSLType, 3, kHigh_GrSLPrecision)
+ , fEdgeDistanceEquation("edge_distance_equation", kVec3f_GrSLType,
GrShaderVar::kNonArray, kHigh_GrSLPrecision)
- , fKLMD(kHighFloat4_GrSLType) {}
+ , fKLMD(kVec4f_GrSLType) {}
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
varyingHandler->addVarying("klmd", &fKLMD, kHigh_GrSLPrecision);
@@ -71,7 +71,7 @@ class GrCCPRCubicHullProcessor : public GrCCPRCubicProcessor {
public:
GrCCPRCubicHullProcessor(CubicType cubicType)
: INHERITED(cubicType)
- , fGradMatrix(kHighFloat2x2_GrSLType) {}
+ , fGradMatrix(kMat22f_GrSLType) {}
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
this->INHERITED::resetVaryings(varyingHandler);
@@ -93,10 +93,10 @@ class GrCCPRCubicCornerProcessor : public GrCCPRCubicProcessor {
public:
GrCCPRCubicCornerProcessor(CubicType cubicType)
: INHERITED(cubicType)
- , fEdgeDistanceDerivatives("edge_distance_derivatives", kHighFloat2_GrSLType,
+ , fEdgeDistanceDerivatives("edge_distance_derivatives", kVec2f_GrSLType,
GrShaderVar::kNonArray, kHigh_GrSLPrecision)
- , fdKLMDdx(kHighFloat4_GrSLType)
- , fdKLMDdy(kHighFloat4_GrSLType) {}
+ , fdKLMDdx(kVec4f_GrSLType)
+ , fdKLMDdy(kVec4f_GrSLType) {}
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
this->INHERITED::resetVaryings(varyingHandler);
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
index bb0ecc9e22..429767d3d0 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
@@ -121,12 +121,12 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
const char* atlasAdjust;
fAtlasAdjustUniform = uniHandler->addUniform(
kVertex_GrShaderFlag,
- kHighFloat2_GrSLType, "atlas_adjust", &atlasAdjust);
+ kVec2f_GrSLType, kHigh_GrSLPrecision, "atlas_adjust", &atlasAdjust);
varyingHandler->emitAttributes(proc);
- GrGLSLVertToFrag texcoord(kHighFloat2_GrSLType);
- GrGLSLVertToFrag color(kHalf4_GrSLType);
+ GrGLSLVertToFrag texcoord(kVec2f_GrSLType);
+ GrGLSLVertToFrag color(kVec4f_GrSLType);
varyingHandler->addVarying("texcoord", &texcoord, kHigh_GrSLPrecision);
varyingHandler->addFlatPassThroughAttribute(&proc.getInstanceAttrib(InstanceAttribs::kColor),
args.fOutputColor, kLow_GrSLPrecision);
@@ -137,41 +137,41 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// 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("highfloat2x2 N = highfloat2x2(%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("highfloat2 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("highfloat2 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 *= highfloat2x2(.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 ("highfloat2 K = highfloat2(dot(N[0], refpt), dot(N[1], refpt45));");
- v->codeAppendf("highfloat2 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(kHighFloat2_GrSLType, "octocoord");
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "octocoord");
// Convert to atlas coordinates in order to do our texture lookup.
- v->codeAppendf("highfloat2 atlascoord = octocoord + highfloat2(%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 = highfloat2(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("highfloat2 pathcoord = inverse(highfloat2x2(%s)) * (octocoord - %s);",
+ v->codeAppendf("highp float2 pathcoord = inverse(float2x2(%s)) * (octocoord - %s);",
proc.getInstanceAttrib(InstanceAttribs::kViewMatrix).fName,
proc.getInstanceAttrib(InstanceAttribs::kViewTranslate).fName);
@@ -181,16 +181,16 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// Fragment shader.
GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
- f->codeAppend ("half coverage_count = ");
- f->appendTextureLookup(args.fTexSamplers[0], texcoord.fsIn(), kHighFloat2_GrSLType);
+ f->codeAppend ("mediump float coverage_count = ");
+ f->appendTextureLookup(args.fTexSamplers[0], texcoord.fsIn(), kVec2f_GrSLType);
f->codeAppend (".a;");
if (SkPath::kWinding_FillType == proc.fillType()) {
- f->codeAppendf("%s = half4(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 ("half t = mod(abs(coverage_count), 2);");
- f->codeAppendf("%s = half4(1 - abs(t - 1));", args.fOutputCoverage);
+ f->codeAppend ("mediump float t = mod(abs(coverage_count), 2);");
+ 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 ced5be1f70..73d0d1e3d0 100644
--- a/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
@@ -16,18 +16,18 @@ void GrCCPRQuadraticProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
const TexelBufferHandle& pointsBuffer,
const char* atlasOffset, const char* rtAdjust,
GrGPArgs* gpArgs) const {
- v->codeAppend ("highfloat2 self = ");
+ v->codeAppend ("highp float2 self = ");
v->appendTexelFetch(pointsBuffer,
SkStringPrintf("%s.x + sk_VertexID", proc.instanceAttrib()).c_str());
v->codeAppendf(".xy + %s;", atlasOffset);
- gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "self");
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "self");
}
void GrCCPRQuadraticProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdjust,
const char* outputWind) const {
// We will define bezierpts in onEmitGeometryShader.
- g->codeAppend ("highfloat area_times_2 = "
- "determinant(highfloat2x2(bezierpts[1] - 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)) {",
@@ -46,26 +46,26 @@ void GrCCPRQuadraticProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
const char* emitVertexFn, const char* wind,
const char* rtAdjust) const {
// Prepend bezierpts at the start of the shader.
- g->codePrependf("highfloat3x2 bezierpts = highfloat3x2(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 = highfloat3x3(0.0, 0, 1, "
- "0.5, 0, 1, "
- "1.0, 1, 1) * "
- "inverse(highfloat3x3(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 = highfloat2x2(%s) * highfloat2x2(%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);
g->declareGlobal(fEdgeDistanceEquation);
- g->codeAppendf("highfloat2 edgept0 = bezierpts[%s > 0 ? 2 : 0];", wind);
- g->codeAppendf("highfloat2 edgept1 = bezierpts[%s > 0 ? 0 : 2];", wind);
+ g->codeAppendf("highp float2 edgept0 = bezierpts[%s > 0 ? 2 : 0];", wind);
+ g->codeAppendf("highp float2 edgept1 = bezierpts[%s > 0 ? 0 : 2];", wind);
this->emitEdgeDistanceEquation(g, "edgept0", "edgept1", fEdgeDistanceEquation.c_str());
this->emitQuadraticGeometry(g, emitVertexFn, rtAdjust);
@@ -74,7 +74,7 @@ void GrCCPRQuadraticProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
void GrCCPRQuadraticProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("%s.xy = (%s * highfloat3(%s, 1)).xy;",
+ fnBody->appendf("%s.xy = (%s * float3(%s, 1)).xy;",
fXYD.gsOut(), fCanonicalMatrix.c_str(), position);
fnBody->appendf("%s.z = dot(%s.xy, %s) + %s.z;",
fXYD.gsOut(), fEdgeDistanceEquation.c_str(), position,
@@ -87,18 +87,18 @@ void GrCCPRQuadraticHullProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder*
const char* /*rtAdjust*/) const {
// Find the t value whose tangent is halfway between the tangents at the endpionts.
// (We defined bezierpts in onEmitGeometryShader.)
- g->codeAppend ("highfloat2 tan0 = bezierpts[1] - bezierpts[0];");
- g->codeAppend ("highfloat2 tan1 = bezierpts[2] - bezierpts[1];");
- g->codeAppend ("highfloat2 midnorm = normalize(tan0) - normalize(tan1);");
- g->codeAppend ("highfloat2 T = midnorm * highfloat2x2(tan0 - tan1, tan0);");
- g->codeAppend ("highfloat t = clamp(T.t / T.s, 0, 1);"); // T.s=0 is weeded out by this point.
+ g->codeAppend ("highp float2 tan0 = bezierpts[1] - bezierpts[0];");
+ g->codeAppend ("highp float2 tan1 = bezierpts[2] - bezierpts[1];");
+ g->codeAppend ("highp float2 midnorm = normalize(tan0) - normalize(tan1);");
+ g->codeAppend ("highp float2 T = midnorm * float2x2(tan0 - tan1, tan0);");
+ g->codeAppend ("highp float t = clamp(T.t / T.s, 0, 1);"); // T.s=0 is weeded out by this point.
// Clip the bezier triangle by the tangent at our new t value. This is a simple application for
// De Casteljau's algorithm.
- g->codeAppendf("highfloat4x2 quadratic_hull = highfloat4x2(bezierpts[0], "
- "bezierpts[0] + tan0 * t, "
- "bezierpts[1] + tan1 * t, "
- "bezierpts[2]);");
+ g->codeAppendf("highp float4x2 quadratic_hull = float4x2(bezierpts[0], "
+ "bezierpts[0] + tan0 * t, "
+ "bezierpts[1] + tan1 * t, "
+ "bezierpts[2]);");
int maxVerts = this->emitHullGeometry(g, emitVertexFn, "quadratic_hull", 4, "sk_InvocationID");
@@ -108,13 +108,13 @@ void GrCCPRQuadraticHullProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder*
}
void GrCCPRQuadraticHullProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) const {
- fnBody->appendf("%s = highfloat2(2 * %s.x, -1) * %s;",
+ fnBody->appendf("%s = float2(2 * %s.x, -1) * %s;",
fGradXY.gsOut(), fXYD.gsOut(), fCanonicalDerivatives.c_str());
}
void GrCCPRQuadraticHullProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
const char* outputCoverage) const {
- f->codeAppendf("highfloat d = (%s.x * %s.x - %s.y) * inversesqrt(dot(%s, %s));",
+ f->codeAppendf("highp float d = (%s.x * %s.x - %s.y) * inversesqrt(dot(%s, %s));",
fXYD.fsIn(), fXYD.fsIn(), fXYD.fsIn(), fGradXY.fsIn(), fGradXY.fsIn());
f->codeAppendf("%s = clamp(0.5 - d, 0, 1);", outputCoverage);
f->codeAppendf("%s += min(%s.z, 0);", outputCoverage, fXYD.fsIn()); // Flat closing edge.
@@ -127,7 +127,7 @@ void GrCCPRQuadraticCornerProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder
g->codeAppendf("%s = %s.xy * %s.xz;",
fEdgeDistanceDerivatives.c_str(), fEdgeDistanceEquation.c_str(), rtAdjust);
- g->codeAppendf("highfloat2 corner = bezierpts[sk_InvocationID * 2];");
+ g->codeAppendf("highp float2 corner = bezierpts[sk_InvocationID * 2];");
int numVertices = this->emitCornerGeometry(g, emitVertexFn, "corner");
g->configure(GrGLSLGeometryBuilder::InputType::kTriangles,
@@ -135,35 +135,35 @@ void GrCCPRQuadraticCornerProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder
}
void GrCCPRQuadraticCornerProcessor::onEmitPerVertexGeometryCode(SkString* fnBody) const {
- fnBody->appendf("%s = highfloat3(%s[0].x, %s[0].y, %s.x);",
+ fnBody->appendf("%s = float3(%s[0].x, %s[0].y, %s.x);",
fdXYDdx.gsOut(), fCanonicalDerivatives.c_str(), fCanonicalDerivatives.c_str(),
fEdgeDistanceDerivatives.c_str());
- fnBody->appendf("%s = highfloat3(%s[1].x, %s[1].y, %s.y);",
+ fnBody->appendf("%s = float3(%s[1].x, %s[1].y, %s.y);",
fdXYDdy.gsOut(), fCanonicalDerivatives.c_str(), fCanonicalDerivatives.c_str(),
fEdgeDistanceDerivatives.c_str());
}
void GrCCPRQuadraticCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
const char* outputCoverage) const {
- f->codeAppendf("highfloat x = %s.x, y = %s.y, d = %s.z;",
+ f->codeAppendf("highp float x = %s.x, y = %s.y, d = %s.z;",
fXYD.fsIn(), fXYD.fsIn(), fXYD.fsIn());
- f->codeAppendf("highfloat2x3 grad_xyd = highfloat2x3(%s, %s);", fdXYDdx.fsIn(), fdXYDdy.fsIn());
+ f->codeAppendf("highp float2x3 grad_xyd = float2x3(%s, %s);", fdXYDdx.fsIn(), fdXYDdy.fsIn());
// Erase what the previous hull shader wrote. We don't worry about the two corners falling on
// the same pixel because those cases should have been weeded out by this point.
- f->codeAppend ("highfloat f = x*x - y;");
- f->codeAppend ("highfloat2 grad_f = highfloat2(2*x, -1) * highfloat2x2(grad_xyd);");
+ f->codeAppend ("highp float f = x*x - y;");
+ f->codeAppend ("highp float2 grad_f = float2(2*x, -1) * float2x2(grad_xyd);");
f->codeAppendf("%s = -(0.5 - f * inversesqrt(dot(grad_f, grad_f)));", outputCoverage);
f->codeAppendf("%s -= d;", outputCoverage);
// Use software msaa to approximate coverage at the corner pixels.
int sampleCount = this->defineSoftSampleLocations(f, "samples");
- f->codeAppendf("highfloat3 xyd_center = highfloat3(%s.xy, %s.z + 0.5);",
+ f->codeAppendf("highp float3 xyd_center = float3(%s.xy, %s.z + 0.5);",
fXYD.fsIn(), fXYD.fsIn());
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
- f->codeAppend ( "highfloat3 xyd = grad_xyd * samples[i] + xyd_center;");
- f->codeAppend ( "half f = xyd.y - xyd.x * xyd.x;"); // f > 0 -> inside curve.
- f->codeAppendf( "%s += all(greaterThan(highfloat2(f,xyd.z), highfloat2(0))) ? %f : 0;",
+ f->codeAppend ( "highp float3 xyd = grad_xyd * samples[i] + xyd_center;");
+ f->codeAppend ( "lowp float f = xyd.y - xyd.x * xyd.x;"); // f > 0 -> inside curve.
+ f->codeAppendf( "%s += all(greaterThan(float2(f,xyd.z), float2(0))) ? %f : 0;",
outputCoverage, 1.0 / sampleCount);
f->codeAppendf("}");
}
diff --git a/src/gpu/ccpr/GrCCPRQuadraticProcessor.h b/src/gpu/ccpr/GrCCPRQuadraticProcessor.h
index 80237b62b4..85be23e962 100644
--- a/src/gpu/ccpr/GrCCPRQuadraticProcessor.h
+++ b/src/gpu/ccpr/GrCCPRQuadraticProcessor.h
@@ -24,12 +24,13 @@ class GrCCPRQuadraticProcessor : public GrCCPRCoverageProcessor::PrimitiveProces
public:
GrCCPRQuadraticProcessor()
: INHERITED(CoverageType::kShader)
- , fCanonicalMatrix("canonical_matrix", kHighFloat3x3_GrSLType, GrShaderVar::kNonArray)
- , fCanonicalDerivatives("canonical_derivatives", kHighFloat2x2_GrSLType,
- GrShaderVar::kNonArray)
- , fEdgeDistanceEquation("edge_distance_equation", kHighFloat3_GrSLType,
- GrShaderVar::kNonArray)
- , fXYD(kHighFloat3_GrSLType) {}
+ , fCanonicalMatrix("canonical_matrix", kMat33f_GrSLType, GrShaderVar::kNonArray,
+ kHigh_GrSLPrecision)
+ , fCanonicalDerivatives("canonical_derivatives", kMat22f_GrSLType,
+ GrShaderVar::kNonArray, kHigh_GrSLPrecision)
+ , fEdgeDistanceEquation("edge_distance_equation", kVec3f_GrSLType,
+ GrShaderVar::kNonArray, kHigh_GrSLPrecision)
+ , fXYD(kVec3f_GrSLType) {}
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
varyingHandler->addVarying("xyd", &fXYD, kHigh_GrSLPrecision);
@@ -66,7 +67,7 @@ protected:
class GrCCPRQuadraticHullProcessor : public GrCCPRQuadraticProcessor {
public:
GrCCPRQuadraticHullProcessor()
- : fGradXY(kHighFloat2_GrSLType) {}
+ : fGradXY(kVec2f_GrSLType) {}
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
this->INHERITED::resetVaryings(varyingHandler);
@@ -90,10 +91,10 @@ private:
class GrCCPRQuadraticCornerProcessor : public GrCCPRQuadraticProcessor {
public:
GrCCPRQuadraticCornerProcessor()
- : fEdgeDistanceDerivatives("edge_distance_derivatives", kHighFloat2_GrSLType,
- GrShaderVar::kNonArray)
- , fdXYDdx(kHighFloat3_GrSLType)
- , fdXYDdy(kHighFloat3_GrSLType) {}
+ : fEdgeDistanceDerivatives("edge_distance_derivatives", kVec2f_GrSLType,
+ GrShaderVar::kNonArray, kHigh_GrSLPrecision)
+ , fdXYDdx(kVec3f_GrSLType)
+ , fdXYDdy(kVec3f_GrSLType) {}
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
this->INHERITED::resetVaryings(varyingHandler);
diff --git a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
index ee25851497..bb2ad1b4ba 100644
--- a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
@@ -16,16 +16,16 @@ void GrCCPRTriangleProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
const TexelBufferHandle& pointsBuffer,
const char* atlasOffset, const char* rtAdjust,
GrGPArgs* gpArgs) const {
- v->codeAppend ("highfloat2 self = ");
+ v->codeAppend ("highp float2 self = ");
v->appendTexelFetch(pointsBuffer,
SkStringPrintf("%s[sk_VertexID]", proc.instanceAttrib()).c_str());
v->codeAppendf(".xy + %s;", atlasOffset);
- gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "self");
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "self");
}
void GrCCPRTriangleProcessor::defineInputVertices(GrGLSLGeometryBuilder* g) const {
// Prepend in_vertices at the start of the shader.
- g->codePrependf("highfloat3x2 in_vertices = highfloat3x2(sk_in[0].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);");
}
@@ -33,8 +33,8 @@ void GrCCPRTriangleProcessor::defineInputVertices(GrGLSLGeometryBuilder* g) cons
void GrCCPRTriangleProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* /*rtAdjust*/,
const char* outputWind) const {
// We will define in_vertices in defineInputVertices.
- g->codeAppendf("%s = sign(determinant(highfloat2x2(in_vertices[1] - in_vertices[0], "
- "in_vertices[2] - in_vertices[0])));",
+ g->codeAppendf("%s = sign(determinant(float2x2(in_vertices[1] - in_vertices[0], "
+ "in_vertices[2] - in_vertices[0])));",
outputWind);
}
@@ -53,8 +53,8 @@ void GrCCPRTriangleHullAndEdgeProcessor::onEmitGeometryShader(GrGLSLGeometryBuil
if (GeometryType::kHulls != fGeometryType) {
g->codeAppend ("int edgeidx0 = sk_InvocationID, "
"edgeidx1 = (edgeidx0 + 1) % 3;");
- g->codeAppendf("highfloat2 edgept0 = in_vertices[%s > 0 ? edgeidx0 : edgeidx1];", wind);
- g->codeAppendf("highfloat2 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");
}
@@ -73,15 +73,15 @@ void GrCCPRTriangleCornerProcessor::onEmitVertexShader(const GrCCPRCoverageProce
this->INHERITED::onEmitVertexShader(proc, v, pointsBuffer, atlasOffset, rtAdjust, gpArgs);
// Fetch and transform the next point in the triangle.
- v->codeAppend ("highfloat2 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 ("highfloat2 n = highfloat2(next.y - self.y, self.x - next.x);");
- v->codeAppendf("highfloat2 d = n * highfloat2x2(self + %f * sign(n), "
+ 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);
@@ -98,7 +98,7 @@ void GrCCPRTriangleCornerProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder*
const char* rtAdjust) const {
this->defineInputVertices(g);
- g->codeAppend ("highfloat2 self = in_vertices[sk_InvocationID];");
+ g->codeAppend ("highp float2 self = in_vertices[sk_InvocationID];");
int numVertices = this->emitCornerGeometry(g, emitVertexFn, "self");
g->configure(GrGLSLGeometryBuilder::InputType::kTriangles,
@@ -114,7 +114,7 @@ void GrCCPRTriangleCornerProcessor::emitPerVertexGeometryCode(SkString* fnBody,
fNeighbors.gsOut(), fDevCoord.gsIn());
fnBody->appendf("%s.zw = %s[(sk_InvocationID + 2) %% 3];",
fNeighbors.gsOut(), fDevCoord.gsIn());
- fnBody->appendf("%s = highfloat3x3(%s[(sk_InvocationID + 2) %% 3], "
+ fnBody->appendf("%s = float3x3(%s[(sk_InvocationID + 2) %% 3], "
"%s[sk_InvocationID], "
"%s[(sk_InvocationID + 1) %% 3]) * %s;",
fEdgeDistances.gsOut(), fEdgeDistance.gsIn(), fEdgeDistance.gsIn(),
@@ -129,28 +129,32 @@ void GrCCPRTriangleCornerProcessor::emitPerVertexGeometryCode(SkString* fnBody,
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("highfloat2 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", kHighFloat4_GrSLType, GrShaderVar::kNonArray);
+ GrShaderVar samples("samples", kVec4f_GrSLType, GrShaderVar::kNonArray,
+ kHigh_GrSLPrecision);
f->declareGlobal(samples);
- f->codeAppendf("%s = fragcoord.y + highfloat4(-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", kHighFloat4_GrSLType, GrShaderVar::kNonArray);
+ GrShaderVar leftedge("leftedge", kVec4f_GrSLType, GrShaderVar::kNonArray,
+ kHigh_GrSLPrecision);
f->declareGlobal(leftedge);
- f->codeAppendf("%s = highfloat4(fragcoord.x - 0.5);", leftedge.c_str());
+ f->codeAppendf("%s = float4(fragcoord.x - 0.5);", leftedge.c_str());
- GrShaderVar rightedge("rightedge", kHighFloat4_GrSLType, GrShaderVar::kNonArray);
+ GrShaderVar rightedge("rightedge", kVec4f_GrSLType, GrShaderVar::kNonArray,
+ kHigh_GrSLPrecision);
f->declareGlobal(rightedge);
- f->codeAppendf("%s = highfloat4(fragcoord.x + 0.5);", rightedge.c_str());
+ f->codeAppendf("%s = float4(fragcoord.x + 0.5);", rightedge.c_str());
SkString sampleEdgeFn;
- GrShaderVar edgeArg("edge_distance", kHighFloat3_GrSLType, GrShaderVar::kNonArray);
+ GrShaderVar edgeArg("edge_distance", kVec3f_GrSLType, GrShaderVar::kNonArray,
+ kHigh_GrSLPrecision);
f->emitFunction(kVoid_GrSLType, "sampleEdge", 1, &edgeArg, [&]() {
SkString b;
- b.appendf("highfloat m = abs(%s.x) < 1e-3 ? 1e18 : -1 / %s.x;",
+ b.appendf("highp float m = abs(%s.x) < 1e-3 ? 1e18 : -1 / %s.x;",
edgeArg.c_str(), edgeArg.c_str());
- b.appendf("highfloat4 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());
@@ -162,10 +166,10 @@ void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
}().c_str(), &sampleEdgeFn);
// See if the previous neighbor already handled this pixel.
- f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.zw), highfloat2(%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), highfloat2(%f)))) {",
+ f->codeAppendf( "if (%s != 0 || !all(lessThan(abs(fragcoord - %s.xy), float2(%f)))) {",
fCornerIdx.fsIn(), fNeighbors.fsIn(), kAABloatRadius);
f->codeAppend ( "discard;");
f->codeAppend ( "}");
@@ -173,7 +177,7 @@ void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
// 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(highfloat3(fragcoord, 1) * highfloat2x3(%s), highfloat2(1));",
+ f->codeAppendf("%s = dot(float3(fragcoord, 1) * float2x3(%s), float2(1));",
outputCoverage, fEdgeDistances.fsIn());
// Sample the two edges at this corner.
@@ -181,15 +185,15 @@ void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
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), highfloat2(%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], highfloat3(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("highfloat4 widths = max(%s - %s, 0);", rightedge.c_str(), leftedge.c_str());
- f->codeAppendf("%s += dot(widths, highfloat4(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/ccpr/GrCCPRTriangleProcessor.h b/src/gpu/ccpr/GrCCPRTriangleProcessor.h
index 9ac76521bf..1e52d51a45 100644
--- a/src/gpu/ccpr/GrCCPRTriangleProcessor.h
+++ b/src/gpu/ccpr/GrCCPRTriangleProcessor.h
@@ -72,11 +72,11 @@ class GrCCPRTriangleCornerProcessor : public GrCCPRTriangleProcessor {
public:
GrCCPRTriangleCornerProcessor()
: INHERITED(CoverageType::kShader)
- , fEdgeDistance(kHighFloat3_GrSLType)
- , fDevCoord(kHighFloat2_GrSLType)
- , fNeighbors(kHighFloat4_GrSLType)
- , fEdgeDistances(kHighFloat3x3_GrSLType)
- , fCornerIdx(kShort_GrSLType) {}
+ , fEdgeDistance(kVec3f_GrSLType)
+ , fDevCoord(kVec2f_GrSLType)
+ , fNeighbors(kVec4f_GrSLType)
+ , fEdgeDistances(kMat33f_GrSLType)
+ , fCornerIdx(kInt_GrSLType) {}
void resetVaryings(GrGLSLVaryingHandler* varyingHandler) override {
this->INHERITED::resetVaryings(varyingHandler);
diff --git a/src/gpu/effects/GrAtlasedShaderHelpers.h b/src/gpu/effects/GrAtlasedShaderHelpers.h
index b0704954d3..67f2c242c2 100644
--- a/src/gpu/effects/GrAtlasedShaderHelpers.h
+++ b/src/gpu/effects/GrAtlasedShaderHelpers.h
@@ -22,11 +22,11 @@ static void append_index_uv_varyings(GrGLSLPrimitiveProcessor::EmitArgs& args,
// This extracts the texture index and texel coordinates from the same variable
// Packing structure: texel coordinates are multiplied by 2 (or shifted left 1)
// texture index is stored as lower bits of both x and y
- args.fVertBuilder->codeAppendf("half2 indexTexCoords = half2(%s.x, %s.y);",
+ args.fVertBuilder->codeAppendf("float2 indexTexCoords = float2(%s.x, %s.y);",
inTexCoordsName, inTexCoordsName);
- args.fVertBuilder->codeAppend("half2 intCoords = floor(0.5*indexTexCoords);");
- args.fVertBuilder->codeAppend("half2 diff = indexTexCoords - 2.0*intCoords;");
- args.fVertBuilder->codeAppend("half texIdx = 2.0*diff.x + diff.y;");
+ args.fVertBuilder->codeAppend("float2 intCoords = floor(0.5*indexTexCoords);");
+ args.fVertBuilder->codeAppend("float2 diff = indexTexCoords - 2.0*intCoords;");
+ args.fVertBuilder->codeAppend("float texIdx = 2.0*diff.x + diff.y;");
// Multiply by 1/atlasSize to get normalized texture coordinates
args.fVaryingHandler->addVarying("TextureCoords", uv, kHigh_GrSLPrecision);
@@ -51,11 +51,11 @@ static void append_multitexture_lookup(GrGLSLPrimitiveProcessor::EmitArgs& args,
args.fFragBuilder->codeAppendf("if (%s == 0) ", texIdx.fsIn());
}
args.fFragBuilder->codeAppendf("{ %s = ", colorName);
- args.fFragBuilder->appendTextureLookup(args.fTexSamplers[0], coordName, kHighFloat2_GrSLType);
+ args.fFragBuilder->appendTextureLookup(args.fTexSamplers[0], coordName, kVec2f_GrSLType);
args.fFragBuilder->codeAppend("; }");
for (int i = 1; i < numTextureSamplers; ++i) {
args.fFragBuilder->codeAppendf("else if (%s == %d) { %s =", texIdx.fsIn(), i, colorName);
- args.fFragBuilder->appendTextureLookup(args.fTexSamplers[i], coordName, kHighFloat2_GrSLType);
+ args.fFragBuilder->appendTextureLookup(args.fTexSamplers[i], coordName, kVec2f_GrSLType);
args.fFragBuilder->codeAppend("; }");
}
}
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 5848888208..aa9a509887 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -77,7 +77,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// emit attributes
varyingHandler->emitAttributes(gp);
- GrGLSLVertToFrag v(kHighFloat4_GrSLType);
+ GrGLSLVertToFrag v(kVec4f_GrSLType);
varyingHandler->addVarying("ConicCoeffs", &v, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
@@ -102,18 +102,26 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
gp.localMatrix(),
args.fFPCoordTransformHandler);
- // TODO: we should check on the number of bits float and half provide and use the smallest one
- // that suffices. Additionally we should assert that the upstream code only lets us get here if
- // either float or half provides the required number of bits.
+ // TODO: this precision check should actually be a check on the number of bits
+ // high and medium provide and the selection of the lowest level that suffices.
+ // Additionally we should assert that the upstream code only lets us get here if
+ // either high or medium provides the required number of bits.
+ GrSLPrecision precision = kHigh_GrSLPrecision;
+ const GrShaderCaps::PrecisionInfo& highP = args.fShaderCaps->getFloatShaderPrecisionInfo(
+ kFragment_GrShaderType,
+ kHigh_GrSLPrecision);
+ if (!highP.supported()) {
+ precision = kMedium_GrSLPrecision;
+ }
- GrShaderVar edgeAlpha("edgeAlpha", kHighFloat_GrSLType, 0);
- GrShaderVar dklmdx("dklmdx", kHighFloat3_GrSLType, 0);
- GrShaderVar dklmdy("dklmdy", kHighFloat3_GrSLType, 0);
- GrShaderVar dfdx("dfdx", kHighFloat_GrSLType, 0);
- GrShaderVar dfdy("dfdy", kHighFloat_GrSLType, 0);
- GrShaderVar gF("gF", kHighFloat2_GrSLType, 0);
- GrShaderVar gFM("gFM", kHighFloat_GrSLType, 0);
- GrShaderVar func("func", kHighFloat_GrSLType, 0);
+ GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, precision);
+ GrShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, precision);
+ GrShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, precision);
+ GrShaderVar dfdx("dfdx", kFloat_GrSLType, 0, precision);
+ GrShaderVar dfdy("dfdy", kFloat_GrSLType, 0, precision);
+ GrShaderVar gF("gF", kVec2f_GrSLType, 0, precision);
+ GrShaderVar gFM("gFM", kFloat_GrSLType, 0, precision);
+ GrShaderVar func("func", kFloat_GrSLType, 0, precision);
fragBuilder->declAppend(edgeAlpha);
fragBuilder->declAppend(dklmdx);
@@ -138,8 +146,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str());
- fragBuilder->codeAppendf("%s = highfloat2(%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;",
@@ -168,8 +175,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str());
- fragBuilder->codeAppendf("%s = highfloat2(%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;",
@@ -185,7 +191,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
case kFillBW_GrProcessorEdgeType: {
fragBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;",
edgeAlpha.c_str(), v.fsIn(), v.fsIn(), v.fsIn(), v.fsIn());
- fragBuilder->codeAppendf("%s = highfloat(%s < 0.0);",
+ fragBuilder->codeAppendf("%s = float(%s < 0.0);",
edgeAlpha.c_str(), edgeAlpha.c_str());
break;
}
@@ -197,13 +203,14 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
if (gp.coverageScale() != 0xff) {
const char* coverageScale;
fCoverageScaleUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHighFloat_GrSLType,
+ kFloat_GrSLType,
+ kHigh_GrSLPrecision,
"Coverage",
&coverageScale);
- fragBuilder->codeAppendf("%s = half4(%s * %s);",
+ fragBuilder->codeAppendf("%s = float4(%s * %s);",
args.fOutputCoverage, coverageScale, edgeAlpha.c_str());
} else {
- fragBuilder->codeAppendf("%s = half4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
}
}
@@ -331,7 +338,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// emit attributes
varyingHandler->emitAttributes(gp);
- GrGLSLVertToFrag v(kHalf4_GrSLType);
+ GrGLSLVertToFrag v(kVec4f_GrSLType);
varyingHandler->addVarying("HairQuadEdge", &v);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
@@ -356,13 +363,13 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
gp.localMatrix(),
args.fFPCoordTransformHandler);
- fragBuilder->codeAppendf("half edgeAlpha;");
+ fragBuilder->codeAppendf("float edgeAlpha;");
switch (fEdgeType) {
case kHairlineAA_GrProcessorEdgeType: {
- fragBuilder->codeAppendf("half2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("half2 duvdy = dFdy(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("half2 gF = half2(2.0 * %s.x * duvdx.x - duvdx.y,"
+ 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);",
@@ -374,9 +381,9 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
break;
}
case kFillAA_GrProcessorEdgeType: {
- fragBuilder->codeAppendf("half2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("half2 duvdy = dFdy(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("half2 gF = half2(2.0 * %s.x * duvdx.x - duvdx.y,"
+ 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);",
@@ -390,7 +397,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
case kFillBW_GrProcessorEdgeType: {
fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
v.fsIn(), v.fsIn(), v.fsIn());
- fragBuilder->codeAppend("edgeAlpha = half(edgeAlpha < 0.0);");
+ fragBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);");
break;
}
default:
@@ -400,13 +407,13 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
if (0xff != gp.coverageScale()) {
const char* coverageScale;
fCoverageScaleUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf_GrSLType,
+ kFloat_GrSLType,
+ kDefault_GrSLPrecision,
"Coverage",
&coverageScale);
- fragBuilder->codeAppendf("%s = half4(%s * edgeAlpha);", args.fOutputCoverage,
- coverageScale);
+ fragBuilder->codeAppendf("%s = float4(%s * edgeAlpha);", args.fOutputCoverage, coverageScale);
} else {
- fragBuilder->codeAppendf("%s = half4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
}
@@ -554,25 +561,25 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// Setup KLM
const char* devkLMMatrixName;
- fDevKLMUniform = uniformHandler->addUniform(kVertex_GrShaderFlag, kHighFloat3x3_GrSLType, "KLM",
- &devkLMMatrixName);
- GrGLSLVertToFrag v(kHighFloat3_GrSLType);
+ fDevKLMUniform = uniformHandler->addUniform(kVertex_GrShaderFlag, kMat33f_GrSLType,
+ kHigh_GrSLPrecision, "KLM", &devkLMMatrixName);
+ GrGLSLVertToFrag v(kVec3f_GrSLType);
varyingHandler->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = %s * highfloat3(%s, 1);",
+ vertBuilder->codeAppendf("%s = %s * float3(%s, 1);",
v.vsOut(), devkLMMatrixName, gpArgs->fPositionVar.c_str());
- GrGLSLVertToFrag gradCoeffs(kHighFloat4_GrSLType);
+ GrGLSLVertToFrag gradCoeffs(kVec4f_GrSLType);
if (kFillAA_GrProcessorEdgeType == fEdgeType || kHairlineAA_GrProcessorEdgeType == fEdgeType) {
varyingHandler->addVarying("GradCoeffs", &gradCoeffs, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("highfloat k = %s[0], l = %s[1], m = %s[2];",
+ vertBuilder->codeAppendf("highp float k = %s[0], l = %s[1], m = %s[2];",
v.vsOut(), v.vsOut(), v.vsOut());
- vertBuilder->codeAppendf("highfloat2 gk = highfloat2(%s[0][0], %s[1][0]), "
- "gl = highfloat2(%s[0][1], %s[1][1]), "
- "gm = highfloat2(%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 = highfloat4(3 * k * gk, -m * gl - l * gm);",
+ vertBuilder->codeAppendf("%s = float4(3 * k * gk, -m * gl - l * gm);",
gradCoeffs.vsOut());
}
@@ -585,9 +592,9 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
args.fFPCoordTransformHandler);
- GrShaderVar edgeAlpha("edgeAlpha", kHighFloat_GrSLType, 0);
- GrShaderVar gF("gF", kHighFloat2_GrSLType, 0);
- GrShaderVar func("func", kHighFloat_GrSLType, 0);
+ GrShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision);
+ GrShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
fragBuilder->declAppend(edgeAlpha);
fragBuilder->declAppend(gF);
@@ -631,7 +638,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fragBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;",
edgeAlpha.c_str(), v.fsIn(), v.fsIn(),
v.fsIn(), v.fsIn(), v.fsIn());
- fragBuilder->codeAppendf("%s = half(%s < 0.0);", edgeAlpha.c_str(), edgeAlpha.c_str());
+ fragBuilder->codeAppendf("%s = float(%s < 0.0);", edgeAlpha.c_str(), edgeAlpha.c_str());
break;
}
default:
@@ -639,7 +646,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
}
- fragBuilder->codeAppendf("%s = highfloat4(%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 743b9e094f..7417e29f12 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -42,7 +42,8 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
const GrBicubicEffect& bicubicEffect = args.fFp.cast<GrBicubicEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
- fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
+ fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
"ImageIncrement");
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
@@ -70,26 +71,26 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
*
* This is GLSL, so the matrix is column-major (transposed from standard matrix notation).
*/
- fragBuilder->codeAppend("half4x4 kMitchellCoefficients = half4x4("
+ 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("highfloat2 coord = %s - %s * highfloat2(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("highfloat2 f = fract(coord);");
- fragBuilder->codeAppendf("coord = (coord - f + highfloat2(0.5)) * %s;", imgInc);
- fragBuilder->codeAppend("half4 wx = kMitchellCoefficients * half4(1.0, f.x, f.x * f.x, f.x * f.x * f.x);");
- fragBuilder->codeAppend("half4 wy = kMitchellCoefficients * half4(1.0, f.y, f.y * f.y, f.y * f.y * f.y);");
- fragBuilder->codeAppend("half4 rowColors[4];");
+ 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 * highfloat2(%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,
@@ -101,7 +102,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
args.fTexSamplers[0]);
}
fragBuilder->codeAppendf(
- "half4 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 dfdd5addc1..2d665c50cb 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -32,13 +32,13 @@ public:
const char* atlasSizeInvName;
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kHighFloat2_GrSLType,
+ kVec2f_GrSLType,
kHigh_GrSLPrecision,
"AtlasSizeInv",
&atlasSizeInvName);
- GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
- GrGLSLVertToFrag texIdx(kHalf_GrSLType);
+ GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag texIdx(kFloat_GrSLType);
append_index_uv_varyings(args, btgp.inTextureCoords()->fName, atlasSizeInvName,
&uv, &texIdx, nullptr);
@@ -63,14 +63,14 @@ public:
btgp.localMatrix(),
args.fFPCoordTransformHandler);
- fragBuilder->codeAppend("half4 texColor;");
+ fragBuilder->codeAppend("float4 texColor;");
append_multitexture_lookup(args, btgp.numTextureSamplers(),
texIdx, uv.fsIn(), "texColor");
if (btgp.maskFormat() == kARGB_GrMaskFormat) {
// modulate by color
fragBuilder->codeAppendf("%s = %s * texColor;", args.fOutputColor, args.fOutputColor);
- fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
} else {
fragBuilder->codeAppendf("%s = texColor;", args.fOutputCoverage);
}
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
index ff997cdec4..1b5ea600f9 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
@@ -25,12 +25,12 @@ public:
args.fFp.cast<GrBlurredEdgeFragmentProcessor>();
(void)_outer;
fragBuilder->codeAppendf(
- "half factor = half(1.0 - highfloat(%s.w));\n@switch (%d) {\n case 0:\n "
- "factor = half(exp(highfloat(highfloat(-factor * factor) * 4.0)) - "
- "0.017999999999999999);\n break;\n case 1:\n factor = "
- "half(smoothstep(1.0, 0.0, highfloat(factor)));\n break;\n}\n%s = "
- "half4(factor);\n",
- args.fInputColor ? args.fInputColor : "half4(1)", _outer.mode(), args.fOutputColor);
+ "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 = "
+ "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 fe5ffd5eb3..3ff233a705 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
@@ -15,7 +15,7 @@
layout(key) in int mode;
void main() {
- half factor = 1.0 - sk_InColor.a;
+ float factor = 1.0 - sk_InColor.a;
@switch (mode) {
case 0: // kGaussian_Mode
factor = exp(-factor * factor * 4.0) - 0.018;
@@ -24,5 +24,5 @@ void main() {
factor = smoothstep(1.0, 0.0, factor);
break;
}
- sk_OutColor = half4(factor);
+ sk_OutColor = float4(factor);
}
diff --git a/src/gpu/effects/GrCircleEffect.cpp b/src/gpu/effects/GrCircleEffect.cpp
index 7b4a9f7794..b764559ed4 100644
--- a/src/gpu/effects/GrCircleEffect.cpp
+++ b/src/gpu/effects/GrCircleEffect.cpp
@@ -24,15 +24,14 @@ public:
const GrCircleEffect& _outer = args.fFp.cast<GrCircleEffect>();
(void)_outer;
prevRadius = -1.0;
- fCircleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
+ fCircleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
kDefault_GrSLPrecision, "circle");
fragBuilder->codeAppendf(
- "half2 prevCenter;\nhalf prevRadius = %f;\nhalf d;\n@if (%d == 2 || %d == 3) {\n "
- " d = (highfloat(length((%s.xy - half2(sk_FragCoord.xy)) * %s.w)) - 1.0) * "
- "%s.z;\n} else {\n d = half((1.0 - highfloat(length((%s.xy - "
- "half2(sk_FragCoord.xy)) * %s.w))) * highfloat(%s.z));\n}\n@if ((%d == 1 || %d == "
- "3) || %d == 4) {\n d = half(clamp(highfloat(d), 0.0, 1.0));\n} else {\n d = "
- "half(highfloat(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),
@@ -41,7 +40,7 @@ public:
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar), _outer.edgeType(),
_outer.edgeType(), _outer.edgeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "half4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrCircleEffect.fp b/src/gpu/effects/GrCircleEffect.fp
index 031b2ee0a6..884112ecc9 100644
--- a/src/gpu/effects/GrCircleEffect.fp
+++ b/src/gpu/effects/GrCircleEffect.fp
@@ -6,14 +6,14 @@
*/
layout(key) in int edgeType;
-in half2 center;
-in half radius;
+in float2 center;
+in float radius;
-half2 prevCenter;
-half prevRadius = -1;
+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 half4 circle;
+uniform float4 circle;
@optimizationFlags { kCompatibleWithCoverageAsAlpha_OptimizationFlag }
@@ -36,7 +36,7 @@ void main() {
// TODO: Right now the distance to circle caclulation is performed in a space normalized to the
// radius and then denormalized. This is to prevent overflow on devices that have a "real"
// mediump. It'd be nice to only do this on mediump devices.
- half d;
+ float d;
@if (edgeType == 2 /* kInverseFillBW_GrProcessorEdgeType */ ||
edgeType == 3 /* kInverseFillAA_GrProcessorEdgeType */) {
d = (length((circle.xy - sk_FragCoord.xy) * circle.w) - 1.0) * circle.z;
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index e1ecc7f864..2cf7919543 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -21,16 +21,16 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Use highp throughout the shader to avoid some precision issues on specific GPUs.
- fragBuilder->forceHighPrecision();
+ fragBuilder->elevateDefaultPrecision(kHigh_GrSLPrecision);
if (nullptr == args.fInputColor) {
// could optimize this case, but we aren't for now.
- args.fInputColor = "half4(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("half4 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 @@ public:
case GrConfigConversionEffect::kToUnpremul_PMConversion:
fragBuilder->codeAppend(
- "color.rgb = color.a <= 0.0 ? half3(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/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp
index 7051872bf3..a8b328e9b9 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -19,7 +19,7 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* colorUni;
fColorUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf4_GrSLType,
+ kVec4f_GrSLType, kMedium_GrSLPrecision,
"constantColor",
&colorUni);
GrConstColorProcessor::InputMode mode = args.fFp.cast<GrConstColorProcessor>().inputMode();
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 97f456953d..e61923c29e 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -103,7 +103,8 @@ void GLAARectEffect::emitCode(EmitArgs& args) {
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
// respectively.
fRectUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf4_GrSLType,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
"rect",
&rectName);
@@ -111,16 +112,16 @@ void GLAARectEffect::emitCode(EmitArgs& args) {
if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) {
// The amount of coverage removed in x and y by the edges is computed as a pair of negative
// numbers, xSub and ySub.
- fragBuilder->codeAppend("\t\thalf xSub, ySub;\n");
+ fragBuilder->codeAppend("\t\tfloat xSub, ySub;\n");
fragBuilder->codeAppendf("\t\txSub = min(sk_FragCoord.x - %s.x, 0.0);\n", rectName);
fragBuilder->codeAppendf("\t\txSub += min(%s.z - sk_FragCoord.x, 0.0);\n", rectName);
fragBuilder->codeAppendf("\t\tySub = min(sk_FragCoord.y - %s.y, 0.0);\n", rectName);
fragBuilder->codeAppendf("\t\tySub += min(%s.w - sk_FragCoord.y, 0.0);\n", rectName);
// Now compute coverage in x and y and multiply them to get the fraction of the pixel
// covered.
- fragBuilder->codeAppendf("\t\thalf alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));\n");
+ fragBuilder->codeAppendf("\t\tfloat alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));\n");
} else {
- fragBuilder->codeAppendf("\t\thalf alpha = 1.0;\n");
+ fragBuilder->codeAppendf("\t\tfloat alpha = 1.0;\n");
fragBuilder->codeAppendf("\t\talpha *= (sk_FragCoord.x - %s.x) > -0.5 ? 1.0 : 0.0;\n",
rectName);
fragBuilder->codeAppendf("\t\talpha *= (%s.z - sk_FragCoord.x) > -0.5 ? 1.0 : 0.0;\n",
@@ -190,15 +191,16 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
const char *edgeArrayName;
fEdgeUniform = args.fUniformHandler->addUniformArray(kFragment_GrShaderFlag,
- kHalf3_GrSLType,
+ kVec3f_GrSLType,
+ kDefault_GrSLPrecision,
"edges",
cpe.getEdgeCount(),
&edgeArrayName);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppend("\t\thalf alpha = 1.0;\n");
- fragBuilder->codeAppend("\t\thalf edge;\n");
+ 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], half3(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 ab0d835cf8..2d66e1e1b6 100644
--- a/src/gpu/effects/GrDisableColorXP.cpp
+++ b/src/gpu/effects/GrDisableColorXP.cpp
@@ -53,7 +53,7 @@ private:
// 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 = half4(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 7800186d05..66e96199eb 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -45,7 +45,7 @@ public:
const char* atlasSizeInvName;
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kHighFloat2_GrSLType,
+ kVec2f_GrSLType,
kHigh_GrSLPrecision,
"AtlasSizeInv",
&atlasSizeInvName);
@@ -53,7 +53,8 @@ public:
// adjust based on gamma
const char* distanceAdjustUniName = nullptr;
// width, height, 1/(3*width)
- fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
+ fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
"DistanceAdjust", &distanceAdjustUniName);
#endif
@@ -77,9 +78,9 @@ public:
args.fFPCoordTransformHandler);
// add varyings
- GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
- GrGLSLVertToFrag texIdx(kHalf_GrSLType);
- GrGLSLVertToFrag st(kHighFloat2_GrSLType);
+ GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag texIdx(kFloat_GrSLType);
+ GrGLSLVertToFrag st(kVec2f_GrSLType);
append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
&uv, &texIdx, &st);
@@ -92,19 +93,19 @@ public:
SkToBool(dfTexEffect.getFlags() & kAliased_DistanceFieldEffectFlag);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highfloat2 uv = %s;\n", uv.fsIn());
- fragBuilder->codeAppend("half4 texColor;");
+ fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppend("float4 texColor;");
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
texIdx, "uv", "texColor");
- fragBuilder->codeAppend("half distance = "
+ fragBuilder->codeAppend("float distance = "
SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ");");
#ifdef SK_GAMMA_APPLY_TO_A8
// adjust width based on gamma
fragBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
#endif
- fragBuilder->codeAppend("half afwidth;");
+ fragBuilder->codeAppend("float afwidth;");
if (isUniformScale) {
// For uniform scale, we adjust for the effect of the transformation on the distance
// by using the length of the gradient of the t coordinate in the y direction.
@@ -127,29 +128,29 @@ public:
// this gives us a smooth step across approximately one fragment
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("half st_grad_len = length(dFdx(%s));", st.fsIn());
+ fragBuilder->codeAppendf("float st_grad_len = length(dFdx(%s));", st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("half st_grad_len = length(dFdy(%s));", st.fsIn());
+ fragBuilder->codeAppendf("float st_grad_len = length(dFdy(%s));", st.fsIn());
#endif
fragBuilder->codeAppend("afwidth = abs(" SK_DistanceFieldAAFactor "*st_grad_len);");
} else {
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("half2 dist_grad = half2(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("half dg_len2 = dot(dist_grad, dist_grad);");
+ fragBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("half2 Jdx = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppendf("half2 Jdy = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->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
@@ -157,18 +158,18 @@ public:
}
if (isAliased) {
- fragBuilder->codeAppend("half val = distance > 0 ? 1.0 : 0.0;");
+ fragBuilder->codeAppend("float val = distance > 0 ? 1.0 : 0.0;");
} else if (isGammaCorrect) {
// The smoothstep falloff compensates for the non-linear sRGB response curve. If we are
// doing gamma-correct rendering (to an sRGB or F16 buffer), then we actually want
// distance mapped linearly to coverage, so use a linear step:
fragBuilder->codeAppend(
- "half val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
+ "float val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
} else {
- fragBuilder->codeAppend("half val = smoothstep(-afwidth, afwidth, distance);");
+ fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = half4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -330,14 +331,14 @@ public:
const char* atlasSizeInvName;
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kHighFloat2_GrSLType,
+ kVec2f_GrSLType,
kHigh_GrSLPrecision,
"AtlasSizeInv",
&atlasSizeInvName);
- GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
- GrGLSLVertToFrag texIdx(kHalf_GrSLType);
- GrGLSLVertToFrag st(kHighFloat2_GrSLType);
+ GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag texIdx(kFloat_GrSLType);
+ GrGLSLVertToFrag st(kVec2f_GrSLType);
append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
&uv, &texIdx, &st);
@@ -361,15 +362,15 @@ public:
args.fFPCoordTransformHandler);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highfloat2 uv = %s;", uv.fsIn());
- fragBuilder->codeAppend("half4 texColor;");
+ fragBuilder->codeAppendf("highp float2 uv = %s;", uv.fsIn());
+ fragBuilder->codeAppend("float4 texColor;");
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
texIdx, "uv", "texColor");
- fragBuilder->codeAppend("half distance = "
+ fragBuilder->codeAppend("float distance = "
SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ");");
- fragBuilder->codeAppend("half afwidth;");
+ fragBuilder->codeAppend("float afwidth;");
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
kUniformScale_DistanceFieldEffectMask;
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
@@ -396,30 +397,30 @@ public:
// this gives us a smooth step across approximately one fragment
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("half st_grad_len = length(dFdx(%s));", st.fsIn());
+ fragBuilder->codeAppendf("float st_grad_len = length(dFdx(%s));", st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("half st_grad_len = length(dFdy(%s));", st.fsIn());
+ fragBuilder->codeAppendf("float st_grad_len = length(dFdy(%s));", st.fsIn());
#endif
fragBuilder->codeAppend("afwidth = abs(" SK_DistanceFieldAAFactor "*st_grad_len);");
} else {
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("half2 dist_grad = half2(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("half dg_len2 = dot(dist_grad, dist_grad);");
+ fragBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("half2 Jdx = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppendf("half2 Jdy = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
- fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
+ 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
fragBuilder->codeAppend("afwidth = " SK_DistanceFieldAAFactor "*length(grad);");
@@ -429,12 +430,12 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppend(
- "half val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
+ "float val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
} else {
- fragBuilder->codeAppend("half val = smoothstep(-afwidth, afwidth, distance);");
+ fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = half4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -579,7 +580,7 @@ public:
const char* atlasSizeInvName;
fAtlasSizeInvUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kHighFloat2_GrSLType,
+ kVec2f_GrSLType,
kHigh_GrSLPrecision,
"AtlasSizeInv",
&atlasSizeInvName);
@@ -606,13 +607,13 @@ public:
args.fFPCoordTransformHandler);
// set up varyings
- GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
- GrGLSLVertToFrag texIdx(kHalf_GrSLType);
- GrGLSLVertToFrag st(kHighFloat2_GrSLType);
+ GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag texIdx(kFloat_GrSLType);
+ GrGLSLVertToFrag st(kVec2f_GrSLType);
append_index_uv_varyings(args, dfTexEffect.inTextureCoords()->fName, atlasSizeInvName,
&uv, &texIdx, &st);
- GrGLSLVertToFrag delta(kHighFloat_GrSLType);
+ GrGLSLVertToFrag delta(kFloat_GrSLType);
varyingHandler->addVarying("Delta", &delta, kHigh_GrSLPrecision);
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
vertBuilder->codeAppendf("%s = -%s.x/3.0;", delta.vsOut(), atlasSizeInvName);
@@ -629,48 +630,48 @@ public:
// create LCD offset adjusted by inverse of transform
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highfloat2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
if (isUniformScale) {
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("half st_grad_len = abs(dFdx(%s.x));", st.fsIn());
+ fragBuilder->codeAppendf("float st_grad_len = abs(dFdx(%s.x));", st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("half st_grad_len = abs(dFdy(%s.y));", st.fsIn());
+ fragBuilder->codeAppendf("float st_grad_len = abs(dFdy(%s.y));", st.fsIn());
#endif
- fragBuilder->codeAppendf("half2 offset = half2(st_grad_len*%s, 0.0);", delta.fsIn());
+ fragBuilder->codeAppendf("float2 offset = float2(st_grad_len*%s, 0.0);", delta.fsIn());
} else if (isSimilarity) {
// For a similarity matrix with rotation, the gradient will not be aligned
// with the texel coordinate axes, so we need to calculate it.
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("half2 st_grad = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppendf("half2 offset = %s*st_grad;", delta.fsIn());
+ fragBuilder->codeAppendf("float2 st_grad = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppendf("float2 offset = %s*st_grad;", delta.fsIn());
#else
// We use dFdy because of a Mali 400 bug, and rotate -90 degrees to
// get the gradient in the x direction.
- fragBuilder->codeAppendf("half2 st_grad = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppendf("half2 offset = %s*half2(st_grad.y, -st_grad.x);",
+ fragBuilder->codeAppendf("float2 st_grad = dFdy(%s);", st.fsIn());
+ fragBuilder->codeAppendf("float2 offset = %s*float2(st_grad.y, -st_grad.x);",
delta.fsIn());
#endif
- fragBuilder->codeAppend("half st_grad_len = length(st_grad);");
+ fragBuilder->codeAppend("float st_grad_len = length(st_grad);");
} else {
- fragBuilder->codeAppendf("half2 st = %s;\n", st.fsIn());
+ fragBuilder->codeAppendf("float2 st = %s;\n", st.fsIn());
- fragBuilder->codeAppend("half2 Jdx = dFdx(st);");
- fragBuilder->codeAppend("half2 Jdy = dFdy(st);");
- fragBuilder->codeAppendf("half2 offset = %s*Jdx;", delta.fsIn());
+ fragBuilder->codeAppend("float2 Jdx = dFdx(st);");
+ fragBuilder->codeAppend("float2 Jdy = dFdy(st);");
+ fragBuilder->codeAppendf("float2 offset = %s*Jdx;", delta.fsIn());
}
// sample the texture by index
- fragBuilder->codeAppend("half4 texColor;");
+ fragBuilder->codeAppend("float4 texColor;");
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
texIdx, "uv", "texColor");
// green is distance to uv center
- fragBuilder->codeAppend("half3 distance;");
+ fragBuilder->codeAppend("float3 distance;");
fragBuilder->codeAppend("distance.y = texColor.r;");
// red is distance to left offset
- fragBuilder->codeAppend("half2 uv_adjusted = uv - offset;");
+ fragBuilder->codeAppend("float2 uv_adjusted = uv - offset;");
append_multitexture_lookup(args, dfTexEffect.numTextureSamplers(),
texIdx, "uv_adjusted", "texColor");
fragBuilder->codeAppend("distance.x = texColor.r;");
@@ -681,11 +682,12 @@ public:
fragBuilder->codeAppend("distance.z = texColor.r;");
fragBuilder->codeAppend("distance = "
- "half3(" SK_DistanceFieldMultiplier ")*(distance - half3(" SK_DistanceFieldThreshold"));");
+ "float3(" SK_DistanceFieldMultiplier ")*(distance - float3(" SK_DistanceFieldThreshold"));");
// adjust width based on gamma
const char* distanceAdjustUniName = nullptr;
- fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf3_GrSLType,
+ fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec3f_GrSLType, kDefault_GrSLPrecision,
"DistanceAdjust", &distanceAdjustUniName);
fragBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
@@ -693,7 +695,7 @@ public:
// for each color component. However, this is only important when using perspective
// transformations, and even then using a single factor seems like a reasonable
// trade-off between quality and speed.
- fragBuilder->codeAppend("half afwidth;");
+ fragBuilder->codeAppend("float afwidth;");
if (isSimilarity) {
// For similarity transform (uniform scale-only is a subset of this), we adjust for the
// effect of the transformation on the distance by using the length of the gradient of
@@ -706,16 +708,16 @@ public:
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance.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("half dg_len2 = dot(dist_grad, dist_grad);");
+ fragBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppend("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
@@ -727,11 +729,11 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppendf("%s = "
- "half4(clamp((distance + half3(afwidth)) / half3(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 = half4(smoothstep(half3(-afwidth), half3(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 6f5266e738..d78af4ee5a 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -24,22 +24,21 @@ public:
const GrDitherEffect& _outer = args.fFp.cast<GrDitherEffect>();
(void)_outer;
fragBuilder->codeAppendf(
- "half value;\nhalf range;\n@switch (%d) {\n case 0:\n range = "
+ "float value;\nfloat range;\n@switch (%d) {\n case 0:\n range = "
"0.0039215686274509803;\n break;\n case 1:\n range = "
"0.015873015873015872;\n break;\n default:\n range = "
"0.066666666666666666;\n break;\n}\n@if (sk_Caps.integerSupport) {\n "
"uint x = uint(sk_FragCoord.x);\n uint y = uint(sk_FragCoord.y);\n uint m = "
"(((((y & 1) << 5 | (x & 1) << 4) | (y & 2) << 2) | (x & 2) << 1) | (y & 4) >> 1) "
- "| (x & 4) >> 2;\n value = highfloat(highfloat(half(m)) / 64.0) - 0.4921875;\n} "
- "else {\n half4 modValues = half4(mod(sk_FragCoord.xyxy, highfloat4(half4(2.0, "
- "2.0, 4.0, 4.0))));\n half4 stepValues = half4(step(highfloat4(modValues), "
- "highfloat4(half4(1.0, 1.0, 2.0, 2.0))));\n value = highfloat(dot(stepValues, "
- "half4(0.5, 0.25, 0.125, 0.0625))) - 0.46875;\n}\n%s = "
- "half4(clamp(highfloat3(%s.xyz + value * range), 0.0, highfloat(%s.w)), %s.w);\n",
+ "| (x & 4) >> 2;\n value = float(m) / 64.0 - 0.4921875;\n} else {\n float4 "
+ "modValues = mod(sk_FragCoord.xyxy, float4(2.0, 2.0, 4.0, 4.0));\n float4 "
+ "stepValues = step(modValues, float4(1.0, 1.0, 2.0, 2.0));\n value = "
+ "dot(stepValues, float4(0.5, 0.25, 0.125, 0.0625)) - 0.46875;\n}\n%s = "
+ "float4(clamp(%s.xyz + value * range, 0.0, %s.w), %s.w);\n",
_outer.rangeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "half4(1)",
- args.fInputColor ? args.fInputColor : "half4(1)",
- args.fInputColor ? args.fInputColor : "half4(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 f2d54cf2eb..fe641c6132 100644
--- a/src/gpu/effects/GrDitherEffect.fp
+++ b/src/gpu/effects/GrDitherEffect.fp
@@ -32,8 +32,8 @@ layout(key) in int rangeType;
}
void main() {
- half value;
- half range;
+ float value;
+ float range;
@switch (rangeType) {
case 0:
range = 1.0 / 255.0;
@@ -53,17 +53,17 @@ void main() {
uint m = (y & 1) << 5 | (x & 1) << 4 |
(y & 2) << 2 | (x & 2) << 1 |
(y & 4) >> 1 | (x & 4) >> 2;
- value = half(m) * 1.0 / 64.0 - 63.0 / 128.0;
+ value = float(m) * 1.0 / 64.0 - 63.0 / 128.0;
} else {
// Simulate the integer effect used above using step/mod. For speed, simulates a 4x4
// dither pattern rather than an 8x8 one.
- half4 modValues = mod(sk_FragCoord.xyxy, half4(2.0, 2.0, 4.0, 4.0));
- half4 stepValues = step(modValues, half4(1.0, 1.0, 2.0, 2.0));
- value = dot(stepValues, half4(8.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0)) - 15.0 / 32.0;
+ float4 modValues = mod(sk_FragCoord.xyxy, float4(2.0, 2.0, 4.0, 4.0));
+ float4 stepValues = step(modValues, float4(1.0, 1.0, 2.0, 2.0));
+ value = dot(stepValues, float4(8.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0)) - 15.0 / 32.0;
}
// 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 = half4(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 3f35311717..30391450d8 100644
--- a/src/gpu/effects/GrEllipseEffect.cpp
+++ b/src/gpu/effects/GrEllipseEffect.cpp
@@ -23,34 +23,35 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrEllipseEffect& _outer = args.fFp.cast<GrEllipseEffect>();
(void)_outer;
- prevRadii = half2(-1.0);
+ prevRadii = float2(-1.0);
useScale = sk_Caps.floatPrecisionVaries;
- fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHighFloat4_GrSLType,
- kDefault_GrSLPrecision, "ellipse");
+ fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
+ kHigh_GrSLPrecision, "ellipse");
if (useScale) {
- fScaleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
+ fScaleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec2f_GrSLType,
kDefault_GrSLPrecision, "scale");
}
fragBuilder->codeAppendf(
- "half2 prevCenter;\nhalf2 prevRadii = half2(%f, %f);\nbool useScale = %s;\nhalf2 d "
- "= half2(sk_FragCoord.xy - %s.xy);\n@if (useScale) {\n d *= %s.y;\n}\nhalf2 Z = "
- "d * half2(%s.zw);\nhalf implicit = dot(Z, d) - 1.0;\nhalf grad_dot = 4.0 * dot(Z, "
- "Z);\ngrad_dot = half(max(highfloat(grad_dot), 0.0001));\nhalf approx_dist = "
- "highfloat(implicit) * inversesqrt(highfloat(grad_dot));\n@if (useScale) {\n "
- "approx_dist *= %s.x;\n}\nhalf alpha;\n@switch (%d) {\n case 0:\n alpha "
- "= half(highfloat(approx_dist) > 0.0 ? 0.0 : 1.0);\n break;\n case 1:\n "
- " alpha = half(clamp(0.5 - highfloat(approx_dist), 0.0, 1.0));\n "
- "break;\n case 2:\n alpha = half(highfloat(approx_dist) > 0.0 ? 1.0 : "
- "0.0);\n break;\n case 3:\n alpha = half(clamp(0.5 + "
- "highfloat(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) : "half2(0)",
+ fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar)
+ : "float2(0.0)",
args.fUniformHandler->getUniformCStr(fEllipseVar),
- fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "half2(0)",
+ fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar)
+ : "float2(0.0)",
_outer.edgeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "half4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrEllipseEffect.fp b/src/gpu/effects/GrEllipseEffect.fp
index 3663d5622e..85c4c96f75 100644
--- a/src/gpu/effects/GrEllipseEffect.fp
+++ b/src/gpu/effects/GrEllipseEffect.fp
@@ -6,17 +6,17 @@
*/
layout(key) in int edgeType;
-in half2 center;
-in half2 radii;
+in float2 center;
+in float2 radii;
-half2 prevCenter;
-half2 prevRadii = half2(-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 with halfs, so we use floats.
-uniform highfloat4 ellipse;
+// The last two terms can underflow on mediump, so we use highp.
+uniform highp float4 ellipse;
bool useScale = sk_Caps.floatPrecisionVaries;
-layout(when=useScale) uniform half2 scale;
+layout(when=useScale) uniform float2 scale;
@optimizationFlags { kCompatibleWithCoverageAsAlpha_OptimizationFlag }
@@ -50,7 +50,7 @@ layout(when=useScale) uniform half2 scale;
void main() {
// d is the offset to the ellipse center
- half2 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,19 +58,19 @@ void main() {
@if (useScale) {
d *= scale.y;
}
- half2 Z = d * ellipse.zw;
+ float2 Z = d * ellipse.zw;
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
- half implicit = dot(Z, d) - 1;
+ float implicit = dot(Z, d) - 1;
// grad_dot is the squared length of the gradient of the implicit.
- half grad_dot = 4 * dot(Z, Z);
+ float grad_dot = 4 * dot(Z, Z);
// Avoid calling inversesqrt on zero.
grad_dot = max(grad_dot, 1e-4);
- half approx_dist = implicit * inversesqrt(grad_dot);
+ float approx_dist = implicit * inversesqrt(grad_dot);
@if (useScale) {
approx_dist *= scale.x;
}
- half alpha;
+ float alpha;
@switch (edgeType) {
case 0 /* kFillBW_GrProcessorEdgeType */:
alpha = approx_dist > 0.0 ? 0.0 : 1.0;
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index dfbe17a289..23b617849c 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -41,11 +41,11 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
args.fFp.cast<GrGaussianConvolutionFragmentProcessor>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
- fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
- "ImageIncrement");
+ fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kVec2f_GrSLType,
+ kDefault_GrSLPrecision, "ImageIncrement");
if (ce.useBounds()) {
- fBoundsUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
- "Bounds");
+ fBoundsUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kVec2f_GrSLType,
+ kDefault_GrSLPrecision, "Bounds");
}
int width = ce.width();
@@ -53,19 +53,19 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
int arrayCount = (width + 3) / 4;
SkASSERT(4 * arrayCount >= width);
- fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag, kHalf4_GrSLType,
- "Kernel", arrayCount);
+ fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag, kVec4f_GrSLType,
+ kDefault_GrSLPrecision, "Kernel", arrayCount);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppendf("%s = half4(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("highfloat2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
- fragBuilder->codeAppend("highfloat2 coordSampled = half2(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 063f8f3772..9d9a03ed4b 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -47,15 +47,20 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
SkASSERT(4 * arrayCount >= kWidth * kHeight);
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
- fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
+ fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
"ImageIncrement");
- fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag, kHalf4_GrSLType,
+ fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
"Kernel",
arrayCount);
- fKernelOffsetUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
+ fKernelOffsetUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
"KernelOffset");
- fGainUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "Gain");
- fBiasUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "Bias");
+ fGainUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kFloat_GrSLType, kDefault_GrSLPrecision, "Gain");
+ fBiasUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kFloat_GrSLType, kDefault_GrSLPrecision, "Bias");
const char* kernelOffset = uniformHandler->getUniformCStr(fKernelOffsetUni);
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
@@ -65,9 +70,9 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppend("half4 sum = half4(0, 0, 0, 0);");
- fragBuilder->codeAppendf("highfloat2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
- fragBuilder->codeAppend("half4 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++) {
@@ -75,10 +80,10 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
GrGLSLShaderBuilder::ShaderBlock block(fragBuilder);
int offset = y*kWidth + x;
- fragBuilder->codeAppendf("half k = %s[%d]%s;", kernel, offset / 4,
+ fragBuilder->codeAppendf("float k = %s[%d]%s;", kernel, offset / 4,
kVecSuffix[offset & 0x3]);
SkString coord;
- coord.printf("coord + half2(%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 fee7f17992..b30746acb7 100644
--- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
+++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
@@ -23,21 +23,24 @@ public:
const char* srcCoeffsName = nullptr;
if (SkToBool(csxe.ops() & GrNonlinearColorSpaceXformEffect::kSrcTransfer_Op)) {
fSrcTransferFnUni = uniformHandler->addUniformArray(
- kFragment_GrShaderFlag, kHalf_GrSLType, "SrcTransferFn",
- GrNonlinearColorSpaceXformEffect::kNumTransferFnCoeffs, &srcCoeffsName);
+ kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision,
+ "SrcTransferFn", GrNonlinearColorSpaceXformEffect::kNumTransferFnCoeffs,
+ &srcCoeffsName);
}
const char* dstCoeffsName = nullptr;
if (SkToBool(csxe.ops() & GrNonlinearColorSpaceXformEffect::kDstTransfer_Op)) {
fDstTransferFnUni = uniformHandler->addUniformArray(
- kFragment_GrShaderFlag, kHalf_GrSLType, "DstTransferFn",
- GrNonlinearColorSpaceXformEffect::kNumTransferFnCoeffs, &dstCoeffsName);
+ kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision,
+ "DstTransferFn", GrNonlinearColorSpaceXformEffect::kNumTransferFnCoeffs,
+ &dstCoeffsName);
}
const char* gamutXformName = nullptr;
if (SkToBool(csxe.ops() & GrNonlinearColorSpaceXformEffect::kGamutXform_Op)) {
- fGamutXformUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4x4_GrSLType,
- "GamutXform", &gamutXformName);
+ fGamutXformUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kMat44f_GrSLType,
+ kDefault_GrSLPrecision, "GamutXform",
+ &gamutXformName);
}
// Helper function to apply the src or dst transfer function to a single value
@@ -49,32 +52,32 @@ public:
}
const char* fnName = i ? "dst_transfer_fn" : "src_transfer_fn";
static const GrShaderVar gTransferFnFuncArgs[] = {
- GrShaderVar("x", kHalf_GrSLType),
+ GrShaderVar("x", kFloat_GrSLType),
};
SkString transferFnBody;
// Temporaries to make evaluation line readable
- transferFnBody.printf("half A = %s[0];", coeffsName);
- transferFnBody.appendf("half B = %s[1];", coeffsName);
- transferFnBody.appendf("half C = %s[2];", coeffsName);
- transferFnBody.appendf("half D = %s[3];", coeffsName);
- transferFnBody.appendf("half E = %s[4];", coeffsName);
- transferFnBody.appendf("half F = %s[5];", coeffsName);
- transferFnBody.appendf("half G = %s[6];", coeffsName);
- transferFnBody.append("half s = sign(x);");
+ transferFnBody.printf("float A = %s[0];", coeffsName);
+ transferFnBody.appendf("float B = %s[1];", coeffsName);
+ transferFnBody.appendf("float C = %s[2];", coeffsName);
+ transferFnBody.appendf("float D = %s[3];", coeffsName);
+ transferFnBody.appendf("float E = %s[4];", coeffsName);
+ transferFnBody.appendf("float F = %s[5];", coeffsName);
+ transferFnBody.appendf("float G = %s[6];", coeffsName);
+ transferFnBody.append("float s = sign(x);");
transferFnBody.append("x = abs(x);");
transferFnBody.appendf("return s * ((x < D) ? (C * x) + F : pow(A * x + B, G) + E);");
- fragBuilder->emitFunction(kHalf_GrSLType, fnName, SK_ARRAY_COUNT(gTransferFnFuncArgs),
+ fragBuilder->emitFunction(kFloat_GrSLType, fnName, SK_ARRAY_COUNT(gTransferFnFuncArgs),
gTransferFnFuncArgs, transferFnBody.c_str(), &tfFuncNames[i]);
}
if (nullptr == args.fInputColor) {
- args.fInputColor = "half4(1)";
+ args.fInputColor = "float4(1)";
}
- fragBuilder->codeAppendf("half4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
// 1: Un-premultiply the input color (if necessary)
- fragBuilder->codeAppendf("half nonZeroAlpha = max(color.a, 0.00001);");
- fragBuilder->codeAppendf("color = half4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
+ fragBuilder->codeAppendf("float nonZeroAlpha = max(color.a, 0.00001);");
+ fragBuilder->codeAppendf("color = float4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
// 2: Apply src transfer function (to get to linear RGB)
if (srcCoeffsName) {
@@ -86,7 +89,7 @@ public:
// 3: Apply gamut matrix
if (gamutXformName) {
fragBuilder->codeAppendf(
- "color.rgb = (%s * half4(color.rgb, 1.0)).rgb;", gamutXformName);
+ "color.rgb = (%s * float4(color.rgb, 1.0)).rgb;", gamutXformName);
}
// 4: Apply dst transfer fn
@@ -97,7 +100,7 @@ public:
}
// 5: Premultiply again
- fragBuilder->codeAppendf("%s = half4(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 e6c7bf9a80..658f190621 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -440,7 +440,7 @@ static void append_color_output(const PorterDuffXferProcessor& xp,
SkASSERT(inColor);
switch (outputType) {
case BlendFormula::kNone_OutputType:
- fragBuilder->codeAppendf("%s = half4(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 @@ static void append_color_output(const PorterDuffXferProcessor& xp,
fragBuilder->codeAppendf("%s = (1.0 - %s.a) * %s;", output, inColor, inCoverage);
break;
case BlendFormula::kISCModulate_OutputType:
- fragBuilder->codeAppendf("%s = (half4(1.0) - %s) * %s;", output, inColor, inCoverage);
+ fragBuilder->codeAppendf("%s = (float4(1.0) - %s) * %s;", output, inColor, inCoverage);
break;
default:
SK_ABORT("Unsupported output type.");
@@ -629,8 +629,8 @@ public:
private:
void emitOutputsForBlendState(const EmitArgs& args) override {
const char* alpha;
- fAlphaUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
- "alpha", &alpha);
+ fAlphaUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat_GrSLType,
+ kDefault_GrSLPrecision, "alpha", &alpha);
GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder;
// We want to force our primary output to be alpha * Coverage, where alpha is the alpha
// value of the src color. We know that there are no color stages (or we wouldn't have
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 7ad354cee3..6d47e58292 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -160,11 +160,15 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
// edges correspond to components x, y, z, and w, respectively. When a side of the rrect has
// only rectangular corners, that side's value corresponds to the rect edge's value outset by
// half a pixel.
- fInnerRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
- "innerRect", &rectName);
+ fInnerRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "innerRect",
+ &rectName);
// x is (r + .5) and y is 1/(r + .5)
- fRadiusPlusHalfUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
- "radiusPlusHalf", &radiusPlusHalfName);
+ fRadiusPlusHalfUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "radiusPlusHalf",
+ &radiusPlusHalfName);
// If we're on a device with a "real" mediump then the length calculation could overflow.
SkString clampedCircleDistance;
@@ -193,87 +197,87 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
// alphas together.
switch (crre.getCircularCornerFlags()) {
case CircularRRectEffect::kAll_CornerFlags:
- fragBuilder->codeAppendf("half2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("half2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("half2 dxy = max(max(dxy0, dxy1), 0.0);");
- fragBuilder->codeAppendf("half alpha = %s;", clampedCircleDistance.c_str());
+ 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("half2 dxy = max(%s.xy - sk_FragCoord.xy, 0.0);",
+ fragBuilder->codeAppendf("float2 dxy = max(%s.xy - sk_FragCoord.xy, 0.0);",
rectName);
- fragBuilder->codeAppendf("half rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = bottomAlpha * rightAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = bottomAlpha * rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTopRight_CornerFlag:
- fragBuilder->codeAppendf("half2 dxy = max(half2(sk_FragCoord.x - %s.z, "
- "%s.y - sk_FragCoord.y), 0.0);",
+ fragBuilder->codeAppendf("float2 dxy = max(float2(sk_FragCoord.x - %s.z, "
+ "%s.y - sk_FragCoord.y), 0.0);",
rectName, rectName);
- fragBuilder->codeAppendf("half leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = bottomAlpha * leftAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = bottomAlpha * leftAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomRight_CornerFlag:
- fragBuilder->codeAppendf("half2 dxy = max(sk_FragCoord.xy - %s.zw, 0.0);",
+ fragBuilder->codeAppendf("float2 dxy = max(sk_FragCoord.xy - %s.zw, 0.0);",
rectName);
- fragBuilder->codeAppendf("half leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = topAlpha * leftAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = topAlpha * leftAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomLeft_CornerFlag:
- fragBuilder->codeAppendf("half2 dxy = max(half2(%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("half rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = topAlpha * rightAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = topAlpha * rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kLeft_CornerFlags:
- fragBuilder->codeAppendf("half2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("half dy1 = sk_FragCoord.y - %s.w;", rectName);
- fragBuilder->codeAppend("half2 dxy = max(half2(dxy0.x, max(dxy0.y, dy1)), 0.0);");
- fragBuilder->codeAppendf("half rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float dy1 = sk_FragCoord.y - %s.w;", rectName);
+ fragBuilder->codeAppend("float2 dxy = max(float2(dxy0.x, max(dxy0.y, dy1)), 0.0);");
+ fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = rightAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTop_CornerFlags:
- fragBuilder->codeAppendf("half2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("half dx1 = sk_FragCoord.x - %s.z;", rectName);
- fragBuilder->codeAppend("half2 dxy = max(half2(max(dxy0.x, dx1), dxy0.y), 0.0);");
- fragBuilder->codeAppendf("half bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float dx1 = sk_FragCoord.x - %s.z;", rectName);
+ fragBuilder->codeAppend("float2 dxy = max(float2(max(dxy0.x, dx1), dxy0.y), 0.0);");
+ fragBuilder->codeAppendf("float bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = bottomAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = bottomAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kRight_CornerFlags:
- fragBuilder->codeAppendf("half dy0 = %s.y - sk_FragCoord.y;", rectName);
- fragBuilder->codeAppendf("half2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("half2 dxy = max(half2(dxy1.x, max(dy0, dxy1.y)), 0.0);");
- fragBuilder->codeAppendf("half leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float dy0 = %s.y - sk_FragCoord.y;", rectName);
+ fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
+ fragBuilder->codeAppend("float2 dxy = max(float2(dxy1.x, max(dy0, dxy1.y)), 0.0);");
+ fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = leftAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = leftAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottom_CornerFlags:
- fragBuilder->codeAppendf("half dx0 = %s.x - sk_FragCoord.x;", rectName);
- fragBuilder->codeAppendf("half2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("half2 dxy = max(half2(max(dx0, dxy1.x), dxy1.y), 0.0);");
- fragBuilder->codeAppendf("half topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
+ fragBuilder->codeAppendf("float dx0 = %s.x - sk_FragCoord.x;", rectName);
+ fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
+ fragBuilder->codeAppend("float2 dxy = max(float2(max(dx0, dxy1.x), dxy1.y), 0.0);");
+ fragBuilder->codeAppendf("float topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
rectName);
- fragBuilder->codeAppendf("half alpha = topAlpha * %s;",
+ fragBuilder->codeAppendf("float alpha = topAlpha * %s;",
clampedCircleDistance.c_str());
break;
}
@@ -510,8 +514,10 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
const char *rectName;
// The inner rect is the rrect bounds inset by the x/y radii
- fInnerRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
- "innerRect", &rectName);
+ fInnerRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "innerRect",
+ &rectName);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
// At each quarter-ellipse corner we compute a vector that is the offset of the fragment pos
@@ -526,16 +532,17 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
// 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("half2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("half2 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
// radii uniform values are already in this normalized space.
const char* scaleName = nullptr;
if (args.fShaderCaps->floatPrecisionVaries()) {
- fScaleUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType, "scale",
- &scaleName);
+ fScaleUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "scale", &scaleName);
}
// The uniforms with the inv squared radii are highp to prevent underflow.
@@ -543,32 +550,34 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
case SkRRect::kSimple_Type: {
const char *invRadiiXYSqdName;
fInvRadiiSqdUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf2_GrSLType,
+ kVec2f_GrSLType,
+ kDefault_GrSLPrecision,
"invRadiiXY",
&invRadiiXYSqdName);
- fragBuilder->codeAppend("half2 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("half2 Z = dxy * %s.xy;", invRadiiXYSqdName);
+ fragBuilder->codeAppendf("float2 Z = dxy * %s.xy;", invRadiiXYSqdName);
break;
}
case SkRRect::kNinePatch_Type: {
const char *invRadiiLTRBSqdName;
fInvRadiiSqdUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf4_GrSLType,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
"invRadiiLTRB",
&invRadiiLTRBSqdName);
if (scaleName) {
fragBuilder->codeAppendf("dxy0 *= %s.y;", scaleName);
fragBuilder->codeAppendf("dxy1 *= %s.y;", scaleName);
}
- fragBuilder->codeAppend("half2 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("half2 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;
@@ -577,20 +586,20 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
SK_ABORT("RRect should always be simple or nine-patch.");
}
// implicit is the evaluation of (x/a)^2 + (y/b)^2 - 1.
- fragBuilder->codeAppend("half implicit = dot(Z, dxy) - 1.0;");
+ fragBuilder->codeAppend("float implicit = dot(Z, dxy) - 1.0;");
// grad_dot is the squared length of the gradient of the implicit.
- fragBuilder->codeAppend("half grad_dot = 4.0 * dot(Z, Z);");
+ fragBuilder->codeAppend("float grad_dot = 4.0 * dot(Z, Z);");
// avoid calling inversesqrt on zero.
fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fragBuilder->codeAppend("half approx_dist = implicit * inversesqrt(grad_dot);");
+ fragBuilder->codeAppend("float approx_dist = implicit * inversesqrt(grad_dot);");
if (scaleName) {
fragBuilder->codeAppendf("approx_dist *= %s.x;", scaleName);
}
if (kFillAA_GrProcessorEdgeType == erre.getEdgeType()) {
- fragBuilder->codeAppend("half alpha = clamp(0.5 - approx_dist, 0.0, 1.0);");
+ fragBuilder->codeAppend("float alpha = clamp(0.5 - approx_dist, 0.0, 1.0);");
} else {
- fragBuilder->codeAppend("half alpha = clamp(0.5 + approx_dist, 0.0, 1.0);");
+ fragBuilder->codeAppend("float alpha = clamp(0.5 + approx_dist, 0.0, 1.0);");
}
fragBuilder->codeAppendf("%s = %s * alpha;", args.fOutputColor, args.fInputColor);
diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp
index 0e56dfcdb9..f415a6cef1 100644
--- a/src/gpu/effects/GrSRGBEffect.cpp
+++ b/src/gpu/effects/GrSRGBEffect.cpp
@@ -20,11 +20,11 @@ public:
SkString srgbFuncName;
static const GrShaderVar gSrgbArgs[] = {
- GrShaderVar("x", kHalf_GrSLType),
+ GrShaderVar("x", kFloat_GrSLType),
};
switch (srgbe.mode()) {
case GrSRGBEffect::Mode::kLinearToSRGB:
- fragBuilder->emitFunction(kHalf_GrSLType,
+ fragBuilder->emitFunction(kFloat_GrSLType,
"linear_to_srgb",
SK_ARRAY_COUNT(gSrgbArgs),
gSrgbArgs,
@@ -33,7 +33,7 @@ public:
&srgbFuncName);
break;
case GrSRGBEffect::Mode::kSRGBToLinear:
- fragBuilder->emitFunction(kHalf_GrSLType,
+ fragBuilder->emitFunction(kFloat_GrSLType,
"srgb_to_linear",
SK_ARRAY_COUNT(gSrgbArgs),
gSrgbArgs,
@@ -44,20 +44,20 @@ public:
}
if (nullptr == args.fInputColor) {
- args.fInputColor = "half4(1)";
+ args.fInputColor = "float4(1)";
}
- fragBuilder->codeAppendf("half4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
if (srgbe.alpha() == GrSRGBEffect::Alpha::kPremul) {
- fragBuilder->codeAppendf("half nonZeroAlpha = max(color.a, 0.00001);");
- fragBuilder->codeAppendf("color = half4(color.rgb / nonZeroAlpha, color.a);");
+ fragBuilder->codeAppendf("float nonZeroAlpha = max(color.a, 0.00001);");
+ fragBuilder->codeAppendf("color = float4(color.rgb / nonZeroAlpha, color.a);");
}
- fragBuilder->codeAppendf("color = half4(%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 = half4(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 ca4c5dba75..297dd50ada 100644
--- a/src/gpu/effects/GrShadowGeoProc.cpp
+++ b/src/gpu/effects/GrShadowGeoProc.cpp
@@ -26,7 +26,7 @@ public:
// emit attributes
varyingHandler->emitAttributes(rsgp);
- fragBuilder->codeAppend("half4 shadowParams;");
+ fragBuilder->codeAppend("float4 shadowParams;");
varyingHandler->addPassThroughAttribute(rsgp.inShadowParams(), "shadowParams");
// setup pass through color
@@ -43,12 +43,12 @@ public:
rsgp.inPosition()->fName,
args.fFPCoordTransformHandler);
- fragBuilder->codeAppend("half d = length(shadowParams.xy);");
- fragBuilder->codeAppend("half distance = shadowParams.z * (1.0 - d);");
+ fragBuilder->codeAppend("float d = length(shadowParams.xy);");
+ fragBuilder->codeAppend("float distance = shadowParams.z * (1.0 - d);");
- fragBuilder->codeAppend("half factor = 1.0 - clamp(distance, 0.0, shadowParams.w);");
+ 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 = half4(factor);",
+ fragBuilder->codeAppendf("%s = float4(factor);",
args.fOutputCoverage);
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index ad2a5339f0..3301694004 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -26,15 +26,15 @@ public:
fColorSpaceHelper.emitCode(args.fUniformHandler, _outer.colorXform().get());
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
- "half4 _tmpVar1;%s = %s * %stexture(%s, %s).%s%s;\n", args.fOutputColor,
- args.fInputColor ? args.fInputColor : "half4(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(", half4(clamp((%s * half4(_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 456448a6ea..a4275b566f 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 half4x4 matrix;
+in float4x4 matrix;
@constructorParams {
GrSamplerState samplerParams
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index c297560cea..3bb96b23cd 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -78,7 +78,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
if (textureDomain.fIndex >= 0) {
uniName.appendS32(textureDomain.fIndex);
}
- fDomainUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
+ fDomainUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
uniName.c_str(), &name);
fDomainName = name;
}
@@ -87,7 +88,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
case kIgnore_Mode: {
builder->codeAppendf("%s = ", outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
- kHighFloat2_GrSLType, colorXformHelper);
+ kVec2f_GrSLType, colorXformHelper);
builder->codeAppend(";");
break;
}
@@ -98,7 +99,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
builder->codeAppendf("%s = ", outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
- kHighFloat2_GrSLType, colorXformHelper);
+ kVec2f_GrSLType, colorXformHelper);
builder->codeAppend(";");
break;
}
@@ -114,20 +115,20 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
// 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("half4 outside = half4(0.0, 0.0, 0.0, 0.0);");
- builder->codeAppend("half4 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(),
- kHighFloat2_GrSLType, colorXformHelper);
+ kVec2f_GrSLType, colorXformHelper);
builder->codeAppend(";");
- builder->codeAppendf("highfloat x = (%s).x;", inCoords.c_str());
- builder->codeAppendf("highfloat y = (%s).y;", inCoords.c_str());
+ builder->codeAppendf("highp float x = (%s).x;", inCoords.c_str());
+ builder->codeAppendf("highp float y = (%s).y;", inCoords.c_str());
builder->codeAppendf("x = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1.0);",
domain, domain, domain);
builder->codeAppendf("y = abs(2.0*(y - %s.y)/(%s.w - %s.y) - 1.0);",
domain, domain, domain);
- builder->codeAppend("half blend = step(1.0, max(x, y));");
+ builder->codeAppend("float blend = step(1.0, max(x, y));");
builder->codeAppendf("%s = mix(inside, outside, blend);", outColor);
} else {
builder->codeAppend("bool4 outside;\n");
@@ -135,10 +136,10 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
domain);
builder->codeAppendf("outside.zw = greaterThan(%s, %s.zw);", inCoords.c_str(),
domain);
- builder->codeAppendf("%s = any(outside) ? half4(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(),
- kHighFloat2_GrSLType, colorXformHelper);
+ kVec2f_GrSLType, colorXformHelper);
builder->codeAppend(";");
}
break;
@@ -151,7 +152,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
builder->codeAppendf("%s = ", outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
- kHighFloat2_GrSLType, colorXformHelper);
+ kVec2f_GrSLType, colorXformHelper);
builder->codeAppend(";");
break;
}
@@ -376,10 +377,11 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS
args.fFp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
const char* scaleAndTranslateName;
fScaleAndTranslateUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf4_GrSLType,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
"scaleAndTranslate",
&scaleAndTranslateName);
- args.fFragBuilder->codeAppendf("half2 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 6d1f4b268c..ec0ef4ea8b 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -23,7 +23,7 @@ struct SkRect;
/**
* 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 half4 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,7 +98,7 @@ public:
* Call this from GrGLSLFragmentProcessor::emitCode() to sample the texture W.R.T. the
* domain and mode.
*
- * @param outcolor name of half4 variable to hold the sampled color.
+ * @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
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 11dee67f29..3b9b44cd57 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -217,7 +217,7 @@ void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
const char* inputColor = nullptr;
if (args.fInputColor) {
inputColor = "inputColor";
- fragBuilder->codeAppendf("half4 inputColor = half4(%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
@@ -452,7 +452,7 @@ public:
const char* inputColor = args.fInputColor;
// We don't try to optimize for this case at all
if (!inputColor) {
- fragBuilder->codeAppendf("const half4 ones = half4(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 bf9e94ff76..c45e9b257e 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -89,9 +89,10 @@ public:
const YUVtoRGBEffect& effect = args.fFp.cast<YUVtoRGBEffect>();
const char* colorSpaceMatrix = nullptr;
- fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4x4_GrSLType,
+ fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
+ kMat44f_GrSLType, kDefault_GrSLPrecision,
"ColorSpaceMatrix", &colorSpaceMatrix);
- fragBuilder->codeAppendf("%s = half4(", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(", args.fOutputColor);
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
args.fTransformedCoords[0].c_str(),
args.fTransformedCoords[0].getType());
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 3f66819a77..29df888f30 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3474,13 +3474,13 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
}
const char* version = shaderCaps->versionDeclString();
- GrShaderVar aVertex("a_vertex", kHalf2_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrShaderVar uTexCoordXform("u_texCoordXform", kHalf4_GrSLType,
+ GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
GrShaderVar::kUniform_TypeModifier);
- GrShaderVar uPosXform("u_posXform", kHalf4_GrSLType, GrShaderVar::kUniform_TypeModifier);
+ GrShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUniform_TypeModifier);
GrShaderVar uTexture("u_texture", samplerType, GrShaderVar::kUniform_TypeModifier);
- GrShaderVar vTexCoord("v_texCoord", kHalf2_GrSLType, GrShaderVar::kOut_TypeModifier);
- GrShaderVar oFragColor("o_FragColor", kHalf4_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
if (shaderCaps->noperspectiveInterpolationSupport()) {
@@ -3504,7 +3504,7 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
"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 = half2(0, 1);"
+ " gl_Position.zw = float2(0, 1);"
"}"
);
@@ -3518,6 +3518,8 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
fshaderTxt.appendf("#extension %s : require\n",
shaderCaps->externalTextureExtensionString());
}
+ GrGLSLAppendDefaultFloatPrecisionDeclaration(kMedium_GrSLPrecision, *shaderCaps,
+ &fshaderTxt);
vTexCoord.setTypeModifier(GrShaderVar::kIn_TypeModifier);
vTexCoord.appendDecl(shaderCaps, &fshaderTxt);
fshaderTxt.append(";");
@@ -3581,19 +3583,19 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
}
const char* version = shaderCaps->versionDeclString();
- GrShaderVar aVertex("a_vertex", kHalf2_GrSLType, GrShaderVar::kIn_TypeModifier);
- GrShaderVar uTexCoordXform("u_texCoordXform", kHalf4_GrSLType,
+ GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType,
GrShaderVar::kUniform_TypeModifier);
GrShaderVar uTexture("u_texture", kTexture2DSampler_GrSLType,
GrShaderVar::kUniform_TypeModifier);
// We need 1, 2, or 4 texture coordinates (depending on parity of each dimension):
GrShaderVar vTexCoords[] = {
- GrShaderVar("v_texCoord0", kHalf2_GrSLType, GrShaderVar::kOut_TypeModifier),
- GrShaderVar("v_texCoord1", kHalf2_GrSLType, GrShaderVar::kOut_TypeModifier),
- GrShaderVar("v_texCoord2", kHalf2_GrSLType, GrShaderVar::kOut_TypeModifier),
- GrShaderVar("v_texCoord3", kHalf2_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar("v_texCoord0", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar("v_texCoord1", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar("v_texCoord2", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
+ GrShaderVar("v_texCoord3", kVec2f_GrSLType, GrShaderVar::kOut_TypeModifier),
};
- GrShaderVar oFragColor("o_FragColor", kHalf4_GrSLType,GrShaderVar::kOut_TypeModifier);
+ GrShaderVar oFragColor("o_FragColor", kVec4f_GrSLType,GrShaderVar::kOut_TypeModifier);
SkString vshaderTxt(version);
if (shaderCaps->noperspectiveInterpolationSupport()) {
@@ -3618,27 +3620,27 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
vshaderTxt.append(
"// Mipmap Program VS\n"
"void main() {"
- " gl_Position.xy = a_vertex * half2(2, 2) - half2(1, 1);"
- " gl_Position.zw = half2(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 + half2(u_texCoordXform.x, 0);"
- " v_texCoord2 = a_vertex.xy * u_texCoordXform.yw + half2(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 * half2(u_texCoordXform.y, 1);"
- " v_texCoord1 = a_vertex.xy * half2(u_texCoordXform.y, 1) + half2(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 * half2(1, u_texCoordXform.w);"
- " v_texCoord1 = a_vertex.xy * half2(1, u_texCoordXform.w) + half2(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(
@@ -3654,6 +3656,8 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
fshaderTxt.appendf("#extension %s : require\n", extension);
}
}
+ GrGLSLAppendDefaultFloatPrecisionDeclaration(kMedium_GrSLPrecision, *shaderCaps,
+ &fshaderTxt);
for (int i = 0; i < numTaps; ++i) {
vTexCoords[i].setTypeModifier(GrShaderVar::kIn_TypeModifier);
vTexCoords[i].appendDecl(shaderCaps, &fshaderTxt);
@@ -3739,7 +3743,7 @@ bool GrGLGpu::createStencilClipClearProgram() {
return false;
}
- GrShaderVar aVertex("a_vertex", kHalf2_GrSLType, GrShaderVar::kIn_TypeModifier);
+ GrShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kIn_TypeModifier);
const char* version = this->caps()->shaderCaps()->versionDeclString();
SkString vshaderTxt(version);
@@ -3748,14 +3752,17 @@ bool GrGLGpu::createStencilClipClearProgram() {
vshaderTxt.append(
"// Stencil Clip Clear Program VS\n"
"void main() {"
- " gl_Position = highfloat4(a_vertex.x, a_vertex.y, 0, 1);"
+ " gl_Position = float4(a_vertex.x, a_vertex.y, 0, 1);"
"}");
SkString fshaderTxt(version);
+ GrGLSLAppendDefaultFloatPrecisionDeclaration(kMedium_GrSLPrecision,
+ *this->caps()->shaderCaps(),
+ &fshaderTxt);
fshaderTxt.appendf(
"// Stencil Clip Clear Program FS\n"
"void main() {"
- " sk_FragColor = half4(0);"
+ " sk_FragColor = float4(0);"
"}");
const char* str;
diff --git a/src/gpu/gl/GrGLProgramDataManager.cpp b/src/gpu/gl/GrGLProgramDataManager.cpp
index a8e3a6345f..3414abac44 100644
--- a/src/gpu/gl/GrGLProgramDataManager.cpp
+++ b/src/gpu/gl/GrGLProgramDataManager.cpp
@@ -73,7 +73,7 @@ void GrGLProgramDataManager::setImageStorages(const UniformInfoArray& images) co
void GrGLProgramDataManager::set1i(UniformHandle u, int32_t i) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kInt_GrSLType || uni.fType == kShort_GrSLType);
+ SkASSERT(uni.fType == kInt_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fLocation, i));
@@ -84,7 +84,7 @@ void GrGLProgramDataManager::set1iv(UniformHandle u,
int arrayCount,
const int v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kInt_GrSLType || uni.fType == kShort_GrSLType);
+ SkASSERT(uni.fType == kInt_GrSLType);
SkASSERT(arrayCount > 0);
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
if (kUnusedUniform != uni.fLocation) {
@@ -94,7 +94,7 @@ void GrGLProgramDataManager::set1iv(UniformHandle u,
void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
+ SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fLocation, v0));
@@ -105,7 +105,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
+ SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(arrayCount > 0);
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
// This assert fires in some instances of the two-pt gradient for its VSParams.
@@ -119,7 +119,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
+ SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fLocation, v0, v1));
@@ -130,7 +130,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
+ SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(arrayCount > 0);
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
if (kUnusedUniform != uni.fLocation) {
@@ -140,7 +140,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
+ SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fLocation, v0, v1, v2));
@@ -151,7 +151,7 @@ void GrGLProgramDataManager::set3fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
+ SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(arrayCount > 0);
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
if (kUnusedUniform != uni.fLocation) {
@@ -165,7 +165,7 @@ void GrGLProgramDataManager::set4f(UniformHandle u,
float v2,
float v3) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
+ SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
if (kUnusedUniform != uni.fLocation) {
GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fLocation, v0, v1, v2, v3));
@@ -176,7 +176,7 @@ void GrGLProgramDataManager::set4fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
+ SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(arrayCount > 0);
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
if (kUnusedUniform != uni.fLocation) {
@@ -214,8 +214,7 @@ template<int N> inline void GrGLProgramDataManager::setMatrices(UniformHandle u,
int arrayCount,
const float matrices[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat2x2_GrSLType + (N - 2) ||
- uni.fType == kHalf2x2_GrSLType + (N - 2));
+ SkASSERT(uni.fType == kMat22f_GrSLType + (N - 2));
SkASSERT(arrayCount > 0);
ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
if (kUnusedUniform != uni.fLocation) {
@@ -247,10 +246,8 @@ void GrGLProgramDataManager::setPathFragmentInputTransform(VaryingHandle u,
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
const PathProcVarying& fragmentInput = fPathProcVaryings[u.toIndex()];
- SkASSERT((components == 2 && (fragmentInput.fType == kHighFloat2_GrSLType ||
- fragmentInput.fType == kHalf2_GrSLType)) ||
- (components == 3 && (fragmentInput.fType == kHighFloat3_GrSLType ||
- fragmentInput.fType == kHalf3_GrSLType)));
+ SkASSERT((components == 2 && fragmentInput.fType == kVec2f_GrSLType) ||
+ (components == 3 && fragmentInput.fType == kVec3f_GrSLType));
fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID,
fragmentInput.fLocation,
diff --git a/src/gpu/gl/GrGLUniformHandler.cpp b/src/gpu/gl/GrGLUniformHandler.cpp
index 914f8bc6c5..4d718a0e4a 100644
--- a/src/gpu/gl/GrGLUniformHandler.cpp
+++ b/src/gpu/gl/GrGLUniformHandler.cpp
@@ -24,7 +24,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
const char** outName) {
SkASSERT(name && strlen(name));
SkASSERT(0 != visibility);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeTemporarilyAcceptsPrecision(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
UniformInfo& uni = fUniforms.push_back();
uni.fVariable.setType(type);
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 31d20f0421..b7d31203aa 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -139,9 +139,6 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
return nullptr;
}
- if (fFS.fForceHighPrecision) {
- settings.fForceHighPrecision = true;
- }
if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &shadersToDelete,
settings, &inputs)) {
this->cleanupProgram(programID, shadersToDelete);
diff --git a/src/gpu/glsl/GrGLSL.cpp b/src/gpu/glsl/GrGLSL.cpp
index db8b7d6206..6fe1e2665d 100644
--- a/src/gpu/glsl/GrGLSL.cpp
+++ b/src/gpu/glsl/GrGLSL.cpp
@@ -30,47 +30,33 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
switch (t) {
case kVoid_GrSLType:
return "void";
- case kHalf_GrSLType:
- return "half";
- case kHalf2_GrSLType:
- return "half2";
- case kHalf3_GrSLType:
- return "half3";
- case kHalf4_GrSLType:
- return "half4";
- case kHighFloat_GrSLType:
- return "highfloat";
- case kHighFloat2_GrSLType:
- return "highfloat2";
- case kHighFloat3_GrSLType:
- return "highfloat3";
- case kHighFloat4_GrSLType:
- return "highfloat4";
- case kUint2_GrSLType:
+ case kFloat_GrSLType:
+ return "float";
+ case kVec2f_GrSLType:
+ return "float2";
+ case kVec3f_GrSLType:
+ return "float3";
+ case kVec4f_GrSLType:
+ return "float4";
+ case kVec2us_GrSLType:
if (shaderCaps->integerSupport()) {
return "uint2";
} else {
// uint2 (aka uvec2) isn't supported in GLSL ES 1.00/GLSL 1.20
- return "highfloat2";
+ return "float2";
}
- case kInt2_GrSLType:
+ case kVec2i_GrSLType:
return "int2";
- case kInt3_GrSLType:
+ case kVec3i_GrSLType:
return "int3";
- case kInt4_GrSLType:
+ case kVec4i_GrSLType:
return "int4";
- case kHighFloat2x2_GrSLType:
- return "highfloat2x2";
- case kHighFloat3x3_GrSLType:
- return "highfloat3x3";
- case kHighFloat4x4_GrSLType:
- return "highfloat4x4";
- case kHalf2x2_GrSLType:
- return "half2x2";
- case kHalf3x3_GrSLType:
- return "half3x3";
- case kHalf4x4_GrSLType:
- return "half4x4";
+ case kMat22f_GrSLType:
+ return "float2x2";
+ case kMat33f_GrSLType:
+ return "float3x3";
+ case kMat44f_GrSLType:
+ return "float4x4";
case kTexture2DSampler_GrSLType:
return "sampler2D";
case kITexture2DSampler_GrSLType:
@@ -87,10 +73,6 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
return "int";
case kUint_GrSLType:
return "uint";
- case kShort_GrSLType:
- return "short";
- case kUShort_GrSLType:
- return "ushort";
case kTexture2D_GrSLType:
return "texture2D";
case kSampler_GrSLType:
diff --git a/src/gpu/glsl/GrGLSLBlend.cpp b/src/gpu/glsl/GrGLSLBlend.cpp
index 254f4816cb..34df0df410 100644
--- a/src/gpu/glsl/GrGLSLBlend.cpp
+++ b/src/gpu/glsl/GrGLSLBlend.cpp
@@ -50,7 +50,7 @@ static void color_dodge_component(GrGLSLFragmentBuilder* fsBuilder,
fsBuilder->codeAppendf("%s.%c = %s.%c * (1.0 - %s.a);",
final, component, src, component, dst);
fsBuilder->codeAppend("} else {");
- fsBuilder->codeAppendf("half d = %s.a - %s.%c;", src, src, component);
+ fsBuilder->codeAppendf("float d = %s.a - %s.%c;", src, src, component);
fsBuilder->codeAppend("if (0.0 == d) {");
fsBuilder->codeAppendf("%s.%c = %s.a * %s.a + %s.%c * (1.0 - %s.a) + %s.%c * (1.0 - %s.a);",
final, component, src, dst, src, component, dst, dst, component,
@@ -84,7 +84,7 @@ static void color_burn_component(GrGLSLFragmentBuilder* fsBuilder,
fsBuilder->codeAppendf("%s.%c = %s.%c * (1.0 - %s.a);",
final, component, dst, component, src);
fsBuilder->codeAppend("} else {");
- fsBuilder->codeAppendf("half d = max(0.0, %s.a - (%s.a - %s.%c) * %s.a / (%s.%c %s));",
+ fsBuilder->codeAppendf("float d = max(0.0, %s.a - (%s.a - %s.%c) * %s.a / (%s.%c %s));",
dst, dst, dst, component, src, src, component, divisorGuard);
fsBuilder->codeAppendf("%s.%c = %s.a * d + %s.%c * (1.0 - %s.a) + %s.%c * (1.0 - %s.a);",
final, component, src, src, component, dst, dst, component, src);
@@ -114,11 +114,11 @@ static void soft_light_component_pos_dst_alpha(GrGLSLFragmentBuilder* fsBuilder,
// else if (4D < Da)
fsBuilder->codeAppendf("} else if (4.0 * %s.%c <= %s.a) {",
dst, component, dst);
- fsBuilder->codeAppendf("half DSqd = %s.%c * %s.%c;",
+ fsBuilder->codeAppendf("float DSqd = %s.%c * %s.%c;",
dst, component, dst, component);
- fsBuilder->codeAppendf("half DCub = DSqd * %s.%c;", dst, component);
- fsBuilder->codeAppendf("half DaSqd = %s.a * %s.a;", dst, dst);
- fsBuilder->codeAppendf("half DaCub = DaSqd * %s.a;", dst);
+ fsBuilder->codeAppendf("float DCub = DSqd * %s.%c;", dst, component);
+ fsBuilder->codeAppendf("float DaSqd = %s.a * %s.a;", dst, dst);
+ fsBuilder->codeAppendf("float DaCub = DaSqd * %s.a;", dst);
// (Da^3 (-S)+Da^2 (S-D (3 Sa-6 S-1))+12 Da D^2 (Sa-2 S)-16 D^3 (Sa-2 S))/Da^2
fsBuilder->codeAppendf("%s.%c ="
"(DaSqd*(%s.%c - %s.%c * (3.0*%s.a - 6.0*%s.%c - 1.0)) +"
@@ -144,10 +144,10 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
// Emit a helper that gets the luminance of a color.
SkString getFunction;
GrShaderVar getLumArgs[] = {
- GrShaderVar("color", kHalf3_GrSLType),
+ GrShaderVar("color", kVec3f_GrSLType),
};
- SkString getLumBody("return dot(highfloat3(0.3, 0.59, 0.11), color);");
- fsBuilder->emitFunction(kHalf_GrSLType,
+ SkString getLumBody("return dot(float3(0.3, 0.59, 0.11), color);");
+ fsBuilder->emitFunction(kFloat_GrSLType,
"luminance",
SK_ARRAY_COUNT(getLumArgs), getLumArgs,
getLumBody.c_str(),
@@ -155,27 +155,27 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
// Emit the set luminance function.
GrShaderVar setLumArgs[] = {
- GrShaderVar("hueSat", kHalf3_GrSLType),
- GrShaderVar("alpha", kHalf_GrSLType),
- GrShaderVar("lumColor", kHalf3_GrSLType),
+ GrShaderVar("hueSat", kVec3f_GrSLType),
+ GrShaderVar("alpha", kFloat_GrSLType),
+ GrShaderVar("lumColor", kVec3f_GrSLType),
};
SkString setLumBody;
- setLumBody.printf("half diff = %s(lumColor - hueSat);", getFunction.c_str());
- setLumBody.append("half3 outColor = hueSat + diff;");
- setLumBody.appendf("half outLum = %s(outColor);", getFunction.c_str());
- setLumBody.append("half minComp = min(min(outColor.r, outColor.g), outColor.b);"
- "half maxComp = max(max(outColor.r, outColor.g), outColor.b);"
+ setLumBody.printf("float diff = %s(lumColor - hueSat);", getFunction.c_str());
+ 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 - half3(outLum, outLum, outLum)) * outLum) /"
+ "outColor = outLum + ((outColor - float3(outLum, outLum, outLum)) * outLum) /"
"(outLum - minComp);"
"}"
"if (maxComp > alpha && maxComp != outLum) {"
"outColor = outLum +"
- "((outColor - half3(outLum, outLum, outLum)) * (alpha - outLum)) /"
+ "((outColor - float3(outLum, outLum, outLum)) * (alpha - outLum)) /"
"(maxComp - outLum);"
"}"
"return outColor;");
- fsBuilder->emitFunction(kHalf3_GrSLType,
+ fsBuilder->emitFunction(kVec3f_GrSLType,
"set_luminance",
SK_ARRAY_COUNT(setLumArgs), setLumArgs,
setLumBody.c_str(),
@@ -188,11 +188,11 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
// Emit a helper that gets the saturation of a color
SkString getFunction;
- GrShaderVar getSatArgs[] = { GrShaderVar("color", kHalf3_GrSLType) };
+ GrShaderVar getSatArgs[] = { GrShaderVar("color", kVec3f_GrSLType) };
SkString getSatBody;
getSatBody.printf("return max(max(color.r, color.g), color.b) - "
"min(min(color.r, color.g), color.b);");
- fsBuilder->emitFunction(kHalf_GrSLType,
+ fsBuilder->emitFunction(kFloat_GrSLType,
"saturation",
SK_ARRAY_COUNT(getSatArgs), getSatArgs,
getSatBody.c_str(),
@@ -204,33 +204,33 @@ static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatF
// adjusted min, mid, and max inputs, respectively.
SkString helperFunction;
GrShaderVar helperArgs[] = {
- GrShaderVar("minComp", kHalf_GrSLType),
- GrShaderVar("midComp", kHalf_GrSLType),
- GrShaderVar("maxComp", kHalf_GrSLType),
- GrShaderVar("sat", kHalf_GrSLType),
+ GrShaderVar("minComp", kFloat_GrSLType),
+ GrShaderVar("midComp", kFloat_GrSLType),
+ GrShaderVar("maxComp", kFloat_GrSLType),
+ GrShaderVar("sat", kFloat_GrSLType),
};
static const char kHelperBody[] = "if (minComp < maxComp) {"
- "half3 result;"
+ "float3 result;"
"result.r = 0.0;"
"result.g = sat * (midComp - minComp) / (maxComp - minComp);"
"result.b = sat;"
"return result;"
"} else {"
- "return half3(0, 0, 0);"
+ "return float3(0, 0, 0);"
"}";
- fsBuilder->emitFunction(kHalf3_GrSLType,
+ fsBuilder->emitFunction(kVec3f_GrSLType,
"set_saturation_helper",
SK_ARRAY_COUNT(helperArgs), helperArgs,
kHelperBody,
&helperFunction);
GrShaderVar setSatArgs[] = {
- GrShaderVar("hueLumColor", kHalf3_GrSLType),
- GrShaderVar("satColor", kHalf3_GrSLType),
+ GrShaderVar("hueLumColor", kVec3f_GrSLType),
+ GrShaderVar("satColor", kVec3f_GrSLType),
};
const char* helpFunc = helperFunction.c_str();
SkString setSatBody;
- setSatBody.appendf("half sat = %s(satColor);"
+ setSatBody.appendf("float sat = %s(satColor);"
"if (hueLumColor.r <= hueLumColor.g) {"
"if (hueLumColor.g <= hueLumColor.b) {"
"hueLumColor.rgb = %s(hueLumColor.r, hueLumColor.g, hueLumColor.b, sat);"
@@ -249,7 +249,7 @@ static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatF
"return hueLumColor;",
getFunction.c_str(), helpFunc, helpFunc, helpFunc, helpFunc,
helpFunc, helpFunc);
- fsBuilder->emitFunction(kHalf3_GrSLType,
+ fsBuilder->emitFunction(kVec3f_GrSLType,
"set_saturation",
SK_ARRAY_COUNT(setSatArgs), setSatArgs,
setSatBody.c_str(),
@@ -330,7 +330,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
SkString setSat, setLum;
add_sat_function(fsBuilder, &setSat);
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("half4 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);",
@@ -345,7 +345,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
SkString setSat, setLum;
add_sat_function(fsBuilder, &setSat);
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("half4 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);",
@@ -359,7 +359,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
// SetLum(S * Da, Sa* Da, D * Sa) + (1 - Sa) * D + (1 - Da) * S
SkString setLum;
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("half4 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);
@@ -371,7 +371,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
// SetLum(D * Sa, Sa* Da, S * Da) + (1 - Sa) * D + (1 - Da) * S
SkString setLum;
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("half4 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);
@@ -406,13 +406,13 @@ static bool append_porterduff_term(GrGLSLFragmentBuilder* fsBuilder, SkBlendMode
fsBuilder->codeAppendf(" * %s", srcColorName);
break;
case SkBlendModeCoeff::kISC:
- fsBuilder->codeAppendf(" * (half4(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(" * (half4(1.0) - %s)", dstColorName);
+ fsBuilder->codeAppendf(" * (float4(1.0) - %s)", dstColorName);
break;
case SkBlendModeCoeff::kSA:
fsBuilder->codeAppendf(" * %s.a", srcColorName);
@@ -453,7 +453,7 @@ void GrGLSLBlend::AppendMode(GrGLSLFragmentBuilder* fsBuilder, const char* srcCo
false);
// append dst blend
if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) {
- fsBuilder->codeAppend("half4(0, 0, 0, 0)");
+ fsBuilder->codeAppend("float4(0, 0, 0, 0)");
}
if (clamp) {
fsBuilder->codeAppend(", 0, 1);");
@@ -505,7 +505,7 @@ void GrGLSLBlend::AppendRegionOp(GrGLSLFragmentBuilder* fsBuilder, const char* s
false);
// append dst blend
if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) {
- fsBuilder->codeAppend("half4(0, 0, 0, 0)");
+ fsBuilder->codeAppend("float4(0, 0, 0, 0)");
}
fsBuilder->codeAppend(";");
}
diff --git a/src/gpu/glsl/GrGLSLColorSpaceXformHelper.h b/src/gpu/glsl/GrGLSLColorSpaceXformHelper.h
index f9ac30b6aa..b4605ba3ce 100644
--- a/src/gpu/glsl/GrGLSLColorSpaceXformHelper.h
+++ b/src/gpu/glsl/GrGLSLColorSpaceXformHelper.h
@@ -24,8 +24,8 @@ public:
uint32_t visibility = kFragment_GrShaderFlag) {
SkASSERT(uniformHandler);
if (colorSpaceXform) {
- fGamutXformVar = uniformHandler->addUniform(visibility, kHalf4x4_GrSLType,
- "ColorXform");
+ fGamutXformVar = uniformHandler->addUniform(visibility, kMat44f_GrSLType,
+ kDefault_GrSLPrecision, "ColorXform");
fValid = true;
}
}
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
index ac2de139b0..6f75c16fe9 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
@@ -29,7 +29,7 @@ void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
SkASSERT(outputColor);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
outputColor->append(fragBuilder->getMangleString());
- fragBuilder->codeAppendf("half4 %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 68bd1f24c4..ed4b71ffa2 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.h
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.h
@@ -86,9 +86,9 @@ public:
@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 half4 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 half4 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 @@ public:
}
inline void emitChild(int childIndex, SkString* outputColor, EmitArgs& parentArgs) {
- this->emitChild(childIndex, "half4(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 @@ public:
EmitArgs& parentArgs);
inline void emitChild(int childIndex, EmitArgs& args) {
- this->emitChild(childIndex, "half4(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 9d4ece0cff..7e6b8f771c 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -85,7 +85,8 @@ GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* p
, fCustomColorOutputIndex(-1)
, fHasSecondaryOutput(false)
, fUsedSampleOffsetArrays(0)
- , fHasInitializedSampleMask(false) {
+ , fHasInitializedSampleMask(false)
+ , fDefaultPrecision(kMedium_GrSLPrecision) {
fSubstageIndices.push_back(0);
#ifdef SK_DEBUG
fUsedProcessorFeatures = GrProcessor::kNone_RequiredFeatures;
@@ -111,14 +112,14 @@ bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
}
SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords) {
- if (kHighFloat3_GrSLType != coords.getType() && kHalf3_GrSLType != coords.getType()) {
- SkASSERT(kHighFloat2_GrSLType == coords.getType() || kHalf2_GrSLType == coords.getType());
+ if (kVec3f_GrSLType != coords.getType()) {
+ SkASSERT(kVec2f_GrSLType == coords.getType());
return coords.getName();
}
SkString coords2D;
coords2D.printf("%s_ensure2D", coords.c_str());
- this->codeAppendf("\thighfloat2 %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;
}
@@ -174,6 +175,10 @@ void GrGLSLFragmentShaderBuilder::overrideSampleCoverage(const char* mask) {
fHasInitializedSampleMask = true;
}
+void GrGLSLFragmentShaderBuilder::elevateDefaultPrecision(GrSLPrecision precision) {
+ fDefaultPrecision = SkTMax(fDefaultPrecision, precision);
+}
+
const char* GrGLSLFragmentShaderBuilder::dstColor() {
SkDEBUGCODE(fHasReadDstColor = true;)
@@ -194,7 +199,7 @@ const char* GrGLSLFragmentShaderBuilder::dstColor() {
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("half4 %s = %s;", kDstColorName, fbFetchColorName);
+ this->codeAppendf("float4 %s = %s;", kDstColorName, fbFetchColorName);
} else {
return fbFetchColorName;
}
@@ -223,7 +228,7 @@ void GrGLSLFragmentShaderBuilder::enableCustomOutput() {
if (!fHasCustomColorOutput) {
fHasCustomColorOutput = true;
fCustomColorOutputIndex = fOutputs.count();
- fOutputs.push_back().set(kHalf4_GrSLType, DeclaredColorOutputName(),
+ fOutputs.push_back().set(kVec4f_GrSLType, DeclaredColorOutputName(),
GrShaderVar::kOut_TypeModifier);
fProgramBuilder->finalizeFragmentOutputColor(fOutputs.back());
}
@@ -242,7 +247,7 @@ void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() {
// output. The condition also co-incides with the condition in whici GLES SL 2.0
// requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
if (caps.mustDeclareFragmentShaderOutput()) {
- fOutputs.push_back().set(kHalf4_GrSLType, DeclaredSecondaryColorOutputName(),
+ fOutputs.push_back().set(kVec4f_GrSLType, DeclaredSecondaryColorOutputName(),
GrShaderVar::kOut_TypeModifier);
fProgramBuilder->finalizeFragmentSecondaryColor(fOutputs.back());
}
@@ -275,6 +280,9 @@ GrSurfaceOrigin GrGLSLFragmentShaderBuilder::getSurfaceOrigin() const {
void GrGLSLFragmentShaderBuilder::onFinalize() {
fProgramBuilder->varyingHandler()->getFragDecls(&this->inputs(), &this->outputs());
+ GrGLSLAppendDefaultFloatPrecisionDeclaration(fDefaultPrecision,
+ *fProgramBuilder->shaderCaps(),
+ &this->precisionQualifier());
if (fUsedSampleOffsetArrays & (1 << kSkiaDevice_Coordinates)) {
this->defineSampleOffsetArray(sample_offset_array_name(kSkiaDevice_Coordinates),
SkMatrix::MakeTrans(-0.5f, -0.5f));
@@ -297,9 +305,9 @@ void GrGLSLFragmentShaderBuilder::defineSampleOffsetArray(const char* name, cons
SkSTArray<16, SkPoint, true> offsets;
offsets.push_back_n(specs.fEffectiveSampleCnt);
m.mapPoints(offsets.begin(), specs.fSampleLocations, specs.fEffectiveSampleCnt);
- this->definitions().appendf("const highfloat2 %s[] = highfloat2[](", name);
+ this->definitions().appendf("const highp float2 %s[] = float2[](", name);
for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) {
- this->definitions().appendf("highfloat2(%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/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
index f124a449e6..73fe51f171 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
@@ -40,7 +40,7 @@ public:
/**
* This returns a variable name to access the 2D, perspective correct version of the coords in
- * the fragment shader. The passed in coordinates must either be of type kHalf2 or kHalf3. If
+ * the fragment shader. The passed in coordinates must either be of type kVec2f or kVec3f. If
* the coordinates are 3-dimensional, it a perspective divide into is emitted into the
* fragment shader (xy / z) to convert them to 2D.
*/
@@ -90,6 +90,13 @@ public:
virtual void maskSampleCoverage(const char* mask, bool invert = false) = 0;
/**
+ * Overrides the default precision for the entire fragment program. Processors that require
+ * high precision input (eg from incoming texture samples) may use this. For calculations that
+ * are limited to a single processor's code, it is better to annotate individual declarations.
+ */
+ virtual void elevateDefaultPrecision(GrSLPrecision) = 0;
+
+ /**
* Fragment procs with child procs should call these functions before/after calling emitCode
* on a child proc.
*/
@@ -97,8 +104,6 @@ public:
virtual void onAfterChildProcEmitCode() = 0;
virtual const SkString& getMangleString() const = 0;
-
- virtual void forceHighPrecision() = 0;
};
/*
@@ -164,10 +169,10 @@ public:
void appendOffsetToSample(const char* sampleIdx, Coordinates) override;
void maskSampleCoverage(const char* mask, bool invert = false) override;
void overrideSampleCoverage(const char* mask) override;
+ void elevateDefaultPrecision(GrSLPrecision) override;
const SkString& getMangleString() const override { return fMangleString; }
void onBeforeChildProcEmitCode() override;
void onAfterChildProcEmitCode() override;
- void forceHighPrecision() override { fForceHighPrecision = true; }
// GrGLSLXPFragmentBuilder interface.
bool hasCustomColorOutput() const override { return fHasCustomColorOutput; }
@@ -229,7 +234,7 @@ private:
bool fHasSecondaryOutput;
uint8_t fUsedSampleOffsetArrays;
bool fHasInitializedSampleMask;
- bool fForceHighPrecision;
+ GrSLPrecision fDefaultPrecision;
#ifdef SK_DEBUG
// some state to verify shaders and effects are consistent, this is reset between effects by
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index 072d62c509..a390036fe2 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -18,8 +18,7 @@ void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) {
GrGPArgs gpArgs;
this->onEmitCode(args, &gpArgs);
vBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar, args.fRTAdjustName);
- if (kHighFloat2_GrSLType == gpArgs.fPositionVar.getType() ||
- kHalf2_GrSLType == gpArgs.fPositionVar.getType()) {
+ if (kVec2f_GrSLType == gpArgs.fPositionVar.getType()) {
args.fVaryingHandler->setNoPerspective();
}
}
@@ -40,28 +39,32 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
uint32_t type = coordTransform->getMatrix().getType();
type |= localMatrix.getType();
- varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kHighFloat3_GrSLType :
- kHighFloat2_GrSLType;
+ varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSLType :
+ kVec2f_GrSLType;
+ // Coord transforms are always handled at high precision
+ const GrSLPrecision precision = kHigh_GrSLPrecision;
+
const char* uniName;
fInstalledTransforms.push_back().fHandle = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kHighFloat3x3_GrSLType,
+ kMat33f_GrSLType,
+ precision,
strUniName.c_str(),
&uniName).toIndex();
SkString strVaryingName;
strVaryingName.printf("TransformedCoords_%d", i);
GrGLSLVertToFrag v(varyingType);
- varyingHandler->addVarying(strVaryingName.c_str(), &v, kHigh_GrSLPrecision);
+ varyingHandler->addVarying(strVaryingName.c_str(), &v, precision);
- SkASSERT(kHighFloat2_GrSLType == varyingType || kHighFloat3_GrSLType == varyingType);
+ SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
handler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType);
- if (kHighFloat2_GrSLType == varyingType) {
- vb->codeAppendf("%s = (%s * highfloat3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
+ if (kVec2f_GrSLType == varyingType) {
+ vb->codeAppendf("%s = (%s * float3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
} else {
- vb->codeAppendf("%s = %s * highfloat3(%s, 1);", v.vsOut(), uniName, localCoords);
+ vb->codeAppendf("%s = %s * float3(%s, 1);", v.vsOut(), uniName, localCoords);
}
++i;
}
@@ -85,8 +88,8 @@ void GrGLSLGeometryProcessor::setTransformDataHelper(const SkMatrix& localMatrix
void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
GrGPArgs* gpArgs,
const char* posName) {
- gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "pos2");
- vertBuilder->codeAppendf("highfloat2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
+ vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
}
void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuilder,
@@ -96,21 +99,21 @@ void GrGLSLGeometryProcessor::writeOutputPosition(GrGLSLVertexBuilder* vertBuild
const SkMatrix& mat,
UniformHandle* viewMatrixUniform) {
if (mat.isIdentity()) {
- gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "pos2");
- vertBuilder->codeAppendf("highfloat2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
+ vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
} else {
const char* viewMatrixName;
*viewMatrixUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
- kHighFloat3x3_GrSLType,
+ kMat33f_GrSLType, kHigh_GrSLPrecision,
"uViewM",
&viewMatrixName);
if (!mat.hasPerspective()) {
- gpArgs->fPositionVar.set(kHighFloat2_GrSLType, "pos2");
- vertBuilder->codeAppendf("highfloat2 %s = (%s * highfloat3(%s, 1)).xy;",
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
+ vertBuilder->codeAppendf("float2 %s = (%s * float3(%s, 1)).xy;",
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
} else {
- gpArgs->fPositionVar.set(kHighFloat3_GrSLType, "pos3");
- vertBuilder->codeAppendf("highfloat3 %s = %s * highfloat3(%s, 1);",
+ gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
+ vertBuilder->codeAppendf("float3 %s = %s * float3(%s, 1);",
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
}
}
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
index 0cb7e4d541..d9d17e5356 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
@@ -43,12 +43,13 @@ void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLPPFragmentBuilder* fragBu
SkASSERT(colorUniform);
const char* stagedLocalVarName;
*colorUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf4_GrSLType,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
"Color",
&stagedLocalVarName);
fragBuilder->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
if (fragBuilder->getProgramBuilder()->shaderCaps()->mustObfuscateUniformColor()) {
- fragBuilder->codeAppendf("%s = max(%s, half4(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 c2a0d64e5a..bb3dc4f0a9 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -82,7 +82,8 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
rtAdjustVisibility |= kGeometry_GrShaderFlag;
}
fUniformHandles.fRTAdjustmentUni = this->uniformHandler()->addUniform(rtAdjustVisibility,
- kHighFloat4_GrSLType,
+ kVec4f_GrSLType,
+ kHigh_GrSLPrecision,
"rtAdjustment");
const char* rtAdjustName =
this->uniformHandler()->getUniformCStr(fUniformHandles.fRTAdjustmentUni);
@@ -454,7 +455,7 @@ void GrGLSLProgramBuilder::nameExpression(SkString* output, const char* baseName
} else {
this->nameVariable(&outName, '\0', baseName);
}
- fFS.codeAppendf("half4 %s;", outName.c_str());
+ fFS.codeAppendf("float4 %s;", outName.c_str());
*output = outName;
}
@@ -467,7 +468,7 @@ void GrGLSLProgramBuilder::addRTHeightUniform(const char* name) {
GrGLSLUniformHandler* uniformHandler = this->uniformHandler();
fUniformHandles.fRTHeightUni =
uniformHandler->internalAddUniformArray(kFragment_GrShaderFlag,
- kHalf_GrSLType, kDefault_GrSLPrecision,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
name, false, 0, nullptr);
}
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index f87194e3d3..4d54c7529e 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -122,16 +122,16 @@ void GrGLSLShaderBuilder::appendColorGamutXform(SkString* out,
// re-insert the original alpha. The supplied srcColor is likely to be of the form
// "texture(...)", and we don't want to evaluate that twice, so wrap everything in a function.
static const GrShaderVar gColorGamutXformArgs[] = {
- GrShaderVar("color", kHalf4_GrSLType),
- GrShaderVar("xform", kHalf4x4_GrSLType),
+ GrShaderVar("color", kVec4f_GrSLType),
+ GrShaderVar("xform", kMat44f_GrSLType),
};
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 * half4(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(kHalf4_GrSLType,
+ this->emitFunction(kVec4f_GrSLType,
"colorGamutXform",
SK_ARRAY_COUNT(gColorGamutXformArgs),
gColorGamutXformArgs,
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h
index 9ac6ab7626..4906c03b78 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.h
@@ -37,23 +37,23 @@ public:
void appendTextureLookup(SkString* out,
SamplerHandle,
const char* coordName,
- GrSLType coordType = kHalf2_GrSLType) const;
+ GrSLType coordType = kVec2f_GrSLType) const;
/** Version of above that appends the result to the shader code instead.*/
void appendTextureLookup(SamplerHandle,
const char* coordName,
- GrSLType coordType = kHalf2_GrSLType,
+ GrSLType coordType = kVec2f_GrSLType,
GrGLSLColorSpaceXformHelper* colorXformHelper = nullptr);
/** Does the work of appendTextureLookup and modulates the result by modulation. The result is
- always a half4. modulation and the swizzle specified by SamplerHandle must both be
- half4 or half. 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,
const char* coordName,
- GrSLType coordType = kHalf2_GrSLType,
+ GrSLType coordType = kVec2f_GrSLType,
GrGLSLColorSpaceXformHelper* colorXformHelper = nullptr);
/** Adds a helper function to facilitate color gamut transformation, and produces code that
diff --git a/src/gpu/glsl/GrGLSLUniformHandler.h b/src/gpu/glsl/GrGLSLUniformHandler.h
index 84bbfa104c..cf80c3ff0a 100644
--- a/src/gpu/glsl/GrGLSLUniformHandler.h
+++ b/src/gpu/glsl/GrGLSLUniformHandler.h
@@ -38,13 +38,6 @@ public:
return this->addUniformArray(visibility, type, precision, name, 0, outName);
}
- UniformHandle addUniform(uint32_t visibility,
- GrSLType type,
- const char* name,
- const char** outName = nullptr) {
- return this->addUniform(visibility, type, kDefault_GrSLPrecision, name, outName);
- }
-
UniformHandle addUniformArray(uint32_t visibility,
GrSLType type,
GrSLPrecision precision,
@@ -56,16 +49,6 @@ public:
outName);
}
- UniformHandle addUniformArray(uint32_t visibility,
- GrSLType type,
- const char* name,
- int arrayCount,
- const char** outName = nullptr) {
- SkASSERT(!GrSLTypeIsCombinedSamplerType(type));
- return this->internalAddUniformArray(visibility, type, kDefault_GrSLPrecision, name, true,
- arrayCount, outName);
- }
-
virtual const GrShaderVar& getUniformVariable(UniformHandle u) const = 0;
/**
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
index 4e3b6446f8..e06ee2db6c 100644
--- a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
@@ -18,25 +18,25 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
const char* rtAdjustName) {
// setup RT Uniform
if (this->getProgramBuilder()->desc()->header().fSnapVerticesToPixelCenters) {
- if (kHighFloat3_GrSLType == posVar.getType()) {
+ if (kVec3f_GrSLType == posVar.getType()) {
const char* p = posVar.c_str();
- this->codeAppendf("{highfloat2 _posTmp = highfloat2(%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(kHighFloat2_GrSLType == posVar.getType());
- this->codeAppendf("{highfloat2 _posTmp = %s;", posVar.c_str());
+ SkASSERT(kVec2f_GrSLType == posVar.getType());
+ this->codeAppendf("{float2 _posTmp = %s;", posVar.c_str());
}
- this->codeAppendf("_posTmp = floor(_posTmp) + half2(0.5, 0.5);"
- "gl_Position = highfloat4(_posTmp.x * %s.x + %s.y,"
+ 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 (kHighFloat3_GrSLType == posVar.getType()) {
- this->codeAppendf("gl_Position = highfloat4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
+ } else if (kVec3f_GrSLType == posVar.getType()) {
+ 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(kHighFloat2_GrSLType == posVar.getType());
- this->codeAppendf("gl_Position = highfloat4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
+ SkASSERT(kVec2f_GrSLType == posVar.getType());
+ 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 99862e2e23..6c2c460bec 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -52,7 +52,7 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
// 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, half3(0)))) {"
+ fragBuilder->codeAppendf("if (all(lessThanEqual(%s.rgb, float3(0)))) {"
" discard;"
"}", args.fInputCoverage);
}
@@ -61,25 +61,27 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
const char* dstCoordScaleName;
fDstTopLeftUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf2_GrSLType,
+ kVec2f_GrSLType,
+ kDefault_GrSLPrecision,
"DstTextureUpperLeft",
&dstTopLeftName);
fDstScaleUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kHalf2_GrSLType,
+ kVec2f_GrSLType,
+ kDefault_GrSLPrecision,
"DstTextureCoordScale",
&dstCoordScaleName);
fragBuilder->codeAppend("// Read color from copy of the destination.\n");
- fragBuilder->codeAppendf("half2 _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("half4 %s = ", dstColor);
+ fragBuilder->codeAppendf("float4 %s = ", dstColor);
fragBuilder->appendTextureLookup(args.fDstTextureSamplerHandle, "_dstTexCoord",
- kHalf2_GrSLType);
+ kVec2f_GrSLType);
fragBuilder->codeAppend(";");
} else {
needsLocalOutColor = args.fShaderCaps->requiresLocalOutputColorForFBFetch();
@@ -89,7 +91,7 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
if (!needsLocalOutColor) {
outColor = args.fOutputPrimary;
} else {
- fragBuilder->codeAppendf("half4 %s;", outColor);
+ fragBuilder->codeAppendf("float4 %s;", outColor);
}
this->emitBlendCodeForDstRead(fragBuilder,
@@ -137,18 +139,18 @@ void GrGLSLXferProcessor::DefaultCoverageModulation(GrGLSLXPFragmentBuilder* fra
fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
} else {
- fragBuilder->codeAppendf("%s = half4(1.0);", outColorSecondary);
+ fragBuilder->codeAppendf("%s = float4(1.0);", outColorSecondary);
}
} else if (srcCoverage) {
if (proc.isLCD()) {
- fragBuilder->codeAppendf("half lerpRed = mix(%s.a, %s.a, %s.r);",
+ fragBuilder->codeAppendf("float lerpRed = mix(%s.a, %s.a, %s.r);",
dstColor, outColor, srcCoverage);
- fragBuilder->codeAppendf("half lerpBlue = mix(%s.a, %s.a, %s.g);",
+ fragBuilder->codeAppendf("float lerpBlue = mix(%s.a, %s.a, %s.g);",
dstColor, outColor, srcCoverage);
- fragBuilder->codeAppendf("half lerpGreen = mix(%s.a, %s.a, %s.b);",
+ fragBuilder->codeAppendf("float lerpGreen = mix(%s.a, %s.a, %s.b);",
dstColor, outColor, srcCoverage);
}
- fragBuilder->codeAppendf("%s = %s * %s + (half4(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 75279395c0..d1d826cb17 100644
--- a/src/gpu/instanced/InstanceProcessor.cpp
+++ b/src/gpu/instanced/InstanceProcessor.cpp
@@ -105,38 +105,32 @@ public:
void initParams(const TexelBufferHandle paramsBuffer) {
fParamsBuffer = paramsBuffer;
- fVertexBuilder->codeAppendf("int paramsIdx = int(%s & 0x%x);",
+ fVertexBuilder->codeAppendf("highp int paramsIdx = int(%s & 0x%x);",
this->attr(Attrib::kInstanceInfo),
kParamsIdx_InfoMask);
}
const char* attr(Attrib attr) const { return fInstProc.getAttrib((int)attr).fName; }
- void fetchNextParam(const GrShaderCaps* shaderCaps, GrSLType type = kHalf4_GrSLType) const {
+ void fetchNextParam(const GrShaderCaps* shaderCaps, GrSLType type = kVec4f_GrSLType) const {
SkASSERT(fParamsBuffer.isValid());
switch (type) {
- case kHighFloat2_GrSLType: // fall through
- case kHighFloat3_GrSLType: // fall through
- case kHighFloat4_GrSLType: // fall through
- case kHalf2_GrSLType: // fall through
- case kHalf3_GrSLType: // fall through
- case kHalf4_GrSLType:
+ case kVec2f_GrSLType: // fall through
+ case kVec3f_GrSLType: // fall through
+ case kVec4f_GrSLType:
break;
default:
fVertexBuilder->codeAppendf("%s(", GrGLSLTypeString(shaderCaps, type));
}
fVertexBuilder->appendTexelFetch(fParamsBuffer, "paramsIdx++");
switch (type) {
- case kHighFloat2_GrSLType: // fall through
- case kHalf2_GrSLType:
+ case kVec2f_GrSLType:
fVertexBuilder->codeAppend(".xy");
break;
- case kHighFloat3_GrSLType: // fall through
- case kHalf3_GrSLType:
+ case kVec3f_GrSLType:
fVertexBuilder->codeAppend(".xyz");
break;
- case kHighFloat4_GrSLType: // fall through
- case kHalf4_GrSLType:
+ case kVec4f_GrSLType:
break;
default:
fVertexBuilder->codeAppend(")");
@@ -183,11 +177,11 @@ protected:
, fModifiesCoverage(false)
, fModifiesColor(false)
, fNeedsNeighborRadii(false)
- , fColor(kHalf4_GrSLType)
+ , fColor(kVec4f_GrSLType)
, fTriangleIsArc(kInt_GrSLType)
- , fArcCoords(kHalf2_GrSLType)
- , fInnerShapeCoords(kHalf2_GrSLType)
- , fInnerRRect(kHalf4_GrSLType)
+ , fArcCoords(kVec2f_GrSLType)
+ , fInnerShapeCoords(kVec2f_GrSLType)
+ , fInnerRRect(kVec4f_GrSLType)
, fModifiedShapeCoords(nullptr) {
if (fOpInfo.fShapeTypes & kRRect_ShapesMask) {
fModifiedShapeCoords = "adjustedShapeCoords";
@@ -238,16 +232,16 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
}
if (!ip.opInfo().fHasPerspective) {
- v->codeAppendf("half2x3 shapeMatrix = half2x3(%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("half3x3 shapeMatrix = half3x3(%s, %s, half3(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 & uint(PERSPECTIVE_FLAG))) {",
inputs.attr(Attrib::kInstanceInfo));
v->codeAppend ( "shapeMatrix[2] = ");
- inputs.fetchNextParam(args.fShaderCaps, kHalf3_GrSLType);
+ inputs.fetchNextParam(args.fShaderCaps, kVec3f_GrSLType);
v->codeAppend ( ";");
v->codeAppend ("}");
}
@@ -309,16 +303,16 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
inputs.attr(Attrib::kInstanceInfo));
}
// Here we take advantage of the fact that outerRect == localRect in recordDRRect.
- v->codeAppendf("half4 outer = %s;", inputs.attr(Attrib::kLocalRect));
- v->codeAppend ("half4 inner = ");
+ v->codeAppendf("float4 outer = %s;", inputs.attr(Attrib::kLocalRect));
+ v->codeAppend ("float4 inner = ");
inputs.fetchNextParam(args.fShaderCaps);
v->codeAppend (";");
// outer2Inner is a transform from shape coords to inner shape coords:
// e.g. innerShapeCoords = shapeCoords * outer2Inner.xy + outer2Inner.zw
- v->codeAppend ("half4 outer2Inner = half4(outer.zw - outer.xy, "
- "outer.xy + outer.zw - inner.xy - inner.zw) / "
- "(inner.zw - inner.xy).xyxy;");
- v->codeAppendf("half2 innerShapeCoords = %s * outer2Inner.xy + outer2Inner.zw;",
+ v->codeAppend ("float4 outer2Inner = float4(outer.zw - outer.xy, "
+ "outer.xy + outer.zw - inner.xy - inner.zw) / "
+ "(inner.zw - inner.xy).xyxy;");
+ v->codeAppendf("float2 innerShapeCoords = %s * outer2Inner.xy + outer2Inner.zw;",
backend->outShapeCoords());
backend->initInnerShape(varyingHandler, v);
@@ -378,8 +372,8 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
const char* localCoords = nullptr;
if (ip.opInfo().fUsesLocalCoords) {
localCoords = "localCoords";
- v->codeAppendf("half2 t = 0.5 * (%s + half2(1));", backend->outShapeCoords());
- v->codeAppendf("half2 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) {
@@ -389,20 +383,20 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
if (!ip.opInfo().fUsesLocalCoords) {
inputs.skipParams(2);
} else {
- v->codeAppendf( "half2x3 localMatrix;");
+ v->codeAppendf( "float2x3 localMatrix;");
v->codeAppend ( "localMatrix[0] = ");
- inputs.fetchNextParam(args.fShaderCaps, kHalf3_GrSLType);
+ inputs.fetchNextParam(args.fShaderCaps, kVec3f_GrSLType);
v->codeAppend ( ";");
v->codeAppend ( "localMatrix[1] = ");
- inputs.fetchNextParam(args.fShaderCaps, kHalf3_GrSLType);
+ inputs.fetchNextParam(args.fShaderCaps, kVec3f_GrSLType);
v->codeAppend ( ";");
- v->codeAppend ( "localCoords = (half3(localCoords, 1) * localMatrix).xy;");
+ v->codeAppend ( "localCoords = (float3(localCoords, 1) * localMatrix).xy;");
}
v->codeAppend("}");
}
- GrSLType positionType = ip.opInfo().fHasPerspective ? kHighFloat3_GrSLType : kHighFloat2_GrSLType;
- v->codeAppendf("%s deviceCoords = highfloat3(%s, 1) * shapeMatrix;",
+ GrSLType positionType = ip.opInfo().fHasPerspective ? kVec3f_GrSLType : kVec2f_GrSLType;
+ v->codeAppendf("%s deviceCoords = float3(%s, 1) * shapeMatrix;",
GrGLSLTypeString(args.fShaderCaps, positionType), backend->outShapeCoords());
gpArgs->fPositionVar.set(positionType, "deviceCoords");
@@ -415,7 +409,7 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
void GLSLInstanceProcessor::Backend::init(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
if (fModifiedShapeCoords) {
- v->codeAppendf("half2 %s = %s;", fModifiedShapeCoords, fInputs.attr(Attrib::kShapeCoords));
+ v->codeAppendf("float2 %s = %s;", fModifiedShapeCoords, fInputs.attr(Attrib::kShapeCoords));
}
this->onInit(varyingHandler, v);
@@ -431,10 +425,10 @@ void GLSLInstanceProcessor::Backend::setupRRect(const GrShaderCaps* shaderCaps,
int* usedShapeDefinitions) {
v->codeAppendf("uint2 corner = uint2(uint(%s) & 1, (uint(%s) >> 1) & 1);",
fInputs.attr(Attrib::kVertexAttrs), fInputs.attr(Attrib::kVertexAttrs));
- v->codeAppend ("half2 cornerSign = half2(corner) * 2.0 - 1.0;");
- v->codeAppendf("half2 radii%s;", fNeedsNeighborRadii ? ", neighborRadii" : "");
- v->codeAppend ("half2x2 p = ");
- fInputs.fetchNextParam(shaderCaps, kHalf2x2_GrSLType);
+ v->codeAppend ("float2 cornerSign = float2(corner) * 2.0 - 1.0;");
+ v->codeAppendf("float2 radii%s;", fNeedsNeighborRadii ? ", neighborRadii" : "");
+ v->codeAppend ("float2x2 p = ");
+ fInputs.fetchNextParam(shaderCaps, kMat22f_GrSLType);
v->codeAppend (";");
uint8_t types = fOpInfo.fShapeTypes & kRRect_ShapesMask;
if (0 == (types & (types - 1))) {
@@ -475,11 +469,11 @@ void GLSLInstanceProcessor::Backend::setupRRect(const GrShaderCaps* shaderCaps,
this->adjustRRectVertices(v);
if (fArcCoords.vsOut()) {
- v->codeAppendf("%s = (cornerSign * %s + radii - half2(1)) / radii;",
+ v->codeAppendf("%s = (cornerSign * %s + radii - float2(1)) / radii;",
fArcCoords.vsOut(), fModifiedShapeCoords);
}
if (fTriangleIsArc.vsOut()) {
- v->codeAppendf("%s = int(all(equal(half2(1), abs(%s))));",
+ v->codeAppendf("%s = int(all(equal(float2(1), abs(%s))));",
fTriangleIsArc.vsOut(), fInputs.attr(Attrib::kShapeCoords));
}
@@ -494,9 +488,9 @@ void GLSLInstanceProcessor::Backend::setupSimpleRadii(GrGLSLVertexBuilder* v) {
}
void GLSLInstanceProcessor::Backend::setupNinePatchRadii(GrGLSLVertexBuilder* v) {
- v->codeAppend("radii = half2(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 = half2(p[0][1 - corner.x], p[1][1 - corner.y]);");
+ v->codeAppend("neighborRadii = float2(p[0][1 - corner.x], p[1][1 - corner.y]);");
}
}
@@ -516,12 +510,12 @@ void GLSLInstanceProcessor::Backend::setupComplexRadii(const GrShaderCaps* shade
* x2 x4
*
*/
- v->codeAppend("half2x2 p2 = ");
- fInputs.fetchNextParam(shaderCaps, kHalf2x2_GrSLType);
+ v->codeAppend("float2x2 p2 = ");
+ fInputs.fetchNextParam(shaderCaps, kMat22f_GrSLType);
v->codeAppend(";");
- v->codeAppend("radii = half2(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 = half2(p[1 - corner.x][corner.y], "
+ v->codeAppend("neighborRadii = float2(p[1 - corner.x][corner.y], "
"p2[1 - corner.y][corner.x]);");
}
}
@@ -550,10 +544,10 @@ void GLSLInstanceProcessor::Backend::initInnerShape(GrGLSLVaryingHandler* varyin
void GLSLInstanceProcessor::Backend::setupInnerSimpleRRect(const GrShaderCaps* shaderCaps,
GrGLSLVertexBuilder* v) {
- v->codeAppend("half2x2 innerP = ");
- fInputs.fetchNextParam(shaderCaps, kHalf2x2_GrSLType);
+ v->codeAppend("float2x2 innerP = ");
+ fInputs.fetchNextParam(shaderCaps, kMat22f_GrSLType);
v->codeAppend(";");
- v->codeAppend("half2 innerRadii = innerP[0] * 2.0 / innerP[1];");
+ v->codeAppend("float2 innerRadii = innerP[0] * 2.0 / innerP[1];");
this->onSetupInnerSimpleRRect(v);
}
@@ -564,7 +558,7 @@ void GLSLInstanceProcessor::Backend::emitCode(GrGLSLVertexBuilder* v, GrGLSLPPFr
fModifiesColor ? outColor : nullptr);
if (outCoverage && !fModifiesCoverage) {
// Even though the subclass doesn't use coverage, we are expected to assign some value.
- f->codeAppendf("%s = half4(1);", outCoverage);
+ f->codeAppendf("%s = float4(1);", outCoverage);
}
if (!fModifiesColor) {
// The subclass didn't assign a value to the output color.
@@ -631,18 +625,18 @@ void GLSLInstanceProcessor::BackendNonAA::onInitInnerShape(GrGLSLVaryingHandler*
void GLSLInstanceProcessor::BackendNonAA::setupInnerRect(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = half4(1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1);", fInnerRRect.vsOut());
}
}
void GLSLInstanceProcessor::BackendNonAA::setupInnerOval(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = half4(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 = half4(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*,
@@ -653,11 +647,11 @@ void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
if (!fOpInfo.fCannotDiscard) {
dropFragment = "discard";
} else if (fModifiesCoverage) {
- f->codeAppend ("half covered = 1.0;");
+ f->codeAppend ("lowp float covered = 1.0;");
dropFragment = "covered = 0.0";
} else if (fModifiesColor) {
- f->codeAppendf("half4 color = %s;", fColor.fsIn());
- dropFragment = "color = half4(0)";
+ f->codeAppendf("lowp float4 color = %s;", fColor.fsIn());
+ dropFragment = "color = float4(0)";
}
if (fTriangleIsArc.fsIn()) {
SkASSERT(dropFragment);
@@ -668,19 +662,19 @@ void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
SkASSERT(dropFragment);
f->codeAppendf("// Inner shape.\n");
if (kRect_ShapeFlag == fOpInfo.fInnerShapeTypes) {
- f->codeAppendf("if (all(lessThanEqual(abs(%s), half2(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), half2(1)))) {", fInnerShapeCoords.fsIn());
- f->codeAppendf( "half2 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, half2(0)))) {");
+ f->codeAppend ( "if (any(lessThan(distanceToArcEdge, float2(0)))) {");
f->codeAppendf( "%s;", dropFragment);
f->codeAppend ( "} else {");
- f->codeAppendf( "half2 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);
@@ -690,7 +684,7 @@ void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
}
}
if (fModifiesCoverage) {
- f->codeAppendf("%s = half4(covered);", outCoverage);
+ f->codeAppendf("%s = float4(covered);", outCoverage);
} else if (fModifiesColor) {
f->codeAppendf("%s = color;", outColor);
}
@@ -702,15 +696,15 @@ class GLSLInstanceProcessor::BackendCoverage : public Backend {
public:
BackendCoverage(OpInfo opInfo, const VertexInputs& inputs)
: INHERITED(opInfo, inputs)
- , fColorTimesRectCoverage(kHalf4_GrSLType)
- , fRectCoverage(kHalf_GrSLType)
- , fEllipseCoords(kHalf2_GrSLType)
- , fEllipseName(kHalf2_GrSLType)
- , fBloatedRadius(kHalf_GrSLType)
- , fDistanceToInnerEdge(kHalf2_GrSLType)
- , fInnerShapeBloatedHalfSize(kHalf2_GrSLType)
- , fInnerEllipseCoords(kHalf2_GrSLType)
- , fInnerEllipseName(kHalf2_GrSLType) {
+ , fColorTimesRectCoverage(kVec4f_GrSLType)
+ , fRectCoverage(kFloat_GrSLType)
+ , fEllipseCoords(kVec2f_GrSLType)
+ , fEllipseName(kVec2f_GrSLType)
+ , fBloatedRadius(kFloat_GrSLType)
+ , fDistanceToInnerEdge(kVec2f_GrSLType)
+ , fInnerShapeBloatedHalfSize(kVec2f_GrSLType)
+ , fInnerEllipseCoords(kVec2f_GrSLType)
+ , fInnerEllipseName(kVec2f_GrSLType) {
fShapeIsCircle = !fOpInfo.fNonSquare && !(fOpInfo.fShapeTypes & kRRect_ShapesMask);
fTweakAlphaForCoverage = !fOpInfo.fCannotTweakAlphaForCoverage && !fOpInfo.fInnerShapeTypes;
fModifiesCoverage = !fTweakAlphaForCoverage;
@@ -757,10 +751,10 @@ private:
void GLSLInstanceProcessor::BackendCoverage::onInit(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
- v->codeAppend ("half2x2 shapeTransposeMatrix = transpose(half2x2(shapeMatrix));");
- v->codeAppend ("half2 shapeHalfSize = half2(length(shapeTransposeMatrix[0]), "
+ v->codeAppend ("float2x2 shapeTransposeMatrix = transpose(float2x2(shapeMatrix));");
+ v->codeAppend ("float2 shapeHalfSize = float2(length(shapeTransposeMatrix[0]), "
"length(shapeTransposeMatrix[1]));");
- v->codeAppend ("half2 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) {
@@ -773,7 +767,7 @@ void GLSLInstanceProcessor::BackendCoverage::onInit(GrGLSLVaryingHandler* varyin
} else {
varyingHandler->addVarying("rectCoverage", &fRectCoverage, kLow_GrSLPrecision);
}
- v->codeAppend("half rectCoverage = 0.0;");
+ v->codeAppend("float rectCoverage = 0.0;");
}
if (kRect_ShapeFlag != fOpInfo.fShapeTypes) {
varyingHandler->addFlatVarying("triangleIsArc", &fTriangleIsArc, kLow_GrSLPrecision);
@@ -789,18 +783,18 @@ void GLSLInstanceProcessor::BackendCoverage::onInit(GrGLSLVaryingHandler* varyin
void GLSLInstanceProcessor::BackendCoverage::setupRect(GrGLSLVertexBuilder* v) {
// Make the border one pixel wide. Inner vs outer is indicated by coordAttrs.
- v->codeAppendf("half2 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(half2(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
// narrower than a pixel.
- v->codeAppend ("half maxCoverage = 4.0 * min(0.5, shapeHalfSize.x) *"
+ v->codeAppend ("float maxCoverage = 4.0 * min(0.5, shapeHalfSize.x) *"
"min(0.5, shapeHalfSize.y);");
v->codeAppendf("rectCoverage = (%s != 0) ? 0.0 : maxCoverage;",
fInputs.attr(Attrib::kVertexAttrs));
@@ -812,9 +806,9 @@ void GLSLInstanceProcessor::BackendCoverage::setupRect(GrGLSLVertexBuilder* v) {
void GLSLInstanceProcessor::BackendCoverage::setupOval(GrGLSLVertexBuilder* v) {
// Offset the inner and outer octagons by one pixel. Inner vs outer is indicated by coordAttrs.
- v->codeAppendf("half2 ovalBloat = (%s != 0) ? bloat : -bloat;",
+ v->codeAppendf("float2 ovalBloat = (%s != 0) ? bloat : -bloat;",
fInputs.attr(Attrib::kVertexAttrs));
- v->codeAppendf("bloatedShapeCoords = %s * max(half2(1.0 + ovalBloat), half2(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()) {
@@ -837,8 +831,8 @@ void GLSLInstanceProcessor::BackendCoverage::adjustRRectVertices(GrGLSLVertexBui
// 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("half2 innerEdge = max(1.0 - bloat, half2(0));");
- v->codeAppend ("half2 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));
@@ -861,7 +855,7 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupRRect(GrGLSLVertexBuilder* v
// 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("half2 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);
@@ -869,8 +863,8 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupRRect(GrGLSLVertexBuilder* v
// 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("half2 clampedRadii = max(radii, bloat);");
- v->codeAppendf("%s = (cornerSign * bloatedShapeCoords + clampedRadii - half2(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());
@@ -878,7 +872,7 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupRRect(GrGLSLVertexBuilder* v
void GLSLInstanceProcessor::BackendCoverage::onInitInnerShape(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
- v->codeAppend("half2 innerShapeHalfSize = shapeHalfSize / outer2Inner.xy;");
+ v->codeAppend("float2 innerShapeHalfSize = shapeHalfSize / outer2Inner.xy;");
if (kOval_ShapeFlag == fOpInfo.fInnerShapeTypes) {
varyingHandler->addVarying("innerEllipseCoords", &fInnerEllipseCoords,
@@ -916,7 +910,7 @@ void GLSLInstanceProcessor::BackendCoverage::setupInnerOval(GrGLSLVertexBuilder*
v->codeAppendf("%s = innerShapeCoords * innerShapeHalfSize;", fInnerEllipseCoords.vsOut());
}
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = half4(0, 0, innerShapeHalfSize);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, innerShapeHalfSize);", fInnerRRect.vsOut());
}
}
@@ -926,7 +920,7 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupInnerSimpleRRect(GrGLSLVerte
v->codeAppendf("%s = 1.0 / (innerRadii * innerRadii * innerShapeHalfSize * "
"innerShapeHalfSize);",
fInnerEllipseName.vsOut());
- v->codeAppendf("%s = half4(1.0 - innerRadii, innerShapeHalfSize);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1.0 - innerRadii, innerShapeHalfSize);", fInnerRRect.vsOut());
}
void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
@@ -943,7 +937,7 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
v->codeAppendf("%s = rectCoverage;", fRectCoverage.vsOut());
}
- SkString coverage("half coverage");
+ SkString coverage("lowp float coverage");
if (fOpInfo.fInnerShapeTypes || (!fTweakAlphaForCoverage && fTriangleIsArc.fsIn())) {
f->codeAppendf("%s;", coverage.c_str());
coverage = "coverage";
@@ -970,7 +964,7 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
if (fOpInfo.fInnerShapeTypes) {
f->codeAppendf("// Inner shape.\n");
- SkString innerCoverageDecl("half innerCoverage");
+ SkString innerCoverageDecl("lowp float innerCoverage");
if (kOval_ShapeFlag == fOpInfo.fInnerShapeTypes) {
this->emitArc(f, fInnerEllipseCoords.fsIn(), fInnerEllipseName.fsIn(),
true /*ellipseCoordsNeedClamp*/, true /*ellipseCoordsMayBeNegative*/,
@@ -984,12 +978,12 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
this->emitInnerRect(f, innerCoverageDecl.c_str());
} else {
f->codeAppendf("%s = 0.0;", innerCoverageDecl.c_str());
- f->codeAppendf("half2 distanceToArcEdge = abs(%s) - %s.xy;",
+ f->codeAppendf("mediump float2 distanceToArcEdge = abs(%s) - %s.xy;",
fInnerShapeCoords.fsIn(), fInnerRRect.fsIn());
- f->codeAppend ("if (any(lessThan(distanceToArcEdge, half2(1e-5)))) {");
+ f->codeAppend ("if (any(lessThan(distanceToArcEdge, float2(1e-5)))) {");
this->emitInnerRect(f, "innerCoverage");
f->codeAppend ("} else {");
- f->codeAppendf( "half2 ellipseCoords = distanceToArcEdge * %s.zw;",
+ f->codeAppendf( "mediump float2 ellipseCoords = distanceToArcEdge * %s.zw;",
fInnerRRect.fsIn());
this->emitArc(f, "ellipseCoords", fInnerEllipseName.fsIn(),
false /*ellipseCoordsNeedClamp*/,
@@ -997,9 +991,9 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
f->codeAppend ("}");
}
}
- f->codeAppendf("%s = half4(max(coverage - innerCoverage, 0.0));", outCoverage);
+ f->codeAppendf("%s = float4(max(coverage - innerCoverage, 0.0));", outCoverage);
} else if (!fTweakAlphaForCoverage) {
- f->codeAppendf("%s = half4(coverage);", outCoverage);
+ f->codeAppendf("%s = float4(coverage);", outCoverage);
}
}
@@ -1022,7 +1016,7 @@ void GLSLInstanceProcessor::BackendCoverage::emitCircle(GrGLSLPPFragmentBuilder*
const char* outCoverage) {
// TODO: circleCoords = max(circleCoords, 0) if we decide to do this optimization on rrects.
SkASSERT(!(kRRect_ShapesMask & fOpInfo.fShapeTypes));
- f->codeAppendf("half distanceToEdge = %s - length(%s);",
+ f->codeAppendf("mediump float distanceToEdge = %s - length(%s);",
fBloatedRadius.fsIn(), fEllipseCoords.fsIn());
f->codeAppendf("%s = clamp(distanceToEdge, 0.0, 1.0);", outCoverage);
}
@@ -1039,27 +1033,27 @@ void GLSLInstanceProcessor::BackendCoverage::emitArc(GrGLSLPPFragmentBuilder* f,
// - To restrict the arcs of rounded rects to their positive quadrants.
// - To avoid inversesqrt(0) in the ellipse formula.
if (ellipseCoordsMayBeNegative) {
- f->codeAppendf("half2 ellipseClampedCoords = max(abs(%s), half2(1e-4));",
+ f->codeAppendf("mediump float2 ellipseClampedCoords = max(abs(%s), float2(1e-4));",
ellipseCoords);
} else {
- f->codeAppendf("half2 ellipseClampedCoords = max(%s, half2(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("highfloat2 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("highfloat implicit = dot(Z, %s) - 1.0;", ellipseCoords);
+ f->codeAppendf("highp float implicit = dot(Z, %s) - 1.0;", ellipseCoords);
// gradDot is the squared length of the gradient of the implicit.
- f->codeAppendf("highfloat gradDot = 4.0 * dot(Z, Z);");
- f->codeAppend ("half approxDist = implicit * inversesqrt(gradDot);");
+ f->codeAppendf("highp float gradDot = 4.0 * dot(Z, Z);");
+ f->codeAppend ("mediump float approxDist = implicit * inversesqrt(gradDot);");
f->codeAppendf("%s = clamp(0.5 - approxDist, 0.0, 1.0);", outCoverage);
}
void GLSLInstanceProcessor::BackendCoverage::emitInnerRect(GrGLSLPPFragmentBuilder* f,
const char* outCoverage) {
- f->codeAppendf("half2 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);
}
@@ -1071,15 +1065,15 @@ public:
BackendMultisample(OpInfo opInfo, const VertexInputs& inputs, int effectiveSampleCnt)
: INHERITED(opInfo, inputs)
, fEffectiveSampleCnt(effectiveSampleCnt)
- , fShapeCoords(kHalf2_GrSLType)
- , fShapeInverseMatrix(kHalf2x2_GrSLType)
- , fFragShapeHalfSpan(kHalf2_GrSLType)
- , fArcTest(kHalf2_GrSLType)
- , fArcInverseMatrix(kHalf2x2_GrSLType)
- , fFragArcHalfSpan(kHalf2_GrSLType)
+ , fShapeCoords(kVec2f_GrSLType)
+ , fShapeInverseMatrix(kMat22f_GrSLType)
+ , fFragShapeHalfSpan(kVec2f_GrSLType)
+ , fArcTest(kVec2f_GrSLType)
+ , fArcInverseMatrix(kMat22f_GrSLType)
+ , fFragArcHalfSpan(kVec2f_GrSLType)
, fEarlyAccept(kInt_GrSLType)
- , fInnerShapeInverseMatrix(kHalf2x2_GrSLType)
- , fFragInnerShapeHalfSpan(kHalf2_GrSLType) {
+ , fInnerShapeInverseMatrix(kMat22f_GrSLType)
+ , fFragInnerShapeHalfSpan(kVec2f_GrSLType) {
fRectTrianglesMaySplit = fOpInfo.fHasPerspective;
fNeedsNeighborRadii = this->isMixedSampled() && !fOpInfo.fHasPerspective;
}
@@ -1187,9 +1181,9 @@ void GLSLInstanceProcessor::BackendMultisample::onInit(GrGLSLVaryingHandler* var
}
}
if (!fOpInfo.fHasPerspective) {
- v->codeAppend("half2x2 shapeInverseMatrix = inverse(half2x2(shapeMatrix));");
- v->codeAppend("half2 fragShapeSpan = abs(half4(shapeInverseMatrix).xz) + "
- "abs(half4(shapeInverseMatrix).yw);");
+ v->codeAppend("float2x2 shapeInverseMatrix = inverse(float2x2(shapeMatrix));");
+ v->codeAppend("float2 fragShapeSpan = abs(float4(shapeInverseMatrix).xz) + "
+ "abs(float4(shapeInverseMatrix).yw);");
}
}
@@ -1205,7 +1199,7 @@ void GLSLInstanceProcessor::BackendMultisample::setupRect(GrGLSLVertexBuilder* v
}
if (fArcTest.vsOut()) {
// Pick a value that is not > 0.
- v->codeAppendf("%s = highfloat2(0);", fArcTest.vsOut());
+ v->codeAppendf("%s = float2(0);", fArcTest.vsOut());
}
if (fTriangleIsArc.vsOut()) {
v->codeAppendf("%s = 0;", fTriangleIsArc.vsOut());
@@ -1218,8 +1212,8 @@ void GLSLInstanceProcessor::BackendMultisample::setupRect(GrGLSLVertexBuilder* v
void GLSLInstanceProcessor::BackendMultisample::setupOval(GrGLSLVertexBuilder* v) {
v->codeAppendf("%s = abs(%s);", fArcCoords.vsOut(), this->outShapeCoords());
if (fArcInverseMatrix.vsOut()) {
- v->codeAppendf("half2 s = sign(%s);", this->outShapeCoords());
- v->codeAppendf("%s = shapeInverseMatrix * half2x2(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()) {
@@ -1227,7 +1221,7 @@ void GLSLInstanceProcessor::BackendMultisample::setupOval(GrGLSLVertexBuilder* v
}
if (fArcTest.vsOut()) {
// Pick a value that is > 0.
- v->codeAppendf("%s = half2(1);", fArcTest.vsOut());
+ v->codeAppendf("%s = float2(1);", fArcTest.vsOut());
}
if (fTriangleIsArc.vsOut()) {
if (!this->isMixedSampled()) {
@@ -1253,13 +1247,13 @@ void GLSLInstanceProcessor::BackendMultisample::adjustRRectVertices(GrGLSLVertex
// 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 ("half2 midpt = 0.5 * (neighborRadii - radii);");
- v->codeAppend ("half2 cornerSize = any(lessThan(radii, fragShapeSpan)) ? "
- "half2(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 ("half2 cornerSize = any(lessThan(radii, half2(1e-3))) ? half2(0) : radii;");
+ v->codeAppend ("float2 cornerSize = any(lessThan(radii, float2(1e-3))) ? float2(0) : radii;");
}
v->codeAppendf("if (abs(%s.x) == 0.5)"
@@ -1281,12 +1275,12 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupRRect(GrGLSLVertexBuilder
v->codeAppendf("%s = 0.5 * fragShapeSpan;", fFragShapeHalfSpan.vsOut());
}
if (fArcInverseMatrix.vsOut()) {
- v->codeAppend ("half2 s = cornerSign / radii;");
- v->codeAppendf("%s = shapeInverseMatrix * half2x2(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(half4(%s).xz) + abs(half4(%s).yw));",
+ v->codeAppendf("%s = 0.5 * (abs(float4(%s).xz) + abs(float4(%s).yw));",
fFragArcHalfSpan.vsOut(), fArcInverseMatrix.vsOut(),
fArcInverseMatrix.vsOut());
}
@@ -1295,8 +1289,8 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupRRect(GrGLSLVertexBuilder
// 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 == half2(0)) ? half2(0) : "
- "cornerSign * %s * half2x2(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
@@ -1309,7 +1303,7 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupRRect(GrGLSLVertexBuilder
}
if (fEarlyAccept.vsOut()) {
SkASSERT(this->isMixedSampled());
- v->codeAppendf("%s = all(equal(half2(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));
}
}
@@ -1325,7 +1319,7 @@ GLSLInstanceProcessor::BackendMultisample::onInitInnerShape(GrGLSLVaryingHandler
if (!fOpInfo.fHasPerspective) {
varyingHandler->addFlatVarying("innerShapeInverseMatrix", &fInnerShapeInverseMatrix,
kHigh_GrSLPrecision);
- v->codeAppendf("%s = shapeInverseMatrix * highfloat2x2(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);
@@ -1339,14 +1333,14 @@ void GLSLInstanceProcessor::BackendMultisample::setupInnerRect(GrGLSLVertexBuild
// 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 = half4(2.0 * (inner.zw - inner.xy) / (outer.zw - outer.xy), half2(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 = half4(0, 0, 1, 1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, 1, 1);", fInnerRRect.vsOut());
}
}
@@ -1355,9 +1349,9 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupInnerSimpleRRect(GrGLSLVe
if (fFragInnerShapeHalfSpan.vsOut()) {
v->codeAppendf("innerRadii = max(innerRadii, 2e-1 * %s);", fFragInnerShapeHalfSpan.vsOut());
} else {
- v->codeAppend ("innerRadii = max(innerRadii, half2(1e-4));");
+ v->codeAppend ("innerRadii = max(innerRadii, float2(1e-4));");
}
- v->codeAppendf("%s = half4(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*,
@@ -1370,8 +1364,8 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
}
if (kRect_ShapeFlag != (fOpInfo.fShapeTypes | fOpInfo.fInnerShapeTypes)) {
- GrShaderVar x("x", kHighFloat2_GrSLType, GrShaderVar::kNonArray);
- f->emitFunction(kHalf_GrSLType, "square", 1, &x, "return dot(x, x);", &fSquareFun);
+ GrShaderVar x("x", kVec2f_GrSLType, GrShaderVar::kNonArray, kHigh_GrSLPrecision);
+ f->emitFunction(kFloat_GrSLType, "square", 1, &x, "return dot(x, x);", &fSquareFun);
}
EmitShapeCoords shapeCoords;
@@ -1393,7 +1387,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
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("highfloat2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
+ f->codeAppendf("highp float2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
fInnerShapeCoords.fsIn());
}
@@ -1410,7 +1404,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
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("highfloat2 arcTest = %s - 0.5 * fwidth(%s);",
+ f->codeAppendf("highp float2 arcTest = %s - 0.5 * fwidth(%s);",
fArcTest.fsIn(), fArcTest.fsIn());
arcTest = "arcTest";
}
@@ -1421,7 +1415,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
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, highfloat2(0)))) {", arcTest);
+ "all(greaterThan(%s, float2(0)))) {", arcTest);
this->emitArc(f, arcCoords, false, clampArcCoords, opts);
f->codeAppend ("} else {");
this->emitRect(f, shapeCoords, opts);
@@ -1494,10 +1488,10 @@ void GLSLInstanceProcessor::BackendMultisample::emitRect(GrGLSLPPFragmentBuilder
}
f->codeAppend ("int rectMask = 0;");
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highfloat2 pt = ");
+ f->codeAppend ( "highp float2 pt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", coords.fInverseMatrix);
f->codeAppend ( ";");
- f->codeAppend ( "if (all(lessThan(abs(pt), highfloat2(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) {
@@ -1513,7 +1507,7 @@ void GLSLInstanceProcessor::BackendMultisample::emitArc(GrGLSLPPFragmentBuilder*
SkString absArcCoords;
absArcCoords.printf(coordsMayBeNegative ? "abs(%s)" : "%s", coords.fVarying->fsIn());
if (clampCoords) {
- f->codeAppendf("if (%s(max(%s + %s, half2(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) {",
@@ -1521,7 +1515,7 @@ void GLSLInstanceProcessor::BackendMultisample::emitArc(GrGLSLPPFragmentBuilder*
}
// The entire pixel is inside the arc.
this->acceptOrRejectWholeFragment(f, true, opts);
- f->codeAppendf("} else if (%s(max(%s - %s, half2(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);
@@ -1529,12 +1523,12 @@ void GLSLInstanceProcessor::BackendMultisample::emitArc(GrGLSLPPFragmentBuilder*
}
f->codeAppend ( "int arcMask = 0;");
f->codeAppend ( "for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highfloat2 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, highfloat2(0));");
+ f->codeAppend ( "pt = max(pt, float2(0));");
}
f->codeAppendf( "if (%s(pt) < 1.0) arcMask |= (1 << i);", fSquareFun.c_str());
f->codeAppend ( "}");
@@ -1548,31 +1542,31 @@ void GLSLInstanceProcessor::BackendMultisample::emitSimpleRRect(GrGLSLPPFragment
const EmitShapeCoords& coords,
const char* rrect,
const EmitShapeOpts& opts) {
- f->codeAppendf("highfloat2 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, highfloat2(0)))) {");
+ f->codeAppend ("if (any(lessThan(distanceToArcEdge, float2(0)))) {");
this->emitRect(f, coords, opts);
f->codeAppend ("} else {");
if (coords.fInverseMatrix && coords.fFragHalfSpan) {
- f->codeAppendf("highfloat2 rrectCoords = distanceToArcEdge * %s.zw;", rrect);
- f->codeAppendf("highfloat2 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, highfloat2(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( "highfloat2 s = %s.zw * sign(%s);", rrect, coords.fVarying->fsIn());
- f->codeAppendf( "highfloat2x2 innerRRectInverseMatrix = %s * "
- "highfloat2x2(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 ( "highfloat2 pt = rrectCoords + ");
+ f->codeAppend ( "highp float2 pt = rrectCoords + ");
f->appendOffsetToSample("i", GrGLSLFPFragmentBuilder::kSkiaDevice_Coordinates);
f->codeAppend ( "* innerRRectInverseMatrix;");
- f->codeAppendf( "if (%s(max(pt, highfloat2(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);
@@ -1580,10 +1574,10 @@ void GLSLInstanceProcessor::BackendMultisample::emitSimpleRRect(GrGLSLPPFragment
} else {
f->codeAppend ("int rrectMask = 0;");
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highfloat2 shapePt = ");
+ f->codeAppend ( "highp float2 shapePt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", nullptr);
f->codeAppend ( ";");
- f->codeAppendf( "highfloat2 rrectPt = max(abs(shapePt) - %s.xy, highfloat2(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 50077a89b6..91b54c8d01 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -564,7 +564,7 @@ public:
// emit attributes
varyingHandler->emitAttributes(qe);
- GrGLSLVertToFrag v(kHalf4_GrSLType);
+ GrGLSLVertToFrag v(kVec4f_GrSLType);
varyingHandler->addVarying("QuadEdge", &v);
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.fInQuadEdge->fName);
@@ -585,17 +585,17 @@ public:
qe.fLocalMatrix,
args.fFPCoordTransformHandler);
- fragBuilder->codeAppendf("half edgeAlpha;");
+ fragBuilder->codeAppendf("float edgeAlpha;");
// keep the derivative instructions outside the conditional
- fragBuilder->codeAppendf("half2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("half2 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("half2 gF = half2(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 @@ public:
fragBuilder->codeAppendf("edgeAlpha = "
"clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);}");
- fragBuilder->codeAppendf("%s = half4(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 76f1ff4981..640e8a9f7b 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -887,12 +887,12 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->emitAttributes(dce);
// XY are dashPos, Z is dashInterval
- GrGLSLVertToFrag dashParams(kHalf3_GrSLType);
+ GrGLSLVertToFrag dashParams(kVec3f_GrSLType);
varyingHandler->addVarying("DashParam", &dashParams);
vertBuilder->codeAppendf("%s = %s;", dashParams.vsOut(), dce.inDashParams()->fName);
// x refers to circle radius - 0.5, y refers to cicle's center x coord
- GrGLSLVertToFrag circleParams(kHalf2_GrSLType);
+ GrGLSLVertToFrag circleParams(kVec2f_GrSLType);
varyingHandler->addVarying("CircleParams", &circleParams);
vertBuilder->codeAppendf("%s = %s;", circleParams.vsOut(), dce.inCircleParams()->fName);
@@ -913,21 +913,21 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
args.fFPCoordTransformHandler);
// transforms all points so that we can compare them to our test circle
- fragBuilder->codeAppendf("half xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
+ fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
dashParams.fsIn(), dashParams.fsIn(), dashParams.fsIn(),
dashParams.fsIn());
- fragBuilder->codeAppendf("half2 fragPosShifted = half2(xShifted, %s.y);", dashParams.fsIn());
- fragBuilder->codeAppendf("half2 center = half2(%s.y, 0.0);", circleParams.fsIn());
- fragBuilder->codeAppend("half dist = length(center - fragPosShifted);");
+ 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("half diff = dist - %s.x;", circleParams.fsIn());
+ fragBuilder->codeAppendf("float diff = dist - %s.x;", circleParams.fsIn());
fragBuilder->codeAppend("diff = 1.0 - diff;");
- fragBuilder->codeAppend("half alpha = clamp(diff, 0.0, 1.0);");
+ fragBuilder->codeAppend("float alpha = clamp(diff, 0.0, 1.0);");
} else {
- fragBuilder->codeAppendf("half alpha = 1.0;");
+ fragBuilder->codeAppendf("float alpha = 1.0;");
fragBuilder->codeAppendf("alpha *= dist < %s.x + 0.5 ? 1.0 : 0.0;", circleParams.fsIn());
}
- fragBuilder->codeAppendf("%s = half4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
}
void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
@@ -1090,13 +1090,13 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->emitAttributes(de);
// XY refers to dashPos, Z is the dash interval length
- GrGLSLVertToFrag inDashParams(kHighFloat3_GrSLType);
+ GrGLSLVertToFrag inDashParams(kVec3f_GrSLType);
varyingHandler->addVarying("DashParams", &inDashParams, GrSLPrecision::kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", inDashParams.vsOut(), de.inDashParams()->fName);
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
// respectively.
- GrGLSLVertToFrag inRectParams(kHighFloat4_GrSLType);
+ GrGLSLVertToFrag inRectParams(kVec4f_GrSLType);
varyingHandler->addVarying("RectParams", &inRectParams, GrSLPrecision::kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", inRectParams.vsOut(), de.inRectParams()->fName);
@@ -1117,14 +1117,14 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
args.fFPCoordTransformHandler);
// transforms all points so that we can compare them to our test rect
- fragBuilder->codeAppendf("half xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
+ fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(),
inDashParams.fsIn());
- fragBuilder->codeAppendf("half2 fragPosShifted = half2(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.
- fragBuilder->codeAppend("half xSub, ySub;");
+ fragBuilder->codeAppend("float xSub, ySub;");
fragBuilder->codeAppendf("xSub = min(fragPosShifted.x - %s.x, 0.0);", inRectParams.fsIn());
fragBuilder->codeAppendf("xSub += min(%s.z - fragPosShifted.x, 0.0);", inRectParams.fsIn());
fragBuilder->codeAppendf("ySub = min(fragPosShifted.y - %s.y, 0.0);", inRectParams.fsIn());
@@ -1132,24 +1132,24 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// Now compute coverage in x and y and multiply them to get the fraction of the pixel
// covered.
fragBuilder->codeAppendf(
- "half alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));");
+ "float alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));");
} else if (de.aaMode() == AAMode::kCoverageWithMSAA) {
// For MSAA, we don't modulate the alpha by the Y distance, since MSAA coverage will handle
// AA on the the top and bottom edges. The shader is only responsible for intra-dash alpha.
- fragBuilder->codeAppend("half xSub;");
+ fragBuilder->codeAppend("float xSub;");
fragBuilder->codeAppendf("xSub = min(fragPosShifted.x - %s.x, 0.0);", inRectParams.fsIn());
fragBuilder->codeAppendf("xSub += min(%s.z - fragPosShifted.x, 0.0);", inRectParams.fsIn());
// Now compute coverage in x to get the fraction of the pixel covered.
- fragBuilder->codeAppendf("half alpha = (1.0 + max(xSub, -1.0));");
+ fragBuilder->codeAppendf("float alpha = (1.0 + max(xSub, -1.0));");
} else {
// Assuming the bounding geometry is tight so no need to check y values
- fragBuilder->codeAppendf("half alpha = 1.0;");
+ fragBuilder->codeAppendf("float alpha = 1.0;");
fragBuilder->codeAppendf("alpha *= (fragPosShifted.x - %s.x) > -0.5 ? 1.0 : 0.0;",
inRectParams.fsIn());
fragBuilder->codeAppendf("alpha *= (%s.z - fragPosShifted.x) >= -0.5 ? 1.0 : 0.0;",
inRectParams.fsIn());
}
- fragBuilder->codeAppendf("%s = half4(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 45fe9f3009..3fb1acdfa2 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -140,7 +140,7 @@ public:
varyingHandler->emitAttributes(qp);
varyingHandler->addPassThroughAttribute(qp.inColor(), args.fOutputColor);
- GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
+ GrGLSLVertToFrag uv(kVec2f_GrSLType);
varyingHandler->addVarying("uv", &uv, kHigh_GrSLPrecision);
vsBuilder->codeAppendf("%s = %s;", uv.vsOut(), qp.inUV()->fName);
@@ -156,7 +156,7 @@ public:
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
uv.fsIn());
- fsBuilder->codeAppendf("%s = half4(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 5580e52475..243e38b79a 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -119,21 +119,21 @@ private:
// emit attributes
varyingHandler->emitAttributes(cgp);
- fragBuilder->codeAppend("highfloat4 circleEdge;");
+ fragBuilder->codeAppend("highp float4 circleEdge;");
varyingHandler->addPassThroughAttribute(cgp.fInCircleEdge, "circleEdge",
kHigh_GrSLPrecision);
if (cgp.fInClipPlane) {
- fragBuilder->codeAppend("half3 clipPlane;");
+ fragBuilder->codeAppend("float3 clipPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInClipPlane, "clipPlane");
}
if (cgp.fInIsectPlane) {
SkASSERT(cgp.fInClipPlane);
- fragBuilder->codeAppend("half3 isectPlane;");
+ fragBuilder->codeAppend("float3 isectPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInIsectPlane, "isectPlane");
}
if (cgp.fInUnionPlane) {
SkASSERT(cgp.fInClipPlane);
- fragBuilder->codeAppend("half3 unionPlane;");
+ fragBuilder->codeAppend("float3 unionPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInUnionPlane, "unionPlane");
}
@@ -152,19 +152,19 @@ private:
cgp.fLocalMatrix,
args.fFPCoordTransformHandler);
- fragBuilder->codeAppend("highfloat d = length(circleEdge.xy);");
- fragBuilder->codeAppend("half distanceToOuterEdge = circleEdge.z * (1.0 - d);");
- fragBuilder->codeAppend("half edgeAlpha = clamp(distanceToOuterEdge, 0.0, 1.0);");
+ fragBuilder->codeAppend("highp float d = length(circleEdge.xy);");
+ fragBuilder->codeAppend("float distanceToOuterEdge = circleEdge.z * (1.0 - d);");
+ fragBuilder->codeAppend("float edgeAlpha = clamp(distanceToOuterEdge, 0.0, 1.0);");
if (cgp.fStroke) {
fragBuilder->codeAppend(
- "half distanceToInnerEdge = circleEdge.z * (d - circleEdge.w);");
- fragBuilder->codeAppend("half innerAlpha = clamp(distanceToInnerEdge, 0.0, 1.0);");
+ "float distanceToInnerEdge = circleEdge.z * (d - circleEdge.w);");
+ fragBuilder->codeAppend("float innerAlpha = clamp(distanceToInnerEdge, 0.0, 1.0);");
fragBuilder->codeAppend("edgeAlpha *= innerAlpha;");
}
if (cgp.fInClipPlane) {
fragBuilder->codeAppend(
- "half clip = clamp(circleEdge.z * dot(circleEdge.xy, clipPlane.xy) + "
+ "float clip = clamp(circleEdge.z * dot(circleEdge.xy, clipPlane.xy) + "
"clipPlane.z, 0.0, 1.0);");
if (cgp.fInIsectPlane) {
fragBuilder->codeAppend(
@@ -178,7 +178,7 @@ private:
}
fragBuilder->codeAppend("edgeAlpha *= clip;");
}
- fragBuilder->codeAppendf("%s = half4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
@@ -275,12 +275,12 @@ private:
// emit attributes
varyingHandler->emitAttributes(egp);
- GrGLSLVertToFrag ellipseOffsets(kHalf2_GrSLType);
+ GrGLSLVertToFrag ellipseOffsets(kVec2f_GrSLType);
varyingHandler->addVarying("EllipseOffsets", &ellipseOffsets);
vertBuilder->codeAppendf("%s = %s;", ellipseOffsets.vsOut(),
egp.fInEllipseOffset->fName);
- GrGLSLVertToFrag ellipseRadii(kHalf4_GrSLType);
+ GrGLSLVertToFrag ellipseRadii(kVec4f_GrSLType);
varyingHandler->addVarying("EllipseRadii", &ellipseRadii);
vertBuilder->codeAppendf("%s = %s;", ellipseRadii.vsOut(), egp.fInEllipseRadii->fName);
@@ -301,16 +301,16 @@ private:
args.fFPCoordTransformHandler);
// for outer curve
- fragBuilder->codeAppendf("half2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
+ fragBuilder->codeAppendf("float2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
ellipseRadii.fsIn());
- fragBuilder->codeAppend("half test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("half2 grad = 2.0*scaledOffset*%s.xy;", ellipseRadii.fsIn());
- fragBuilder->codeAppend("half grad_dot = dot(grad, grad);");
+ fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
+ fragBuilder->codeAppendf("float2 grad = 2.0*scaledOffset*%s.xy;", ellipseRadii.fsIn());
+ fragBuilder->codeAppend("float grad_dot = dot(grad, grad);");
// avoid calling inversesqrt on zero.
fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fragBuilder->codeAppend("half invlen = inversesqrt(grad_dot);");
- fragBuilder->codeAppend("half edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
+ fragBuilder->codeAppend("float invlen = inversesqrt(grad_dot);");
+ fragBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
// for inner curve
if (egp.fStroke) {
@@ -322,7 +322,7 @@ private:
fragBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);");
}
- fragBuilder->codeAppendf("%s = half4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
@@ -417,11 +417,11 @@ private:
// emit attributes
varyingHandler->emitAttributes(diegp);
- GrGLSLVertToFrag offsets0(kHalf2_GrSLType);
+ GrGLSLVertToFrag offsets0(kVec2f_GrSLType);
varyingHandler->addVarying("EllipseOffsets0", &offsets0);
vertBuilder->codeAppendf("%s = %s;", offsets0.vsOut(), diegp.fInEllipseOffsets0->fName);
- GrGLSLVertToFrag offsets1(kHalf2_GrSLType);
+ GrGLSLVertToFrag offsets1(kVec2f_GrSLType);
varyingHandler->addVarying("EllipseOffsets1", &offsets1);
vertBuilder->codeAppendf("%s = %s;", offsets1.vsOut(), diegp.fInEllipseOffsets1->fName);
@@ -445,25 +445,25 @@ private:
args.fFPCoordTransformHandler);
// for outer curve
- fragBuilder->codeAppendf("half2 scaledOffset = %s.xy;", offsets0.fsIn());
- fragBuilder->codeAppend("half test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("half2 duvdx = dFdx(%s);", offsets0.fsIn());
- fragBuilder->codeAppendf("half2 duvdy = dFdy(%s);", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 scaledOffset = %s.xy;", offsets0.fsIn());
+ fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s);", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s);", offsets0.fsIn());
fragBuilder->codeAppendf(
- "half2 grad = half2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
- " 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
+ "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());
- fragBuilder->codeAppend("half grad_dot = dot(grad, grad);");
+ fragBuilder->codeAppend("float grad_dot = dot(grad, grad);");
// avoid calling inversesqrt on zero.
fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fragBuilder->codeAppend("half invlen = inversesqrt(grad_dot);");
+ fragBuilder->codeAppend("float invlen = inversesqrt(grad_dot);");
if (DIEllipseStyle::kHairline == diegp.fStyle) {
// can probably do this with one step
- fragBuilder->codeAppend("half edgeAlpha = clamp(1.0-test*invlen, 0.0, 1.0);");
+ fragBuilder->codeAppend("float edgeAlpha = clamp(1.0-test*invlen, 0.0, 1.0);");
fragBuilder->codeAppend("edgeAlpha *= clamp(1.0+test*invlen, 0.0, 1.0);");
} else {
- fragBuilder->codeAppend("half edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
+ fragBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
}
// for inner curve
@@ -473,14 +473,14 @@ private:
fragBuilder->codeAppendf("duvdx = dFdx(%s);", offsets1.fsIn());
fragBuilder->codeAppendf("duvdy = dFdy(%s);", offsets1.fsIn());
fragBuilder->codeAppendf(
- "grad = half2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
- " 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
+ "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 = half4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 732b9c9e84..e03d98a309 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -115,7 +115,7 @@ public:
args.fVaryingHandler->addPassThroughAttribute(&textureGP.fColors,
args.fOutputColor);
}
- args.fFragBuilder->codeAppend("highfloat2 texCoord;");
+ args.fFragBuilder->codeAppend("highp float2 texCoord;");
args.fVaryingHandler->addPassThroughAttribute(&textureGP.fTextureCoords, "texCoord",
kHigh_GrSLPrecision);
if (textureGP.numTextureSamplers() > 1) {
@@ -134,7 +134,7 @@ public:
args.fFragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
args.fTexSamplers[i],
"texCoord",
- kHighFloat2_GrSLType,
+ kVec2f_GrSLType,
&fColorSpaceXformHelper);
args.fFragBuilder->codeAppend("; break;");
}
@@ -144,11 +144,11 @@ public:
args.fFragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
args.fTexSamplers[0],
"texCoord",
- kHighFloat2_GrSLType,
+ kVec2f_GrSLType,
&fColorSpaceXformHelper);
}
args.fFragBuilder->codeAppend(";");
- args.fFragBuilder->codeAppendf("%s = highfloat4(1);", args.fOutputCoverage);
+ args.fFragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
}
GrGLSLColorSpaceXformHelper fColorSpaceXformHelper;
};
diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp
index 7ab47e9cf0..2b54d37710 100644
--- a/src/gpu/vk/GrVkCopyManager.cpp
+++ b/src/gpu/vk/GrVkCopyManager.cpp
@@ -44,17 +44,17 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
"#extension GL_ARB_shading_language_420pack : enable\n"
"layout(set = 0, binding = 0) uniform vertexUniformBuffer {"
- "half4 uPosXform;"
- "half4 uTexCoordXform;"
+ "mediump float4 uPosXform;"
+ "mediump float4 uTexCoordXform;"
"};"
- "layout(location = 0) in highfloat2 inPosition;"
- "layout(location = 1) out half2 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 = half2(0, 1);"
+ "gl_Position.zw = float2(0, 1);"
"}"
);
@@ -63,9 +63,11 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
"#extension GL_ARB_separate_shader_objects : enable\n"
"#extension GL_ARB_shading_language_420pack : enable\n"
- "layout(set = 1, binding = 0) uniform sampler2D uTextureSampler;"
- "layout(location = 1) in half2 vTexCoord;"
- "layout(location = 0, index = 0) out half4 fsColorOut;"
+ "precision mediump float;"
+
+ "layout(set = 1, binding = 0) uniform mediump sampler2D uTextureSampler;"
+ "layout(location = 1) in mediump float2 vTexCoord;"
+ "layout(location = 0, index = 0) out mediump float4 fsColorOut;"
"// Copy Program FS\n"
"void main() {"
diff --git a/src/gpu/vk/GrVkPipelineStateDataManager.cpp b/src/gpu/vk/GrVkPipelineStateDataManager.cpp
index 378ec0f0d8..ee0b6a70a1 100644
--- a/src/gpu/vk/GrVkPipelineStateDataManager.cpp
+++ b/src/gpu/vk/GrVkPipelineStateDataManager.cpp
@@ -59,7 +59,7 @@ void* GrVkPipelineStateDataManager::getBufferPtrAndMarkDirty(const Uniform& uni)
void GrVkPipelineStateDataManager::set1i(UniformHandle u, int32_t i) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kInt_GrSLType || uni.fType == kShort_GrSLType);
+ SkASSERT(uni.fType == kInt_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
memcpy(buffer, &i, sizeof(int32_t));
@@ -69,7 +69,7 @@ void GrVkPipelineStateDataManager::set1iv(UniformHandle u,
int arrayCount,
const int32_t v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kInt_GrSLType || uni.fType == kShort_GrSLType);
+ SkASSERT(uni.fType == kInt_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
@@ -85,7 +85,7 @@ void GrVkPipelineStateDataManager::set1iv(UniformHandle u,
void GrVkPipelineStateDataManager::set1f(UniformHandle u, float v0) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
+ SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -96,7 +96,7 @@ void GrVkPipelineStateDataManager::set1fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat_GrSLType || uni.fType == kHalf_GrSLType);
+ SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
@@ -112,7 +112,7 @@ void GrVkPipelineStateDataManager::set1fv(UniformHandle u,
void GrVkPipelineStateDataManager::set2f(UniformHandle u, float v0, float v1) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
+ SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -124,7 +124,7 @@ void GrVkPipelineStateDataManager::set2fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat2_GrSLType || uni.fType == kHalf2_GrSLType);
+ SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
@@ -140,7 +140,7 @@ void GrVkPipelineStateDataManager::set2fv(UniformHandle u,
void GrVkPipelineStateDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
+ SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -152,7 +152,7 @@ void GrVkPipelineStateDataManager::set3fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat3_GrSLType || uni.fType == kHalf3_GrSLType);
+ SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
@@ -172,7 +172,7 @@ void GrVkPipelineStateDataManager::set4f(UniformHandle u,
float v2,
float v3) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
+ SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(GrShaderVar::kNonArray == uni.fArrayCount);
void* buffer = this->getBufferPtrAndMarkDirty(uni);
SkASSERT(sizeof(float) == 4);
@@ -184,7 +184,7 @@ void GrVkPipelineStateDataManager::set4fv(UniformHandle u,
int arrayCount,
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat4_GrSLType || uni.fType == kHalf4_GrSLType);
+ SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
@@ -230,8 +230,7 @@ template<int N> inline void GrVkPipelineStateDataManager::setMatrices(UniformHan
int arrayCount,
const float matrices[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
- SkASSERT(uni.fType == kHighFloat2x2_GrSLType + (N - 2) ||
- uni.fType == kHalf2x2_GrSLType + (N - 2));
+ SkASSERT(uni.fType == kMat22f_GrSLType + (N - 2));
SkASSERT(arrayCount > 0);
SkASSERT(arrayCount <= uni.fArrayCount ||
(1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index abd4b086ae..98a27518a3 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -16,40 +16,31 @@
// aligned to 16 bytes (i.e. has mask of 0xF).
uint32_t grsltype_to_alignment_mask(GrSLType type) {
switch(type) {
- case kShort_GrSLType: // fall through
case kInt_GrSLType:
return 0x3;
- case kUShort_GrSLType: // fall through
case kUint_GrSLType:
return 0x3;
- case kHalf_GrSLType: // fall through
- case kHighFloat_GrSLType:
+ case kFloat_GrSLType:
return 0x3;
- case kHalf2_GrSLType: // fall through
- case kHighFloat2_GrSLType:
+ case kVec2f_GrSLType:
return 0x7;
- case kHalf3_GrSLType: // fall through
- case kHighFloat3_GrSLType:
+ case kVec3f_GrSLType:
return 0xF;
- case kHalf4_GrSLType: // fall through
- case kHighFloat4_GrSLType:
+ case kVec4f_GrSLType:
return 0xF;
- case kUint2_GrSLType:
+ case kVec2us_GrSLType:
return 0x3;
- case kInt2_GrSLType:
+ case kVec2i_GrSLType:
return 0x7;
- case kInt3_GrSLType:
+ case kVec3i_GrSLType:
return 0xF;
- case kInt4_GrSLType:
+ case kVec4i_GrSLType:
return 0xF;
- case kHalf2x2_GrSLType: // fall through
- case kHighFloat2x2_GrSLType:
+ case kMat22f_GrSLType:
return 0x7;
- case kHalf3x3_GrSLType: // fall through
- case kHighFloat3x3_GrSLType:
+ case kMat33f_GrSLType:
return 0xF;
- case kHalf4x4_GrSLType: // fall through
- case kHighFloat4x4_GrSLType:
+ case kMat44f_GrSLType:
return 0xF;
// This query is only valid for certain types.
@@ -75,41 +66,32 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
so a float2x2 takes up 8 floats. */
static inline uint32_t grsltype_to_vk_size(GrSLType type) {
switch(type) {
- case kShort_GrSLType: // fall through
case kInt_GrSLType:
return sizeof(int32_t);
- case kUShort_GrSLType: // fall through
case kUint_GrSLType:
return sizeof(int32_t);
- case kHalf_GrSLType: // fall through
- case kHighFloat_GrSLType:
+ case kFloat_GrSLType:
return sizeof(float);
- case kHalf2_GrSLType: // fall through
- case kHighFloat2_GrSLType:
+ case kVec2f_GrSLType:
return 2 * sizeof(float);
- case kHalf3_GrSLType: // fall through
- case kHighFloat3_GrSLType:
+ case kVec3f_GrSLType:
return 3 * sizeof(float);
- case kHalf4_GrSLType: // fall through
- case kHighFloat4_GrSLType:
+ case kVec4f_GrSLType:
return 4 * sizeof(float);
- case kUint2_GrSLType:
+ case kVec2us_GrSLType:
return 2 * sizeof(uint16_t);
- case kInt2_GrSLType:
+ case kVec2i_GrSLType:
return 2 * sizeof(int32_t);
- case kInt3_GrSLType:
+ case kVec3i_GrSLType:
return 3 * sizeof(int32_t);
- case kInt4_GrSLType:
+ case kVec4i_GrSLType:
return 4 * sizeof(int32_t);
- case kHalf2x2_GrSLType: // fall through
- case kHighFloat2x2_GrSLType:
+ case kMat22f_GrSLType:
//TODO: this will be 4 * szof(float) on std430.
return 8 * sizeof(float);
- case kHalf3x3_GrSLType: // fall through
- case kHighFloat3x3_GrSLType:
+ case kMat33f_GrSLType:
return 12 * sizeof(float);
- case kHalf4x4_GrSLType: // fall through
- case kHighFloat4x4_GrSLType:
+ case kMat44f_GrSLType:
return 16 * sizeof(float);
// This query is only valid for certain types.
@@ -140,7 +122,7 @@ void get_ubo_aligned_offset(uint32_t* uniformOffset,
int arrayCount) {
uint32_t alignmentMask = grsltype_to_alignment_mask(type);
// We want to use the std140 layout here, so we must make arrays align to 16 bytes.
- if (arrayCount || type == kHighFloat2x2_GrSLType) {
+ if (arrayCount || type == kMat22f_GrSLType) {
alignmentMask = 0xF;
}
uint32_t offsetDiff = *currentOffset & alignmentMask;
diff --git a/src/gpu/vk/GrVkVaryingHandler.cpp b/src/gpu/vk/GrVkVaryingHandler.cpp
index 887a422ad1..59120980c1 100644
--- a/src/gpu/vk/GrVkVaryingHandler.cpp
+++ b/src/gpu/vk/GrVkVaryingHandler.cpp
@@ -13,34 +13,27 @@ static inline int grsltype_to_location_size(GrSLType type) {
switch(type) {
case kVoid_GrSLType:
return 0;
- case kHighFloat_GrSLType: // fall through
- case kHalf_GrSLType:
+ case kFloat_GrSLType:
return 1;
- case kHighFloat2_GrSLType: // fall through
- case kHalf2_GrSLType:
+ case kVec2f_GrSLType:
return 1;
- case kHighFloat3_GrSLType:
- case kHalf3_GrSLType:
+ case kVec3f_GrSLType:
return 1;
- case kHighFloat4_GrSLType:
- case kHalf4_GrSLType:
+ case kVec4f_GrSLType:
return 1;
- case kUint2_GrSLType:
+ case kVec2us_GrSLType:
return 1;
- case kInt2_GrSLType:
+ case kVec2i_GrSLType:
return 1;
- case kInt3_GrSLType:
+ case kVec3i_GrSLType:
return 1;
- case kInt4_GrSLType:
+ case kVec4i_GrSLType:
return 1;
- case kHighFloat2x2_GrSLType:
- case kHalf2x2_GrSLType:
+ case kMat22f_GrSLType:
return 2;
- case kHighFloat3x3_GrSLType:
- case kHalf3x3_GrSLType:
+ case kMat33f_GrSLType:
return 3;
- case kHighFloat4x4_GrSLType:
- case kHalf4x4_GrSLType:
+ case kMat44f_GrSLType:
return 4;
case kTexture2DSampler_GrSLType:
return 0;
@@ -54,11 +47,9 @@ static inline int grsltype_to_location_size(GrSLType type) {
return 0;
case kBool_GrSLType:
return 1;
- case kInt_GrSLType: // fall through
- case kShort_GrSLType:
+ case kInt_GrSLType:
return 1;
case kUint_GrSLType:
- case kUShort_GrSLType: // fall through
return 1;
case kTexture2D_GrSLType:
return 0;