src/libANGLE/Display.h


Log

Author Commit Date CI Message
Yuxin Hu e5619a5c 2024-10-15T18:27:00 Use EGL sync global lock for all EGL*sync entrypoint calls To free EGL sync operations from waiting for other EGL calls to finish, we use a separate global lock for EGL*sync entrypoints. Below angle::SimpleMutex are added to protect resources that may have race condition due to being accessed by EGL*sync calls and non EGL*sync calls at the same time: 1. Display::mContextMapMutex that protects Display::mState.contextMap 2. static angle::base::NoDestructor<angle::SimpleMutex> anglePlatformDisplayMapMutex that protects static angle::base::NoDestructor<ANGLEPlatformDisplayMap> displays 3. static angle::base::NoDestructor<angle::SimpleMutex> devicePlatformDisplayMapMutex that protects static angle::base::NoDestructor<DevicePlatformDisplayMap> displays EGL_Terminate() entry point takes both global lock and global egl sync lock. This is to protect Display::mSyncMap, Display::mSyncPools, and Display::mSyncHandleAllocator being get cleared by thread 1 calling eglTerminate, while they are still accessed by thread 2 through a call such as eglCreateSync. So that we won't have thread 2 finish validating the sync object with syncID exists in Display::mSyncMap, but then find the mSyncMap.find(syncID) returns a nullptr due to the mSyncMap is cleared by thread 1. Same applies to EGL_LabelObjectKHR(), EGL_ReleaseThread(), ThreadCleanupCallback(). EGL_Initialize() writes to Display::mInitialized. This is read by EGL Sync API validation functions. EGL_Initialize() also takes both global lock and global sync lock to prevent race conditions between EGL_Initialize() and EGL Sync APIs. When ANGLE_CAPTURE_ENABLED is enabled, fall back to global lock, as the CaptureEGLCallToFrameCapture() touches many resources (e.g. mMaxAccessedResourceIDs, mFrameCalls) that could lead to race conditions without a global lock. Bug: b/362604439 Change-Id: Ic0d54a4cd66743bcd0f48f41f247dd223cff2f5e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5933570 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Igor Nazarov <i.nazarov@samsung.com> Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Alexey Knyazev 78f146e3 2024-10-14T00:00:00 Remove EAGL support Fixed: angleproject:362530620 Change-Id: I6157655a7ad5b1e30c5d0a155d3ae3e8a81997e8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5938872 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Kimmo Kinnunen <kkinnunen@apple.com>
Shahbaz Youssefi b16d105f 2024-10-03T10:25:32 Remove Desktop GL front-end support For Desktop GL applications, please use Zink! Bug: angleproject:370937467 Change-Id: Ie734634bb62a2e98c80e1b32d8b3d34624da3c04 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5905428 Reviewed-by: Geoff Lang <geofflang@chromium.org>
Yuxin Hu 0de7c43f 2024-09-19T16:57:23 Remove unused functions Static function Display::GetEglDisplaySet() is no longer used. The function was first introduced in https://chromium-review.googlesource.com/c/angle/angle/+/3294581, but the usage was removed in https://chromium-review.googlesource.com/c/angle/angle/+/4742383. Remove the unused function. Bug: b/362604439 Change-Id: I007a5850f642a46f6d141ee88cfd6e221f9358fe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5877313 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Kimmo Kinnunen e5532e6c 2024-09-02T20:55:58 Metal: Avoid using Display::prepareForCall The call can be disabled if CGL and EAGL are not in use. Bug: angleproject:363916154 Change-Id: I4aafddec37daae4470316e2ea70a48e4489573b4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5830798 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Geoff Lang 7ce42b42 2024-05-30T16:08:12 Skip Display::prepareForCall calls everywhere except Mac. Display::prepareForCall was added for CGL and EAGL backends which need to know when an EGL call on a new thread is about to happen. Making this virtual call on all EGL calls on all platforms adds overhead which we can avoid so compile out prepareForCall everywhere except Mac. Bug: angleproject:8434 Change-Id: I7b50463ed405a73eb993e18eb4f83434b4a4fd6e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5582015 Commit-Queue: Geoff Lang <geofflang@chromium.org> Auto-Submit: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi c3a1cae4 2024-04-15T14:58:55 Use angle::SimpleMutex everywhere in libGLESv2 Only cases left that use std::mutex are: - Share group and the context ErrorSet mutexes as they need try_lock() - Anywhere mutexes are used in conjunction with std::condition_variables (as they explicitly require std::mutex) Bug: angleproject:8667 Change-Id: Ib6d68938b0886f9e7c43e023162557990ecfb300 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5453294 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi aba3705b 2024-03-02T21:58:34 Vulkan: Completely remove egl::Display from RendererVk This class is now independent of EGL. The only mentions of EGL is egl::ContextPriority, which is just an enum and is tolerable for now. OpenCL can now instantiate RendererVk without having to create a temp egl::Display. Bug: angleproject:8564 Change-Id: Ia78cfcb3a48c97f397441cf7cda71d74cfaddd8f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5335581 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi f044aaf8 2024-03-02T00:51:33 Vulkan: Create instance/device without access to Display The feature overrides are now encapsulated in a struct, a reference to which is passed around until features are initialized. Additionally, some window system information needed to decide which extensions to use or workarounds to apply are passed around. This is a step towards decoupling RendererVk from egl::Display for direct use with OpenCL. Bug: angleproject:8564 Change-Id: Id6c5d1c3b38aafcd4397e54cc6cad32bf849eeda Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5335823 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mike Schuchardt 56a291e8 2024-02-01T02:30:02 Rework external image capture Move external image creation into the trace fixture. Record image size at capture time and then recreate it using a GL staging texture and placeholder data during replay if the original client buffer is missing (MEC) or the image was created from another API (AHB). Track when EGLImages are created and destroyed during capture so they can be restored to their original MEC state at reset time. Clean up the backing GLTexture resources when the corresponding EGLImage is destroyed. In cases where EGL calls are made without an associated GL context, look up and active context to use from the passed in EGLDisplay parameter. Bug: b/300966403 Change-Id: I7033fa25d2cb3a59957887439506f6f6a416c8f1 Test: Trace com.square_enix.android_googleplay.FFVII Test: Trace com.MOBGames.PoppyMobileChap1 Test: Trace com.tocaboca.tocalifeworld Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4903441 Reviewed-by: Cody Northrop <cnorthrop@google.com>
Geoff Lang c27a4a1d 2023-11-27T14:44:07 Re-use EGL sync object allocations. Create a pool of EGL sync objects with their implementations that can be re-used. Update all backend implementations to support multiple calls to initialize/destroy. Pool size of 32 chosen through experimentation using Chrome. Bug: angleproject:8430 Change-Id: I86fea41aed35eddccc953efb3802bf5fdb7f3cb2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5063341 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@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 52fe3116 2023-07-17T16:20:54 Vulkan: Deduplicate share group's context set tracking Bug: angleproject:8224 Change-Id: I7a59a37229682fb91ff777f31e02e05d7ab2b80f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4690345 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 9f9284b7 2023-07-17T15:41:27 Move ShareGroup to its own files Bug: angleproject:8224 Change-Id: Id6d272018bb5ee8c3e35488f641efa4d99fa836d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4690003 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@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>
Roman Lavrov 21f16cb1 2023-06-09T17:30:38 Disable clang-format on ANGLE features autogen outputs Updates the script to produce reasonably formatted code without clang-format. Autogen files moved to autogen/ sub-directories because clang-format does not support per-file settings ;( This allows to run this codegen very quickly (~50ms on my machine) Bug: angleproject:8193 Change-Id: Ie84282090d574ebb4debe3edcfd82f983f27a5ff Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4604578 Commit-Queue: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Cody Northrop d8339e78 2023-05-25T08:40:48 FrameCapture: Support EGLSync in MEC This CL starts treating EGLSync as a tracked resource, such that we can detect when they need to be created in Setup, or regenerated in Reset. Test: MEC of infinity_ops trace Test: Replay new kentucky_route_zero trace without error Bug: angleproject:8176 Change-Id: I130212f6edb78d9df29dd6e572843df25493ae09 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4566949 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Justin Novosad fbff065c 2023-05-03T22:19:07 Replace GetResourceFromHashSet with map lookup Function GetResourceFromHashSet had linear time complexity because it was sweeping through the set until a resource with a matching ID was found. This change replaces hash sets with hash maps to get constant time lookup. This solves, among other things, O(N^2) time complexity for rendering scenes containing a large number of surfaces. Function GetResourceFromHashSet was consuming over 50% of all CPU time on the main thread of Chrome's GPU process while running the MotionMark 1.2 Images test. With this change, the benchmark score increases by 70% on an M1 MacBook running a PGO official build of Chrome. Bug: chromium:1435066 Change-Id: I895ac0141a91d324c63adec2c0efb8e030d9675b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4505950 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Justin Novosad <junov@chromium.org> Reviewed-by: Igor Nazarov <i.nazarov@samsung.com>
Shahbaz Youssefi 2ceb04e0 2023-05-02T10:45:11 Initialize display TLS at thread creation time Bug: chromium:1441754 Change-Id: I611c6f591f2a6d3439e3c5d1250e2fde996c0ecf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4496673 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 144f2d2c 2023-04-24T12:52:27 Vulkan: Use thread-local space for EGL errors The assumption in anglebug.com/3041 that ANGLE is "single-threaded anyway" no longer holds. Bug: angleproject:3041 Change-Id: I613395c8003cad60764362d2776aaf7b6804b788 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4468107 Reviewed-by: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 1328f2f3 2023-04-17T16:43:12 Vulkan: Destroy the surface without holding the EGL lock This change defers surface destruction to the end of the entry point that causes it so that it is done without holding the EGL lock. This works around a specific deadlock in Android. On this platform: - For EGL applications, parts of surface creation and destruction are handled by the platform, and parts of it are done by the native EGL driver. Namely, on surface destruction, native_window_api_disconnect is called outside the EGL driver. - For Vulkan applications, vkDestroySurfaceKHR takes full responsibility for destroying the surface, including calling native_window_api_disconnect. Unfortunately, native_window_api_disconnect may use EGL sync objects and can lead to calling into the EGL driver. For ANGLE, this is particularly problematic because it is simultaneously a Vulkan application and the EGL driver, causing `vkDestroySurfaceKHR` to call back into ANGLE and attempt to reacquire the EGL lock. Since there are no users of the surface when calling vkDestroySurfaceKHR, it is safe for ANGLE to destroy it without holding the EGL lock. Note that only eglDestroySurface and eglMakeCurrent may lead to the destruction of a window surface. Bug: b/275176234 Bug: angleproject:8127 Change-Id: I02dc52e53e150943457e3f503e7ef30469f96b05 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4428754 Reviewed-by: Charlie Lao <cclao@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Gert Wollny a52c0a6c 2023-02-06T16:01:27 Capture/Replay: Add and handle new resource type for EGLSync So far calls involving EGLSync were not tracking the actual sync objects, and this may lead to race conditions in multi-threaded and multi-context scenarios. This CL adds the type EGLSyncID and some specialized code handling of egl::Sync to distinguish EGLSync from the already existing GLSync objects in order to track them separately. Bug: angleproject:7911 Change-Id: I91b188a41069bc0620f51c55ee516d23b55bdd38 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4200095 Commit-Queue: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Gregg Tavares be9e8e7b 2022-12-14T14:13:39 Add EGL_ANGLE_wait_until_work_scheduled extension We're changing eglReleaseTexImage so it calls flushCommandBuffer(mtl::NoWait) instead of flushCommandBuffer(mtl::WaitUntilScheduled) and then adding an extension to allow us to WaitUntilScheduled. This is because Chrome calls eglReleaseTexImage for every canvas and having it WaitUntilScheduled per call is very slow. So instead we'll call eglWaitUntilWorkScheduledANGLE once which will effectively wait just once. Bug: angleproject:7890 Change-Id: I87bc9f9a1a7f4a0f99d93736cc3083799e76afeb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4109311 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Charlie Lao b19d17b8 2022-12-09T14:38:08 Vulkan: Split Serial class into UniqueSerial and Serial This CL splits Serial class into two classes: UniqueSerial and Serial. UniqueSerial supports the object unique serial usage where there is == and != operator but no > or < comparison. UniqueSerial can have invalid value, but Serial will not have invalid value (in next CL). The main reason is for next CL we can further optimize out the invalid value check in the QueueSerial comparison. Bug: b/262047600 Change-Id: Ieaed2a0d5546b012a6d63aa18b6006595e4aee1b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4093557 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Jamie Madill 8403e4c5 2022-10-10T20:59:29 EGL: Resource IDs for Surface, Context and EGL Image. This will make these classes play nicely with resource maps. As these objects are used in a lot of places, and simplified C can't handle unordered_map, it's necessary to index the maps by simple packed IDs in capture/replay code. This indirection will also have increased safety as we validate EGL resource ID handle values before accessing the memory directly. Also hides some of the other EGL capture methods behind helper methods to simplify the C code and hide assignments and other complex maps. Bug: angleproject:7758 Change-Id: Ibc7bb56430d3068bd38877c9dfb011979d4ea234 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3957164 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Shahbaz Youssefi 025504b9 2022-10-17T17:03:03 Pass worker pools to image load functions In preparation for the ASTC decoder using threaded decoding. Bug: b/250688943 Change-Id: I70d669bcb57b900dbb633304182e174aec362203 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3961339 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Greg Schlomoff <gregschlom@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi b5929ac6 2022-10-17T18:06:32 Move worker pools to Display It doesn't make sense for each context to have its own set of CPU-count workers. This change also facilitates access to the thread pools where gl::Context is not available (but egl::Display is). Bug: b/250688943 Change-Id: I240353abba26c15338d59631b4179a58dfd662f5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3961334 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 0d203aef 2022-10-16T10:08:01 EGL: Add ID types for egl::Surface and egl::Image. This is in preparation for using resource maps for Context, Surface and EGLImage. The map change will make it much easier to work with the trace fixture. It will also have a small benefit in safety as we will longer be casting raw pointers for these types. As these objects are used in a lot of places, and simplified C can't handle unordered_map, it's necessary to index the maps by simple packed IDs in capture/replay code. Bug: angleproject:7758 Change-Id: Ib1d19622a4f2a6f0458cc28f5bbe30bb9f349b98 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3957163 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Eddie Hatfield 3960e63b 2022-08-09T14:02:59 Infra: Enable angle_deqp_gl46_tests on SwiftShader This change disables the WGL frontend by default on Windows when building ANGLE for desktop GL. This is because the WGL frontend is not yet fully implemented and it causes some of the trace tests to fail. The WGL frontend should be enabled by default on windows when more of its functionality gets implemented. Test: angle_deqp_gl46_tests --use-angle=swiftshader Bug: angleproject:7566 Bug: angleproject:7628 Change-Id: I69c695eb56d3858f715eeb86d28cc805e25c60eb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3858142 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Eddie Hatfield 955adb77 2022-08-12T10:14:48 Cache compiled shader By storing the compiled shader in the blob cache, the time to recompile the same shader is reduced. Based on work by <hckim.kim@samsung.com> Bug: angleproject:7036 Change-Id: I884ae40e715c49a9ccd12903012e8327811e3557 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3808235 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Mohan Maiya 7a87e90d 2022-07-16T11:39:08 An inactive but alive thread shouldn't prevent cleanup 1. Acquire EGL global lock before thread cleanup and remove all clean up related mutexes 2. Mark contexts that are not current as invalid during terminate 3. During thread exit, if there are other active threads, terminate with TerminateReason::InternalCleanup. This gives an opportunity for well behaved threads to cleanup up invalid objects. Bug: angleproject:6723 Bug: angleproject:6798 Test: EGLContextSharingTestNoFixture.InactiveThreadDoesntPreventCleanup* Change-Id: I418e5f8b486d3d309bd58c4cfb04b7dc1149ffc1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3768667 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Peng Huang 52b18311 2022-08-08T07:51:21 Use angle::HashSet to replace std::set in Display.h The std::set uses heap allocation for each item, so change it to angle::HashSet for ContextSet, SurfaceSet, ThreadSet, ImageSet, StreamSet, SyncSet and EglDisplaySet. angle::HashSet is a flat set, all items are in one memory allocation. It should has better performance for small size set container. Ideally, it is better to use angle::FlatUnorderedSet which doesn't need heap allocation at all in most cases. However FlatUnorderedSet doesn't support common std container methods. So we can only use angle::HashSet for now. Maybe improve angle::FlatUnorderedSet in follow CLs. Bug: chromium:1336126 Change-Id: I18b3afd8722d222183c88f876b792c1af23bc195 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3816401 Auto-Submit: Peng Huang <penghuang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 12efe5b2 2022-06-21T15:43:42 Cleanup invalid EGL handles only if app called eglTermiate Maintain set of active threads instead of a global refCount and free display's invalid EGL resources iff - 1. app previously called eglTerminate on that display 2. there are no more active threads associated with that display Bug: angleproject:6723 Test: EGLMultiContextTest.RepeatedEglInitAndTerminate* Test: EGLMultiContextTest.ReuseUnterminatedDisplay* Change-Id: I868491bbbf0664e9129dcb0d1fa9e2243ef36d82 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3717277 Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com>
Jamie Madill 9d08c29a 2022-05-25T11:39:29 Expose the EGL Display Context Set in the DisplayState. This will let the Vulkan back-end iterate through and flush pending command buffers in other Contexts. Bug: angleproject:5664 Change-Id: I0d22eb68fa754a97b4836ec8c59ff8c6e5ef2d96 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3668145 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Cody Northrop e0183a42 2022-04-25T09:07:55 Revert "Mark contexts as shared when importing EGL images." This reverts commit e18240d136d15e5cdfa4fa4a6355ca21c8d807b6. Reason for revert: Applications not responding in AOSP: https://buganizer.corp.google.com/issues/229807074 Original change's description: > Mark contexts as shared when importing EGL images. > > Once a context references an EGL image, it can share resources with > contexts in other share groups. Marking the context as shared ensures > that locks are held by all contexts referencing EGL images for GL > functions. > > Bug: angleproject:6957 > Change-Id: Ic3901c458f388306c59f6bb01560a7c66d0574c0 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3424659 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: mohan maiya <m.maiya@samsung.com> > Commit-Queue: Geoff Lang <geofflang@chromium.org> Test: CtsWindowManagerDeviceTestCases Bug: b/229807074 Change-Id: I5b7050bd68f67925f77242e483e2aa970ed0ca17 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3602954 Commit-Queue: Cody Northrop <cnorthrop@google.com> Auto-Submit: Cody Northrop <cnorthrop@google.com> Reviewed-by: Lingfeng Yang <lfy@google.com> Commit-Queue: Lingfeng Yang <lfy@google.com>
Shahbaz Youssefi 400d9fe4 2022-04-23T01:08:19 Rename feature files to *_autogen.h To clarify further that they are not to be edited by hand. Bug: angleproject:6435 Change-Id: Iaf79706d2b688a43b3ebb65700cfbdd71a49a742 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3603842 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Antonio Caggiano 0f3710d9 2022-03-16T14:30:17 Generalize GetDisplayFromNativeDisplay Add a platform parameter to this function to possibly accept other platforms besides EGL_PLATFORM_ANGLE_ANGLE. Bug: angleproject:6902 Change-Id: I90bd9cf2e8142ca0e656dee4bf687953515b71a3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3528757 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Geoff Lang e18240d1 2022-01-28T13:46:41 Mark contexts as shared when importing EGL images. Once a context references an EGL image, it can share resources with contexts in other share groups. Marking the context as shared ensures that locks are held by all contexts referencing EGL images for GL functions. Bug: angleproject:6957 Change-Id: Ic3901c458f388306c59f6bb01560a7c66d0574c0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3424659 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: mohan maiya <m.maiya@samsung.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen 9637185c 2022-03-10T15:38:13 Add ForceGPUSwitch to EGL_ANGLE_power_preference eglHandleGPUSwitch() does not work with WebKit sandbox profile. The root cause is that we do not know the primary display, and as such we do not know which GPU drives this. Add eglForceGPUSwitchANGLE(display, gpuIDHigh, gpuIDLow). This lets the caller figure out the GPU in another process. Then the caller can just set the GPU in the sandboxed process. Add tests that are disabled by default until the runner and the infrastructure supports running the tests with automatic switching enabled. Bug: angleproject:7092 Change-Id: I316ee431156596effbdb89659a5e24291719a204 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3516274 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Antonio Caggiano 47977b0e 2022-03-01T15:24:51 EGL: Validate and implement dmabuf extensions Add validation and default implementation of dmabuf extensions. Actual implementation should be defined by concrete Display subclasses. Bug: angleproject:7065 Change-Id: Ie8d7081f7bcb065c809a52a42abdb7af0e75c816 Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com> Signed-off-by: Constantine Shablya <constantine.shablya@collabora.com> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3497840 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Sean Risser 3adace15 2022-01-10T22:53:19 Don't expose detailed driver version info to webGL WebGL's GL_RENDERER string now only includes basic version information on all backends. This is controlled through a bool passed through getBackendVersionString. Bug: angleproject:6777 Change-Id: Ie4e3d91d22c96f175a8139fac1c66e985ed9e1b7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3380263 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Sean Risser <srisser@google.com>
Cody Northrop 6cced91b 2022-02-08T10:24:11 FrameCapture: Remove destroyed contexts from share group If a GL Context is destroyed, remove it from the list of shared contexts tracked by FrameCapture. Before this CL, we would crash in runMidExecutionCapture when trying to iterate through contexts that were gone: INFO: checking for SetupCalls in context id: 1 INFO: checking for SetupCalls in context id: 2 INFO: checking for SetupCalls in context id: 1769237601 Test: Mortal Kombat MEC Bug: angleproject:6997 Change-Id: I3c2f6a77419d241af9a0b300936e7784446306f8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3448681 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Mohan Maiya feb599ad 2021-12-09T20:17:14 Invalidate EGL handles during eglTerminate EGL 1.5 spec says - Termination marks all EGL-specific resources, such as contexts and surfaces, associated with the specified display for deletion. Handles to all such resources are invalid as soon as eglTerminate returns Move EGL object handles to another set, tracking invalid objects, during display terminate. Destroy these invalid objects during eglReleaseThread Bug: angleproject:6798 Test: EGLMultiContextTest.NegativeTestAfterEglTerminate* Test: EGLMultiContextTest.RepeatedEglInitAndTerminate* Test: Android CTS WrapperTest.testThreadCleanup Change-Id: Ie160212c98367493e645d9d1c8260e7a30649386 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3329273 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Mohan Maiya 6c172e4b 2021-11-20T16:27:14 Add support for memory cleanup on process exit This patch adds a callback to cleanup memory on process exit. Bug: angleproject:6723 Test: Android CTS WrapperTest.testThreadCleanup Change-Id: Ia517d4c6ae280ddc1f17a3b6f77d437aaaad0678 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3294581 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Tim Van Patten 8bb3c827 2021-07-22T19:06:40 Fix Multithreaded eglDestroyContext()/eglTerminate() The following EGL calls can lead to a crash in eglMakeCurrent(): Thread A: eglMakeCurrent(context A) Thread B: eglDestroyContext(context A) B: eglTerminate() <<--- this release context A Thread A: eglMakeCurrent(context B) The eglMakeCurrent(context B) call will assert when attempting to unMakeCurrent(), since thread A doesn't know that context A was already destroyed by thread B. To fix this: 1.) A Context will only be released once there are no Threads that currently have a reference to it (no longer have the Context current). - Context::mIsCurrent is being removed, since it was inaccurate and not thread-safe. For example, when eglTerminate() was called, the eglTerminate()'ing-Thread would "steal" the Context that was current on another Thread to destroy it. 2.) A Display will only be fully terminated and its resources released once all Contexts have been destroyed and are no longer current. Otherwise, Display::terminate() will return if any Contexts are still in use by a Thread. EGL 1.5 Specification 3.2 Initialization If contexts or surfaces, created with respect to dpy are current (see section 3.7.3) to any thread, then they are not actually destroyed while they remain current. If other resources created with respect to dpy are in use by any current context or surface, then they are also not destroyed until the corresponding context or surface is no longer current. With this fix, the app com.netmarble.sknightsmmo can start. This also exposed an issue with GlslangFinalize(), since glslang can only be initialized/finalized once per process. Otherwise, the following EGL commands will call GlslangFinalize() without ever being able to GlslangInitialize() again, leading to crashes since GlslangFinalize() cleans up glslang for the entire process. dpy1 = eglGetPlatformDisplay() | eglInitialize(dpy1) | GlslangInitialize() dpy2 = eglGetPlatformDisplay() | eglInitialize(dpy2) | GlslangInitialize() eglTerminate(dpy2) | GlslangFinalize() eglInitialize(dpy1) | isInitialized() == true Since Display::isInitialized() == true, the rest of Display::initialize() is skipped and GlslangInitialize() is not called. Later, the next test that attempts to compile a program will crash due to glslang no longer being initialized. Finally, this exposed the following tests leaking EGLContext handles: - EGLSurfaceTest::initializeContext() - EGLContextSharingTest.DisplayShareGroupContextCreation - EGLCreateContextAttribsTest.IMGContextPriorityExtension - EGLMultiContextTest.TestContextDestroySimple Other tests were failing to reset the context, preventing the Display from being terminated since there were still references to Contexts owned by the display: eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); Bug: angleproject:6208 Bug: angleproject:6304 Bug: angleproject:6322 Test: EGLContextSharingTest.EglTerminateMultiThreaded Test: EGLContextSharingTestNoFixture.EglDestoryContextManyTimesSameContext Test: Load com.netmarble.sknightsmmo Change-Id: I160922af93db6cabe0ed396be77762fa8dfc7656 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3046961 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Tim Van Patten 58bb11ca 2021-04-16T12:28:50 Capture/Replay: Multi-Context Support Add support for capturing and replaying multiple contexts. 1.) Create and initialize the Contexts in the share group during SetupReplay(). 2.) Track the Context the command stream is for, and if the Context ID changes, inject an eglMakeCurrent() call to switch to the new Context. 3.) Intercept eglCreateContext() and eglMakeCurrent() to route to either EGLWindow or WGLWindow, depending on the current platform. Specifically, this enables capturing and replaying Asphalt 9. Bug: angleproject:5878 Change-Id: I5bc9b7ece5388ce405ba3f9e9dc3967e78662000 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2830145 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Jamie Madill 839d5318 2021-08-16T08:29:28 Capture/Replay: Changes to MEC first frame capture. Recent changes made it so it was impossible to trigger MEC *after* the first frame and *before* the second frame. Instead it was only possible to capture *before* the first frame or *after* the second frame. Makes it possible for the retracing script to do identical captures. Also includes a number of refactorings to make it simpler to follow the code, including renaming methods, and removing some extra output files. Bug: angleproject:5133 Change-Id: Ice6a189eb9f4d53e8ee1ba39beb537af2ef5fd9f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3097807 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Ivan Murashov 7108f83c 2021-07-20T13:16:44 GCC: Remove double declaration of ContextSet After the CL https://chromium-review.googlesource.com/c/angle/angle/+/2965780 the build with GCC failed with error: /third_party/angle/src/libANGLE/Display.h:325:37: error: declaration of 'typedef class std::__1::set<gl::Context*> egl::Display::ContextSet' changes meaning of 'ContextSet' [-fpermissive] /third_party/angle/src/libANGLE/Display.h:75:7: note: 'ContextSet' declared here as 'using ContextSet = class std::__1::set<gl::Context*>' To fix the error the double declaration of ContextSet is removed. Bug: angleproject:5878, chromium:819294 Change-Id: Id9e52061af53ea18dd5d13b960daaa67a14f61ca Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3038804 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Tim Van Patten 223cd0ac 2021-06-15T18:46:07 Capture/Replay: Refactor shared context handling This is the initial CL to enable capture/replay of multi-context applications. This CL refactors FrameCapture and FrameCaptureShared to move much of the functionality into FrameCaptureShared, since most everything is shared by Contexts in the share group. For example, the setup of the majority of the GL objects is done in the new SetupReplayContextShared() function in the new $LABEL_capture_context_shared_frame001.cpp file. The setup is performed by (for example): void SetupReplay() { $LABEL::InitReplay(); $LABEL::SetupReplayContextShared(); SetupReplayContext2(); } This performs the shared setup first, followed by the context-specific setup, which may reference shared objects careated by LABEL::SetupReplayContextShared(). No re-capturing is required with this change, since the external APIs (i.e., SetupReplay()) are still the same. Bug: angleproject:5878 Test: Manual MEC and replay of Magic Tiles 3, Candy Crush Soda Saga, Temple Run 2 Change-Id: Iab7bfe651437e9be1dee83514cd97acc20c61d1d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2965780 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Peng Huang a8e98a23 2021-07-10T15:25:20 Fix gl::Context::unMakeCurrent crashes The crash is because Display::makeCurrent() may fail, in that case, egl_stubs.cpp will not update the current context in global_state and Thread accordingly. And then Context::refCount could be reach 0, and be released, however egl_stubs.cpp still thinks the context is current, and then user-after-free happens. This CL fixes the problem by updating current context of Thread in Display::makeCurrent, and reading the current context of Thread in egl_stubs.cpp and setting it to global_state. Bug: chromium:1171371 Change-Id: Ifc5fffb0e4902c9c72514839d03e5783d50fe283 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3017210 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Peng Huang <penghuang@chromium.org>
Doug Horn fdba40fe 2021-03-31T12:52:00 Reland "Fix multithreaded crash on draw commands on D3D11 backend." This is a reland of 8b9889bf62272fea2495331b622bde1f7c781bd0 The previous CL relied on a define which now only exists in a specific gn configuration. This reland removes D3D11 as a multithread-supported platform in the test configuration. Original change's description: > Fix multithreaded crash on draw commands on D3D11 backend. > > A crash can occur if thread A is executing eglDestroyContext while > thread B issues a draw call, if the threads are interleaved in such a > manner that a makeCurrent occurs without triggering a change to the > global context and a dirtyAllState call. We handle that case by > explicitly making current the proper contexts in the eglDestroyContext > call. > > A test has been added that triggers a crash without this fix when > running on the D3D11 backend. In addition, all of MultithreadingTest > is enabled for the D3D11 backend. > > Test: Ran MultithreadingTest. Test exhibits a crash before this > change, and does not after this change. Also ran: > dEQP-EGL.functional.sharing.gles2.multithread.* > dEQP-EGL.functional.multithread.* > > Bug: b/183756357 > Change-Id: Ic6f76a062868b2f3b4e60d29dc087ec180bfb7cd > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2798591 > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Doug Horn <doughorn@google.com> Bug: b/183756357 Change-Id: I5be9a011ea99a69730eddc9e4da23bcf92ed3bf2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2815243 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Doug Horn <doughorn@google.com>
Doug Horn fc189386 2021-04-08T21:51:46 Revert "Fix multithreaded crash on draw commands on D3D11 backend." This reverts commit 8b9889bf62272fea2495331b622bde1f7c781bd0. Reason for revert: Breaks CI Original change's description: > Fix multithreaded crash on draw commands on D3D11 backend. > > A crash can occur if thread A is executing eglDestroyContext while > thread B issues a draw call, if the threads are interleaved in such a > manner that a makeCurrent occurs without triggering a change to the > global context and a dirtyAllState call. We handle that case by > explicitly making current the proper contexts in the eglDestroyContext > call. > > A test has been added that triggers a crash without this fix when > running on the D3D11 backend. In addition, all of MultithreadingTest > is enabled for the D3D11 backend. > > Test: Ran MultithreadingTest. Test exhibits a crash before this > change, and does not after this change. Also ran: > dEQP-EGL.functional.sharing.gles2.multithread.* > dEQP-EGL.functional.multithread.* > > Bug: b/183756357 > Change-Id: Ic6f76a062868b2f3b4e60d29dc087ec180bfb7cd > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2798591 > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Doug Horn <doughorn@google.com> Bug: b/183756357 Change-Id: I2e9d6385576330f84623d7dafbf690642fcb441f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2815242 Commit-Queue: Doug Horn <doughorn@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Doug Horn 8b9889bf 2021-03-31T12:52:00 Fix multithreaded crash on draw commands on D3D11 backend. A crash can occur if thread A is executing eglDestroyContext while thread B issues a draw call, if the threads are interleaved in such a manner that a makeCurrent occurs without triggering a change to the global context and a dirtyAllState call. We handle that case by explicitly making current the proper contexts in the eglDestroyContext call. A test has been added that triggers a crash without this fix when running on the D3D11 backend. In addition, all of MultithreadingTest is enabled for the D3D11 backend. Test: Ran MultithreadingTest. Test exhibits a crash before this change, and does not after this change. Also ran: dEQP-EGL.functional.sharing.gles2.multithread.* dEQP-EGL.functional.multithread.* Bug: b/183756357 Change-Id: Ic6f76a062868b2f3b4e60d29dc087ec180bfb7cd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2798591 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Doug Horn <doughorn@google.com>
Jonah Ryan-Davis 4968f6f2 2021-02-04T16:40:36 Move getRendererDescription from ContextImpl to DisplayImpl The other backend description strings are in DisplayImpl. This will help with caching the result of glGetString in the GL backend. Also Update the getters to not be const in order to allow caching. Bug: chromium:1173672 Change-Id: I43df35688762b23429f47f169c04482cf4cd089a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2676881 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Jonah Ryan-Davis 0be050a4 2020-09-23T15:12:56 Pass GL_VERSION info through ANGLE's GL_RENDERER string Chrome needs ANGLE to pass through the underlying driver vendor and version, which cannot always be determined by the SystemInfo library. This is done by construction GL_RENDERER in the frontend through combining GL_VENDOR, GL_RENDERER, and GL_VERSION from the backends. Example changes are in the doc: https://docs.google.com/document/d/1p0dvrLlu8NKhO-RCU5gqlQ_LvcQj-ZqhvfwSk1n3Sz8/edit?usp=sharing Bug: chromium:1126526 Bug: chromium:1131248 Bug: chromium:1134669 Bug: chromium:1169861 Change-Id: Ia618ebcd7f3caaeb376b4b6a03446732efdaeecb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2427383 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill fb82b119 2020-11-22T09:05:06 EGL: Add const to several methods. This is in preparatino for auto-generating the EGL validation header. The auto-generation script will force multiple parameters to const. Bug: angleproject:2621 Change-Id: I04e442c6ff118fd7c296341f12f442901f6fb8c0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2552979 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
James Darpinian 27af0b2d 2020-10-19T16:49:48 Reland "ANGLE_platform_angle_device_context_volatile_* extensions" This is a reland of e70f6aa679dd72eca5c88c71b0932928e92d6067 Original change's description: > ANGLE_platform_angle_device_context_volatile_* extensions > > Change from Kimmo Kinnunen downstream: > https://bugs.webkit.org/show_bug.cgi?id=216106 > > Add two extensions for EAGL and CGL backends to declare the > underlying platform context being "volatile". It means that > the thread-global current context is being modified behind > ANGLE. If ANGLE context is marked volatile for a particular > API, it will sync the underlying context for every EGL > function that needs the context. Most intuitive use is > for the client to call eglMakeCurrent before calling any > gl function if the client knowns the platform state might > be dirty. > > Implement eglReleaseThread for EAGL and CGL backends. > Releasing thread will unset the platform current context. > > Fix a bug of omitting EGL_ANGLE_device_eagl from being > advertised. > > Bug: angleproject:5104 > Change-Id: I1ec98ad35bc0caada23556ae8697fdef20f65b1a > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2486548 > Commit-Queue: James Darpinian <jdarpinian@chromium.org> > Reviewed-by: Kenneth Russell <kbr@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> Bug: angleproject:5104 Change-Id: I88265625a4bb4c1412532768d17d7b4356c7be41 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2508842 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: James Darpinian <jdarpinian@chromium.org>
Geoff Lang 68b95b63 2020-10-29T14:09:08 Revert "ANGLE_platform_angle_device_context_volatile_* extensions" This reverts commit e70f6aa679dd72eca5c88c71b0932928e92d6067. Reason for revert: dEQP failures: dEQP.EGL/functional_get_frame_timestamps_rgb565_no_depth_no_stencil dEQP.EGL/functional_get_frame_timestamps_rgb565_no_depth_stencil dEQP.EGL/functional_hdr_metadata_cta861_3 dEQP.EGL/functional_hdr_metadata_smpte2086 dEQP.EGL/functional_mutable_render_buffer_basic dEQP.EGL/functional_swap_buffers_with_damage_resize_after_swap_buffer_age_clear dEQP.EGL/functional_swap_buffers_with_damage_resize_after_swap_buffer_age_clear_clear dEQP.EGL/functional_swap_buffers_with_damage_resize_after_swap_buffer_age_render dEQP.EGL/functional_swap_buffers_with_damage_resize_before_swap_buffer_age_clear dEQP.EGL/functional_swap_buffers_with_damage_resize_before_swap_buffer_age_clear_clear dEQP.EGL/functional_swap_buffers_with_damage_resize_before_swap_buffer_age_render Original change's description: > ANGLE_platform_angle_device_context_volatile_* extensions > > Change from Kimmo Kinnunen downstream: > https://bugs.webkit.org/show_bug.cgi?id=216106 > > Add two extensions for EAGL and CGL backends to declare the > underlying platform context being "volatile". It means that > the thread-global current context is being modified behind > ANGLE. If ANGLE context is marked volatile for a particular > API, it will sync the underlying context for every EGL > function that needs the context. Most intuitive use is > for the client to call eglMakeCurrent before calling any > gl function if the client knowns the platform state might > be dirty. > > Implement eglReleaseThread for EAGL and CGL backends. > Releasing thread will unset the platform current context. > > Fix a bug of omitting EGL_ANGLE_device_eagl from being > advertised. > > Bug: angleproject:5104 > Change-Id: I1ec98ad35bc0caada23556ae8697fdef20f65b1a > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2486548 > Commit-Queue: James Darpinian <jdarpinian@chromium.org> > Reviewed-by: Kenneth Russell <kbr@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> TBR=geofflang@chromium.org,kbr@chromium.org,jdarpinian@chromium.org,jonahr@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: angleproject:5104 Change-Id: Ib683625a55a582c39e5a4a0466038cfa6e782e6c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2507260 Reviewed-by: Geoff Lang <geofflang@chromium.org>
James Darpinian e70f6aa6 2020-10-19T16:49:48 ANGLE_platform_angle_device_context_volatile_* extensions Change from Kimmo Kinnunen downstream: https://bugs.webkit.org/show_bug.cgi?id=216106 Add two extensions for EAGL and CGL backends to declare the underlying platform context being "volatile". It means that the thread-global current context is being modified behind ANGLE. If ANGLE context is marked volatile for a particular API, it will sync the underlying context for every EGL function that needs the context. Most intuitive use is for the client to call eglMakeCurrent before calling any gl function if the client knowns the platform state might be dirty. Implement eglReleaseThread for EAGL and CGL backends. Releasing thread will unset the platform current context. Fix a bug of omitting EGL_ANGLE_device_eagl from being advertised. Bug: angleproject:5104 Change-Id: I1ec98ad35bc0caada23556ae8697fdef20f65b1a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2486548 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Cody Northrop 3e8305f5 2020-10-06T23:16:38 FrameCapture: Move compressed texture cache to shared location In support of tracking compressed texture data across multiple threads and contexts, move our cache to FrameCaptureShared. Make this accessible only via egl::ShareGroup, which will ensure unique texture IDs. Test: Asphalt 8 MEC Bug: b/150484427 Bug: angleproject:4048 Change-Id: I4e75b323d7aedc0333ceffba305439e54c4d6ac1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2455266 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Ian Elliott 08142700 2020-10-01T19:30:03 Work-around test runner & DebugAnnotator Note: This precedes another CL that needs this change. DebugAnnotator uses a global variable. The test runner doesn't change state between testing different back-ends. This works-around the problem by setting the global variable when the context is switched. Because the GL back-end doesn't have its own DebugAnnotator sub-class, add a Display* to DisplayImpl::makeCurrent(), so that DisplayGL::makeCurrent() can install the front-end-Display's DebugAnnotator. Note: the Vulkan back-end gets this fix even though the new DebugAnnotatorVk class will be added in a follow-on CL. Bug: b/162068318 Bug: b/169243237 Bug: angleproject:5121 Change-Id: If08626a5310f9b4e3210e1a897a6886248e4d8ac Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2451423 Reviewed-by: Ian Elliott <ianelliott@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
Kai Ninomiya da61c40e 2020-10-06T01:57:55 Revert "Work-around test runner & DebugAnnotator" This reverts commit e44c94d96a9b65615fe8f5038e124763ac8c45e5. Reason for revert: Breaks build of DisplayGbm on ChromeOS: src/libANGLE/renderer/gl/egl/gbm/DisplayGbm.{h,cpp} First failing builds: https://ci.chromium.org/p/chromium/builders/ci/ChromeOS%20FYI%20Release%20%28amd64-generic%29/1608 https://ci.chromium.org/p/chromium/builders/ci/ChromeOS%20FYI%20Release%20%28kevin%29/2212 Original change's description: > Work-around test runner & DebugAnnotator > > Note: This precedes another CL that needs this change. > > DebugAnnotator uses a global variable. The test runner doesn't change > state between testing different back-ends. This works-around the > problem by setting the global variable when the context is switched. > > Because the GL back-end doesn't have its own DebugAnnotator sub-class, > add a Display* to DisplayImpl::makeCurrent(), so that > DisplayGL::makeCurrent() can install the front-end-Display's > DebugAnnotator. > > Note: the Vulkan back-end gets this fix even though the new > DebugAnnotatorVk class will be added in a follow-on CL. > > Bug: b/162068318 > Bug: b/169243237 > Bug: angleproject:5121 > Change-Id: I748e8a1fd09b72e07242ac7fb39154537dcce534 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2444095 > Reviewed-by: Ian Elliott <ianelliott@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> > Commit-Queue: Ian Elliott <ianelliott@google.com> TBR=courtneygo@google.com,ianelliott@google.com,jmadill@chromium.org Change-Id: I99df2716951726ead24961dc3d27a7ec63aeda80 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: b/162068318 Bug: b/169243237 Bug: angleproject:5121 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2451420 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Ian Elliott e44c94d9 2020-10-01T19:30:03 Work-around test runner & DebugAnnotator Note: This precedes another CL that needs this change. DebugAnnotator uses a global variable. The test runner doesn't change state between testing different back-ends. This works-around the problem by setting the global variable when the context is switched. Because the GL back-end doesn't have its own DebugAnnotator sub-class, add a Display* to DisplayImpl::makeCurrent(), so that DisplayGL::makeCurrent() can install the front-end-Display's DebugAnnotator. Note: the Vulkan back-end gets this fix even though the new DebugAnnotatorVk class will be added in a follow-on CL. Bug: b/162068318 Bug: b/169243237 Bug: angleproject:5121 Change-Id: I748e8a1fd09b72e07242ac7fb39154537dcce534 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2444095 Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
Trevor David Black e815afbf 2020-09-07T22:09:22 First pass at increasing inclusivity Link to the inclusivity rules https://source.android.com/setup/contribute/respectful-code Bug: b/162834212 Bug: chromium:1097198 Change-Id: Ied5a9e3879d72bff3f77ea6fcda9b82f30c32c2f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2396737 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Trevor Black <vantablack@google.com>
Courtney Goeltzenleuchter b156a753 2020-09-28T16:43:50 Move LayoutCaches to ShareGroup Testing with TSN found a race condition with RefCounted objects (DescriptorSetLayout and PipelineLayout). Rather than add more lock calls to protect accesses to mRefCount and mObject recommendation was to put these caches in the ShareGroup (basically part of the context). Locking at the GL level will ensure that two threads that share the same context will not access the ShareGroup at the same time. The ShareGroup also works because these layouts are not destroyed until the context is destroyed so don't have to worry about other threads (e.g. command processor thread) accessing them. Bug: b/168744561 Change-Id: Icc0aa07bf4787a69572d6ec62da2f21d286232c3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2437509 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Jamie Madill 4043b9d1 2020-09-17T12:03:12 Guard against data race with MemoryProgramCache. Uses the display global mutex. Caught with angle_end2end_tests MultithreadingTest and TSAN. Bug: b/168744561 Change-Id: I5a60346cb5f95ff506dc166604eeae501863a774 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2415182 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill f2749096 2020-09-17T12:03:12 Fix racy global in gl::Compiler. We introduce a new Display Global Mutex in egl::Display that can guard access to gActiveCompilers in Compiler.cpp. Was detected by running MultithreadingTest against TSAN. Bug: b/168744561 Change-Id: I97866b60a173f60899cd0406fe0f71000035c0cf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2415181 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Mohan Maiya c99c22bb 2020-09-15T16:53:26 EGL: Add support for EGL_ANDROID_create_native_client_buffer This EGL extension will add support for creating EGLClientBuffer backed by an Android window buffer (struct ANativeWindowBuffer) which can be later used to create an EGLImage. Bug: angleproject:5018 Tests: angle_end2end_tests --gtest_filter=ImageTest.SourceNativeClientBufferTarget* Change-Id: If78ed7b80ad09629b8c5f5b5a0eb07a548e82e6e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2404320 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Jonah Ryan-Davis 1ab73f0f 2020-09-10T14:32:58 Cleanup disable_program_binary workaround This workaround should also clear the shader binary formats. Also, we can use this workaround when disabling program binaries for capture/replay. Bug: angleproject:5007 Change-Id: I57c78e2cc95e7148cb8a1e7fb9bf3ed958fa69c8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2404383 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill d0b270e6 2020-08-14T21:55:17 Feedback Loop Redesign 1/3: Framebuffer Serials. Currently we track feedback loops by counting the times a Texture is bound as a sampler or image in a particular context. This is a bit tricky because Texture bindings change frequently. Relative to the number of times we need to check for a feedback loop this causes excess overhead. Usually Framebuffers have a low number of Textures bound (in many cases just 1). And Textures aren't usually bound to many different FBOs. So instead of counting the number of times a Texture is bound as a sampler or image we will track the Framebuffers that the Texture is bound to. Because FBOs are unique to a Context, a Texture could be bound to two different FBOs with the same ID. In this CL we introduce a new Serial for the FBO which is unique to an EGL Share Group. This way we can ensure we don't make the wrong call when a Texture is referenced by a Framebuffer. It also replaces the old FB serial which was again only unique to a particular Context. Bug: angleproject:4500 Bug: angleproject:4959 Change-Id: I0a9989d861a4132bd3b7ed85f699a4448ff37a4e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2358849 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tobin Ehlis <tobine@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Courtney Goeltzenleuchter 3a3d419d 2020-08-04T09:06:01 Reference count context to fix ASAN issues Running with ASAN there are several use after free issues because a eglDestroyContext destroys the context right away even though it's in use in other thread(s). Adding reference count to context so that it's not destroyed until all users are done using it. Bug: b/162609728 Change-Id: I00b24b53d760e38ff61dd9ce652a49b1f32f0cd2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2336447 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Tobin Ehlis <tobine@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Peng Huang 4cf2501c 2020-07-27T13:19:27 Add extension EGL_ANGLE_display_semaphore_share_group For sharing semaphores globally. Bug: angleproject:4877 Change-Id: I472e0902fd04ca8350d74e6c0ae6925ee930ccf9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2319370 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Kenneth Russell af727792 2020-06-10T21:55:43 Improve EGL_ANGLE_power_preference on dual-GPU MacBook Pros. Add the ability to release and reacquire the high-power GPU, and to respond to changes in the active GPU. In Chromium, the GPU process can not access the WindowServer. An external process must inform ANGLE that the active GPU has changed, and that ANGLE should switch its internal context to the new GPU. Incorporates a couple of functions from WebKit, used with permission, to effect this GPU switch. A follow-on change in Chromium which uses these new APIs will make the existing dual-GPU tests pass with ANGLE and the passthrough command decoder. Carry forward Chromium's workaround of disabling GPU switching on older MacBook Pros to ensure stability. Document the process of adding new EGL extensions to ANGLE. Bug: chromium:1091824 Change-Id: I499739156e851b493555d4d6e4aef87d8b97fa31 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2240638 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 4e6f6545 2020-04-16T16:31:24 GLX: Support X11 pixmaps Add support for creating EGL pixmaps from X11 pixmaps using GLX. Pixmaps are needed for various external APIs such as VAAPI. Add support for EGL_NOK_texture_from_pixmap to allow binding pixmaps to textures. BUG=angleproject:4560 Change-Id: I4a6d3ad7e87151ff5317bbdaaf093ac1b46daf5f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2153805 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 29bb612e 2020-05-28T10:32:26 Add egl::ShareGroup class to abstract the share context group Vulkan backend has a barrier tracker that tracks memory barrier needs of all shared resources. Because the buffer/texture objects are shared resources within a shared group, the tracker can not live in a context. Putting it in a device/renderer requires locks. It fits perfectly in a shareGroup object. The work is already done at API level to handle the mutex lock for shared context access so that no extra lock needs to be taken in the backend. This CL adds egl::ShareGroup class that represents the object that are shared among all share context group. At the front end this usually will include all the shared resource managers (not done in this CL). The ShareGroup object is accessible from gl::State object. This CL also adds ability for backend driver to allocate implementation specific ShareGroupImpl object. Vulkan backend will then use it to keeps the barrier tracker and other things that naturally fits the share group concept. Bug: angleproject:4664 Change-Id: Ifcd975cbdf5130022e21c41397894afc28f572e7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2217252 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Xinyi He 4864413b 2020-02-17T15:34:33 Vulkan: Implement eglWaitNative function Implement eglWaitNative API. It will call XSync() on XCB and do nothing on other systems. Bug: angleproject:4281 Change-Id: I597b75124a380df519ab10af3cab9b6e26f3194f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2059620 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Geoff Lang aa6dd50d 2020-02-03T17:10:58 Share scratch buffers between contexts. The Display now owns scratch buffers and loans them out to contexts while they are current. This allows us to to only allocate one scratch buffer in a single-threaded use case. Tick the scratch buffers every time a new context is made current. Lower the lifetime from 1000 to 64 to ensure that in the worst case, the buffers are cleared after not being used for ~1 second. BUG=chromium:1030835 BUG=angleproject:4363 Change-Id: I83552424e2beac62b9e41152876b04fc84f53692 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2031698 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Brandon Schade 3eaf6294 2019-11-25T18:08:18 Vulkan: Add options to select more device types Add support to set a default device type using existing ANGLE_DEFAULT_PLATFORM environment variable. The valid vulkan options are as follows: vulkan - vulkan with device hardware vulkan-null - vulkan with null device (Mock ICD) swiftshader - vulkan with swiftshader Bug: angleproject:3998 Change-Id: I15f00e8024818fbaf674ca6fcdbcdac5a90cace2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1956140 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jonah Ryan-Davis f9c3eaf4 2019-11-19T15:19:04 Add ability to disable all ANGLE features Chrome has a --disable-gpu-driver-bug-workarounds flag that needs to be able to be forwarded to ANGLE Bug: 1016377 Change-Id: Ied6c8656742e25c32d508b8bfe76a902d82bcf93 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1925249 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Stuart Morgan 9d737966 2019-08-14T12:25:12 Standardize copyright notices to project style For all "ANGLE Project" copyrights, standardize to the format specified by the style guide. Changes: - "Copyright (c)" and "Copyright(c)" changed to just "Copyright". - Removed the second half of date ranges ("Y1Y1-Y2Y2"->"Y1Y1"). - Fixed a small number of files that had no copyright date using the initial commit year from the version control history. - Fixed one instance of copyright being "The ANGLE Project" rather than "The ANGLE Project Authors" These changes are applied both to the copyright of source file, and where applicable to copyright statements that are generated by templates. BUG=angleproject:3811 Change-Id: I973dd65e4ef9deeba232d5be74c768256a0eb2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1754397 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tobin Ehlis a2ec1344 2019-08-13T14:13:35 Add shared mutex to frontend Add shared mutex to frontend API entrypoints that is only enabled when ANGLE is being used with a shared context. Bug: angleproject:2464 Change-Id: I0d918e37d9579dccd013dc88f563bed7de7ee55f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1685712 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill eb1b1646 2019-07-30T17:22:17 Capture/Replay: Fix capture-enabled libs build. Adds a build option to use the capture libraries in the default output location for libGLESv2. With |angle_with_capture_by_default| enabled, libGLESv2 will have capture enabled and the non-capture libGLESv2 is built as libGLESv2_no_capture. Also moves the FrameCapture to be owned by gl::Context. Rearranges the code a bit so that we don't require a separate version of libANGLE for capture. Also implements a read pixels entry point parameter. Bug: angleproject:3611 Change-Id: Ic528e43e4779f794c8b6d0bf35410166dacc81b1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1719064 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Clemen Deng 0c83813f 2019-07-04T11:38:38 Implement core wgl functions - wglSwapBuffers - wglCreateContext - wglMakeCurrent These functions are needed by the OpenGL tutorial for Windows desktop Bug: angleproject:3620 Change-Id: I699af63eca4a2c8aaf2c72278a580322410ac499 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1688499 Commit-Queue: Clemen Deng <clemendeng@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 3fd0b2db 2018-09-20T15:59:54 Implement EGL_ANDROID_get_native_client_buffer. BUG=angleproject:2508 Change-Id: I21e6251cd1341c1f85f1ba16ba08f5876a8ff8de Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1238885 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Clemen Deng b344fbd9 2019-07-05T11:38:02 Adding client param to context constructor so it can support other clients This change will make it possible for context classes to access multiple versions, e.g. GL version and GLES version Bug: angleproject:3661 Change-Id: I77a33d1c3ea3bffe94c64deb272219bbda1725a4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1689023 Commit-Queue: Clemen Deng <clemendeng@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 612b7417 2019-07-05T11:13:30 Capture/Replay: Add frame capture to cpp files. Capture is implemented mostly via code auto-generation. The capture requires a bit of custom logic for each captured pointer parameter. We handle this by using auto-generation to lay out the base template for each GL call and then custom logic that uses ANGLE's internals to know how much data to capture at which point. Client array pointers are captured before each draw call. Currently only GLES capture is supported. We write out cpp files and an optional data file accompanying each cpp. For small data chunks we inline them in the cpp files. For bigger chunks like texture data we pack them into the data file. Mid-execution capture is not yet supported. Configuring the capture is currently only available by modifying the cpp sources. Both of these features will be implemented in the future. Bug: angleproject:3611 Change-Id: If6d5dac2f7bf363129d42ea9198162aef0d3a4ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1671904 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Cody Northrop 7d6923de 2019-07-01T03:22:42 Revert "Vulkan: pipeline cache not populated as blob cache is not set" This reverts commit 134d6eed2a7d1f148a42c78c8e5da3cfc2df288e. Reason for revert: glmark2 is unable to start on Android-Q when using ANGLE as the driver. Original change's description: > Vulkan: pipeline cache not populated as blob cache is not set > > 1. Use vkMergePipelineCaches in eglSetBlobCacheFuncsANDROID as > blob cache callbacks are set after eglInititalize. > 2. Use a more proper way to save the cache data to disk. > > Bug: angleproject:3318 > Change-Id: Ieb5d10ab93e7afb2aab4446b387d7f36c878a686 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1559671 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Jamie Madill <jmadill@chromium.org> TBR=syoussefi@chromium.org,jmadill@chromium.org,fei.yang@arm.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: angleproject:3318 Change-Id: I51e49bf103142e80b2c9028b3af6d3bb58cf6348 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1683820 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Fei Yang 134d6eed 2019-04-09T14:50:23 Vulkan: pipeline cache not populated as blob cache is not set 1. Use vkMergePipelineCaches in eglSetBlobCacheFuncsANDROID as blob cache callbacks are set after eglInititalize. 2. Use a more proper way to save the cache data to disk. Bug: angleproject:3318 Change-Id: Ieb5d10ab93e7afb2aab4446b387d7f36c878a686 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1559671 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jonah Ryan-Davis beb0eb2d 2019-06-14T15:10:33 Clean up workarounds/features to single location. Rename all workarounds structs to features, and move the lists to a shared location in include/platform (to help with documentation, see: https://cs.chromium.org/chromium/src/ui/gl/gl_switches.cc?sq=package:chromium&g=0&l=69) Bug: angleproject:1621 Change-Id: I4069f08131db5e886047a007efb5d7764dfee5f2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1660952 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jonah Ryan-Davis 78a51911 2019-06-12T14:28:14 Clean up and expose frontend features to egl. gl::Workarounds was used to hold frontend features. Change ownership of this struct from Context to Display, so it can be exposed to egl. Also rename to features and clean up for consistency. Bug: angleproject:1621 Change-Id: I82e98e53873abb7a402c93e60f8a662a7263e0d5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1655772 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jonah Ryan-Davis fce1e2d1 2019-06-04T15:02:08 Extend eglGetPlatformDisplay to allow feature overrides. Add EGL_FEATURE_OVERRIDES_ENABLED_ANGLE and EGL_FEATURE_OVERRIDES_DISABLED_ANGLE to submit lists of strings naming the features that should be overridden (either enabled or disabled) on display creation. Bug: angleproject:1621 Change-Id: I4bb75c5dbab0e3b701a72069c38f8c60ecfffad2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1646595 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jonah Ryan-Davis 2dd40a44 2019-05-30T16:40:13 Add eglQueryDisplayAttribANGLE to query workarounds count. Add eglQueryDisplayAttribANGLE based on eglQueryDisplayAttribEXT to add behavior for quering the count of all workarounds available. Used externally to build a list of workarounds. Bug: angleproject:1621 Change-Id: I793acedc76111fd018600169d58bf5d8cf4a63ee Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1637817 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jonah Ryan-Davis f52f2637 2019-05-23T13:52:52 Add EGL_ANGLE_workaround_control extension. This extension is used to query strings from an array based on index, which will be used to query all the information about workarounds in ANGLE. Bug: angleproject:1621 Change-Id: I27157f278f7f17c92c8b4fd7753e2a5ecd0528f6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1627723 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Geoff Lang 82133763 2019-04-02T16:58:37 Vulkan: Add an unMakeCurrent for contexts. This allows contexts to flush and update state when they are no longer going to be current. BUG=angleproject:2464 Change-Id: Ie577475a94090631a0208542b32a12a239bdeb75 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1553824 Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 9049d321 2019-03-27T14:08:44 Vulkan: Pass the current context to egl Sync operations. The EGL_KHR_fence_sync spec says that if a flush is needed before waiting on the sync, it's done on the current context for the current thread. This helps simplify the multithreading design, we don't need to worry about flusing on a context that may no longer exist or is executing on a different thread. It does allow infinite waits because the context with the fence is never flushed but the spec allows this. BUG=angleproject:2464 Change-Id: I8bf2f93c408fee2dae95caa5bb9c76ba67687931 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1542256 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Ian Elliott 4e87659e 2019-03-12T16:23:55 Fix eglChooseConfig for attributes that have exact default values. The implementation of eglChooseConfig does not match the specification for attributes not provided by the calling function. It is supposed to use the default value and match semantics, per the specification. This is fine for many attributes (where the value in the EGLConfig doesn't matter). Currently, this affects the following attributes: - EGL_COLOR_BUFFER_TYPE - EGL_LEVEL - EGL_RENDERABLE_TYPE - EGL_SURFACE_TYPE - EGL_TRANSPARENT_TYPE - EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE - EGL_COLOR_COMPONENT_TYPE_EXT This change causes 55 of 65 of the dEQP-EGL.functional.choose_config.* tests to start passing. Bug: angleproject:3172 Change-Id: I287af5ba7d296694d9a78ded5d1e3bc4e7043d03 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1506696 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Shahbaz Youssefi 5313c8a8 2019-01-14T17:02:52 Implement EGL_KHR_fence_sync and EGL_KHR_wait_sync EGL_KHR_fence_sync introduces the EGLSync object and associated create/destroy/clientWait functions. EGL_KHR_wait_sync adds the serverWait function on top of that. Bug: angleproject:2466 Change-Id: Iebb239a85c4471ea18b3c3a8a83b793af555e31d Reviewed-on: https://chromium-review.googlesource.com/c/1412261 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 85ca1895 2019-01-16T13:27:15 Vulkan: Store reference to context command buffer. This frees us from checking the FB every draw. Slightly reduces time spent in all draw methods. Improvement seen on the draw call overhead tests. Scores went from 28.17 ns/draw to 26.76 ns/draw on my machine. In a future improvement we could make this command buffer a dirty bit. Currently it's a bit slower to call a handler function due to the dispatch table. Likely we could optimize this by reverting back to a dirty bit switch and inlining the handler functions. That is left for future work. Vulkan is happy enough to run multiple RenderPasses and bind different Pipelines in the same command buffer. But ANGLE defers RenderPass init until we submit our work. Thus we can only support one RenderPass per secondary buffer. Test: angle_perftests DrawCall*/vulkan_null Bug: angleproject:3014 Change-Id: I89fd0d9e0822400a5c5a16acb5a9c400a0e71ab5 Reviewed-on: https://chromium-review.googlesource.com/c/1393905 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill ab2bfa81 2019-01-15T19:06:47 Enable Chromium clang style plugin for libANGLE. This fixes a few style warnings: * auto should not deduce to raw pointer type * inlined virtual methods are not allowed * non-trivial constructors and destructors should be explicit * inlined non-trivial constructors should not be in-class * missing override keywords Bug: angleproject:3069 Change-Id: I3b3e55683691da3ebf6da06a5d3c729c71b6ee53 Reviewed-on: https://chromium-review.googlesource.com/c/1407640 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>