baked in a few more precision modifiers

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5146

Change-Id: If824ddd3551fd50b66e98edc39f10fa60a0560dc
Reviewed-on: https://skia-review.googlesource.com/5146
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2016-11-22 15:40:27 -05:00 committed by Skia Commit-Bot
parent d5de013643
commit 6762dd6f73
2 changed files with 6 additions and 17 deletions

View File

@ -167,10 +167,9 @@ const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
// depending on the surrounding code, accessing .xy with a uniform involved can
// do the same thing. Copying gl_FragCoord.xy into a temp vec2 beforehand
// (and only accessing .xy) seems to "fix" things.
const char* precision = glslCaps->usesPrecisionModifiers() ? "highp " : "";
this->codePrependf("\t%svec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n",
precision, kCoordName, kTempName, rtHeightName, kTempName);
this->codePrependf("%svec2 %s = gl_FragCoord.xy;", precision, kTempName);
this->codePrependf("\thighp vec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n", kCoordName,
kTempName, rtHeightName, kTempName);
this->codePrependf("highp vec2 %s = gl_FragCoord.xy;", kTempName);
fSetupFragPosition = true;
}
SkASSERT(fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
@ -359,11 +358,7 @@ 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().append("const ");
if (fProgramBuilder->glslCaps()->usesPrecisionModifiers()) {
this->definitions().append("highp ");
}
this->definitions().appendf("vec2 %s[] = vec2[](", name);
this->definitions().appendf("const highp vec2 %s[] = vec2[](", name);
for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) {
this->definitions().appendf("vec2(%f, %f)", offsets[i].x(), offsets[i].y());
this->definitions().append(i + 1 != specs.fEffectiveSampleCnt ? ", " : ");\n");

View File

@ -925,10 +925,7 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
v->codeAppendf("%s = rectCoverage;", fRectCoverage.vsOut());
}
SkString coverage("float coverage");
if (f->getProgramBuilder()->glslCaps()->usesPrecisionModifiers()) {
coverage.prependf("lowp ");
}
SkString coverage("lowp float coverage");
if (fBatchInfo.fInnerShapeTypes || (!fTweakAlphaForCoverage && fTriangleIsArc.fsIn())) {
f->codeAppendf("%s;", coverage.c_str());
coverage = "coverage";
@ -955,10 +952,7 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
if (fBatchInfo.fInnerShapeTypes) {
f->codeAppendf("// Inner shape.\n");
SkString innerCoverageDecl("float innerCoverage");
if (f->getProgramBuilder()->glslCaps()->usesPrecisionModifiers()) {
innerCoverageDecl.prependf("lowp ");
}
SkString innerCoverageDecl("lowp float innerCoverage");
if (kOval_ShapeFlag == fBatchInfo.fInnerShapeTypes) {
this->emitArc(f, fInnerEllipseCoords.fsIn(), fInnerEllipseName.fsIn(),
true /*ellipseCoordsNeedClamp*/, true /*ellipseCoordsMayBeNegative*/,