Commit 2074d5f7 by Geoff Lang Committed by Commit Bot

GL: Clamp uniform array access on Android and AMD devices.

Chrome used to clamp it everywhere but in practice it is only needed on these devices. TEST=conformance/uniforms/out-of-bounds-uniform-array-access.html Change-Id: Idffe84023f8b27733bfda209edd59bbb220b5c0c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1680054Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 134d6eed
......@@ -292,6 +292,12 @@ struct FeaturesGL : FeatureSetBase
"Using glClear for robust resource initialization is buggy on some drivers and leads to "
"texture corruption. Default to data uploads except on MacOS where it is very slow.",
&members, "http://crbug.com/883276"};
// Some drivers automatically handle out-of-bounds uniform array access but others need manual
// clamping to satisfy the WebGL requirements.
Feature clampArrayAccess = {"clamp_array_access", FeatureCategory::OpenGLWorkarounds,
"Clamp uniform array access to avoid reading invalid memory.",
&members, "http://anglebug.com/2978"};
};
inline FeaturesGL::FeaturesGL() = default;
......
......@@ -328,6 +328,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderGL::compile(const gl::Context *conte
additionalOptions |= SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER;
}
if (features.clampArrayAccess.enabled)
{
additionalOptions |= SH_CLAMP_INDIRECT_ARRAY_BOUNDS;
}
options |= additionalOptions;
auto workerThreadPool = context->getWorkerThreadPool();
......
......@@ -1507,6 +1507,10 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
features->limitMaxMSAASamplesTo4.enabled = IsAndroid();
features->allowClearForRobustResourceInit.enabled = IsApple();
// The WebGL conformance/uniforms/out-of-bounds-uniform-array-access test has been seen to fail
// on AMD and Android devices.
features->clampArrayAccess.enabled = IsAndroid() || IsAMD(vendor);
}
void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment