aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2018-03-07 07:46:10 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-14 16:35:50 +0000
commitc2d0dd658bbb8caebf0cc9d5cf4b98b1bda616e7 (patch)
treee3484818ca2d9b65df1c1b54595ea0e5b2f44891 /src/sksl
parentc4f49040919ef5698c9abd31f7f250f572d8caa8 (diff)
Add a shader cap for incomplete short int precision
Bug: skia: Change-Id: Iac36eb763e687f6ecc3acbd4afced66f95596be2 Reviewed-on: https://skia-review.googlesource.com/109003 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/sksl')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp10
-rw-r--r--src/sksl/SkSLUtil.h8
2 files changed, 16 insertions, 2 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 2fa7492b20..996714ec62 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -1015,8 +1015,14 @@ const char* GLSLCodeGenerator::getTypePrecision(const Type& type) {
if (usesPrecisionModifiers()) {
switch (type.kind()) {
case Type::kScalar_Kind:
- if (type == *fContext.fHalf_Type || type == *fContext.fShort_Type ||
- type == *fContext.fUShort_Type) {
+ if (type == *fContext.fShort_Type || type == *fContext.fUShort_Type) {
+ if (fProgram.fSettings.fForceHighPrecision ||
+ fProgram.fSettings.fCaps->incompleteShortIntPrecision()) {
+ return "highp ";
+ }
+ return "mediump ";
+ }
+ if (type == *fContext.fHalf_Type) {
return fProgram.fSettings.fForceHighPrecision ? "highp " : "mediump ";
}
if (type == *fContext.fFloat_Type || type == *fContext.fInt_Type ||
diff --git a/src/sksl/SkSLUtil.h b/src/sksl/SkSLUtil.h
index c16156a413..113b13a644 100644
--- a/src/sksl/SkSLUtil.h
+++ b/src/sksl/SkSLUtil.h
@@ -299,6 +299,14 @@ public:
result->fCanUseFragCoord = false;
return result;
}
+
+ static sk_sp<GrShaderCaps> IncompleteShortIntPrecision() {
+ sk_sp<GrShaderCaps> result = sk_make_sp<GrShaderCaps>(GrContextOptions());
+ result->fVersionDeclString = "#version 310es";
+ result->fUsesPrecisionModifiers = true;
+ result->fIncompleteShortIntPrecision = true;
+ return result;
+ }
};
#endif