Bug 1288540 - Strip invariance qualifiers on OSX Compat profiles. - r=daoshengmu
MozReview-Commit-ID: BxyONzsvZq5
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -54,34 +54,32 @@ ChooseValidatorCompileOptions(const ShBu
if (gl->WorkAroundDriverBugs()) {
// Work around https://bugs.webkit.org/show_bug.cgi?id=124684,
// https://chromium.googlesource.com/angle/angle/+/5e70cf9d0b1bb
options |= SH_UNFOLD_SHORT_CIRCUIT;
// Work around that Mac drivers handle struct scopes incorrectly.
options |= SH_REGENERATE_STRUCT_NAMES;
options |= SH_INIT_OUTPUT_VARIABLES;
+ options |= SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL;
+ if (gl->IsCompatibilityProfile()) {
+ options |= SH_REMOVE_INVARIANT_AND_CENTROID;
+ }
}
#endif
if (gfxPrefs::WebGLAllANGLEOptions()) {
options = -1;
options ^= SH_INTERMEDIATE_TREE;
options ^= SH_LINE_DIRECTIVES;
options ^= SH_SOURCE_PATH;
options ^= SH_LIMIT_EXPRESSION_COMPLEXITY;
options ^= SH_LIMIT_CALL_STACK_DEPTH;
-
- options ^= SH_EXPAND_SELECT_HLSL_INTEGER_POW_EXPRESSIONS;
- options ^= SH_HLSL_GET_DIMENSIONS_IGNORES_BASE_LEVEL;
-
- options ^= SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT;
- options ^= SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3;
}
if (resources.MaxExpressionComplexity > 0) {
options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
}
if (resources.MaxCallStackDepth > 0) {
options |= SH_LIMIT_CALL_STACK_DEPTH;
}
--- a/gfx/angle/include/GLSLANG/ShaderLang.h
+++ b/gfx/angle/include/GLSLANG/ShaderLang.h
@@ -200,21 +200,21 @@ const ShCompileOptions SH_USE_UNUSED_STA
// must match between vertex and fragment shader, e.g. AMD. The behavior on AMD is obviously wrong.
// Remove invariant for input in fragment shader to workaround the restriction on Intel Mesa.
// But don't remove on AMD Linux to avoid triggering the bug on AMD.
const ShCompileOptions SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT = UINT64_C(1) << 29;
// Due to spec difference between GLSL 4.1 or lower and ESSL3, some platforms (for example, Mac OSX
// core profile) require a variable's "invariant"/"centroid" qualifiers to match between vertex and
// fragment shader. A simple solution to allow such shaders to link is to omit the two qualifiers.
-// Note that the two flags only take effect on ESSL3 input shaders translated to GLSL 4.1 or lower.
+// Also GLSL 1.2 doesn't support invariant fragment built-ins.
// TODO(zmo): This is not a good long-term solution. Simply dropping these qualifiers may break some
// developers' content. A more complex workaround of dynamically generating, compiling, and
// re-linking shaders that use these qualifiers should be implemented.
-const ShCompileOptions SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3 = UINT64_C(1) << 30;
+const ShCompileOptions SH_REMOVE_INVARIANT_AND_CENTROID = UINT64_C(1) << 30;
// Defines alternate strategies for implementing array index clamping.
enum ShArrayIndexClampingStrategy
{
// Use the clamp intrinsic for array index clamping.
SH_CLAMP_WITH_CLAMP_INTRINSIC = 1,
// Use a user-defined function for array index clamping.
--- a/gfx/angle/src/compiler/translator/Compiler.cpp
+++ b/gfx/angle/src/compiler/translator/Compiler.cpp
@@ -107,18 +107,17 @@ bool RemoveInvariant(sh::GLenum shaderTy
int shaderVersion,
ShShaderOutput outputType,
ShCompileOptions compileOptions)
{
if ((compileOptions & SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT) == 0 &&
shaderType == GL_FRAGMENT_SHADER && IsGLSL420OrNewer(outputType))
return true;
- if ((compileOptions & SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3) != 0 &&
- shaderVersion >= 300 && shaderType == GL_VERTEX_SHADER && IsGLSL410OrOlder(outputType))
+ if ((compileOptions & SH_REMOVE_INVARIANT_AND_CENTROID) != 0)
return true;
return false;
}
size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
{
// WebGL defines a max token legnth of 256, while ES2 leaves max token
--- a/gfx/angle/src/compiler/translator/OutputGLSLBase.cpp
+++ b/gfx/angle/src/compiler/translator/OutputGLSLBase.cpp
@@ -157,18 +157,17 @@ void TOutputGLSLBase::writeLayoutQualifi
out << getImageInternalFormatString(layoutQualifier.imageInternalFormat);
}
out << ") ";
}
const char *TOutputGLSLBase::mapQualifierToString(TQualifier qualifier)
{
- if (sh::IsGLSL410OrOlder(mOutput) && mShaderVersion >= 300 &&
- (mCompileOptions & SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3) != 0)
+ if ((mCompileOptions & SH_REMOVE_INVARIANT_AND_CENTROID) != 0)
{
switch (qualifier)
{
// The return string is consistent with sh::getQualifierString() from
// BaseTypes.h minus the "centroid" keyword.
case EvqCentroid:
return "";
case EvqCentroidIn: