Add cap and builder feature for multisample interpolation
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
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 792f3ed..132e9b2 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -640,6 +640,19 @@
}
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) {
diff --git a/src/gpu/glsl/GrGLSLCaps.cpp b/src/gpu/glsl/GrGLSLCaps.cpp
index 0aa3e4f..3b6c205 100755
--- a/src/gpu/glsl/GrGLSLCaps.cpp
+++ b/src/gpu/glsl/GrGLSLCaps.cpp
@@ -25,6 +25,7 @@
fMustForceNegatedAtanParamToFloat = false;
fFlatInterpolationSupport = false;
fNoPerspectiveInterpolationSupport = false;
+ fMultisampleInterpolationSupport = false;
fSampleVariablesSupport = false;
fSampleMaskOverrideCoverageSupport = false;
fVersionDeclString = nullptr;
@@ -33,6 +34,7 @@
fSecondaryOutputExtensionString = nullptr;
fExternalTextureExtensionString = nullptr;
fNoPerspectiveInterpolationExtensionString = nullptr;
+ fMultisampleInterpolationExtensionString = nullptr;
fSampleVariablesExtensionString = nullptr;
fFBFetchColorName = nullptr;
fFBFetchExtensionString = nullptr;
@@ -67,6 +69,8 @@
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"));
diff --git a/src/gpu/glsl/GrGLSLCaps.h b/src/gpu/glsl/GrGLSLCaps.h
index 914b0db..1c79945 100755
--- a/src/gpu/glsl/GrGLSLCaps.h
+++ b/src/gpu/glsl/GrGLSLCaps.h
@@ -58,6 +58,8 @@
bool noperspectiveInterpolationSupport() const { return fNoPerspectiveInterpolationSupport; }
+ bool multisampleInterpolationSupport() const { return fMultisampleInterpolationSupport; }
+
bool sampleVariablesSupport() const { return fSampleVariablesSupport; }
bool sampleMaskOverrideCoverageSupport() const { return fSampleMaskOverrideCoverageSupport; }
@@ -118,6 +120,11 @@
return fNoPerspectiveInterpolationExtensionString;
}
+ const char* multisampleInterpolationExtensionString() const {
+ SkASSERT(this->multisampleInterpolationSupport());
+ return fMultisampleInterpolationExtensionString;
+ }
+
const char* sampleVariablesExtensionString() const {
SkASSERT(this->sampleVariablesSupport());
return fSampleVariablesExtensionString;
@@ -157,6 +164,7 @@
bool fCanUseAnyFunctionInShader : 1;
bool fFlatInterpolationSupport : 1;
bool fNoPerspectiveInterpolationSupport : 1;
+ bool fMultisampleInterpolationSupport : 1;
bool fSampleVariablesSupport : 1;
bool fSampleMaskOverrideCoverageSupport : 1;
@@ -171,6 +179,7 @@
const char* fSecondaryOutputExtensionString;
const char* fExternalTextureExtensionString;
const char* fNoPerspectiveInterpolationExtensionString;
+ const char* fMultisampleInterpolationExtensionString;
const char* fSampleVariablesExtensionString;
const char* fFBFetchColorName;
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index bd01084..e6717a9 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -87,25 +87,31 @@
}
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;
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
index 1219d34..57b8ee9 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
@@ -31,7 +31,8 @@
*/
enum GLSLFeature {
kStandardDerivatives_GLSLFeature = kLastGLSLPrivateFeature + 1,
- kPixelLocalStorage_GLSLFeature
+ kPixelLocalStorage_GLSLFeature,
+ kMultisampleInterpolation_GLSLFeature
};
/**