Commit aded991b by Jonah Ryan-Davis Committed by Commit Bot

Fix hang on Linux Intel when allocating large textures.

Intel Linux graphics drivers before kernel 5.0 can hang when allocating large textures. Limit the texture size as a workaround. Bug: chromium:927470 Change-Id: Ic8c14235396492efafd663b1cd012fd752427992 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1700146 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 6c90ebb0
......@@ -269,11 +269,13 @@ struct FeaturesGL : FeatureSetBase
&members, "http://crbug.com/849576"};
// Most Android devices fail to allocate a texture that is larger than 4096. Limit the caps
// instead of generating GL_OUT_OF_MEMORY errors.
Feature limitMaxTextureSizeTo4096 = {
"max_texture_size_limit_4096", FeatureCategory::OpenGLWorkarounds,
"Limit max texture size to 4096 to avoid frequent out-of-memory errors on Android",
&members};
// instead of generating GL_OUT_OF_MEMORY errors. Also causes system to hang on some older
// intel mesa drivers on Linux.
Feature limitMaxTextureSizeTo4096 = {"max_texture_size_limit_4096",
FeatureCategory::OpenGLWorkarounds,
"Limit max texture size to 4096 to avoid frequent "
"out-of-memory errors on Android or Intel Linux",
&members, "http://crbug.com/927470"};
// Prevent excessive MSAA allocations on Android devices, various rendering bugs have been
// observed and they tend to be high DPI anyways. http://crbug.com/797243
......@@ -313,6 +315,14 @@ struct FeaturesGL : FeatureSetBase
"clear_to_zero_or_one_broken", FeatureCategory::OpenGLWorkarounds,
"Clears when the clear color is all zeros or ones do not work.", &members,
"https://crbug.com/710443"};
// Some older Linux Intel mesa drivers will hang the system when allocating large textures. Fix
// this by capping the max texture size.
Feature limitMax3dArrayTextureSizeTo1024 = {
"max_3d_array_texture_size_1024", FeatureCategory::OpenGLWorkarounds,
"Limit max 3d texture size and max array texture layers to 1024 to avoid system hang on "
"older Intel Linux",
&members, "http://crbug.com/927470"};
};
inline FeaturesGL::FeaturesGL() = default;
......
......@@ -470,11 +470,17 @@ void GenerateCaps(const FunctionsGL *functions,
textureSizeLimit = 4096;
}
GLint max3dArrayTextureSizeLimit = std::numeric_limits<GLint>::max();
if (features.limitMax3dArrayTextureSizeTo1024.enabled)
{
max3dArrayTextureSizeLimit = 1024;
}
if (functions->isAtLeastGL(gl::Version(1, 2)) || functions->isAtLeastGLES(gl::Version(3, 0)) ||
functions->hasGLESExtension("GL_OES_texture_3D"))
{
caps->max3DTextureSize =
std::min(QuerySingleGLInt(functions, GL_MAX_3D_TEXTURE_SIZE), textureSizeLimit);
caps->max3DTextureSize = std::min({QuerySingleGLInt(functions, GL_MAX_3D_TEXTURE_SIZE),
textureSizeLimit, max3dArrayTextureSizeLimit});
}
else
{
......@@ -493,7 +499,8 @@ void GenerateCaps(const FunctionsGL *functions,
functions->isAtLeastGLES(gl::Version(3, 0)))
{
caps->maxArrayTextureLayers =
std::min(QuerySingleGLInt(functions, GL_MAX_ARRAY_TEXTURE_LAYERS), textureSizeLimit);
std::min({QuerySingleGLInt(functions, GL_MAX_ARRAY_TEXTURE_LAYERS), textureSizeLimit,
max3dArrayTextureSizeLimit});
}
else
{
......@@ -1506,8 +1513,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
features->disableWorkerContexts.enabled =
(IsWindows() && (IsIntel(vendor) || IsAMD(vendor))) || (IsLinux() && IsNvidia(vendor));
features->limitMaxTextureSizeTo4096.enabled = IsAndroid();
features->limitMaxTextureSizeTo4096.enabled = IsAndroid() || (IsIntel(vendor) && IsLinux());
features->limitMaxMSAASamplesTo4.enabled = IsAndroid();
features->limitMax3dArrayTextureSizeTo1024.enabled = IsIntel(vendor) && IsLinux();
features->allowClearForRobustResourceInit.enabled = IsApple();
......
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