From eca11cc81c5018a3ae866e19a414c5df50973772 Mon Sep 17 00:00:00 2001 From: shrekshao Date: Tue, 28 Jan 2020 14:18:40 -0800 Subject: [PATCH] SH_CLAMP_INDIRECT_ARRAY_BOUNDS logic update Remain the old hardware requirement for turning on clampArrayAccess. But also turns it on universally for WebGL context. So that we won't suffer from clampArrayAccess not handled properly on some compute shader deqp tests. Bug: chromium:1042252, angleproject:4361 Change-Id: Ib11affd6df27ce7d2100980d2b8decdee36876e8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2026029 Reviewed-by: James Darpinian Reviewed-by: Geoff Lang Commit-Queue: Shrek Shao --- include/GLSLANG/ShaderLang.h | 1 + src/compiler/translator/Compiler.cpp | 2 +- src/libANGLE/renderer/gl/ShaderGL.cpp | 2 +- src/libANGLE/renderer/gl/renderergl_utils.cpp | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) 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));