Add cap and builder feature for multisample interpolation
authorcdalton <cdalton@nvidia.com>
Tue, 1 Mar 2016 20:12:20 +0000 (12:12 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 1 Mar 2016 20:12:20 +0000 (12:12 -0800)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1722363002

Review URL: https://codereview.chromium.org/1722363002

src/gpu/gl/GrGLCaps.cpp
src/gpu/glsl/GrGLSLCaps.cpp
src/gpu/glsl/GrGLSLCaps.h
src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
src/gpu/glsl/GrGLSLFragmentShaderBuilder.h

index 792f3ed..132e9b2 100644 (file)
@@ -640,6 +640,19 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) {
     }
 
     if (kGL_GrGLStandard == standard) {
+        glslCaps->fMultisampleInterpolationSupport =
+                ctxInfo.glslGeneration() >= k400_GrGLSLGeneration;
+    } else {
+        if (ctxInfo.glslGeneration() >= k320es_GrGLSLGeneration) {
+            glslCaps->fMultisampleInterpolationSupport = true;
+        } else if (ctxInfo.hasExtension("GL_OES_shader_multisample_interpolation")) {
+            glslCaps->fMultisampleInterpolationSupport = true;
+            glslCaps->fMultisampleInterpolationExtensionString =
+                "GL_OES_shader_multisample_interpolation";
+        }
+    }
+
+    if (kGL_GrGLStandard == standard) {
         glslCaps->fSampleVariablesSupport = ctxInfo.glslGeneration() >= k400_GrGLSLGeneration;
     } else {
         if (ctxInfo.glslGeneration() >= k320es_GrGLSLGeneration) {
index 0aa3e4f..3b6c205 100755 (executable)
@@ -25,6 +25,7 @@ GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
     fMustForceNegatedAtanParamToFloat = false;
     fFlatInterpolationSupport = false;
     fNoPerspectiveInterpolationSupport = false;
+    fMultisampleInterpolationSupport = false;
     fSampleVariablesSupport = false;
     fSampleMaskOverrideCoverageSupport = false;
     fVersionDeclString = nullptr;
@@ -33,6 +34,7 @@ GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
     fSecondaryOutputExtensionString = nullptr;
     fExternalTextureExtensionString = nullptr;
     fNoPerspectiveInterpolationExtensionString = nullptr;
+    fMultisampleInterpolationExtensionString = nullptr;
     fSampleVariablesExtensionString = nullptr;
     fFBFetchColorName = nullptr;
     fFBFetchExtensionString = nullptr;
@@ -67,6 +69,8 @@ SkString GrGLSLCaps::dump() const {
     r.appendf("Flat interpolation support: %s\n", (fFlatInterpolationSupport ?  "YES" : "NO"));
     r.appendf("No perspective interpolation support: %s\n", (fNoPerspectiveInterpolationSupport ?
                                                              "YES" : "NO"));
+    r.appendf("Multisample interpolation support: %s\n", (fMultisampleInterpolationSupport ?
+                                                          "YES" : "NO"));
     r.appendf("Sample variables support: %s\n", (fSampleVariablesSupport ? "YES" : "NO"));
     r.appendf("Sample mask override coverage support: %s\n", (fSampleMaskOverrideCoverageSupport ?
                                                               "YES" : "NO"));
index 914b0db..1c79945 100755 (executable)
@@ -58,6 +58,8 @@ public:
 
     bool noperspectiveInterpolationSupport() const { return fNoPerspectiveInterpolationSupport; }
 
+    bool multisampleInterpolationSupport() const { return fMultisampleInterpolationSupport; }
+
     bool sampleVariablesSupport() const { return fSampleVariablesSupport; }
 
     bool sampleMaskOverrideCoverageSupport() const { return fSampleMaskOverrideCoverageSupport; }
@@ -118,6 +120,11 @@ public:
         return fNoPerspectiveInterpolationExtensionString;
     }
 
+    const char* multisampleInterpolationExtensionString() const {
+        SkASSERT(this->multisampleInterpolationSupport());
+        return fMultisampleInterpolationExtensionString;
+    }
+
     const char* sampleVariablesExtensionString() const {
         SkASSERT(this->sampleVariablesSupport());
         return fSampleVariablesExtensionString;
@@ -157,6 +164,7 @@ private:
     bool fCanUseAnyFunctionInShader : 1;
     bool fFlatInterpolationSupport : 1;
     bool fNoPerspectiveInterpolationSupport : 1;
+    bool fMultisampleInterpolationSupport : 1;
     bool fSampleVariablesSupport : 1;
     bool fSampleMaskOverrideCoverageSupport : 1;
 
@@ -171,6 +179,7 @@ private:
     const char* fSecondaryOutputExtensionString;
     const char* fExternalTextureExtensionString;
     const char* fNoPerspectiveInterpolationExtensionString;
+    const char* fMultisampleInterpolationExtensionString;
     const char* fSampleVariablesExtensionString;
 
     const char* fFBFetchColorName;
index bd01084..e6717a9 100644 (file)
@@ -87,25 +87,31 @@ bool GrGLSLFragmentShaderBuilder::hasFragmentPosition() const {
 }
 
 bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
+    const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps();
     switch (feature) {
-        case kStandardDerivatives_GLSLFeature: {
-            if (!fProgramBuilder->glslCaps()->shaderDerivativeSupport()) {
+        case kStandardDerivatives_GLSLFeature:
+            if (!glslCaps.shaderDerivativeSupport()) {
                 return false;
             }
-            const char* extension = fProgramBuilder->glslCaps()->shaderDerivativeExtensionString();
-            if (extension) {
+            if (const char* extension = glslCaps.shaderDerivativeExtensionString()) {
                 this->addFeature(1 << kStandardDerivatives_GLSLFeature, extension);
             }
             return true;
-        }
-        case kPixelLocalStorage_GLSLFeature: {
-            if (fProgramBuilder->glslCaps()->pixelLocalStorageSize() <= 0) {
+        case kPixelLocalStorage_GLSLFeature:
+            if (glslCaps.pixelLocalStorageSize() <= 0) {
                 return false;
             }
             this->addFeature(1 << kPixelLocalStorage_GLSLFeature,
                              "GL_EXT_shader_pixel_local_storage");
             return true;
-        }
+        case kMultisampleInterpolation_GLSLFeature:
+            if (!glslCaps.multisampleInterpolationSupport()) {
+                return false;
+            }
+            if (const char* extension = glslCaps.multisampleInterpolationExtensionString()) {
+                this->addFeature(1 << kMultisampleInterpolation_GLSLFeature, extension);
+            }
+            return true;
         default:
             SkFAIL("Unexpected GLSLFeature requested.");
             return false;
index 1219d34..57b8ee9 100644 (file)
@@ -31,7 +31,8 @@ public:
      */
     enum GLSLFeature {
         kStandardDerivatives_GLSLFeature = kLastGLSLPrivateFeature + 1,
-        kPixelLocalStorage_GLSLFeature
+        kPixelLocalStorage_GLSLFeature,
+        kMultisampleInterpolation_GLSLFeature
     };
 
     /**