diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h index 1b5c5817b..5c1a8f00a 100644 --- a/include/GLSLANG/ShaderLang.h +++ b/include/GLSLANG/ShaderLang.h @@ -128,6 +128,7 @@ const ShCompileOptions SH_ENFORCE_PACKING_RESTRICTIONS = UINT64_C(1) << 9; // vec234, or mat234 type. The ShArrayIndexClampingStrategy enum, // specified in the ShBuiltInResources when constructing the // compiler, selects the strategy for the clamping implementation. +// TODO(http://anglebug.com/4361): fix for compute shaders. const ShCompileOptions SH_CLAMP_INDIRECT_ARRAY_BOUNDS = UINT64_C(1) << 10; // This flag limits the complexity of an expression. diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp index ed5674eb9..98e8a5f7b 100644 --- a/src/compiler/translator/Compiler.cpp +++ b/src/compiler/translator/Compiler.cpp @@ -617,7 +617,7 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root, } // Clamping uniform array bounds needs to happen after validateLimitations pass. - if (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS && mShaderType != GL_COMPUTE_SHADER) + if (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS) { mArrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root); } diff --git a/src/libANGLE/renderer/gl/ShaderGL.cpp b/src/libANGLE/renderer/gl/ShaderGL.cpp index a20459e56..9c1eb50ee 100644 --- a/src/libANGLE/renderer/gl/ShaderGL.cpp +++ b/src/libANGLE/renderer/gl/ShaderGL.cpp @@ -333,7 +333,7 @@ std::shared_ptr ShaderGL::compile(const gl::Context *conte additionalOptions |= SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER; } - if (features.clampArrayAccess.enabled) + if (features.clampArrayAccess.enabled || isWebGL) { additionalOptions |= SH_CLAMP_INDIRECT_ARRAY_BOUNDS; } diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp index 23a0ea261..4f7d672a7 100644 --- a/src/libANGLE/renderer/gl/renderergl_utils.cpp +++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp @@ -1601,7 +1601,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature // on AMD and Android devices. // This test is also flaky on Linux Nvidia. So we just turn it on everywhere and don't rely on // driver since security is important. - ANGLE_FEATURE_CONDITION(features, clampArrayAccess, true); + ANGLE_FEATURE_CONDITION( + features, clampArrayAccess, + IsAndroid() || isAMD || !functions->hasExtension("GL_KHR_robust_buffer_access_behavior")); ANGLE_FEATURE_CONDITION(features, resetTexImage2DBaseLevel, IsApple() && isIntel && GetMacOSVersion() >= OSVersion(10, 12, 4));