Skip to content

Commit

Permalink
ANGLE eglBindTexImage ASSERT when overwriting a binding
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=265127
rdar://118649807

Reviewed by Dan Glastonbury.

glBindTexture(GL_TEXTURE_2D, tex);
eglBindTexImage(.., pbuffer, ...);
  - Would set the Surface::mBoundTexture of pbuffer
  - Would set the Texture::mBoundSurface of tex
eglBindTexImage(.., pbuffer2, ...);
  - Would set the Surface::mBoundTexture of pbuffer2
  - Would set the Texture::mBoundSurface of tex
  - Would fail to unset Surface::mBoundTexture of pbuffer

Fix by making the unset logic linear, avoiding
Surface -> Texture -> Surface call sequence.

* Source/ThirdParty/ANGLE/src/libANGLE/Surface.cpp:
(egl::Surface::bindTexImage):
* Source/ThirdParty/ANGLE/src/libANGLE/Texture.cpp:
(gl::Texture::bindTexImageFromSurface):
* Source/ThirdParty/ANGLE/src/tests/gl_tests/PbufferTest.cpp:

Canonical link: https://commits.webkit.org/267815.587@safari-7617-branch
  • Loading branch information
kkinnunen-apple committed Nov 28, 2023
1 parent e408ece commit db3f6a7
Show file tree
Hide file tree
Showing 3 changed files with 406 additions and 23 deletions.
5 changes: 4 additions & 1 deletion Source/ThirdParty/ANGLE/src/libANGLE/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,10 @@ Error Surface::bindTexImage(gl::Context *context, gl::Texture *texture, EGLint b
{
ASSERT(!mTexture);
ANGLE_TRY(mImplementation->bindTexImage(context, texture, buffer));

if (auto *previousSurface = texture->getBoundSurface())
{
ANGLE_TRY(previousSurface->releaseTexImage(context, buffer));
}
if (texture->bindTexImageFromSurface(context, this) == angle::Result::Stop)
{
return Error(EGL_BAD_SURFACE);
Expand Down
7 changes: 1 addition & 6 deletions Source/ThirdParty/ANGLE/src/libANGLE/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1827,12 +1827,7 @@ angle::Result Texture::generateMipmap(Context *context)
angle::Result Texture::bindTexImageFromSurface(Context *context, egl::Surface *surface)
{
ASSERT(surface);

if (mBoundSurface)
{
ANGLE_TRY(releaseTexImageFromSurface(context));
}

ASSERT(!mBoundSurface);
mBoundSurface = surface;

// Set the image info to the size and format of the surface
Expand Down
Loading

0 comments on commit db3f6a7

Please sign in to comment.