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
This commit is contained in:
cdalton 2016-03-01 12:12:20 -08:00 committed by Commit bot
parent b3f3148ac4
commit 4a98cdb761
5 changed files with 42 additions and 9 deletions

View File

@ -639,6 +639,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 {

View File

@ -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"));

View File

@ -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;

View 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;

View File

@ -31,7 +31,8 @@ public:
*/
enum GLSLFeature {
kStandardDerivatives_GLSLFeature = kLastGLSLPrivateFeature + 1,
kPixelLocalStorage_GLSLFeature
kPixelLocalStorage_GLSLFeature,
kMultisampleInterpolation_GLSLFeature
};
/**