diff --git a/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp index 9f009baa69..683cf7be08 100644 --- a/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp +++ b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp @@ -1533,14 +1533,15 @@ bool GLSLCodeGenerator::generateCode() { } if (this->usesPrecisionModifiers()) { - this->writeLine("precision mediump float;"); - this->writeLine("precision mediump sampler2D;"); - if (fFoundExternalSamplerDecl && - !this->caps().noDefaultPrecisionForExternalSamplers()) { - this->writeLine("precision mediump samplerExternalOES;"); + const char* precision = + fProgram.fConfig->fSettings.fForceHighPrecision ? "highp" : "mediump"; + this->write(String::printf("precision %s float;\n", precision)); + this->write(String::printf("precision %s sampler2D;\n", precision)); + if (fFoundExternalSamplerDecl && !this->caps().noDefaultPrecisionForExternalSamplers()) { + this->write(String::printf("precision %s samplerExternalOES;\n", precision)); } if (fFoundRectSamplerDecl) { - this->writeLine("precision mediump sampler2DRect;"); + this->write(String::printf("precision %s sampler2DRect;\n", precision)); } } write_stringstream(fExtraFunctions, *rawOut); diff --git a/tests/sksl/glsl/ForceHighPrecision.glsl b/tests/sksl/glsl/ForceHighPrecision.glsl index 07acf78892..f440f499d5 100644 --- a/tests/sksl/glsl/ForceHighPrecision.glsl +++ b/tests/sksl/glsl/ForceHighPrecision.glsl @@ -1,6 +1,6 @@ #version 400 -precision mediump float; -precision mediump sampler2D; +precision highp float; +precision highp sampler2D; out mediump vec4 sk_FragColor; uniform highp float unknownInput; void main() {