src/libANGLE/Thread.cpp


Log

Author Commit Date CI Message
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 b9fd47b8 2022-08-12T10:55:49 Not use Android TLS slot for chromium In the profile, GetGlobalContext() & GetValidGlobalContext() have extra overhead for checking angle::gUseAndroidOpenGLTlsSlot. Since angle::gUseAndroidOpenGLTlsSlot is always false for now, so add a build flag to disable it for chromium build. In the profile, with angle_use_android_tls_slot = false, GetValidGlobalContext() is reduced from 0.153% to 0.044%. Bug: chromium:1336126 Change-Id: Id5e1752b0a03289fb299e8de2ed6e962e35291c0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3827955 Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Peng Huang <penghuang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@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>
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>
Jamie Madill cfe14e28 2020-11-19T18:11:42 EGL: Remove egl::Error from validation code. Instead of using an egl::Error return value, errors are recorded on the egl::Thread immediately at the call site. This makes the code work the same way as in the GL entry points. Updates the EGL "try" macros to include a special handler for the EGL validation entry points. Uses a special ValidationContext helper class to preserve the existing info. Bug: angleproject:5378 Change-Id: I897f221a41fe406676950600e4ac559081b9f541 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2551790 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill cb286073 2020-09-20T21:59:24 Use c++ thread_local for current thread. This solves a race condition using the global context. Sadly we can't use an unprotected variable safely because it can be written/read from multiple threads doing MakeCurrent. Has about a 2 ns regression when tested in Linux/Release per call. "null" benchmark test went from 27 -> 29 ns/iteration. Fixes a TSAN warning that popped up in angle_end2end_tests. Test: DrawCallPerfBenchmark.Run/vulkan_null Test: EGLContextASANTest.DestroyContextInUse/ES3_Vulkan Bug: b/168744561 Change-Id: Ic56f3faae81c1087b942a3cfc0e011b9ab439e0f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2419641 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@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>
Geoff Lang fb6fbdbc 2019-04-12T15:16:30 Return that polling queries have completed after context loss. KHR_robustness says that certain queries that poll such as GetSynciv with SYNC_STATUS should still generate errors after context loss but also return that the result is available. BUG=angleproject:3379 Change-Id: Ibf61f8481bc7c3d1b4fa8979dc404d0ca3952fcd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1566142 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi a254fa28 2019-04-09T14:25:59 Rename getCurrentDisplay to getDisplay There is always only one display that can be associated with a context, so get*Current*Display is confusing. Bug: None Change-Id: Iff3a9fc5ad1154b046bb30d7f46a468802ba7fcc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1558958 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 526392dd 2018-11-16T09:35:14 Use angle::Result in front-end (Part 9) This removes the ANGLE_TRY_HANDLE macro. Also the internal uses of gl::ErrorStreamBase. There are remaining uses in the validation code. Further progress will be blocked on removing egl::Error and the use of gl::Error in the validation layer. Also reduces binary size by up to 4k. Bug: angleproject:2491 Change-Id: I3e0481f99738f9f24256c10e73f3efcce9826a35 Reviewed-on: https://chromium-review.googlesource.com/c/1334427 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Geoff Lang 75359664 2018-04-11T01:42:27 Implement EGL_KHR_debug. BUG=angleproject:1618 Change-Id: I790944b49badc910b6c72266469fcb8e86ac4252 Reviewed-on: https://chromium-review.googlesource.com/1019387 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 61e16b44 2017-06-19T11:13:23 Context: Bind current display/surface. Looking at the EGL spec, it says for eglGetCurrentDisplay: "The display for the current context in the calling thread, for the current rendering API, is returned." This implies that MakeCurrent binds a display to a Context. There's also pretty clear language for the read/draw Surface as well, that they can only be bound to one Context/thread at a time. Hence we don't need to duplicate this storage in the egl::Thread structure, merely storing a pointer to the current Context, which has access to the read/draw Surface and current Display. BUG=angleproject:1156 Change-Id: Ia3b99d50b3591012c43e851834c1af02ff62a33f Reviewed-on: https://chromium-review.googlesource.com/538865 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Yuly Novikov c4d18aac 2017-03-09T18:45:02 Use ErrorStream everywhere Eliminates one more usage of FormatString and its static initializer. Add more ErrorStream types and replace gl::Error and egl::Error with them. BUG=angleproject:1644 Change-Id: Ib498d0ae4b81a332ec71aed7cf709993b154e6bb Reviewed-on: https://chromium-review.googlesource.com/505429 Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Geoff Lang 7b8f3c9b 2016-11-10T10:42:48 Encapsulate the thread local storage into an egl::Thread class. Instead of having separate GetGlobal* functions, interact with the global objects through a single Thread object. This reduces the number of TLS lookups in many EGL functions and allows the Thread object to be passed down to other objects if needed. BUG=angleproject:1618 Change-Id: I1f9a89e8899d637633f4e91fda0e38ac308dd020 Reviewed-on: https://chromium-review.googlesource.com/409637 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>