Revert "Make egl surface uncurrent when being destroyed"

This reverts commit 497440cdcb.

Reason for revert: this caused chromium webview tests failures: https://chromium-review.googlesource.com/c/chromium/src/+/4860891.

Original change's description:
> Make egl surface uncurrent when being destroyed
>
> This is to workaround errors when app does below behaviors:
>
> 1) while there is a context still bound to the current
> rendering thread and the surface, call eglDestroySurface()
> 2) create a new surface eglCreateWindowSurface()
> 3) call eglMakeCurrent() with the surface created in step 2)
> 4) does work on the new surface
>
> The old surface won't be destroyed in step 1) because
> it was still bound by the context of the current rendering
> thread. When creating new surface on step 2), some hardware
> will return error code EGL_BAD_ALLOC, because the old egl
> surface is still associated with the native window.
>
> To workaround, when destroying surface, if the surface
> is still bound by the context of the current rendering
> thread, release the context and surface by passing
> EGL_NO_CONTEXT and EGL_NO_SURFACE to eglMakeCurrent().
>
> The workaround is controlled by a frontend feature
> uncurrentEglSurfaceUponSurfaceDestroy. This feature
> is only enabled on vulkan and gl backends.
>
> Bug: b/292285899
> Change-Id: I872d2e116ba6860f58d1176f011a5ef7c5a5af4e
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4851255
> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
> Reviewed-by: Charlie Lao <cclao@google.com>
> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
> Commit-Queue: Yuxin Hu <yuxinhu@google.com>

Bug: b/292285899
Change-Id: I760054d856294e6691e79e165fd73ce9e560621f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4862958
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Yuxin Hu <yuxinhu@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
This commit is contained in:
Yuxin Hu
2023-09-13 15:11:46 +00:00
committed by Angle LUCI CQ
parent 297877bc20
commit 8a7ad933a2
8 changed files with 0 additions and 94 deletions

View File

@@ -161,13 +161,6 @@ struct FrontendFeatures : FeatureSetBase
&members, "http://anglebug.com/8280"
};
FeatureInfo uncurrentEglSurfaceUponSurfaceDestroy = {
"uncurrentEglSurfaceUponSurfaceDestroy",
FeatureCategory::FrontendWorkarounds,
"Make egl surface uncurrent when calling eglDestroySurface(), if the surface is still bound by the context of current render thread",
&members, "https://issuetracker.google.com/292285899"
};
};
inline FrontendFeatures::FrontendFeatures() = default;

View File

@@ -161,14 +161,6 @@
"Check the filesystem for translated shaders to use instead of the shader translator's"
],
"issue": "http://anglebug.com/8280"
},
{
"name": "uncurrent_egl_surface_upon_surface_destroy",
"category": "Workarounds",
"description": [
"Make egl surface uncurrent when calling eglDestroySurface(), if the surface is still bound by the context of current render thread"
],
"issue": "https://issuetracker.google.com/292285899"
}
]
}

View File

@@ -2608,9 +2608,6 @@ void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFea
// https://crbug.com/480992
// Disable shader program cache to workaround PowerVR Rogue issues.
ANGLE_FEATURE_CONDITION(features, disableProgramBinary, IsPowerVrRogue(functions));
// https://issuetracker.google.com/292285899
ANGLE_FEATURE_CONDITION(features, uncurrentEglSurfaceUponSurfaceDestroy, true);
}
void ReInitializeFeaturesAtGPUSwitch(const FunctionsGL *functions, angle::FeaturesGL *features)

View File

@@ -5014,9 +5014,6 @@ void RendererVk::initializeFrontendFeatures(angle::FrontendFeatures *features) c
ANGLE_FEATURE_CONDITION(features, forceGlErrorChecking, (IsAndroid() && isSwiftShader));
ANGLE_FEATURE_CONDITION(features, cacheCompiledShader, true);
// https://issuetracker.google.com/292285899
ANGLE_FEATURE_CONDITION(features, uncurrentEglSurfaceUponSurfaceDestroy, true);
}
angle::Result RendererVk::getPipelineCacheSize(DisplayVk *displayVk, size_t *pipelineCacheSizeOut)

View File

@@ -331,33 +331,6 @@ EGLBoolean DestroySurface(Thread *thread, Display *display, egl::SurfaceID surfa
{
Surface *eglSurface = display->getSurface(surfaceID);
// Workaround https://issuetracker.google.com/292285899
// When destroying surface, if the surface
// is still bound by the context of the current rendering
// thread, release the surface by passing EGL_NO_SURFACE to eglMakeCurrent().
if (display->getFrontendFeatures().uncurrentEglSurfaceUponSurfaceDestroy.enabled &&
eglSurface->isCurrentOnAnyContext() &&
(thread->getCurrentDrawSurface() == eglSurface ||
thread->getCurrentReadSurface() == eglSurface))
{
SurfaceID drawSurface = PackParam<SurfaceID>(EGL_NO_SURFACE);
SurfaceID readSurface = PackParam<SurfaceID>(EGL_NO_SURFACE);
const gl::Context *currentContext = thread->getContext();
const gl::ContextID contextID = currentContext->id();
// if surfaceless context is supported, only release the surface.
if (display->getExtensions().surfacelessContext)
{
MakeCurrent(thread, display, drawSurface, readSurface, contextID);
}
else
{
// if surfaceless context is not supported, release the context, too.
MakeCurrent(thread, display, drawSurface, readSurface,
PackParam<gl::ContextID>(EGL_NO_CONTEXT));
}
}
ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglDestroySurface",
GetDisplayIfValid(display), EGL_FALSE);

View File

@@ -2792,50 +2792,6 @@ TEST_P(EGLSurfaceTest, DISABLED_RandomClearTearing)
mOSWindow->resize(kInitialSize, kInitialSize);
}
// Make sure a surface (from the same window) can be recreated after being destroyed, even if it's
// still current.
TEST_P(EGLSurfaceTest, DestroyAndRecreateWhileCurrent)
{
setWindowVisible(mOSWindow, true);
initializeDisplay();
mConfig = chooseDefaultConfig(true);
ASSERT_NE(mConfig, nullptr);
EGLint surfaceType = EGL_NONE;
eglGetConfigAttrib(mDisplay, mConfig, EGL_SURFACE_TYPE, &surfaceType);
ASSERT_NE((surfaceType & EGL_WINDOW_BIT), 0);
initializeWindowSurfaceWithAttribs(mConfig, {}, EGL_SUCCESS);
initializeMainContext();
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_EGL_SUCCESS();
// Draw with this surface to make sure it's used.
ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), essl1_shaders::fs::Red());
glViewport(0, 0, 64, 64);
drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f);
ASSERT_GL_NO_ERROR();
// Destroy the surface while it's current; it won't actually be destroyed.
eglDestroySurface(mDisplay, mWindowSurface);
mWindowSurface = EGL_NO_SURFACE;
// Create another surface from the same window right away.
initializeWindowSurfaceWithAttribs(mConfig, {}, EGL_SUCCESS);
// Make the new surface current; this leads to the actual destruction of the previous surface.
EXPECT_EGL_TRUE(eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext));
ASSERT_EGL_SUCCESS();
// Verify everything still works
ANGLE_GL_PROGRAM(program2, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green());
drawQuad(program2, essl1_shaders::PositionAttrib(), 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
ASSERT_GL_NO_ERROR();
}
} // anonymous namespace
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EGLSingleBufferTest);

View File

@@ -346,7 +346,6 @@ constexpr PackedEnumMap<Feature, const char *> kFeatureNames = {{
{Feature::SyncMonolithicPipelinesToBlobCache, "syncMonolithicPipelinesToBlobCache"},
{Feature::SyncVertexArraysToDefault, "syncVertexArraysToDefault"},
{Feature::UnbindFBOBeforeSwitchingContext, "unbindFBOBeforeSwitchingContext"},
{Feature::UncurrentEglSurfaceUponSurfaceDestroy, "uncurrentEglSurfaceUponSurfaceDestroy"},
{Feature::UnfoldShortCircuits, "unfoldShortCircuits"},
{Feature::UnpackLastRowSeparatelyForPaddingInclusion, "unpackLastRowSeparatelyForPaddingInclusion"},
{Feature::UnpackOverlappingRowsSeparatelyUnpackBuffer, "unpackOverlappingRowsSeparatelyUnpackBuffer"},

View File

@@ -346,7 +346,6 @@ enum class Feature
SyncMonolithicPipelinesToBlobCache,
SyncVertexArraysToDefault,
UnbindFBOBeforeSwitchingContext,
UncurrentEglSurfaceUponSurfaceDestroy,
UnfoldShortCircuits,
UnpackLastRowSeparatelyForPaddingInclusion,
UnpackOverlappingRowsSeparatelyUnpackBuffer,