From 4b724130cb848472592d6e5b2fe9d2fbb0011422 Mon Sep 17 00:00:00 2001 From: Igor Nazarov Date: Tue, 27 Jun 2023 18:08:27 +0300 Subject: [PATCH] Rename SharedContexMutex into ContexMutex Follow up after: Replace (Single/Shared)ContextMutex classed with ContextMutex Renamed build option: angle_enable_shared_context_mutex -> angle_enable_context_mutex Renamed because there is no more SharedContexMutex class and ContextMutex is now used for both Shared and not Shared Contexts. Bug: angleproject:8226 Change-Id: I68eea84aa59441d9c5b19870910b2bb499311e08 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4650350 Reviewed-by: Shahbaz Youssefi Commit-Queue: Igor Nazarov --- BUILD.gn | 6 +++--- .../GL_EGL_entry_points.json | 2 +- scripts/generate_entry_points.py | 2 +- src/libANGLE/Context.cpp | 2 +- .../{SharedContextMutex.cpp => ContextMutex.cpp} | 4 ++-- .../{SharedContextMutex.h => ContextMutex.h} | 14 +++++++------- src/libANGLE/Display.cpp | 4 ++-- src/libANGLE/Image.cpp | 2 +- src/libANGLE/State.h | 2 +- src/libGLESv2.gni | 4 ++-- src/libGLESv2/global_state.h | 10 +++++----- 11 files changed, 26 insertions(+), 26 deletions(-) rename src/libANGLE/{SharedContextMutex.cpp => ContextMutex.cpp} (98%) rename src/libANGLE/{SharedContextMutex.h => ContextMutex.h} (95%) diff --git a/BUILD.gn b/BUILD.gn index 1c37d66d6..80dc111b5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -81,7 +81,7 @@ declare_args() { angle_enable_global_mutex_load_time_allocate = is_android && !build_with_chromium - angle_enable_shared_context_mutex = true + angle_enable_context_mutex = true } declare_args() { @@ -187,9 +187,9 @@ config("internal_config") { defines += [ "ANGLE_ENABLE_GLOBAL_MUTEX_LOAD_TIME_ALLOCATE=1" ] } - if (angle_enable_shared_context_mutex && angle_enable_share_context_lock && + if (angle_enable_context_mutex && angle_enable_share_context_lock && !angle_force_context_check_every_call) { - defines += [ "ANGLE_ENABLE_SHARED_CONTEXT_MUTEX=1" ] + defines += [ "ANGLE_ENABLE_CONTEXT_MUTEX=1" ] } if (angle_enable_context_mutex_recursion) { diff --git a/scripts/code_generation_hashes/GL_EGL_entry_points.json b/scripts/code_generation_hashes/GL_EGL_entry_points.json index 10acd8b72..7af9bb73a 100644 --- a/scripts/code_generation_hashes/GL_EGL_entry_points.json +++ b/scripts/code_generation_hashes/GL_EGL_entry_points.json @@ -6,7 +6,7 @@ "scripts/entry_point_packed_gl_enums.json": "1c6b036918aabb9822a638fbf33f87f4", "scripts/generate_entry_points.py": - "64ef644064c7fcbbf89458dc53ca5c94", + "ee19e5c267b0d86d725ddb37578a1214", "scripts/gl_angle_ext.xml": "3d6d9529c6d0da797652c366ddaa9087", "scripts/registry_xml.py": diff --git a/scripts/generate_entry_points.py b/scripts/generate_entry_points.py index c21a3a9e3..e1be7b08c 100755 --- a/scripts/generate_entry_points.py +++ b/scripts/generate_entry_points.py @@ -3022,7 +3022,7 @@ def get_egl_entry_point_labeled_object(ep_to_object, cmd_stripped, params, packe def get_context_lock(api, cmd_name): # EGLImage related commands need to access EGLImage and Display which should # be protected with global lock - # Also handles ContexMutex marging when SharedContextMutex is enabled. + # Also handles ContextMutex merging when "angle_enable_context_mutex" is true. if api == apis.GLES and cmd_name.startswith("glEGLImage"): return "SCOPED_EGL_IMAGE_SHARE_CONTEXT_LOCK(context, imagePacked);" diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp index c84e8ca7c..b77d110db 100644 --- a/src/libANGLE/Context.cpp +++ b/src/libANGLE/Context.cpp @@ -173,7 +173,7 @@ egl::ContextMutex *AllocateOrUseContextMutex(egl::ContextMutex *sharedContextMut { if (sharedContextMutex != nullptr) { - ASSERT(egl::kIsSharedContextMutexEnabled); + ASSERT(egl::kIsContextMutexEnabled); ASSERT(sharedContextMutex->isReferenced()); return sharedContextMutex; } diff --git a/src/libANGLE/SharedContextMutex.cpp b/src/libANGLE/ContextMutex.cpp similarity index 98% rename from src/libANGLE/SharedContextMutex.cpp rename to src/libANGLE/ContextMutex.cpp index 206025cb8..71b425c04 100644 --- a/src/libANGLE/SharedContextMutex.cpp +++ b/src/libANGLE/ContextMutex.cpp @@ -3,9 +3,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// SharedContextMutex.cpp: Classes for protecting Shared Context access and EGLImage siblings. +// ContextMutex.cpp: Classes for protecting Context access and EGLImage siblings. -#include "libANGLE/SharedContextMutex.h" +#include "libANGLE/ContextMutex.h" #include "common/system_utils.h" #include "libANGLE/Context.h" diff --git a/src/libANGLE/SharedContextMutex.h b/src/libANGLE/ContextMutex.h similarity index 95% rename from src/libANGLE/SharedContextMutex.h rename to src/libANGLE/ContextMutex.h index 7976a81bf..80d359801 100644 --- a/src/libANGLE/SharedContextMutex.h +++ b/src/libANGLE/ContextMutex.h @@ -3,10 +3,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// SharedContextMutex.h: Classes for protecting Shared Context access and EGLImage siblings. +// ContextMutex.h: Classes for protecting Context access and EGLImage siblings. -#ifndef LIBANGLE_SHARED_CONTEXT_MUTEX_H_ -#define LIBANGLE_SHARED_CONTEXT_MUTEX_H_ +#ifndef LIBANGLE_CONTEXT_MUTEX_H_ +#define LIBANGLE_CONTEXT_MUTEX_H_ #include @@ -19,10 +19,10 @@ class Context; namespace egl { -#if defined(ANGLE_ENABLE_SHARED_CONTEXT_MUTEX) -constexpr bool kIsSharedContextMutexEnabled = true; +#if defined(ANGLE_ENABLE_CONTEXT_MUTEX) +constexpr bool kIsContextMutexEnabled = true; #else -constexpr bool kIsSharedContextMutexEnabled = false; +constexpr bool kIsContextMutexEnabled = false; #endif // Use standard mutex for now @@ -211,4 +211,4 @@ class [[nodiscard]] ScopedContextMutexLock final } // namespace egl -#endif // LIBANGLE_SHARED_CONTEXT_MUTEX_H_ +#endif // LIBANGLE_CONTEXT_MUTEX_H_ diff --git a/src/libANGLE/Display.cpp b/src/libANGLE/Display.cpp index db945d7d6..1a16c76da 100644 --- a/src/libANGLE/Display.cpp +++ b/src/libANGLE/Display.cpp @@ -1123,7 +1123,7 @@ Error Display::initialize() mSingleThreadPool = angle::WorkerThreadPool::Create(1, ANGLEPlatformCurrent()); mMultiThreadPool = angle::WorkerThreadPool::Create(0, ANGLEPlatformCurrent()); - if (kIsSharedContextMutexEnabled) + if (kIsContextMutexEnabled) { ASSERT(mManagersMutex == nullptr); mManagersMutex = new ContextMutex(); @@ -1563,7 +1563,7 @@ Error Display::createContext(const Config *configuration, ScopedContextMutexLock mutexLock; ContextMutex *sharedContextMutex = nullptr; - if (kIsSharedContextMutexEnabled) + if (kIsContextMutexEnabled) { ASSERT(mManagersMutex != nullptr); if (shareContext != nullptr) diff --git a/src/libANGLE/Image.cpp b/src/libANGLE/Image.cpp index 98287506b..e246f84fd 100644 --- a/src/libANGLE/Image.cpp +++ b/src/libANGLE/Image.cpp @@ -316,7 +316,7 @@ Image::Image(rx::EGLImplFactory *factory, ASSERT(mImplementation != nullptr); ASSERT(buffer != nullptr); - if (kIsSharedContextMutexEnabled) + if (kIsContextMutexEnabled) { if (context != nullptr) { diff --git a/src/libANGLE/State.h b/src/libANGLE/State.h index f680c6b3c..fe7c6d39e 100644 --- a/src/libANGLE/State.h +++ b/src/libANGLE/State.h @@ -15,6 +15,7 @@ #include "common/Color.h" #include "common/angleutils.h" #include "common/bitset_utils.h" +#include "libANGLE/ContextMutex.h" #include "libANGLE/Debug.h" #include "libANGLE/GLES1State.h" #include "libANGLE/Overlay.h" @@ -24,7 +25,6 @@ #include "libANGLE/RefCountObject.h" #include "libANGLE/Renderbuffer.h" #include "libANGLE/Sampler.h" -#include "libANGLE/SharedContextMutex.h" #include "libANGLE/Texture.h" #include "libANGLE/TransformFeedback.h" #include "libANGLE/Version.h" diff --git a/src/libGLESv2.gni b/src/libGLESv2.gni index 24017a51c..e110555c8 100644 --- a/src/libGLESv2.gni +++ b/src/libGLESv2.gni @@ -301,7 +301,7 @@ libangle_headers = [ "src/libANGLE/Semaphore.h", "src/libANGLE/Shader.h", "src/libANGLE/ShareGroup.h", - "src/libANGLE/SharedContextMutex.h", + "src/libANGLE/ContextMutex.h", "src/libANGLE/SizedMRUCache.h", "src/libANGLE/State.h", "src/libANGLE/Stream.h", @@ -400,6 +400,7 @@ libangle_sources = [ "src/libANGLE/Compiler.cpp", "src/libANGLE/Config.cpp", "src/libANGLE/Context.cpp", + "src/libANGLE/ContextMutex.cpp", "src/libANGLE/Context_gles_1_0.cpp", "src/libANGLE/Debug.cpp", "src/libANGLE/Device.cpp", @@ -438,7 +439,6 @@ libangle_sources = [ "src/libANGLE/Semaphore.cpp", "src/libANGLE/Shader.cpp", "src/libANGLE/ShareGroup.cpp", - "src/libANGLE/SharedContextMutex.cpp", "src/libANGLE/State.cpp", "src/libANGLE/Stream.cpp", "src/libANGLE/Surface.cpp", diff --git a/src/libGLESv2/global_state.h b/src/libGLESv2/global_state.h index 324b3147f..bed684fba 100644 --- a/src/libGLESv2/global_state.h +++ b/src/libGLESv2/global_state.h @@ -54,7 +54,7 @@ class [[nodiscard]] ScopedSyncCurrentContextFromThread // Tries to lock "ContextMutex" of the Context current to the "thread". ANGLE_INLINE ScopedContextMutexLock TryLockCurrentContext(Thread *thread) { - ASSERT(kIsSharedContextMutexEnabled); + ASSERT(kIsContextMutexEnabled); gl::Context *context = thread->getContext(); return context != nullptr ? ScopedContextMutexLock(context->getContextMutex()) : ScopedContextMutexLock(); @@ -63,7 +63,7 @@ ANGLE_INLINE ScopedContextMutexLock TryLockCurrentContext(Thread *thread) // Tries to lock "ContextMutex" of the Context with "contextID" if it is valid. ANGLE_INLINE ScopedContextMutexLock TryLockContext(Display *display, gl::ContextID contextID) { - ASSERT(kIsSharedContextMutexEnabled); + ASSERT(kIsContextMutexEnabled); gl::Context *context = GetContextIfValid(display, contextID); return context != nullptr ? ScopedContextMutexLock(context->getContextMutex()) : ScopedContextMutexLock(); @@ -74,7 +74,7 @@ ANGLE_INLINE ScopedContextMutexLock TryLockContext(Display *display, gl::Context ANGLE_INLINE ScopedContextMutexLock LockAndTryMergeContextMutexes(gl::Context *context, ImageID imageID) { - ASSERT(kIsSharedContextMutexEnabled); + ASSERT(kIsContextMutexEnabled); ASSERT(context->getDisplay() != nullptr); ScopedContextMutexLock lock(context->getContextMutex()); const Image *image = context->getDisplay()->getImage(imageID); @@ -89,7 +89,7 @@ ANGLE_INLINE ScopedContextMutexLock LockAndTryMergeContextMutexes(gl::Context *c return lock; } -#if !defined(ANGLE_ENABLE_SHARED_CONTEXT_MUTEX) +#if !defined(ANGLE_ENABLE_CONTEXT_MUTEX) # define ANGLE_EGL_SCOPED_CONTEXT_LOCK(EP, THREAD, ...) #else # define ANGLE_EGL_SCOPED_CONTEXT_LOCK(EP, THREAD, ...) \ @@ -158,7 +158,7 @@ static ANGLE_INLINE void DirtyContextIfNeeded(Context *context) DirtyContextIfNeeded(context) # define SCOPED_EGL_IMAGE_SHARE_CONTEXT_LOCK(context, imageID) \ SCOPED_SHARE_CONTEXT_LOCK(context) -# elif !defined(ANGLE_ENABLE_SHARED_CONTEXT_MUTEX) +# elif !defined(ANGLE_ENABLE_CONTEXT_MUTEX) # define SCOPED_SHARE_CONTEXT_LOCK(context) \ egl::ScopedOptionalGlobalMutexLock shareContextLock(context->isShared()) # define SCOPED_EGL_IMAGE_SHARE_CONTEXT_LOCK(context, imageID) ANGLE_SCOPED_GLOBAL_LOCK()