Don't reset the texture size to zero in TextureGL::releaseTexImage on Mac.

After unbinding IOSurface textures, we reset the texture size to 0 because
some platforms don't correctly update their state tracking.  This call ends
up generating GL_INVALID_OPERATION errors on Mac for unknown reasons.

Skip the call, the size reset is not required on Mac anyways.

BUG=angleproject:3859

Change-Id: I5e39b6a36aaff41082a5fcc923970f8e97774675
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1769059
Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Geoff Lang 2019-08-23 14:05:53 -04:00 коммит произвёл Commit Bot
Родитель 2ed7b2906c
Коммит e2ea45bac5
3 изменённых файлов: 21 добавлений и 7 удалений

Просмотреть файл

@ -338,6 +338,12 @@ struct FeaturesGL : FeatureSetBase
"clip_src_region_for_blitframebuffer", FeatureCategory::OpenGLWorkarounds, "clip_src_region_for_blitframebuffer", FeatureCategory::OpenGLWorkarounds,
"Mac has issues with blitFramebuffer when the parameters don't match the framebuffer size.", "Mac has issues with blitFramebuffer when the parameters don't match the framebuffer size.",
&members, "http://crbug.com/830046"}; &members, "http://crbug.com/830046"};
// Calling glTexImage2D with zero size on a rectangle texture generates GL errors
Feature resettingRectangleTexturesGeneratesErrors = {
"reset_rectangle_texture_generates_errors", FeatureCategory::OpenGLWorkarounds,
"Calling glTexImage2D with zero size on a rectangle texture generates errors.", &members,
"http://anglebug.com/3859"};
}; };
inline FeaturesGL::FeaturesGL() = default; inline FeaturesGL::FeaturesGL() = default;

Просмотреть файл

@ -1191,9 +1191,13 @@ angle::Result TextureGL::bindTexImage(const gl::Context *context, egl::Surface *
angle::Result TextureGL::releaseTexImage(const gl::Context *context) angle::Result TextureGL::releaseTexImage(const gl::Context *context)
{ {
// Not all Surface implementations reset the size of mip 0 when releasing, do it manually
ASSERT(getType() == gl::TextureType::_2D || getType() == gl::TextureType::Rectangle); ASSERT(getType() == gl::TextureType::_2D || getType() == gl::TextureType::Rectangle);
const angle::FeaturesGL &features = GetFeaturesGL(context);
if (getType() != gl::TextureType::Rectangle &&
!features.resettingRectangleTexturesGeneratesErrors.enabled)
{
// Not all Surface implementations reset the size of mip 0 when releasing, do it manually
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
@ -1201,6 +1205,8 @@ angle::Result TextureGL::releaseTexImage(const gl::Context *context)
ASSERT(nativegl::UseTexImage2D(getType())); ASSERT(nativegl::UseTexImage2D(getType()));
functions->texImage2D(ToGLenum(getType()), 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, functions->texImage2D(ToGLenum(getType()), 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr); nullptr);
}
return angle::Result::Continue; return angle::Result::Continue;
} }

Просмотреть файл

@ -1545,6 +1545,8 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
IsLinux() || (IsAndroid() && IsNvidia(vendor)) || (IsWindows() && IsNvidia(vendor)); IsLinux() || (IsAndroid() && IsNvidia(vendor)) || (IsWindows() && IsNvidia(vendor));
features->clipSrcRegionBlitFramebuffer.enabled = IsApple(); features->clipSrcRegionBlitFramebuffer.enabled = IsApple();
features->resettingRectangleTexturesGeneratesErrors.enabled = IsApple();
} }
void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features) void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)