// // Copyright 2016 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // EGLContextSharingTest.cpp: // Tests relating to shared Contexts. #include <gtest/gtest.h> #include "common/tls.h" #include "test_utils/ANGLETest.h" #include "test_utils/MultiThreadSteps.h" #include "test_utils/angle_test_configs.h" #include "test_utils/gl_raii.h" #include "util/EGLWindow.h" #include "util/OSWindow.h" #include "util/test_utils.h" usingnamespaceangle; namespace { EGLBoolean SafeDestroyContext(EGLDisplay display, EGLContext &context) { … } class EGLContextSharingTest : public ANGLETest<> { … }; class EGLContextSharingTestNoFixture : public EGLContextSharingTest { … }; // Tests that creating resources works after freeing the share context. TEST_P(EGLContextSharingTest, BindTextureAfterShareContextFree) { … } // Tests the creation of contexts using EGL_ANGLE_display_texture_share_group TEST_P(EGLContextSharingTest, DisplayShareGroupContextCreation) { … } // Tests the sharing of textures using EGL_ANGLE_display_texture_share_group TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing) { … } // Tests that shared textures using EGL_ANGLE_display_texture_share_group are released when the last // context is destroyed TEST_P(EGLContextSharingTest, DisplayShareGroupReleasedWithLastContext) { … } // Tests that after creating a texture using EGL_ANGLE_display_texture_share_group, // and deleting the Context and the egl::ShareGroup who own a texture staged updates, // the texture staged updates are flushed, and the Context and egl::ShareGroup can be destroyed // successfully, and the texture can still be accessed from the global display texture share group TEST_P(EGLContextSharingTest, DisplayShareGroupReleaseShareGroupThatOwnsStagedUpdates) { … } // Tests that after creating a texture using EGL_ANGLE_display_texture_share_group, // and use it for sampling, and then deleting the Context (which destroys shareGroup) works. If // anything cached in ShareGroup, it should be handled nicely if texture can outlive ShareGroup (for // example, bugs like angleproject:7466). TEST_P(EGLContextSharingTest, DisplayShareGroupReleaseShareGroupThenDestroyTexture) { … } // Tests that deleting an object on one Context doesn't destroy it ahead-of-time. Mostly focused // on the Vulkan back-end where we manage object lifetime manually. TEST_P(EGLContextSharingTest, TextureLifetime) { … } // Tests that deleting an object on one Context doesn't destroy it ahead-of-time. Mostly focused // on the Vulkan back-end where we manage object lifetime manually. TEST_P(EGLContextSharingTest, SamplerLifetime) { … } // Test that deleting an object reading from a shared object in one context doesn't cause the other // context to crash. Mostly focused on the Vulkan back-end where we track resource dependencies in // a graph. TEST_P(EGLContextSharingTest, DeleteReaderOfSharedTexture) { … } // Tests that Context will be destroyed in thread cleanup callback and it is safe to call GLES APIs. TEST_P(EGLContextSharingTest, ThreadCleanupCallback) { … } // Tests that Context will be automatically unmade from current on thread exit. TEST_P(EGLContextSharingTest, UnmakeFromCurrentOnThreadExit) { … } // Test that an inactive but alive thread doesn't prevent memory cleanup. TEST_P(EGLContextSharingTestNoFixture, InactiveThreadDoesntPreventCleanup) { … } // Test that eglTerminate() with a thread doesn't cause other threads to crash. TEST_P(EGLContextSharingTestNoFixture, EglTerminateMultiThreaded) { … } // Test that eglDestoryContext() can be called multiple times on the same Context without causing // errors. TEST_P(EGLContextSharingTestNoFixture, EglDestoryContextManyTimesSameContext) { … } // Test that eglTerminate() can be called multiple times on the same Display while Contexts are // still current without causing errors. TEST_P(EGLContextSharingTestNoFixture, EglTerminateMultipleTimes) { … } // Test that we can eglSwapBuffers in one thread while another thread renders to a texture. TEST_P(EGLContextSharingTestNoFixture, SwapBuffersShared) { … } class EGLContextSharingTestNoSyncTextureUploads : public EGLContextSharingTest { … }; // Test that an application that does not synchronize when using textures across shared contexts can // still see texture updates. This behavior is not required by the GLES specification, but is // exhibited by some applications. That application will malfunction if our implementation does not // handle this in the way it expects. Only the vulkan backend has the workaround needed for this // usecase. TEST_P(EGLContextSharingTestNoSyncTextureUploads, NoSync) { … } // Tests that creating a context and immediately destroying it works when no surface has been // created. TEST_P(EGLContextSharingTestNoFixture, ImmediateContextDestroyAfterCreation) { … } } // anonymous namespace GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(…); ANGLE_INSTANTIATE_TEST(…); ANGLE_INSTANTIATE_TEST(…); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(…); ANGLE_INSTANTIATE_TEST(…);