Commit 8333d061 by Geoff Lang Committed by Angle LUCI CQ

GL: Respect TexSubImage upload limits for robust init

The chunked_texture_upload splits texture uploads for glTexSubImage calls but ANGLE uses glTexSubImage internally for robust resource initialization. Also chunk those uploads. Bug: chromium:1181068 Change-Id: Ia6eaac8117173946630f420b396cbc54c163b7ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2961230Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent c40262dc
...@@ -557,7 +557,8 @@ struct FeaturesGL : FeatureSetBase ...@@ -557,7 +557,8 @@ struct FeaturesGL : FeatureSetBase
// Mac OpenGL drivers often hang when calling glTexSubImage with >120kb of data. Instead, upload // Mac OpenGL drivers often hang when calling glTexSubImage with >120kb of data. Instead, upload
// the data in <120kb chunks. // the data in <120kb chunks.
Feature uploadTextureDataInChunks = { static constexpr const size_t kUploadTextureDataInChunksUploadSize = (120 * 1024) - 1;
Feature uploadTextureDataInChunks = {
"chunked_texture_upload", FeatureCategory::OpenGLWorkarounds, "chunked_texture_upload", FeatureCategory::OpenGLWorkarounds,
"Upload texture data in <120kb chunks to work around Mac driver hangs and crashes.", "Upload texture data in <120kb chunks to work around Mac driver hangs and crashes.",
&members, "http://crbug.com/1181068"}; &members, "http://crbug.com/1181068"};
......
...@@ -358,9 +358,9 @@ angle::Result TextureGL::setSubImage(const gl::Context *context, ...@@ -358,9 +358,9 @@ angle::Result TextureGL::setSubImage(const gl::Context *context,
if (features.uploadTextureDataInChunks.enabled) if (features.uploadTextureDataInChunks.enabled)
{ {
constexpr const size_t kMaxUploadChunkSize = (120 * 1024) - 1; return setSubImageRowByRowWorkaround(
return setSubImageRowByRowWorkaround(context, target, level, area, format, type, unpack, context, target, level, area, format, type, unpack, unpackBuffer,
unpackBuffer, kMaxUploadChunkSize, pixels); angle::FeaturesGL::kUploadTextureDataInChunksUploadSize, pixels);
} }
if (nativegl::UseTexImage2D(getType())) if (nativegl::UseTexImage2D(getType()))
...@@ -2077,11 +2077,22 @@ angle::Result TextureGL::initializeContents(const gl::Context *context, ...@@ -2077,11 +2077,22 @@ angle::Result TextureGL::initializeContents(const gl::Context *context,
if (nativegl::UseTexImage2D(getType())) if (nativegl::UseTexImage2D(getType()))
{ {
ANGLE_GL_TRY(context, if (features.uploadTextureDataInChunks.enabled)
functions->texSubImage2D(ToGLenum(imageIndex.getTarget()), {
imageIndex.getLevelIndex(), 0, 0, desc.size.width, gl::Box area(0, 0, 0, desc.size.width, desc.size.height, 1);
desc.size.height, nativeSubImageFormat.format, ANGLE_TRY(setSubImageRowByRowWorkaround(
nativeSubImageFormat.type, zero->data())); context, imageIndex.getTarget(), imageIndex.getLevelIndex(), area,
nativeSubImageFormat.format, nativeSubImageFormat.type, unpackState, nullptr,
angle::FeaturesGL::kUploadTextureDataInChunksUploadSize, zero->data()));
}
else
{
ANGLE_GL_TRY(context,
functions->texSubImage2D(
ToGLenum(imageIndex.getTarget()), imageIndex.getLevelIndex(), 0, 0,
desc.size.width, desc.size.height, nativeSubImageFormat.format,
nativeSubImageFormat.type, zero->data()));
}
} }
else else
{ {
......
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