|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|