diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-09-15 16:55:33 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-15 21:22:54 +0000 |
commit | 9752c3c3079140d7dbcf1fb2feb513f1e139a03a (patch) | |
tree | 1600689dfb45148c7cf610205f5a56346c5cfdf3 | |
parent | 7031b247c9fe0cb8fa32129f9bc24fea2043cee2 (diff) |
Minor fixes to SkSL precisions
No-Presubmit: true
No-Tree-Checks: true
Bug: skia:
Change-Id: Ife95d3ba457f79c00bf4fdd54af898a3a50402aa
Reviewed-on: https://skia-review.googlesource.com/47241
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
-rw-r--r-- | src/gpu/ccpr/GrCCPRCubicProcessor.cpp | 4 | ||||
-rw-r--r-- | src/sksl/SkSLGLSLCodeGenerator.cpp | 3 | ||||
-rw-r--r-- | tests/SkSLGLSLTest.cpp | 6 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp index fcf2076c1c..1fc2a29342 100644 --- a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp +++ b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp @@ -124,7 +124,7 @@ void GrCCPRCubicProcessor::emitPerVertexGeometryCode(SkString* fnBody, const cha 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("highfloat d = dot(highfloat3(%s, 1), %s);", position, fEdgeDistanceEquation.c_str()); fnBody->appendf("%s = highfloat4(klm, d);", fKLMD.gsOut()); this->onEmitPerVertexGeometryCode(fnBody); @@ -202,7 +202,7 @@ void GrCCPRCubicCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f, // 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("highfloat4 klmd_center = highfloat4(%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;"); diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp index a30262f3fe..c6b4806245 100644 --- a/src/sksl/SkSLGLSLCodeGenerator.cpp +++ b/src/sksl/SkSLGLSLCodeGenerator.cpp @@ -1025,6 +1025,9 @@ bool GLSLCodeGenerator::generateCode() { fOut = rawOut; write_stringstream(fHeader, *rawOut); + if (this->usesPrecisionModifiers()) { + this->writeLine("precision mediump float;"); + } write_stringstream(body, *rawOut); return true; } diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp index 851c0e8a34..bfcedacc90 100644 --- a/tests/SkSLGLSLTest.cpp +++ b/tests/SkSLGLSLTest.cpp @@ -321,6 +321,7 @@ DEF_TEST(SkSLUsesPrecisionModifiers, r) { "sk_FragColor.rg = half2(x, y); }", *SkSL::ShaderCapsFactory::UsesPrecisionModifiers(), "#version 400\n" + "precision mediump float;\n" "out mediump vec4 sk_FragColor;\n" "void main() {\n" " mediump float x = 0.75;\n" @@ -510,6 +511,7 @@ DEF_TEST(SkSLDerivatives, r) { "void main() { sk_FragColor.r = 1; }", *SkSL::ShaderCapsFactory::ShaderDerivativeExtensionString(), "#version 400\n" + "precision mediump float;\n" "out mediump vec4 sk_FragColor;\n" "void main() {\n" " sk_FragColor.x = 1.0;\n" @@ -519,6 +521,7 @@ DEF_TEST(SkSLDerivatives, r) { *SkSL::ShaderCapsFactory::ShaderDerivativeExtensionString(), "#version 400\n" "#extension GL_OES_standard_derivatives : require\n" + "precision mediump float;\n" "out mediump vec4 sk_FragColor;\n" "void main() {\n" " sk_FragColor.x = dFdx(1.0);\n" @@ -1485,6 +1488,7 @@ DEF_TEST(SkSLTypePrecision, r) { "half2x4 h24 = half2x4(1, 2, 3, 4, 5, 6, 7, 8);", *SkSL::ShaderCapsFactory::UsesPrecisionModifiers(), "#version 400\n" + "precision mediump float;\n" "out mediump vec4 sk_FragColor;\n" "highp float f = 1.0;\n" "mediump float h = 2.0;\n" @@ -1578,6 +1582,7 @@ DEF_TEST(SkSLForceHighPrecision, r) { "void main() { half x = sqrt(1); half4 y = half4(x); sk_FragColor = y; }", *SkSL::ShaderCapsFactory::UsesPrecisionModifiers(), "#version 400\n" + "precision mediump float;\n" "out mediump vec4 sk_FragColor;\n" "void main() {\n" " mediump float x = sqrt(1.0);\n" @@ -1593,6 +1598,7 @@ DEF_TEST(SkSLForceHighPrecision, r) { "void main() { half x = sqrt(1); half4 y = half4(x); sk_FragColor = y; }", settings, "#version 400\n" + "precision mediump float;\n" "out mediump vec4 sk_FragColor;\n" "void main() {\n" " highp float x = sqrt(1.0);\n" |