Commit e2ea45ba by Geoff Lang Committed by Commit Bot

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/+/1769059Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 2ed7b290
...@@ -338,6 +338,12 @@ struct FeaturesGL : FeatureSetBase ...@@ -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,16 +1191,22 @@ angle::Result TextureGL::bindTexImage(const gl::Context *context, egl::Surface * ...@@ -1191,16 +1191,22 @@ 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 FunctionsGL *functions = GetFunctionsGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
StateManagerGL *stateManager = GetStateManagerGL(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);
StateManagerGL *stateManager = GetStateManagerGL(context);
stateManager->bindTexture(getType(), mTextureID);
ASSERT(nativegl::UseTexImage2D(getType()));
functions->texImage2D(ToGLenum(getType()), 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
}
stateManager->bindTexture(getType(), mTextureID);
ASSERT(nativegl::UseTexImage2D(getType()));
functions->texImage2D(ToGLenum(getType()), 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -1545,6 +1545,8 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature ...@@ -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)
......
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