aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl/GrGLSLCaps.cpp
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-04-11 12:03:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-11 12:03:08 -0700
commita6b92ad1f7b79106caef6a4c721903544f507a02 (patch)
treef91503b26a515e060202000ecd6bb1923de1e7ed /src/gpu/glsl/GrGLSLCaps.cpp
parent21a465d7f4c5e639044e79971aeaa1194fc73078 (diff)
Infer sampler precision from pixel config
Adds a "samplerPrecision" method to GrGLSLCaps and updates GrGLSLProgramBuilder to infer a sampler's precision based on its config and visibility. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1846963004 Review URL: https://codereview.chromium.org/1846963004
Diffstat (limited to 'src/gpu/glsl/GrGLSLCaps.cpp')
-rwxr-xr-xsrc/gpu/glsl/GrGLSLCaps.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/gpu/glsl/GrGLSLCaps.cpp b/src/gpu/glsl/GrGLSLCaps.cpp
index c2404c6e52..60bea8663a 100755
--- a/src/gpu/glsl/GrGLSLCaps.cpp
+++ b/src/gpu/glsl/GrGLSLCaps.cpp
@@ -92,5 +92,60 @@ SkString GrGLSLCaps::dump() const {
return r;
}
+void GrGLSLCaps::initSamplerPrecisionTable() {
+ // Determine the largest precision qualifiers that are effectively the same as lowp/mediump.
+ // e.g. if lowp == mediump, then use mediump instead of lowp.
+ GrSLPrecision effectiveMediumP[kGrShaderTypeCount];
+ GrSLPrecision effectiveLowP[kGrShaderTypeCount];
+ for (int s = 0; s < kGrShaderTypeCount; ++s) {
+ const PrecisionInfo* info = fFloatPrecisions[s];
+ effectiveMediumP[s] = info[kHigh_GrSLPrecision] == info[kMedium_GrSLPrecision] ?
+ kHigh_GrSLPrecision : kMedium_GrSLPrecision;
+ effectiveLowP[s] = info[kMedium_GrSLPrecision] == info[kLow_GrSLPrecision] ?
+ effectiveMediumP[s] : kLow_GrSLPrecision;
+ }
+
+ // Determine which precision qualifiers should be used with samplers.
+ for (int visibility = 0; visibility < (1 << kGrShaderTypeCount); ++visibility) {
+ GrSLPrecision mediump = kHigh_GrSLPrecision;
+ GrSLPrecision lowp = kHigh_GrSLPrecision;
+ for (int s = 0; s < kGrShaderTypeCount; ++s) {
+ if (visibility & (1 << s)) {
+ mediump = SkTMin(mediump, effectiveMediumP[s]);
+ lowp = SkTMin(lowp, effectiveLowP[s]);
+ }
+
+ GR_STATIC_ASSERT(0 == kLow_GrSLPrecision);
+ GR_STATIC_ASSERT(1 == kMedium_GrSLPrecision);
+ GR_STATIC_ASSERT(2 == kHigh_GrSLPrecision);
+
+ GR_STATIC_ASSERT((1 << kVertex_GrShaderType) == kVertex_GrShaderFlag);
+ GR_STATIC_ASSERT((1 << kGeometry_GrShaderType) == kGeometry_GrShaderFlag);
+ GR_STATIC_ASSERT((1 << kFragment_GrShaderType) == kFragment_GrShaderFlag);
+ GR_STATIC_ASSERT(3 == kGrShaderTypeCount);
+ }
+
+ uint8_t* table = fSamplerPrecisions[visibility];
+ table[kUnknown_GrPixelConfig] = kDefault_GrSLPrecision;
+ table[kAlpha_8_GrPixelConfig] = lowp;
+ table[kIndex_8_GrPixelConfig] = lowp;
+ table[kRGB_565_GrPixelConfig] = lowp;
+ table[kRGBA_4444_GrPixelConfig] = lowp;
+ table[kRGBA_8888_GrPixelConfig] = lowp;
+ table[kBGRA_8888_GrPixelConfig] = lowp;
+ table[kSRGBA_8888_GrPixelConfig] = lowp;
+ table[kSBGRA_8888_GrPixelConfig] = lowp;
+ table[kETC1_GrPixelConfig] = lowp;
+ table[kLATC_GrPixelConfig] = lowp;
+ table[kR11_EAC_GrPixelConfig] = lowp;
+ table[kASTC_12x12_GrPixelConfig] = lowp;
+ table[kRGBA_float_GrPixelConfig] = kHigh_GrSLPrecision;
+ table[kAlpha_half_GrPixelConfig] = mediump;
+ table[kRGBA_half_GrPixelConfig] = mediump;
+
+ GR_STATIC_ASSERT(16 == kGrPixelConfigCnt);
+ }
+}
+
void GrGLSLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
}