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,6 +557,7 @@ struct FeaturesGL : FeatureSetBase ...@@ -557,6 +557,7 @@ 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.
static constexpr const size_t kUploadTextureDataInChunksUploadSize = (120 * 1024) - 1;
Feature uploadTextureDataInChunks = { 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.",
......
...@@ -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,12 +2077,23 @@ angle::Result TextureGL::initializeContents(const gl::Context *context, ...@@ -2077,12 +2077,23 @@ angle::Result TextureGL::initializeContents(const gl::Context *context,
if (nativegl::UseTexImage2D(getType())) if (nativegl::UseTexImage2D(getType()))
{ {
if (features.uploadTextureDataInChunks.enabled)
{
gl::Box area(0, 0, 0, desc.size.width, desc.size.height, 1);
ANGLE_TRY(setSubImageRowByRowWorkaround(
context, imageIndex.getTarget(), imageIndex.getLevelIndex(), area,
nativeSubImageFormat.format, nativeSubImageFormat.type, unpackState, nullptr,
angle::FeaturesGL::kUploadTextureDataInChunksUploadSize, zero->data()));
}
else
{
ANGLE_GL_TRY(context, ANGLE_GL_TRY(context,
functions->texSubImage2D(ToGLenum(imageIndex.getTarget()), functions->texSubImage2D(
imageIndex.getLevelIndex(), 0, 0, desc.size.width, ToGLenum(imageIndex.getTarget()), imageIndex.getLevelIndex(), 0, 0,
desc.size.height, nativeSubImageFormat.format, desc.size.width, desc.size.height, nativeSubImageFormat.format,
nativeSubImageFormat.type, zero->data())); nativeSubImageFormat.type, zero->data()));
} }
}
else else
{ {
ASSERT(nativegl::UseTexImage3D(getType())); ASSERT(nativegl::UseTexImage3D(getType()));
......
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