From f60052072ca994facb588984911ebe6a06f754d2 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Fri, 2 Jul 2021 17:12:59 -0400 Subject: [PATCH] When force-high-precision is enabled, change default precision Change-Id: I7b033c891ee997f1ca022b73d6f78cc501c5cdc2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424302 Commit-Queue: Brian Osman Reviewed-by: Ethan Nicholas --- src/sksl/codegen/SkSLGLSLCodeGenerator.cpp | 13 +++++++------ tests/sksl/glsl/ForceHighPrecision.glsl | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) 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() {