diff options
author | android-autoroll <android-autoroll@skia-public.iam.gserviceaccount.com> | 2024-05-07 08:29:18 +0000 |
---|---|---|
committer | android-autoroll <android-autoroll@skia-public.iam.gserviceaccount.com> | 2024-05-07 08:29:18 +0000 |
commit | 4da052199c0fecaf7582f90bad826a056d741372 (patch) | |
tree | f09e2e3ad304fcedc595f46dc9dd8cd0462b7672 | |
parent | 8551af9e6633688d0e8c94640454a0cbc1975850 (diff) | |
parent | da1fbbc6497d299d488beba33fc56d068ab01c45 (diff) | |
download | angle-4da052199c0fecaf7582f90bad826a056d741372.tar.gz |
Roll ANGLE from a951e0e08234 to da1fbbc6497d (4 revisions)
https://chromium.googlesource.com/angle/angle.git/+log/a951e0e08234..da1fbbc6497d
Please enable autosubmit on changes if possible when approving them.
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/angle-android-autoroll
Please CC abdolrashidi@google.com,angle-team@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.
To file a bug in ANGLE: https://bugs.chromium.org/p/angleproject/issues/entry
To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622
Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Test: Presubmit checks will test this change.
Exempt-From-Owner-Approval: The autoroll bot does not require owner approval.
Bug: b/331680143
Bug: b/333235176
Change-Id: Ibb4dad491e51f0e5c24d8c95403a52a9775bfe9b
62 files changed, 309 insertions, 229 deletions
diff --git a/Android.bp b/Android.bp index b2d6346abd..ccfd063435 100644 --- a/Android.bp +++ b/Android.bp @@ -49,6 +49,7 @@ cc_defaults { cflags: [ "-O2", "-Wno-unknown-warning-option", + "-fno-stack-protector", "-fno-unwind-tables", ], } @@ -452,8 +452,14 @@ config("angle_common_config") { "src/common/base", "src/common/third_party/xxhash", ] + libs = [] if (is_android) { - libs = [ "log" ] + libs += [ "log" ] + } + + if (is_win && !angle_is_winuwp && !build_with_chromium) { + # Needed for futex support + libs += [ "synchronization.lib" ] } defines = [] @@ -1098,11 +1104,6 @@ angle_source_set("libANGLE_no_vulkan") { "gdi32.lib", "user32.lib", ] - - if (!build_with_chromium) { - # Needed for futex support - libs += [ "synchronization.lib" ] - } } if (angle_enable_d3d11) { @@ -43,7 +43,7 @@ vars = { 'checkout_angle_mesa': False, # Version of Chromium our Chromium-based DEPS are mirrored from. - 'chromium_revision': '4beb6b144a74446ea0a065efb2ee1e0abb334ea7', + 'chromium_revision': '7a22cfe5a3e75f89c6ac0c0ffeb694e739635d36', # We never want to checkout chromium, # but need a dummy DEPS entry for the autoroller 'dummy_checkout_chromium': False, @@ -133,7 +133,7 @@ vars = { 'reclient_version': 're_client_version:0.138.0.e854224-gomaip', # siso CIPD package version. - 'siso_version': 'git_revision:70d9e16bcc9dff0264905018f5a5652b37ed0e10', + 'siso_version': 'git_revision:4524544994f4eac131378143f498ee4d0b7d1f36', # 'magic' text to tell depot_tools that git submodules should be accepted but # but parity with DEPS file is expected. @@ -415,7 +415,7 @@ vars = { deps = { 'build': { - 'url': Var('chromium_git') + '/chromium/src/build.git@beb031dae28225164206945c568b5d9b44132491', + 'url': Var('chromium_git') + '/chromium/src/build.git@39e82ca2f8e9005de3a4152832a2bcb893eff416', 'condition': 'not build_with_chromium', }, @@ -474,7 +474,7 @@ deps = { }, 'testing': { - 'url': '{chromium_git}/chromium/src/testing@3cdb58b6840ac9982978b4523cac967cf7084274', + 'url': '{chromium_git}/chromium/src/testing@de4f9bcc5766f6dbeb69752cbd939cf9fec3d143', 'condition': 'not build_with_chromium', }, @@ -656,7 +656,7 @@ deps = { }, 'third_party/depot_tools': { - 'url': Var('chromium_git') + '/chromium/tools/depot_tools.git@a60f90e38e53738d3cf115cf0a6c75a0dfef0438', + 'url': Var('chromium_git') + '/chromium/tools/depot_tools.git@4d9ad255f1ad7793ad1ed911d92cc8f5b387f492', 'condition': 'not build_with_chromium', }, @@ -780,7 +780,7 @@ deps = { }, 'third_party/libc++abi/src': { - 'url': Var('chromium_git') + '/external/github.com/llvm/llvm-project/libcxxabi.git@09737b8e11281840ff019de74a9e576611167ed5', + 'url': Var('chromium_git') + '/external/github.com/llvm/llvm-project/libcxxabi.git@d17298ab09b44bbc95e5e59c0f285145d0e5f8a7', 'condition': 'not build_with_chromium', }, @@ -872,7 +872,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'NvYmFgaDR5pSbEH88fOJRqBbLZT5maGLr_7_iZD3vg4C', + 'version': 'a2gKt0z-OOG5sntIiNXVd6LFDWUuvR-rstsrF59EEnIC', }, ], 'condition': 'checkout_android and not build_with_chromium', @@ -964,7 +964,7 @@ deps = { }, 'tools/clang': { - 'url': Var('chromium_git') + '/chromium/src/tools/clang.git@9e76abab9ce51aaec9e87d3796a13bc98445ded8', + 'url': Var('chromium_git') + '/chromium/src/tools/clang.git@14ba9b58df1e77f4802c199971c48e36f3c6bff0', 'condition': 'not build_with_chromium', }, diff --git a/build/android/gyp/gcc_preprocess.py b/build/android/gyp/gcc_preprocess.py index b43a55df47..e859e1e9df 100755 --- a/build/android/gyp/gcc_preprocess.py +++ b/build/android/gyp/gcc_preprocess.py @@ -21,7 +21,7 @@ _LLVM_CLANG_PATH = os.path.join(_CHROMIUM_SRC, 'third_party', 'llvm-build', 'Release+Asserts', 'bin', 'clang') def _ParsePackageName(data): - m = re.match(r'^\s*package\s+(.*?)\s*;', data, re.MULTILINE) + m = re.search(r'^\s*package\s+(.*?)\s*;', data, re.MULTILINE) return m.group(1) if m else '' @@ -29,6 +29,7 @@ def ProcessJavaFile(template, defines, include_dirs): clang_cmd = [ _LLVM_CLANG_PATH, '-E', # stop after preprocessing. + '-CC', # Keep comments '-DANDROID', # Specify ANDROID define for pre-processor. '-x', 'c-header', # treat sources as C header files diff --git a/build/android/gyp/gcc_preprocess_tests.py b/build/android/gyp/gcc_preprocess_tests.py index 3699575e02..6cf4c4b825 100755 --- a/build/android/gyp/gcc_preprocess_tests.py +++ b/build/android/gyp/gcc_preprocess_tests.py @@ -106,6 +106,46 @@ public class Sample { } """.strip(), data.strip()) + def testPreserveComments(self): + with tempfile.NamedTemporaryFile(mode='w') as f: + template = f.name + f.file.write(""" +// Copyright header ... +package org.chromium.fake; +/** + * Some javadoc. + */ +public class Sample { + // This is a comment outside the #if block. +#if defined(_ENABLE_ASSERTS) + // Inside the #if block. + public boolean ENABLE_ASSERTS = true; +#else + // Inside the #else block. + public boolean ENABLE_ASSERTS = false; +#endif +} +""") + f.file.flush() + defines = [ + '_ENABLE_ASSERTS', + ] + package_name, data = gcc_preprocess.ProcessJavaFile(template, defines, []) + self.assertEqual('org.chromium.fake', package_name) + self.assertEqual( + """ +// Copyright header ... +package org.chromium.fake; +/** + * Some javadoc. + */ +public class Sample { + // This is a comment outside the #if block. + // Inside the #if block. + public boolean ENABLE_ASSERTS = true; +} +""".strip(), data.strip()) + if __name__ == '__main__': unittest.main() diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni index c70f131263..39d25e036c 100644 --- a/build/config/ios/rules.gni +++ b/build/config/ios/rules.gni @@ -1390,9 +1390,11 @@ template("ios_framework_bundle") { # less error prone that having the developer duplicate the list of all # headers in addition to "sources". sources = [] - foreach(_source, invoker.sources) { - if (get_path_info(_source, "extension") == "h") { - sources += [ _source ] + if (defined(invoker.sources)) { + foreach(_source, invoker.sources) { + if (get_path_info(_source, "extension") == "h") { + sources += [ _source ] + } } } diff --git a/build/config/unsafe_buffers_paths.txt b/build/config/unsafe_buffers_paths.txt index 0c576c7e62..120f0847d8 100644 --- a/build/config/unsafe_buffers_paths.txt +++ b/build/config/unsafe_buffers_paths.txt @@ -65,6 +65,7 @@ -clank/ -codelabs/ -components/ ++components/discardable_memory -content/ -courgette/ -crypto/ diff --git a/build/util/LASTCHANGE b/build/util/LASTCHANGE index 818fb55172..3e1b4c209f 100644 --- a/build/util/LASTCHANGE +++ b/build/util/LASTCHANGE @@ -1,2 +1,2 @@ -LASTCHANGE=beb031dae28225164206945c568b5d9b44132491-refs/heads/main@{#1296356} +LASTCHANGE=39e82ca2f8e9005de3a4152832a2bcb893eff416-refs/heads/main@{#1297146} LASTCHANGE_YEAR=2024 diff --git a/build/util/LASTCHANGE.committime b/build/util/LASTCHANGE.committime index 5adb3d5466..2a6717b2e1 100644 --- a/build/util/LASTCHANGE.committime +++ b/build/util/LASTCHANGE.committime @@ -1 +1 @@ -1714773552
\ No newline at end of file +1715033649
\ No newline at end of file diff --git a/infra/specs/angle.json b/infra/specs/angle.json index 2d2cbff576..d599aee141 100644 --- a/infra/specs/angle.json +++ b/infra/specs/angle.json @@ -1208,7 +1208,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1233,7 +1233,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1259,7 +1259,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1285,7 +1285,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1311,7 +1311,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1336,7 +1336,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1361,7 +1361,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1387,7 +1387,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1412,7 +1412,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1438,7 +1438,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1463,7 +1463,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1492,7 +1492,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1520,7 +1520,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1548,7 +1548,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1576,7 +1576,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1605,7 +1605,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1634,7 +1634,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1662,7 +1662,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1690,7 +1690,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1718,7 +1718,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1746,7 +1746,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1772,7 +1772,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1800,7 +1800,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1823,7 +1823,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1848,7 +1848,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1875,7 +1875,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1909,7 +1909,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1940,7 +1940,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -1970,7 +1970,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -2000,7 +2000,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -2030,7 +2030,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -2060,7 +2060,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", @@ -2090,7 +2090,7 @@ "swarming": { "containment_type": "AUTO", "dimensions": { - "device_os": "R", + "device_os": "RP1A.201105.002", "device_os_type": "userdebug", "device_type": "flame", "os": "Android", diff --git a/infra/specs/generate_test_spec_json.py b/infra/specs/generate_test_spec_json.py index 31e9a9868c..e15a82447d 100755 --- a/infra/specs/generate_test_spec_json.py +++ b/infra/specs/generate_test_spec_json.py @@ -53,6 +53,39 @@ ADDITIONAL_MIXINS = { } } }, + 'angle_pixel_4_stable': { + 'swarming': { + 'dimensions': { + "os": "Android", + "device_type": "flame", + "device_os": "RP1A.201105.002", + "device_os_type": "userdebug", + "pool": "chromium.tests.gpu", + } + } + }, + 'angle_pixel_6_stable': { + 'swarming': { + 'dimensions': { + "os": "Android", + "device_type": "oriole", + "device_os": "TP1A.220624.021", + "device_os_type": "userdebug", + "pool": "chromium.tests.gpu", + } + } + }, + 'angle_pixel_6_experimental': { + 'swarming': { + 'dimensions': { + "os": "Android", + "device_type": "oriole", + "device_os": "AP1A.240405.002", + "device_os_type": "userdebug", + "pool": "chromium.tests.gpu", + } + } + }, 'timeout_120m': { 'swarming': { 'hard_timeout': 7200, diff --git a/infra/specs/mixins.pyl b/infra/specs/mixins.pyl index 5d1b22e1a2..44822f4cf8 100644 --- a/infra/specs/mixins.pyl +++ b/infra/specs/mixins.pyl @@ -13,17 +13,27 @@ # # For more info see Chromium's mixins.pyl in testing/buildbot. -{ 'android_r': {'swarming': {'dimensions': {'device_os': 'R'}}}, - 'android_t': {'swarming': {'dimensions': {'device_os': 'TP1A.220624.021'}}}, - 'android_u': {'swarming': {'dimensions': {'device_os': 'AP1A.240405.002'}}}, +{ 'angle_pixel_4_stable': { 'swarming': { 'dimensions': { 'device_os': 'RP1A.201105.002', + 'device_os_type': 'userdebug', + 'device_type': 'flame', + 'os': 'Android', + 'pool': 'chromium.tests.gpu'}}}, + 'angle_pixel_6_experimental': { 'swarming': { 'dimensions': { 'device_os': 'AP1A.240405.002', + 'device_os_type': 'userdebug', + 'device_type': 'oriole', + 'os': 'Android', + 'pool': 'chromium.tests.gpu'}}}, + 'angle_pixel_6_stable': { 'swarming': { 'dimensions': { 'device_os': 'TP1A.220624.021', + 'device_os_type': 'userdebug', + 'device_type': 'oriole', + 'os': 'Android', + 'pool': 'chromium.tests.gpu'}}}, 'angle_skia_gold_test': { 'args': ['--git-revision=${got_angle_revision}'], 'precommit_args': [ '--gerrit-issue=${patch_issue}', '--gerrit-patchset=${patch_set}', '--buildbucket-id=${buildbucket_build_id}', '--use-permissive-pixel-comparison=${use_permissive_angle_pixel_comparison}']}, 'chromium-tester-service-account': { 'swarming': { 'service_account': 'chromium-tester@chops-service-accounts.iam.gserviceaccount.com'}}, - 'flame': { 'swarming': { 'dimensions': { 'device_type': 'flame', - 'os': 'Android'}}}, 'gpu-swarming-pool': { 'swarming': { 'dimensions': { 'pool': 'chromium.tests.gpu'}}}, 'limited_capacity_bot': {'swarming': {'expiration': 21600}}, 'linux-jammy': {'swarming': {'dimensions': {'os': 'Ubuntu-22.04'}}}, @@ -74,8 +84,6 @@ 'os': 'Mac-11.7.9', 'pool': 'chromium.tests.gpu'}}}, 'no_gpu': {'swarming': {'dimensions': {'gpu': 'none'}}}, - 'oriole': { 'swarming': { 'dimensions': { 'device_type': 'oriole', - 'os': 'Android'}}}, 'samsung_s22': { 'swarming': { 'dimensions': { 'device_os': 'UP1A.231005.007', 'device_os_type': 'user', 'device_type': 's5e9925', diff --git a/infra/specs/waterfalls.pyl b/infra/specs/waterfalls.pyl index da96a99bac..8e51e68266 100644 --- a/infra/specs/waterfalls.pyl +++ b/infra/specs/waterfalls.pyl @@ -22,9 +22,7 @@ 'android-arm64-exp-pixel6': { # android-arm64-pixel6 below for android-arm64-test 'os_type': 'android', 'mixins': [ - 'android_u', - 'oriole', - 'gpu-swarming-pool', + 'angle_pixel_6_experimental', 'limited_capacity_bot', ], 'test_suites': { @@ -46,9 +44,7 @@ 'android-arm64-pixel4': { 'os_type': 'android', 'mixins': [ - 'android_r', - 'flame', - 'gpu-swarming-pool', + 'angle_pixel_4_stable', ], 'test_suites': { 'gtest_tests': 'android_gtests', @@ -58,9 +54,7 @@ 'android-arm64-pixel4-perf': { 'os_type': 'android', 'mixins': [ - 'android_r', - 'flame', - 'gpu-swarming-pool', + 'angle_pixel_4_stable', 'timeout_120m', ], 'test_suites': { @@ -70,9 +64,7 @@ 'android-arm64-pixel6': { 'os_type': 'android', 'mixins': [ - 'android_t', - 'oriole', - 'gpu-swarming-pool', + 'angle_pixel_6_stable', ], 'test_suites': { 'gtest_tests': 'android_vulkan_gtests', @@ -82,9 +74,7 @@ 'android-arm64-pixel6-perf': { 'os_type': 'android', 'mixins': [ - 'android_t', - 'oriole', - 'gpu-swarming-pool', + 'angle_pixel_6_stable', 'timeout_120m', ], 'test_suites': { diff --git a/scripts/generate_android_bp.py b/scripts/generate_android_bp.py index c967ecb73f..bd17c15178 100644 --- a/scripts/generate_android_bp.py +++ b/scripts/generate_android_bp.py @@ -639,6 +639,8 @@ def main(): '-O2', # Override AOSP build flags to match ANGLE's CQ testing and reduce binary size '-fno-unwind-tables', + # Disable stack protector to reduce cpu overhead. + '-fno-stack-protector', ], })) diff --git a/src/common/RingBufferAllocator.cpp b/src/common/RingBufferAllocator.cpp index da16886593..1d05626b6f 100644 --- a/src/common/RingBufferAllocator.cpp +++ b/src/common/RingBufferAllocator.cpp @@ -294,7 +294,7 @@ void SharedRingBufferAllocatorCheckPoint::releaseAndUpdate(RingBufferAllocatorCh // Must always remain 1 ref #endif { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); mValue = *newValue; } newValue->reset(); @@ -302,7 +302,7 @@ void SharedRingBufferAllocatorCheckPoint::releaseAndUpdate(RingBufferAllocatorCh RingBufferAllocatorCheckPoint SharedRingBufferAllocatorCheckPoint::pop() { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); RingBufferAllocatorCheckPoint value = mValue; mValue.reset(); return value; diff --git a/src/common/RingBufferAllocator.h b/src/common/RingBufferAllocator.h index e53806f153..c717a1a9a1 100644 --- a/src/common/RingBufferAllocator.h +++ b/src/common/RingBufferAllocator.h @@ -11,6 +11,7 @@ #define COMMON_RING_BUFFER_ALLOCATOR_H_ #include "angleutils.h" +#include "common/SimpleMutex.h" #include "common/debug.h" #include <atomic> @@ -142,7 +143,7 @@ class SharedRingBufferAllocatorCheckPoint final : angle::NonCopyable private: friend class SharedRingBufferAllocator; RingBufferAllocatorCheckPoint pop(); - std::mutex mMutex; + angle::SimpleMutex mMutex; RingBufferAllocatorCheckPoint mValue; #if defined(ANGLE_ENABLE_ASSERTS) diff --git a/src/common/angleutils.h b/src/common/angleutils.h index b88a7f7072..3108387f13 100644 --- a/src/common/angleutils.h +++ b/src/common/angleutils.h @@ -375,32 +375,6 @@ inline bool IsLittleEndian() return isLittleEndian; } -// Helper class to use a mutex with the control of boolean. -class ConditionalMutex final : angle::NonCopyable -{ - public: - ConditionalMutex() : mUseMutex(true) {} - void init(bool useMutex) { mUseMutex = useMutex; } - void lock() - { - if (mUseMutex) - { - mMutex.lock(); - } - } - void unlock() - { - if (mUseMutex) - { - mMutex.unlock(); - } - } - - private: - std::mutex mMutex; - bool mUseMutex; -}; - // Helper macro that casts to a bitfield type then verifies no bits were dropped. #define SetBitField(lhs, rhs) \ do \ diff --git a/src/common/debug.cpp b/src/common/debug.cpp index f56475b1b0..634eea878d 100644 --- a/src/common/debug.cpp +++ b/src/common/debug.cpp @@ -31,6 +31,7 @@ #include "anglebase/no_destructor.h" #include "common/Optional.h" +#include "common/SimpleMutex.h" #include "common/angleutils.h" #include "common/entry_points_enum_autogen.h" #include "common/system_utils.h" @@ -43,7 +44,7 @@ namespace DebugAnnotator *g_debugAnnotator = nullptr; -std::mutex *g_debugMutex = nullptr; +angle::SimpleMutex *g_debugMutex = nullptr; constexpr std::array<const char *, LOG_NUM_SEVERITIES> g_logSeverityNames = { {"EVENT", "INFO", "WARN", "ERR", "FATAL"}}; @@ -123,11 +124,11 @@ void InitializeDebugMutexIfNeeded() { if (g_debugMutex == nullptr) { - g_debugMutex = new std::mutex(); + g_debugMutex = new angle::SimpleMutex(); } } -std::mutex &GetDebugMutex() +angle::SimpleMutex &GetDebugMutex() { ASSERT(g_debugMutex); return *g_debugMutex; @@ -181,10 +182,10 @@ LogMessage::LogMessage(const char *file, const char *function, int line, LogSeve LogMessage::~LogMessage() { { - std::unique_lock<std::mutex> lock; + std::unique_lock<angle::SimpleMutex> lock; if (g_debugMutex != nullptr) { - lock = std::unique_lock<std::mutex>(*g_debugMutex); + lock = std::unique_lock<angle::SimpleMutex>(*g_debugMutex); } if (DebugAnnotationsInitialized() && (mSeverity > LOG_INFO)) diff --git a/src/common/debug.h b/src/common/debug.h index 5c37c8ca57..48a1979e5e 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -19,6 +19,7 @@ #include <sstream> #include <string> +#include "common/SimpleMutex.h" #include "common/angleutils.h" #include "common/entry_points_enum_autogen.h" #include "common/log_utils.h" @@ -83,7 +84,7 @@ bool DebugAnnotationsInitialized(); void InitializeDebugMutexIfNeeded(); -std::mutex &GetDebugMutex(); +angle::SimpleMutex &GetDebugMutex(); } // namespace gl // The state tracked by ANGLE will be validated with the driver state before each call diff --git a/src/image_util/AstcDecompressor.cpp b/src/image_util/AstcDecompressor.cpp index 644a398296..b32affd6dd 100644 --- a/src/image_util/AstcDecompressor.cpp +++ b/src/image_util/AstcDecompressor.cpp @@ -11,6 +11,7 @@ #include <unordered_map> #include "astcenc.h" +#include "common/SimpleMutex.h" #include "common/WorkerThread.h" #include "image_util/AstcDecompressor.h" @@ -243,7 +244,7 @@ class AstcDecompressorImpl : public AstcDecompressor private: std::unique_ptr<AstcDecompressorContextCache> mContextCache; - std::mutex mMutex; // Locked while calling `decode()` + angle::SimpleMutex mMutex; // Locked while calling `decode()` std::vector<std::shared_ptr<DecompressTask>> mTasks; std::vector<std::shared_ptr<WaitableEvent>> mWaitEvents; }; diff --git a/src/libANGLE/BlobCache.cpp b/src/libANGLE/BlobCache.cpp index 766a0d4446..ef20646e3f 100644 --- a/src/libANGLE/BlobCache.cpp +++ b/src/libANGLE/BlobCache.cpp @@ -26,7 +26,7 @@ void BlobCache::put(const BlobCache::Key &key, angle::MemoryBuffer &&value) { if (areBlobCacheFuncsSet()) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); // Store the result in the application's cache mSetBlobFunc(key.data(), key.size(), value.data(), value.size()); } @@ -55,14 +55,14 @@ void BlobCache::putApplication(const BlobCache::Key &key, const angle::MemoryBuf { if (areBlobCacheFuncsSet()) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); mSetBlobFunc(key.data(), key.size(), value.data(), value.size()); } } void BlobCache::populate(const BlobCache::Key &key, angle::MemoryBuffer &&value, CacheSource source) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); CacheEntry newEntry; newEntry.first = std::move(value); newEntry.second = source; @@ -78,7 +78,7 @@ bool BlobCache::get(angle::ScratchBuffer *scratchBuffer, // Look into the application's cache, if there is such a cache if (areBlobCacheFuncsSet()) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); EGLsizeiANDROID valueSize = mGetBlobFunc(key.data(), key.size(), nullptr, 0); if (valueSize <= 0) { @@ -111,7 +111,7 @@ bool BlobCache::get(angle::ScratchBuffer *scratchBuffer, return true; } - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); // Otherwise we are doing caching internally, so try to find it there const CacheEntry *entry; bool result = mBlobCache.get(key, &entry); @@ -126,7 +126,7 @@ bool BlobCache::get(angle::ScratchBuffer *scratchBuffer, bool BlobCache::getAt(size_t index, const BlobCache::Key **keyOut, BlobCache::Value *valueOut) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); const CacheEntry *valueBuf; bool result = mBlobCache.getAt(index, keyOut, &valueBuf); if (result) @@ -153,7 +153,7 @@ BlobCache::GetAndDecompressResult BlobCache::getAndDecompress( { // This needs to be locked because `DecompressBlob` is reading shared memory from // `compressedValue.data()`. - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); if (!angle::DecompressBlob(compressedValue.data(), compressedValue.size(), maxUncompressedDataSize, uncompressedValueOut)) { @@ -166,20 +166,20 @@ BlobCache::GetAndDecompressResult BlobCache::getAndDecompress( void BlobCache::remove(const BlobCache::Key &key) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); mBlobCache.eraseByKey(key); } void BlobCache::setBlobCacheFuncs(EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); mSetBlobFunc = set; mGetBlobFunc = get; } bool BlobCache::areBlobCacheFuncsSet() const { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); // Either none or both of the callbacks should be set. ASSERT((mSetBlobFunc != nullptr) == (mGetBlobFunc != nullptr)); diff --git a/src/libANGLE/BlobCache.h b/src/libANGLE/BlobCache.h index 4f5ed91920..ce77e8d0c3 100644 --- a/src/libANGLE/BlobCache.h +++ b/src/libANGLE/BlobCache.h @@ -13,6 +13,7 @@ #include <array> #include <cstring> +#include "common/SimpleMutex.h" #include "libANGLE/Error.h" #include "libANGLE/SizedMRUCache.h" #include "libANGLE/angletypes.h" @@ -126,13 +127,13 @@ class BlobCache final : angle::NonCopyable bool isCachingEnabled() const { return areBlobCacheFuncsSet() || maxSize() > 0; } - std::mutex &getMutex() { return mBlobCacheMutex; } + angle::SimpleMutex &getMutex() { return mBlobCacheMutex; } private: // This internal cache is used only if the application is not providing caching callbacks using CacheEntry = std::pair<angle::MemoryBuffer, CacheSource>; - mutable std::mutex mBlobCacheMutex; + mutable angle::SimpleMutex mBlobCacheMutex; angle::SizedMRUCache<BlobCache::Key, CacheEntry> mBlobCache; EGLSetBlobFuncANDROID mSetBlobFunc; diff --git a/src/libANGLE/Compiler.cpp b/src/libANGLE/Compiler.cpp index 73275347ef..d008594bb5 100644 --- a/src/libANGLE/Compiler.cpp +++ b/src/libANGLE/Compiler.cpp @@ -37,7 +37,7 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const State &state, egl::Disp state.getClientMajorVersion() == 3 || state.getClientMajorVersion() == 4); { - std::lock_guard<std::mutex> lock(display->getDisplayGlobalMutex()); + std::lock_guard<angle::SimpleMutex> lock(display->getDisplayGlobalMutex()); if (gActiveCompilers == 0) { sh::Initialize(); @@ -277,7 +277,7 @@ Compiler::~Compiler() = default; void Compiler::onDestroy(const Context *context) { - std::lock_guard<std::mutex> lock(context->getDisplay()->getDisplayGlobalMutex()); + std::lock_guard<angle::SimpleMutex> lock(context->getDisplay()->getDisplayGlobalMutex()); for (auto &pool : mPools) { for (ShCompilerInstance &instance : pool) diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp index 0bff8b8d71..1b23bd94a8 100644 --- a/src/libANGLE/Context.cpp +++ b/src/libANGLE/Context.cpp @@ -9626,7 +9626,7 @@ egl::Error Context::releaseExternalContext() return egl::NoError(); } -std::mutex &Context::getProgramCacheMutex() const +angle::SimpleMutex &Context::getProgramCacheMutex() const { return mDisplay->getProgramCacheMutex(); } diff --git a/src/libANGLE/Context.h b/src/libANGLE/Context.h index 49dc8c5006..efec3e0d19 100644 --- a/src/libANGLE/Context.h +++ b/src/libANGLE/Context.h @@ -18,6 +18,7 @@ #include "angle_gl.h" #include "common/MemoryBuffer.h" #include "common/PackedEnums.h" +#include "common/SimpleMutex.h" #include "common/angleutils.h" #include "libANGLE/Caps.h" #include "libANGLE/Constants.h" @@ -654,7 +655,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl MemoryProgramCache *getMemoryProgramCache() const { return mMemoryProgramCache; } MemoryShaderCache *getMemoryShaderCache() const { return mMemoryShaderCache; } - std::mutex &getProgramCacheMutex() const; + angle::SimpleMutex &getProgramCacheMutex() const; bool hasBeenCurrent() const { return mHasBeenCurrent; } egl::Display *getDisplay() const { return mDisplay; } diff --git a/src/libANGLE/Debug.cpp b/src/libANGLE/Debug.cpp index 24d3c58b54..61427eb23d 100644 --- a/src/libANGLE/Debug.cpp +++ b/src/libANGLE/Debug.cpp @@ -211,7 +211,7 @@ void Debug::insertMessage(GLenum source, } else { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); if (mMessages.size() >= mMaxLoggedMessages) { @@ -239,7 +239,7 @@ size_t Debug::getMessages(GLuint count, GLsizei *lengths, GLchar *messageLog) { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); size_t messageCount = 0; size_t messageStringIndex = 0; @@ -297,13 +297,13 @@ size_t Debug::getMessages(GLuint count, size_t Debug::getNextMessageLength() const { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); return mMessages.empty() ? 0 : mMessages.front().message.length() + 1; } size_t Debug::getMessageCount() const { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); return mMessages.size(); } diff --git a/src/libANGLE/Debug.h b/src/libANGLE/Debug.h index 0c48488b9d..ad308b471a 100644 --- a/src/libANGLE/Debug.h +++ b/src/libANGLE/Debug.h @@ -11,6 +11,7 @@ #include "angle_gl.h" #include "common/PackedEnums.h" +#include "common/SimpleMutex.h" #include "common/angleutils.h" #include "libANGLE/AttributeMap.h" #include "libANGLE/Error.h" @@ -129,7 +130,7 @@ class Debug : angle::NonCopyable }; bool mOutputEnabled; - mutable std::mutex mMutex; + mutable angle::SimpleMutex mMutex; GLDEBUGPROCKHR mCallbackFunction; const void *mCallbackUserParam; mutable std::deque<Message> mMessages; diff --git a/src/libANGLE/Display.cpp b/src/libANGLE/Display.cpp index 176536a43d..d81a60aafc 100644 --- a/src/libANGLE/Display.cpp +++ b/src/libANGLE/Display.cpp @@ -1754,7 +1754,7 @@ Error Display::makeCurrent(Thread *thread, // Tick all the scratch buffers to make sure they get cleaned up eventually if they stop being // used. { - std::lock_guard<std::mutex> lock(mScratchBufferMutex); + std::lock_guard<angle::SimpleMutex> lock(mScratchBufferMutex); for (angle::ScratchBuffer &scatchBuffer : mScratchBuffers) { @@ -2591,7 +2591,7 @@ void Display::returnZeroFilledBuffer(angle::ScratchBuffer zeroFilledBuffer) angle::ScratchBuffer Display::requestScratchBufferImpl( std::vector<angle::ScratchBuffer> *bufferVector) { - std::lock_guard<std::mutex> lock(mScratchBufferMutex); + std::lock_guard<angle::SimpleMutex> lock(mScratchBufferMutex); if (!bufferVector->empty()) { angle::ScratchBuffer buffer = std::move(bufferVector->back()); @@ -2605,7 +2605,7 @@ angle::ScratchBuffer Display::requestScratchBufferImpl( void Display::returnScratchBufferImpl(angle::ScratchBuffer scratchBuffer, std::vector<angle::ScratchBuffer> *bufferVector) { - std::lock_guard<std::mutex> lock(mScratchBufferMutex); + std::lock_guard<angle::SimpleMutex> lock(mScratchBufferMutex); bufferVector->push_back(std::move(scratchBuffer)); } diff --git a/src/libANGLE/Display.h b/src/libANGLE/Display.h index 8ec253beb9..f69e15f0cb 100644 --- a/src/libANGLE/Display.h +++ b/src/libANGLE/Display.h @@ -14,6 +14,7 @@ #include <mutex> #include <vector> +#include "common/SimpleMutex.h" #include "common/WorkerThread.h" #include "libANGLE/AttributeMap.h" #include "libANGLE/BlobCache.h" @@ -281,8 +282,8 @@ class Display final : public LabeledObject, egl::Error waitUntilWorkScheduled(); - std::mutex &getDisplayGlobalMutex() { return mDisplayGlobalMutex; } - std::mutex &getProgramCacheMutex() { return mProgramCacheMutex; } + angle::SimpleMutex &getDisplayGlobalMutex() { return mDisplayGlobalMutex; } + angle::SimpleMutex &getProgramCacheMutex() { return mProgramCacheMutex; } gl::MemoryShaderCache *getMemoryShaderCache() { return &mMemoryShaderCache; } @@ -417,12 +418,12 @@ class Display final : public LabeledObject, angle::FeatureList mFeatures; - std::mutex mScratchBufferMutex; + angle::SimpleMutex mScratchBufferMutex; std::vector<angle::ScratchBuffer> mScratchBuffers; std::vector<angle::ScratchBuffer> mZeroFilledBuffers; - std::mutex mDisplayGlobalMutex; - std::mutex mProgramCacheMutex; + angle::SimpleMutex mDisplayGlobalMutex; + angle::SimpleMutex mProgramCacheMutex; bool mTerminatedByApi; }; diff --git a/src/libANGLE/Image.h b/src/libANGLE/Image.h index 8aa7fe694c..3921ca12f2 100644 --- a/src/libANGLE/Image.h +++ b/src/libANGLE/Image.h @@ -10,6 +10,7 @@ #define LIBANGLE_IMAGE_H_ #include "common/FastVector.h" +#include "common/SimpleMutex.h" #include "common/angleutils.h" #include "libANGLE/AttributeMap.h" #include "libANGLE/Debug.h" @@ -154,7 +155,7 @@ struct ImageState : private angle::NonCopyable EGLenum colorspace; bool hasProtectedContent; - mutable std::mutex targetsLock; + mutable angle::SimpleMutex targetsLock; static constexpr size_t kTargetsSetSize = 2; angle::FlatUnorderedSet<ImageSibling *, kTargetsSetSize> targets; diff --git a/src/libANGLE/MemoryProgramCache.cpp b/src/libANGLE/MemoryProgramCache.cpp index d93274b71e..8f59b31c5c 100644 --- a/src/libANGLE/MemoryProgramCache.cpp +++ b/src/libANGLE/MemoryProgramCache.cpp @@ -194,7 +194,7 @@ angle::Result MemoryProgramCache::putProgram(const egl::BlobCache::Key &programH } { - std::scoped_lock<std::mutex> lock(mBlobCache.getMutex()); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCache.getMutex()); // TODO: http://anglebug.com/7568 // This was a workaround for Chrome until it added support for EGL_ANDROID_blob_cache, // tracked by http://anglebug.com/2516. This issue has since been closed, but removing this diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp index 17d9182d13..d86e24bead 100644 --- a/src/libANGLE/Program.cpp +++ b/src/libANGLE/Program.cpp @@ -966,7 +966,7 @@ angle::Result Program::link(const Context *context, angle::JobResultExpectancy r // TODO: http://anglebug.com/4530: Enable program caching for separable programs if (cache && !isSeparable()) { - std::lock_guard<std::mutex> cacheLock(context->getProgramCacheMutex()); + std::lock_guard<angle::SimpleMutex> cacheLock(context->getProgramCacheMutex()); egl::CacheGetResult result = egl::CacheGetResult::NotFound; ANGLE_TRY(cache->getProgram(context, this, &mProgramHash, &result)); @@ -2349,7 +2349,7 @@ void Program::cacheProgramBinary(const Context *context) ASSERT(mState.mExecutable->mPostLinkSubTasks.empty()); // Save to the program cache. - std::lock_guard<std::mutex> cacheLock(context->getProgramCacheMutex()); + std::lock_guard<angle::SimpleMutex> cacheLock(context->getProgramCacheMutex()); MemoryProgramCache *cache = context->getMemoryProgramCache(); // TODO: http://anglebug.com/4530: Enable program caching for separable programs if (cache && !isSeparable() && diff --git a/src/libANGLE/Program.h b/src/libANGLE/Program.h index 50895ca265..40fd753bda 100644 --- a/src/libANGLE/Program.h +++ b/src/libANGLE/Program.h @@ -22,6 +22,7 @@ #include <vector> #include "common/Optional.h" +#include "common/SimpleMutex.h" #include "common/angleutils.h" #include "common/mathutil.h" #include "common/utilities.h" @@ -567,7 +568,7 @@ class Program final : public LabeledObject, public angle::Subject // actual binary. This cache ensures the second call does not need to call |serialize()| again. angle::MemoryBuffer mBinary; - std::mutex mHistogramMutex; + angle::SimpleMutex mHistogramMutex; }; } // namespace gl diff --git a/src/libANGLE/capture/FrameCapture.cpp b/src/libANGLE/capture/FrameCapture.cpp index 44a46c0607..22daf186f7 100644 --- a/src/libANGLE/capture/FrameCapture.cpp +++ b/src/libANGLE/capture/FrameCapture.cpp @@ -6580,7 +6580,7 @@ CoherentBufferTracker::~CoherentBufferTracker() PageFaultHandlerRangeType CoherentBufferTracker::handleWrite(uintptr_t address) { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); auto pagesInBuffers = getBufferPagesForAddress(address); if (pagesInBuffers.empty()) @@ -6677,7 +6677,7 @@ bool CoherentBufferTracker::haveBuffer(gl::BufferID id) void CoherentBufferTracker::onEndFrame() { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); if (!mEnabled) { @@ -6719,7 +6719,7 @@ void CoherentBufferTracker::disable() uintptr_t CoherentBufferTracker::addBuffer(gl::BufferID id, uintptr_t start, size_t size) { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); if (haveBuffer(id)) { @@ -6808,7 +6808,7 @@ PageSharingType CoherentBufferTracker::doesBufferSharePage(gl::BufferID id) void CoherentBufferTracker::removeBuffer(gl::BufferID id) { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); if (!haveBuffer(id)) { @@ -7367,7 +7367,7 @@ void FrameCaptureShared::maybeCaptureCoherentBuffers(const gl::Context *context) return; } - std::lock_guard<std::mutex> lock(mCoherentBufferTracker.mMutex); + std::lock_guard<angle::SimpleMutex> lock(mCoherentBufferTracker.mMutex); for (const auto &pair : mCoherentBufferTracker.mBuffers) { diff --git a/src/libANGLE/capture/FrameCapture.h b/src/libANGLE/capture/FrameCapture.h index 7f3f26b4a4..b2107c705c 100644 --- a/src/libANGLE/capture/FrameCapture.h +++ b/src/libANGLE/capture/FrameCapture.h @@ -11,6 +11,7 @@ #define LIBANGLE_FRAME_CAPTURE_H_ #include "common/PackedEnums.h" +#include "common/SimpleMutex.h" #include "common/frame_capture_utils.h" #include "common/system_utils.h" #include "libANGLE/Context.h" @@ -557,7 +558,7 @@ class CoherentBufferTracker final : angle::NonCopyable PageFaultHandlerRangeType handleWrite(uintptr_t address); public: - std::mutex mMutex; + angle::SimpleMutex mMutex; HashMap<GLuint, std::shared_ptr<CoherentBuffer>> mBuffers; private: @@ -709,7 +710,7 @@ class FrameCaptureShared final : angle::NonCopyable void *maybeGetShadowMemoryPointer(gl::Buffer *buffer, GLsizeiptr length, GLbitfield access); void determineMemoryProtectionSupport(gl::Context *context); - std::mutex &getFrameCaptureMutex() { return mFrameCaptureMutex; } + angle::SimpleMutex &getFrameCaptureMutex() { return mFrameCaptureMutex; } void setDeferredLinkProgram(gl::ShaderProgramID programID) { @@ -796,7 +797,7 @@ class FrameCaptureShared final : angle::NonCopyable std::string mValidationExpression; PackedEnumMap<ResourceIDType, uint32_t> mMaxAccessedResourceIDs; CoherentBufferTracker mCoherentBufferTracker; - std::mutex mFrameCaptureMutex; + angle::SimpleMutex mFrameCaptureMutex; ResourceTracker mResourceTracker; ReplayWriter mReplayWriter; @@ -839,7 +840,7 @@ void CaptureGLCallToFrameCapture(CaptureFuncT captureFunc, // EGL calls are protected by the global context mutex but only a subset of GL calls // are so protected. Ensure FrameCaptureShared access thread safety by using a // frame-capture only mutex. - std::lock_guard<std::mutex> lock(frameCaptureShared->getFrameCaptureMutex()); + std::lock_guard<angle::SimpleMutex> lock(frameCaptureShared->getFrameCaptureMutex()); if (!frameCaptureShared->isCapturing()) { diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 4a313d127c..6d9cfe1092 100644 --- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -12,6 +12,7 @@ #include <sstream> #include "anglebase/no_destructor.h" +#include "common/SimpleMutex.h" #include "common/debug.h" #include "common/tls.h" #include "common/utilities.h" @@ -1035,10 +1036,10 @@ egl::Error Renderer11::initializeD3DDevice() void Renderer11::setGlobalDebugAnnotator() { - static angle::base::NoDestructor<std::mutex> gMutex; + static angle::base::NoDestructor<angle::SimpleMutex> gMutex; static angle::base::NoDestructor<DebugAnnotator11> gGlobalAnnotator; - std::lock_guard<std::mutex> lg(*gMutex); + std::lock_guard<angle::SimpleMutex> lg(*gMutex); gl::InitializeDebugAnnotations(gGlobalAnnotator.get()); } diff --git a/src/libANGLE/renderer/d3d/d3d9/ShaderCache.h b/src/libANGLE/renderer/d3d/d3d9/ShaderCache.h index bd1a4cf269..689a59e459 100644 --- a/src/libANGLE/renderer/d3d/d3d9/ShaderCache.h +++ b/src/libANGLE/renderer/d3d/d3d9/ShaderCache.h @@ -12,6 +12,7 @@ #include "libANGLE/Error.h" +#include "common/SimpleMutex.h" #include "common/debug.h" #include "libANGLE/renderer/d3d/d3d9/Context9.h" @@ -41,7 +42,7 @@ class ShaderCache : angle::NonCopyable size_t length, ShaderObject **outShaderObject) { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); std::string key(reinterpret_cast<const char *>(function), length); typename Map::iterator it = mMap.find(key); @@ -72,7 +73,7 @@ class ShaderCache : angle::NonCopyable void clear() { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); for (typename Map::iterator it = mMap.begin(); it != mMap.end(); ++it) { @@ -97,7 +98,7 @@ class ShaderCache : angle::NonCopyable typedef angle::HashMap<std::string, ShaderObject *> Map; Map mMap; - std::mutex mMutex; + angle::SimpleMutex mMutex; IDirect3DDevice9 *mDevice; }; diff --git a/src/libANGLE/renderer/vulkan/CLMemoryVk.h b/src/libANGLE/renderer/vulkan/CLMemoryVk.h index 4decd44b00..fbffc6760f 100644 --- a/src/libANGLE/renderer/vulkan/CLMemoryVk.h +++ b/src/libANGLE/renderer/vulkan/CLMemoryVk.h @@ -8,6 +8,8 @@ #ifndef LIBANGLE_RENDERER_VULKAN_CLMEMORYVK_H_ #define LIBANGLE_RENDERER_VULKAN_CLMEMORYVK_H_ +#include "common/SimpleMutex.h" + #include "libANGLE/renderer/vulkan/cl_types.h" #include "libANGLE/renderer/vulkan/vk_helpers.h" @@ -57,7 +59,7 @@ class CLMemoryVk : public CLMemoryImpl CLContextVk *mContext; vk::Renderer *mRenderer; vk::Allocation mAllocation; - std::mutex mMapLock; + angle::SimpleMutex mMapLock; uint8_t *mMapPtr; uint32_t mMapCount; CLMemoryVk *mParent; diff --git a/src/libANGLE/renderer/vulkan/CLPlatformVk.cpp b/src/libANGLE/renderer/vulkan/CLPlatformVk.cpp index bb5ad5a723..ea693ff6bc 100644 --- a/src/libANGLE/renderer/vulkan/CLPlatformVk.cpp +++ b/src/libANGLE/renderer/vulkan/CLPlatformVk.cpp @@ -270,14 +270,14 @@ const char *CLPlatformVk::getWSIExtension() // vk::GlobalOps void CLPlatformVk::putBlob(const angle::BlobCacheKey &key, const angle::MemoryBuffer &value) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); size_t valueSize = value.size(); mBlobCache.put(key, std::move(const_cast<angle::MemoryBuffer &>(value)), valueSize); } bool CLPlatformVk::getBlob(const angle::BlobCacheKey &key, angle::BlobCacheValue *valueOut) { - std::scoped_lock<std::mutex> lock(mBlobCacheMutex); + std::scoped_lock<angle::SimpleMutex> lock(mBlobCacheMutex); const angle::MemoryBuffer *entry; bool result = mBlobCache.get(key, &entry); if (result) diff --git a/src/libANGLE/renderer/vulkan/CLPlatformVk.h b/src/libANGLE/renderer/vulkan/CLPlatformVk.h index 1ce95f1811..2d4e638141 100644 --- a/src/libANGLE/renderer/vulkan/CLPlatformVk.h +++ b/src/libANGLE/renderer/vulkan/CLPlatformVk.h @@ -9,6 +9,7 @@ #define LIBANGLE_RENDERER_VULKAN_CLPLATFORMVK_H_ #include "common/MemoryBuffer.h" +#include "common/SimpleMutex.h" #include "libANGLE/angletypes.h" #include "libANGLE/renderer/CLPlatformImpl.h" @@ -69,7 +70,7 @@ class CLPlatformVk : public CLPlatformImpl, public vk::Context, public vk::Globa const char *getWSIExtension(); const char *getWSILayer() { return nullptr; } - mutable std::mutex mBlobCacheMutex; + mutable angle::SimpleMutex mBlobCacheMutex; angle::SizedMRUCache<angle::BlobCacheKey, angle::MemoryBuffer> mBlobCache; }; diff --git a/src/libANGLE/renderer/vulkan/CLProgramVk.cpp b/src/libANGLE/renderer/vulkan/CLProgramVk.cpp index 38fb4ac7b1..dc1e419028 100644 --- a/src/libANGLE/renderer/vulkan/CLProgramVk.cpp +++ b/src/libANGLE/renderer/vulkan/CLProgramVk.cpp @@ -618,7 +618,7 @@ angle::Result CLProgramVk::createKernel(const cl::Kernel &kernel, const char *name, CLKernelImpl::Ptr *kernelOut) { - std::scoped_lock<std::mutex> sl(mProgramMutex); + std::scoped_lock<angle::SimpleMutex> sl(mProgramMutex); const auto devProgram = getDeviceProgramData(name); ASSERT(devProgram != nullptr); @@ -757,7 +757,7 @@ bool CLProgramVk::buildInternal(const cl::DevicePtrs &devices, BuildType buildType, const LinkProgramsList &LinkProgramsList) { - std::scoped_lock<std::mutex> sl(mProgramMutex); + std::scoped_lock<angle::SimpleMutex> sl(mProgramMutex); // Cache original options string mProgramOpts = options; diff --git a/src/libANGLE/renderer/vulkan/CLProgramVk.h b/src/libANGLE/renderer/vulkan/CLProgramVk.h index abbd0e2606..da279b2ad5 100644 --- a/src/libANGLE/renderer/vulkan/CLProgramVk.h +++ b/src/libANGLE/renderer/vulkan/CLProgramVk.h @@ -8,6 +8,8 @@ #ifndef LIBANGLE_RENDERER_VULKAN_CLPROGRAMVK_H_ #define LIBANGLE_RENDERER_VULKAN_CLPROGRAMVK_H_ +#include "common/SimpleMutex.h" + #include "libANGLE/renderer/vulkan/CLContextVk.h" #include "libANGLE/renderer/vulkan/CLKernelVk.h" #include "libANGLE/renderer/vulkan/cl_types.h" @@ -247,7 +249,7 @@ class CLProgramVk : public CLProgramImpl DescriptorSetLayoutCache mDescSetLayoutCache; vk::DescriptorSetArray<vk::DescriptorPoolPointer> mDescriptorPools; vk::RefCountedDescriptorPoolBinding mPoolBinding; - std::mutex mProgramMutex; + angle::SimpleMutex mProgramMutex; }; class CLAsyncBuildTask : public angle::Closure diff --git a/src/libANGLE/renderer/vulkan/DisplayVk.cpp b/src/libANGLE/renderer/vulkan/DisplayVk.cpp index d36caa03e8..60817ef78e 100644 --- a/src/libANGLE/renderer/vulkan/DisplayVk.cpp +++ b/src/libANGLE/renderer/vulkan/DisplayVk.cpp @@ -144,7 +144,7 @@ void InstallDebugAnnotator(egl::Display *display, vk::Renderer *renderer) if (!installedAnnotator) { - std::unique_lock<std::mutex> lock(gl::GetDebugMutex()); + std::unique_lock<angle::SimpleMutex> lock(gl::GetDebugMutex()); display->setGlobalDebugAnnotator(); } } diff --git a/src/libANGLE/renderer/vulkan/MemoryTracking.cpp b/src/libANGLE/renderer/vulkan/MemoryTracking.cpp index 8a1cf73be3..4fc493ed96 100644 --- a/src/libANGLE/renderer/vulkan/MemoryTracking.cpp +++ b/src/libANGLE/renderer/vulkan/MemoryTracking.cpp @@ -249,7 +249,7 @@ void MemoryAllocationTracker::onMemoryAllocImpl(vk::MemoryAllocationType allocTy { // If enabled (debug layers), we keep more details in the memory tracker, such as handle, // and log the action to the output. - std::unique_lock<std::mutex> lock(mMemoryAllocationMutex); + std::unique_lock<angle::SimpleMutex> lock(mMemoryAllocationMutex); uint32_t allocTypeIndex = ToUnderlying(allocType); uint32_t memoryHeapIndex = @@ -313,7 +313,7 @@ void MemoryAllocationTracker::onMemoryDeallocImpl(vk::MemoryAllocationType alloc { vk::MemoryAllocInfoMapKey memoryAllocInfoMapKey(handle); MemoryAllocInfoMap &memInfoMap = memInfoPerBacktrace.second; - std::unique_lock<std::mutex> lock(mMemoryAllocationMutex); + std::unique_lock<angle::SimpleMutex> lock(mMemoryAllocationMutex); if (memInfoMap.find(memoryAllocInfoMapKey) != memInfoMap.end()) { @@ -505,7 +505,7 @@ MemoryReport::MemoryReport() void MemoryReport::processCallback(const VkDeviceMemoryReportCallbackDataEXT &callbackData, bool logCallback) { - std::unique_lock<std::mutex> lock(mMemoryReportMutex); + std::unique_lock<angle::SimpleMutex> lock(mMemoryReportMutex); VkDeviceSize size = 0; std::string reportType; switch (callbackData.type) @@ -583,7 +583,7 @@ void MemoryReport::processCallback(const VkDeviceMemoryReportCallbackDataEXT &ca void MemoryReport::logMemoryReportStats() const { - std::unique_lock<std::mutex> lock(mMemoryReportMutex); + std::unique_lock<angle::SimpleMutex> lock(mMemoryReportMutex); INFO() << std::right << "GPU Memory Totals: Allocated=" << std::setw(10) << mCurrentTotalAllocatedMemory << " (max=" << std::setw(10) << mMaxTotalAllocatedMemory diff --git a/src/libANGLE/renderer/vulkan/MemoryTracking.h b/src/libANGLE/renderer/vulkan/MemoryTracking.h index f3c3475e99..ae3f3d7755 100644 --- a/src/libANGLE/renderer/vulkan/MemoryTracking.h +++ b/src/libANGLE/renderer/vulkan/MemoryTracking.h @@ -12,8 +12,8 @@ #include <array> #include <atomic> -#include <mutex> +#include "common/SimpleMutex.h" #include "common/angleutils.h" #include "common/backtrace_utils.h" #include "common/vulkan/vk_headers.h" @@ -113,7 +113,7 @@ class MemoryReport final : angle::NonCopyable VkDeviceSize importedMemory; VkDeviceSize importedMemoryMax; }; - mutable std::mutex mMemoryReportMutex; + mutable angle::SimpleMutex mMemoryReportMutex; VkDeviceSize mCurrentTotalAllocatedMemory; VkDeviceSize mMaxTotalAllocatedMemory; angle::HashMap<VkObjectType, MemorySizes> mSizesPerType; @@ -198,7 +198,7 @@ class MemoryAllocationTracker : angle::NonCopyable std::atomic<uint32_t> mPendingMemoryTypeIndex; // Mutex is used to update the data when debug layers are enabled. - std::mutex mMemoryAllocationMutex; + angle::SimpleMutex mMemoryAllocationMutex; // Additional information regarding memory allocation with debug layers enabled, including // allocation ID and a record of all active allocations. diff --git a/src/libANGLE/renderer/vulkan/SecondaryCommandPool.cpp b/src/libANGLE/renderer/vulkan/SecondaryCommandPool.cpp index 840b12d223..5acdf77167 100644 --- a/src/libANGLE/renderer/vulkan/SecondaryCommandPool.cpp +++ b/src/libANGLE/renderer/vulkan/SecondaryCommandPool.cpp @@ -89,7 +89,7 @@ void SecondaryCommandPool::collect(VulkanSecondaryCommandBuffer *buffer) } else { - std::lock_guard<std::mutex> lock(mOverflowMutex); + std::lock_guard<angle::SimpleMutex> lock(mOverflowMutex); mCollectedBuffersOverflow.emplace_back(bufferHandle); mHasOverflow.store(true, std::memory_order_relaxed); } @@ -111,7 +111,7 @@ void SecondaryCommandPool::freeCollectedBuffers(VkDevice device) { std::vector<VkCommandBuffer> buffers; { - std::lock_guard<std::mutex> lock(mOverflowMutex); + std::lock_guard<angle::SimpleMutex> lock(mOverflowMutex); buffers = std::move(mCollectedBuffersOverflow); mHasOverflow.store(false, std::memory_order_relaxed); } diff --git a/src/libANGLE/renderer/vulkan/SecondaryCommandPool.h b/src/libANGLE/renderer/vulkan/SecondaryCommandPool.h index 91749dc388..93de25a618 100644 --- a/src/libANGLE/renderer/vulkan/SecondaryCommandPool.h +++ b/src/libANGLE/renderer/vulkan/SecondaryCommandPool.h @@ -11,6 +11,7 @@ #define LIBANGLE_RENDERER_VULKAN_SECONDARYCOMMANDPOOL_H_ #include "common/FixedQueue.h" +#include "common/SimpleMutex.h" #include "libANGLE/renderer/vulkan/vk_command_buffer_utils.h" #include "libANGLE/renderer/vulkan/vk_wrapper.h" @@ -59,7 +60,7 @@ class SecondaryCommandPool final : angle::NonCopyable // Overflow vector to use in cases when FixedQueue is filled. std::vector<VkCommandBuffer> mCollectedBuffersOverflow; - std::mutex mOverflowMutex; + angle::SimpleMutex mOverflowMutex; std::atomic<bool> mHasOverflow; }; diff --git a/src/libANGLE/renderer/vulkan/Suballocation.cpp b/src/libANGLE/renderer/vulkan/Suballocation.cpp index e0bbff77c2..1cd5a0edd3 100644 --- a/src/libANGLE/renderer/vulkan/Suballocation.cpp +++ b/src/libANGLE/renderer/vulkan/Suballocation.cpp @@ -154,14 +154,14 @@ VkResult BufferBlock::allocate(VkDeviceSize size, VmaVirtualAllocation *allocationOut, VkDeviceSize *offsetOut) { - std::unique_lock<std::mutex> lock(mVirtualBlockMutex); + std::unique_lock<angle::SimpleMutex> lock(mVirtualBlockMutex); mCountRemainsEmpty = 0; return mVirtualBlock.allocate(size, alignment, allocationOut, offsetOut); } void BufferBlock::free(VmaVirtualAllocation allocation, VkDeviceSize offset) { - std::unique_lock<std::mutex> lock(mVirtualBlockMutex); + std::unique_lock<angle::SimpleMutex> lock(mVirtualBlockMutex); mVirtualBlock.free(allocation, offset); } @@ -172,7 +172,7 @@ int32_t BufferBlock::getAndIncrementEmptyCounter() void BufferBlock::calculateStats(vma::StatInfo *pStatInfo) const { - std::unique_lock<std::mutex> lock(mVirtualBlockMutex); + std::unique_lock<angle::SimpleMutex> lock(mVirtualBlockMutex); mVirtualBlock.calculateStats(pStatInfo); } diff --git a/src/libANGLE/renderer/vulkan/Suballocation.h b/src/libANGLE/renderer/vulkan/Suballocation.h index ec12181a31..e8b80e8ba4 100644 --- a/src/libANGLE/renderer/vulkan/Suballocation.h +++ b/src/libANGLE/renderer/vulkan/Suballocation.h @@ -10,6 +10,7 @@ #ifndef LIBANGLE_RENDERER_VULKAN_SUBALLOCATION_H_ #define LIBANGLE_RENDERER_VULKAN_SUBALLOCATION_H_ +#include "common/SimpleMutex.h" #include "common/debug.h" #include "libANGLE/angletypes.h" #include "libANGLE/renderer/serial_utils.h" @@ -95,7 +96,7 @@ class BufferBlock final : angle::NonCopyable } private: - mutable std::mutex mVirtualBlockMutex; + mutable angle::SimpleMutex mVirtualBlockMutex; VirtualBlock mVirtualBlock; Buffer mBuffer; @@ -131,7 +132,7 @@ class BufferBlockGarbageList final : angle::NonCopyable void add(BufferBlock *bufferBlock) { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); if (mBufferBlockQueue.full()) { size_t newCapacity = mBufferBlockQueue.capacity() << 1; @@ -144,7 +145,7 @@ class BufferBlockGarbageList final : angle::NonCopyable { if (!mBufferBlockQueue.empty()) { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); size_t count = mBufferBlockQueue.size(); for (size_t i = 0; i < count; i++) { @@ -166,7 +167,7 @@ class BufferBlockGarbageList final : angle::NonCopyable private: static constexpr size_t kInitialQueueCapacity = 4; - std::mutex mMutex; + angle::SimpleMutex mMutex; angle::FixedQueue<BufferBlock *> mBufferBlockQueue; }; @@ -275,7 +276,7 @@ ANGLE_INLINE VkDeviceSize BufferBlock::getMemorySize() const ANGLE_INLINE VkBool32 BufferBlock::isEmpty() { - std::unique_lock<std::mutex> lock(mVirtualBlockMutex); + std::unique_lock<angle::SimpleMutex> lock(mVirtualBlockMutex); return vma::IsVirtualBlockEmpty(mVirtualBlock.getHandle()); } diff --git a/src/libANGLE/renderer/vulkan/SurfaceVk.cpp b/src/libANGLE/renderer/vulkan/SurfaceVk.cpp index 326b8c73fe..e22771208c 100644 --- a/src/libANGLE/renderer/vulkan/SurfaceVk.cpp +++ b/src/libANGLE/renderer/vulkan/SurfaceVk.cpp @@ -483,7 +483,7 @@ void TryAcquireNextImageUnlocked(VkDevice device, impl::UnlockedTryAcquireData *tryAcquire = &acquire->unlockedTryAcquireData; impl::UnlockedTryAcquireResult *result = &acquire->unlockedTryAcquireResult; - std::lock_guard<std::mutex> lock(tryAcquire->mutex); + std::lock_guard<angle::SimpleMutex> lock(tryAcquire->mutex); // Check again under lock if acquire is still needed. Another thread might have done it before // the lock is taken. diff --git a/src/libANGLE/renderer/vulkan/SurfaceVk.h b/src/libANGLE/renderer/vulkan/SurfaceVk.h index dd8bb577bf..51bd45901e 100644 --- a/src/libANGLE/renderer/vulkan/SurfaceVk.h +++ b/src/libANGLE/renderer/vulkan/SurfaceVk.h @@ -11,6 +11,7 @@ #define LIBANGLE_RENDERER_VULKAN_SURFACEVK_H_ #include "common/CircularBuffer.h" +#include "common/SimpleMutex.h" #include "common/vulkan/vk_headers.h" #include "libANGLE/renderer/SurfaceImpl.h" #include "libANGLE/renderer/vulkan/CommandProcessor.h" @@ -207,7 +208,7 @@ struct SwapchainImage : angle::NonCopyable struct UnlockedTryAcquireData : angle::NonCopyable { // A mutex to protect against concurrent attempts to call vkAcquireNextImageKHR. - std::mutex mutex; + angle::SimpleMutex mutex; // Given that the CPU is throttled after a number of swaps, there is an upper bound to the // number of semaphores that are used to acquire swapchain images, and that is diff --git a/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp b/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp index e1d1b3cd23..37e596902a 100644 --- a/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp +++ b/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp @@ -6379,21 +6379,21 @@ template class SharedCacheKeyManager<SharedFramebufferCacheKey>; template class SharedCacheKeyManager<SharedDescriptorSetCacheKey>; // PipelineCacheAccess implementation. -std::unique_lock<std::mutex> PipelineCacheAccess::getLock() +std::unique_lock<angle::SimpleMutex> PipelineCacheAccess::getLock() { if (mMutex == nullptr) { - return std::unique_lock<std::mutex>(); + return std::unique_lock<angle::SimpleMutex>(); } - return std::unique_lock<std::mutex>(*mMutex); + return std::unique_lock<angle::SimpleMutex>(*mMutex); } VkResult PipelineCacheAccess::createGraphicsPipeline(vk::Context *context, const VkGraphicsPipelineCreateInfo &createInfo, vk::Pipeline *pipelineOut) { - std::unique_lock<std::mutex> lock = getLock(); + std::unique_lock<angle::SimpleMutex> lock = getLock(); return pipelineOut->initGraphics(context->getDevice(), createInfo, *mPipelineCache); } @@ -6402,7 +6402,7 @@ VkResult PipelineCacheAccess::createComputePipeline(vk::Context *context, const VkComputePipelineCreateInfo &createInfo, vk::Pipeline *pipelineOut) { - std::unique_lock<std::mutex> lock = getLock(); + std::unique_lock<angle::SimpleMutex> lock = getLock(); return pipelineOut->initCompute(context->getDevice(), createInfo, *mPipelineCache); } @@ -6411,7 +6411,7 @@ void PipelineCacheAccess::merge(Renderer *renderer, const vk::PipelineCache &pip { ASSERT(isThreadSafe()); - std::unique_lock<std::mutex> lock = getLock(); + std::unique_lock<angle::SimpleMutex> lock = getLock(); mPipelineCache->merge(renderer->getDevice(), 1, pipelineCache.ptr()); } @@ -7476,7 +7476,7 @@ angle::Result DescriptorSetLayoutCache::getDescriptorSetLayout( vk::AtomicBindingPointer<vk::DescriptorSetLayout> *descriptorSetLayoutOut) { // Note: this function may be called without holding the share group lock. - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); auto iter = mPayload.find(desc); if (iter != mPayload.end()) @@ -7550,7 +7550,7 @@ angle::Result PipelineLayoutCache::getPipelineLayout( vk::AtomicBindingPointer<vk::PipelineLayout> *pipelineLayoutOut) { // Note: this function may be called without holding the share group lock. - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); auto iter = mPayload.find(desc); if (iter != mPayload.end()) diff --git a/src/libANGLE/renderer/vulkan/vk_cache_utils.h b/src/libANGLE/renderer/vulkan/vk_cache_utils.h index b04b604403..19d6249371 100644 --- a/src/libANGLE/renderer/vulkan/vk_cache_utils.h +++ b/src/libANGLE/renderer/vulkan/vk_cache_utils.h @@ -13,6 +13,7 @@ #include "common/Color.h" #include "common/FixedVector.h" +#include "common/SimpleMutex.h" #include "common/WorkerThread.h" #include "libANGLE/Uniform.h" #include "libANGLE/renderer/vulkan/ShaderInterfaceVariableInfoMap.h" @@ -1306,7 +1307,7 @@ class PipelineCacheAccess PipelineCacheAccess() = default; ~PipelineCacheAccess() = default; - void init(const vk::PipelineCache *pipelineCache, std::mutex *mutex) + void init(const vk::PipelineCache *pipelineCache, angle::SimpleMutex *mutex) { mPipelineCache = pipelineCache; mMutex = mutex; @@ -1324,10 +1325,10 @@ class PipelineCacheAccess bool isThreadSafe() const { return mMutex != nullptr; } private: - std::unique_lock<std::mutex> getLock(); + std::unique_lock<angle::SimpleMutex> getLock(); const vk::PipelineCache *mPipelineCache = nullptr; - std::mutex *mMutex; + angle::SimpleMutex *mMutex; }; // Monolithic pipeline creation tasks are created as soon as a pipeline is created out of libraries. @@ -2572,7 +2573,7 @@ class DescriptorSetLayoutCache final : angle::NonCopyable size_t getCacheMissCount() const { return mCacheStats.getMissCount(); } private: - mutable std::mutex mMutex; + mutable angle::SimpleMutex mMutex; std::unordered_map<vk::DescriptorSetLayoutDesc, vk::RefCountedDescriptorSetLayout> mPayload; CacheStats mCacheStats; }; @@ -2592,7 +2593,7 @@ class PipelineLayoutCache final : public HasCacheStats<VulkanCacheType::Pipeline vk::AtomicBindingPointer<vk::PipelineLayout> *pipelineLayoutOut); private: - mutable std::mutex mMutex; + mutable angle::SimpleMutex mMutex; std::unordered_map<vk::PipelineLayoutDesc, vk::RefCountedPipelineLayout> mPayload; }; diff --git a/src/libANGLE/renderer/vulkan/vk_format_utils.cpp b/src/libANGLE/renderer/vulkan/vk_format_utils.cpp index 22cbf849a1..f81152639c 100644 --- a/src/libANGLE/renderer/vulkan/vk_format_utils.cpp +++ b/src/libANGLE/renderer/vulkan/vk_format_utils.cpp @@ -311,7 +311,7 @@ angle::FormatID ExternalFormatTable::getOrAllocExternalFormatID(uint64_t externa VkFormat colorAttachmentFormat, VkFormatFeatureFlags formatFeatures) { - std::unique_lock<std::mutex> lock(mExternalYuvFormatMutex); + std::unique_lock<angle::SimpleMutex> lock(mExternalYuvFormatMutex); for (size_t index = 0; index < mExternalYuvFormats.size(); index++) { if (mExternalYuvFormats[index].externalFormat == externalFormat) diff --git a/src/libANGLE/renderer/vulkan/vk_format_utils.h b/src/libANGLE/renderer/vulkan/vk_format_utils.h index c3d702bb8b..141f4a0931 100644 --- a/src/libANGLE/renderer/vulkan/vk_format_utils.h +++ b/src/libANGLE/renderer/vulkan/vk_format_utils.h @@ -9,6 +9,7 @@ #ifndef LIBANGLE_RENDERER_VULKAN_VK_FORMAT_UTILS_H_ #define LIBANGLE_RENDERER_VULKAN_VK_FORMAT_UTILS_H_ +#include "common/SimpleMutex.h" #include "common/vulkan/vk_headers.h" #include "libANGLE/formatutils.h" #include "libANGLE/renderer/Format.h" @@ -257,7 +258,7 @@ class ExternalFormatTable final : angle::NonCopyable ToUnderlying(angle::FormatID::EXTERNAL7) - ToUnderlying(angle::FormatID::EXTERNAL0) + 1; // YUV rendering format cache. We build this table at run time when external formats are used. angle::FixedVector<ExternalYuvFormatInfo, kMaxExternalFormatCountSupported> mExternalYuvFormats; - mutable std::mutex mExternalYuvFormatMutex; + mutable angle::SimpleMutex mExternalYuvFormatMutex; }; bool IsYUVExternalFormat(angle::FormatID formatID); diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.cpp b/src/libANGLE/renderer/vulkan/vk_helpers.cpp index 62bb845d2b..07ad00981e 100644 --- a/src/libANGLE/renderer/vulkan/vk_helpers.cpp +++ b/src/libANGLE/renderer/vulkan/vk_helpers.cpp @@ -3155,7 +3155,7 @@ std::string RenderPassCommandBufferHelper::getCommandDiagnostics() template <typename CommandBufferHelperT> void CommandBufferRecycler<CommandBufferHelperT>::onDestroy() { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); for (CommandBufferHelperT *commandBufferHelper : mCommandBufferHelperFreeList) { SafeDelete(commandBufferHelper); @@ -3173,7 +3173,7 @@ angle::Result CommandBufferRecycler<CommandBufferHelperT>::getCommandBufferHelpe SecondaryCommandMemoryAllocator *commandsAllocator, CommandBufferHelperT **commandBufferHelperOut) { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); if (mCommandBufferHelperFreeList.empty()) { CommandBufferHelperT *commandBuffer = new CommandBufferHelperT(); @@ -3215,7 +3215,7 @@ void CommandBufferRecycler<CommandBufferHelperT>::recycleCommandBufferHelper( (*commandBuffer)->markOpen(); { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); mCommandBufferHelperFreeList.push_back(*commandBuffer); } diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.h b/src/libANGLE/renderer/vulkan/vk_helpers.h index a5fc2f60f8..0876d7e083 100644 --- a/src/libANGLE/renderer/vulkan/vk_helpers.h +++ b/src/libANGLE/renderer/vulkan/vk_helpers.h @@ -10,6 +10,7 @@ #define LIBANGLE_RENDERER_VULKAN_VK_HELPERS_H_ #include "common/MemoryBuffer.h" +#include "common/SimpleMutex.h" #include "libANGLE/renderer/vulkan/MemoryTracking.h" #include "libANGLE/renderer/vulkan/Suballocation.h" #include "libANGLE/renderer/vulkan/vk_cache_utils.h" @@ -1979,7 +1980,7 @@ class CommandBufferRecycler void recycleCommandBufferHelper(CommandBufferHelperT **commandBuffer); private: - std::mutex mMutex; + angle::SimpleMutex mMutex; std::vector<CommandBufferHelperT *> mCommandBufferHelperFreeList; }; diff --git a/src/libANGLE/renderer/vulkan/vk_renderer.cpp b/src/libANGLE/renderer/vulkan/vk_renderer.cpp index 5386378954..2e5b8b9861 100644 --- a/src/libANGLE/renderer/vulkan/vk_renderer.cpp +++ b/src/libANGLE/renderer/vulkan/vk_renderer.cpp @@ -1404,7 +1404,7 @@ void OneOffCommandPool::init(vk::ProtectionType protectionType) void OneOffCommandPool::destroy(VkDevice device) { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); for (PendingOneOffCommands &pending : mPendingCommands) { pending.commandBuffer.releaseHandle(); @@ -1416,7 +1416,7 @@ void OneOffCommandPool::destroy(VkDevice device) angle::Result OneOffCommandPool::getCommandBuffer(vk::Context *context, vk::PrimaryCommandBuffer *commandBufferOut) { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); if (!mPendingCommands.empty() && context->getRenderer()->hasResourceUseFinished(mPendingCommands.front().use)) @@ -1463,7 +1463,7 @@ angle::Result OneOffCommandPool::getCommandBuffer(vk::Context *context, void OneOffCommandPool::releaseCommandBuffer(const QueueSerial &submitQueueSerial, vk::PrimaryCommandBuffer &&primary) { - std::unique_lock<std::mutex> lock(mMutex); + std::unique_lock<angle::SimpleMutex> lock(mMutex); mPendingCommands.push_back({vk::ResourceUse(submitQueueSerial), std::move(primary)}); } @@ -5134,7 +5134,7 @@ angle::Result Renderer::ensurePipelineCacheInitialized(vk::Context *context) return angle::Result::Continue; } - std::unique_lock<std::mutex> lock(mPipelineCacheMutex); + std::unique_lock<angle::SimpleMutex> lock(mPipelineCacheMutex); // If another thread initialized it first don't redo it if (mPipelineCacheInitialized) @@ -5160,7 +5160,7 @@ angle::Result Renderer::getPipelineCache(vk::Context *context, { ANGLE_TRY(ensurePipelineCacheInitialized(context)); - std::mutex *pipelineCacheMutex = + angle::SimpleMutex *pipelineCacheMutex = (context->getFeatures().mergeProgramPipelineCachesToGlobalCache.enabled) ? &mPipelineCacheMutex : nullptr; @@ -5604,7 +5604,7 @@ void Renderer::setGlobalDebugAnnotator(bool *installedAnnotatorOut) { if (installDebugAnnotatorVk) { - std::unique_lock<std::mutex> lock(gl::GetDebugMutex()); + std::unique_lock<angle::SimpleMutex> lock(gl::GetDebugMutex()); gl::InitializeDebugAnnotations(&mAnnotator); } } @@ -5926,7 +5926,7 @@ void Renderer::logCacheStats() const return; } - std::unique_lock<std::mutex> localLock(mCacheStatsMutex); + std::unique_lock<angle::SimpleMutex> localLock(mCacheStatsMutex); int cacheType = 0; INFO() << "Vulkan object cache hit ratios: "; @@ -5993,13 +5993,13 @@ angle::Result Renderer::getFormatDescriptorCountForExternalFormat(vk::Context *c void Renderer::onAllocateHandle(vk::HandleType handleType) { - std::unique_lock<std::mutex> localLock(mActiveHandleCountsMutex); + std::unique_lock<angle::SimpleMutex> localLock(mActiveHandleCountsMutex); mActiveHandleCounts.onAllocate(handleType); } void Renderer::onDeallocateHandle(vk::HandleType handleType) { - std::unique_lock<std::mutex> localLock(mActiveHandleCountsMutex); + std::unique_lock<angle::SimpleMutex> localLock(mActiveHandleCountsMutex); mActiveHandleCounts.onDeallocate(handleType); } diff --git a/src/libANGLE/renderer/vulkan/vk_renderer.h b/src/libANGLE/renderer/vulkan/vk_renderer.h index dde956b2a5..9e6b580fd0 100644 --- a/src/libANGLE/renderer/vulkan/vk_renderer.h +++ b/src/libANGLE/renderer/vulkan/vk_renderer.h @@ -18,6 +18,7 @@ #include <thread> #include "common/PackedEnums.h" +#include "common/SimpleMutex.h" #include "common/WorkerThread.h" #include "common/angleutils.h" #include "common/vulkan/vk_headers.h" @@ -125,7 +126,7 @@ class OneOffCommandPool : angle::NonCopyable private: vk::ProtectionType mProtectionType; - std::mutex mMutex; + angle::SimpleMutex mMutex; vk::CommandPool mCommandPool; struct PendingOneOffCommands { @@ -511,7 +512,7 @@ class Renderer : angle::NonCopyable // Accumulate cache stats for a specific cache void accumulateCacheStats(VulkanCacheType cache, const CacheStats &stats) { - std::unique_lock<std::mutex> localLock(mCacheStatsMutex); + std::unique_lock<angle::SimpleMutex> localLock(mCacheStatsMutex); mVulkanCacheStats[cache].accumulate(stats); } // Log cache stats for all caches @@ -987,7 +988,7 @@ class Renderer : angle::NonCopyable // requires external synchronization when mPipelineCache is the dstCache of // vkMergePipelineCaches. Lock the mutex if mergeProgramPipelineCachesToGlobalCache is // enabled - std::mutex mPipelineCacheMutex; + angle::SimpleMutex mPipelineCacheMutex; vk::PipelineCache mPipelineCache; uint32_t mPipelineCacheVkUpdateTimeout; size_t mPipelineCacheSizeAtLastSync; @@ -1031,7 +1032,7 @@ class Renderer : angle::NonCopyable SamplerYcbcrConversionCache mYuvConversionCache; angle::HashMap<VkFormat, uint32_t> mVkFormatDescriptorCountMap; vk::ActiveHandleCounter mActiveHandleCounts; - std::mutex mActiveHandleCountsMutex; + angle::SimpleMutex mActiveHandleCountsMutex; // Tracks resource serials. vk::ResourceSerialFactory mResourceSerialFactory; @@ -1049,7 +1050,7 @@ class Renderer : angle::NonCopyable // Stats about all Vulkan object caches VulkanCacheStats mVulkanCacheStats; - mutable std::mutex mCacheStatsMutex; + mutable angle::SimpleMutex mCacheStatsMutex; // A mask to filter out Vulkan pipeline stages that are not supported, applied in situations // where multiple stages are prespecified (for example with image layout transitions): diff --git a/src/libANGLE/renderer/vulkan/vk_resource.h b/src/libANGLE/renderer/vulkan/vk_resource.h index 74efa62301..182c2f56b1 100644 --- a/src/libANGLE/renderer/vulkan/vk_resource.h +++ b/src/libANGLE/renderer/vulkan/vk_resource.h @@ -11,6 +11,7 @@ #define LIBANGLE_RENDERER_VULKAN_RESOURCEVK_H_ #include "common/FixedQueue.h" +#include "common/SimpleMutex.h" #include "libANGLE/HandleAllocator.h" #include "libANGLE/renderer/vulkan/vk_utils.h" @@ -198,7 +199,7 @@ class SharedGarbageList final : angle::NonCopyable } else { - std::unique_lock<std::mutex> enqueueLock(mMutex); + std::unique_lock<angle::SimpleMutex> enqueueLock(mMutex); if (garbage.hasResourceUseSubmitted(renderer)) { addGarbageLocked(mSubmittedQueue, std::move(garbage)); @@ -232,7 +233,7 @@ class SharedGarbageList final : angle::NonCopyable // Number of bytes destroyed is returned. void cleanupSubmittedGarbage(Renderer *renderer) { - std::unique_lock<std::mutex> lock(mSubmittedQueueDequeueMutex); + std::unique_lock<angle::SimpleMutex> lock(mSubmittedQueueDequeueMutex); VkDeviceSize bytesDestroyed = 0; while (!mSubmittedQueue.empty()) { @@ -256,7 +257,7 @@ class SharedGarbageList final : angle::NonCopyable // around is expected to be cheap in general, so lock contention is not expected. void cleanupUnsubmittedGarbage(Renderer *renderer) { - std::unique_lock<std::mutex> enqueueLock(mMutex); + std::unique_lock<angle::SimpleMutex> enqueueLock(mMutex); size_t count = mUnsubmittedQueue.size(); VkDeviceSize bytesMoved = 0; for (size_t i = 0; i < count; i++) @@ -285,7 +286,7 @@ class SharedGarbageList final : angle::NonCopyable // temporary storage. if (queue.size() >= queue.capacity() - 1) { - std::unique_lock<std::mutex> dequeueLock(mSubmittedQueueDequeueMutex); + std::unique_lock<angle::SimpleMutex> dequeueLock(mSubmittedQueueDequeueMutex); size_t newCapacity = queue.capacity() << 1; queue.updateCapacity(newCapacity); } @@ -295,9 +296,9 @@ class SharedGarbageList final : angle::NonCopyable static constexpr size_t kInitialQueueCapacity = 64; // Protects both enqueue and dequeue of mUnsubmittedQueue, as well as enqueue of // mSubmittedQueue. - std::mutex mMutex; + angle::SimpleMutex mMutex; // Protect dequeue of mSubmittedQueue, which is expected to be more expensive. - std::mutex mSubmittedQueueDequeueMutex; + angle::SimpleMutex mSubmittedQueueDequeueMutex; // Holds garbage that all of use has been submitted to renderer. angle::FixedQueue<T> mSubmittedQueue; // Holds garbage with at least one of the queueSerials has not yet submitted to renderer. diff --git a/src/libANGLE/renderer/vulkan/vk_utils.h b/src/libANGLE/renderer/vulkan/vk_utils.h index 1eec37a180..dc4ebdf9d6 100644 --- a/src/libANGLE/renderer/vulkan/vk_utils.h +++ b/src/libANGLE/renderer/vulkan/vk_utils.h @@ -18,6 +18,7 @@ #include "common/FixedVector.h" #include "common/Optional.h" #include "common/PackedEnums.h" +#include "common/SimpleMutex.h" #include "common/WorkerThread.h" #include "common/backtrace_utils.h" #include "common/debug.h" @@ -211,7 +212,7 @@ class QueueSerialIndexAllocator final } SerialIndex allocate() { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); if (mFreeIndexBitSetArray.none()) { ERR() << "Run out of queue serial index. All " << kMaxQueueSerialIndexCount @@ -227,7 +228,7 @@ class QueueSerialIndexAllocator final void release(SerialIndex index) { - std::lock_guard<std::mutex> lock(mMutex); + std::lock_guard<angle::SimpleMutex> lock(mMutex); ASSERT(index <= mLargestIndexEverAllocated); ASSERT(!mFreeIndexBitSetArray.test(index)); mFreeIndexBitSetArray.set(index); @@ -245,7 +246,7 @@ class QueueSerialIndexAllocator final private: angle::BitSetArray<kMaxQueueSerialIndexCount> mFreeIndexBitSetArray; std::atomic<size_t> mLargestIndexEverAllocated; - std::mutex mMutex; + angle::SimpleMutex mMutex; }; class [[nodiscard]] ScopedQueueSerialIndex final : angle::NonCopyable diff --git a/third_party/r8/lib/r8.jar b/third_party/r8/lib/r8.jar Binary files differindex d968c4e0a5..0d8798e815 100644 --- a/third_party/r8/lib/r8.jar +++ b/third_party/r8/lib/r8.jar |