src/libGLESv2/egl_context_lock_impl.h


Log

Author Commit Date CI Message
Yuxiang Qian 6a03109f 2025-07-09T18:24:31 Refine getCompressionRate As Vulkan spec states, vkGetImageSubresourceLayout should not be called for the android swapchainimage when the image is not bound to memory. Refine the path of getCompressionRate to make sure at least swapchainimage[0] has been initialized when it is been called. Bug: angleproject:433057375 Change-Id: I80b68874686940c0ef77df97b928b0e153c5bbf8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6774721 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 5b343e8f 2025-03-11T11:35:08 Vulkan: Remove support for Stadia Bug: angleproject:42262714 Change-Id: Icae5fe828fe4e0bcd287d297df1bc586708ef86e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6344390 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Shahbaz Youssefi bbc0d702 2024-12-27T07:44:01 Vulkan: Add entry points to lock the Vulkan queue ... which can be retrieved via EGL_ANGLE_device_vulkan. Otherwise the application is unable to use the VkQueue that is retrieved out of ANGLE from other threads (such as Chromium's DrDC feature). Bug: chromium:380295059 Change-Id: Ife80f54440777486f72fc61697a68fb0c2b2d0f7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6116046 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Yuxiang Qian fb743105 2024-11-26T14:37:39 Add stubs for EGL_EXT_surface_compression This patch adds stubs for EGL_EXT_surface_compression to ANGLE, including new API eglQuerySupportedCompressionRatesEXT and adding EGL_SURFACE_COMPRESSION_EXT in EGLQuerySurface and EGLCreateWindowSurface/EGLCreatePlatformWindowSurface. Bug: angleproject:375496226 Change-Id: I1962a11e8e3e5eb2cd5b13c5ba0f685781dfd015 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6073354 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 4167a9a0 2024-08-29T23:38:05 Don't lock the context mutex if no flush in eglClientWaitSync Bug: b/362604439 Change-Id: Ic514bcb3824514b5fd82ebb14ab97286aeb6557c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5828262 Reviewed-by: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Geoff Lang a70ef7fc 2024-04-25T14:19:50 Add EGL_ANGLE_no_error for disabling EGL validation. Chrome makes many small EGL calls that can have proportionally expensive validation. Bug: angleproject:8434 Change-Id: I4f4d0e6eff64839f76a0f7bf48e5c94b8df9d809 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5491459 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Igor Nazarov ca4dc52e 2023-06-22T15:20:12 Replace (Single/Shared)ContextMutex classed with ContextMutex This CL removes `SingleContextMutex` class and not 100% safe `Context::lockAndActivateSharedContextMutex()` method. `SharedContextMutex<>` was replaced with `ContextMutex` with static mutex type which is defined in "SharedContextMutex.h": - ContextMutexType = std::mutex Above refactoring also allows storing `State::mContext` by value, instead by pointer. Actual mutex is referenced by `ContextMutex::mRoot` member. This removes extra pointer indirection and slightly improves performance. If newly created Context uses shared textures/samplers, then it uses `Display::mManagersMutex` root as its root. Performance in Single/Shared cases now will be the same, and it should be slightly faster then old Shared case (because of the reduced complexity). Bug: angleproject:8226 Change-Id: I7ca4d9ea008c665cbea98ace1c6e7bbc544f54b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4632729 Commit-Queue: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Igor Nazarov f1345d1c 2023-08-02T14:23:59 Call ReleaseThread() entry point from ThreadCleanupCallback Change relevant only for the Android platform. Fixes problems: 1. Current code calls `thread->setCurrent(nullptr)` in `Display::threadCleanup()` method, while not executing other code that will actually unmake Context from current. This will affect following EGL calls from the application's side in its own thread cleanup callback. For example, calls to `eglMakeCurrent()` (to unmake from current) or `eglReleaseThread()` will be no-op. This may lead to memory leak if context was previously marked for destruction. 2. The `Display::threadCleanup()` did not also clears the `CurrentValidContext`. This may cause crashes or other UB if an application will call some GLES API in its thread termination callback (for example `glFinish()`), if ANGLE already destroyed the context in its ThreadCleanupCallback (use after delete). 3. Context will remain current to a thread that terminated. Current implementation of GLES drivers on Mali/Adreno GPUs automatically unmade context from current, so the application may make this context current to some other thread. ANGLE should mimic this behavior to avoid possible bugs. All of the above problems may be fixed by simply calling from the ThreadCleanupCallback either: - MakeCurrent(t, d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) - ReleaseThread(t) This CL choose to call `ReleaseThread()` because this is the API that the application may call in its own thread cleanup callback. And if application's callback will be called later than ANGLE's callback, then application's `eglReleaseThread()` call we be a no-op. Even if the application does not have its own thread cleanup callback (like most of the applications), there is no harm to call `ReleaseThread()` anyway. The only difference with `MakeCurrent()` is that it will also cleanup invalid objects and some other memory depending on the backend. This CL naturally replaces existing logic with Display termination when there is no active threads thanks to the previous CL: "Perform Display terminate(InternalCleanup) from makeCurrent()". Bug: angleproject:6723 Bug: angleproject:8283 Test: angle_end2end_tests --gtest_filter=EGLContextSharingTest.ThreadCleanupCallback* Test: angle_end2end_tests --gtest_filter=EGLContextSharingTest.UnmakeFromCurrentOnThreadExit* Change-Id: I8c5b31f34f91c4bfdac165ac30c213ff5fef992e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4742383 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Shahbaz Youssefi 2d5fb09d 2023-07-22T22:34:20 Stubs for EGL_ANGLE_external_context_and_surface Bug: angleproject:5509 Change-Id: I8e2395784abcd2b4e3e1f888e70a879ef49287bc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4706026 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Igor Nazarov 36c3e0f5 2023-01-17T17:42:59 Implement "Shared Context Mutex" functionality. Existing implementation uses single `GlobalMutex` for - EGL calls - GL calls for Contexts with concurrent access. This CL introduces abstract `egl::ContextMutex` with two implementations: - SingleContextMutex; - SharedContextMutex<Mutex>; Note: `std::mutex` is used in this commit. It is very easy to change mutex type either at compile-time or at run-time (single type per Display). When Context: - is not Shared; - does not use `EGLImage`s; - does not use EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE - does not use EGL_DISPLAY_SEMAPHORE_SHARE_GROUP_ANGLE then it will be using `SingleContextMutex` with minimal overhead. Before such Context is used as `shareContext` or uses `EGLImage` its mutex replaced by `SharedContextMutex<Mutex>`. The `GlobalMutex` is only used for EGL calls, while `egl::ContextMutex` implementations for GL calls. Because some EGL calls use Context, explicit `egl::ContextMutex` lock is required. This is implemented by generating "egl_context_mutex_autogen.h" header, and insertion of `ANGLE_EGL_SCOPED_CONTEXT_LOCK()` macro before `ANGLE_EGL_VALIDATE()` in each EGL entry point. Implementation in "egl_context_lock_impl.h" returns lock for required APIs. Special cases of `egl::ContextMutex` lock handled separately. `std::unique_lock<>` is not used for performance reasons. `egl::ContextMutex` explicitly locked when capturing EGL calls. Fixes EGLImage problem: https://chromium.googlesource.com/angle/angle/+/e18240d136d15e5cdfa4fa4a6355ca21c8d807b6 Mark contexts as shared when importing EGL images. Details: - EGLImage inherits Context's mutex when created. Mutex is used when the EGLImage accessed or destroyed. - When EGLImage is used in Context with other `egl::ContextMutex`, two mutexes are merged into one. - After the mutex merge, Context Groups will remain separate, but will not be able to run in parallel. Fixes race when checking `context->isShared()` in the `SCOPED_SHARE_CONTEXT_LOCK()` macro. One Context may start executing GL call while not "Shared", but become "Shared" inside the call. New (second) "Shared" Context may immediately start using GL and potentially corrupt some "Shared" state. Possible performance benefit: allows parallel execution in some cases, when single `GlobalMutex` would block. Important note: Process of replacing the `SingleContextMutex` by `SharedContextMutex<Mutex>` is not 100% safe. This mean that original Context may still be using `SingleContextMutex` after activating `SharedContextMutex<Mutex>`. However, this was always the case before introduction of this CL. Old `Context::mShared` member update was not synchronized in any way at all. In other words, this solution does not 100% fix the original problem. For 100% safe solution `SingleContextMutex` should not be used (always pass `SharedContextMutex<Mutex>` to the `gl::Context` constructor). See `lockAndActivateSharedContextMutex()` for more details. CL adds new build option: angle_enable_shared_context_mutex = true Behavior with other build options: - When: `angle_enable_shared_context_mutex` is disabled or `angle_enable_share_context_lock` is disabled or `angle_force_context_check_every_call` is enabled, Contexts will always have `SingleContextMutex`, however it will be only used in special cases. `SCOPED_SHARE_CONTEXT_LOCK()` will use `GlobalMutex` when applicable. - Otherwise, `SCOPED_SHARE_CONTEXT_LOCK()` will use `egl::ContextMutex`. Some GFXBench "1080p Driver Overhead 2 Offscreen" performance numbers. Tested on S906B (Samsung Galaxy S22+) on old ANGLE base: https://chromium.googlesource.com/angle/angle/+/807c94ea85e046c6f279d081d99f0fb1bcf1191a Capture/Replay: Adjust tests do adhere to capture limits Each test result is an average frame number from 6 runs. SingleContextMutex 6579 ( +0.13%) (old) GetContextLock() (mShared is false) 6570 Forced `mShared = true` or NOT using `SingleContextMutex`. SharedContextMutex<std::mutex> FORCE 5061 (-22.97%) (old) GetContextLock() FORCE 4766 (-27.46%) Bug: angleproject:6957 Bug: chromium:1336126 Change-Id: Idcd919f9d4bf482b9ae489bd8b4415ec96048e32 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4374545 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>