aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShahbaz Youssefi <syoussefi@chromium.org>2024-04-15 14:58:55 -0400
committerAngle LUCI CQ <angle-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-05-06 18:30:53 +0000
commitc3a1cae44e3571844e22932cfbf62fe96e4d2a22 (patch)
tree06e7c480912a1fc703346b59bf7a109bac6733e5
parenta951e0e0823408ce2a5a827ac135c9454f6fc230 (diff)
downloadangle-c3a1cae44e3571844e22932cfbf62fe96e4d2a22.tar.gz
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>
-rw-r--r--BUILD.gn13
-rw-r--r--src/common/RingBufferAllocator.cpp4
-rw-r--r--src/common/RingBufferAllocator.h3
-rw-r--r--src/common/angleutils.h26
-rw-r--r--src/common/debug.cpp11
-rw-r--r--src/common/debug.h3
-rw-r--r--src/image_util/AstcDecompressor.cpp3
-rw-r--r--src/libANGLE/BlobCache.cpp20
-rw-r--r--src/libANGLE/BlobCache.h5
-rw-r--r--src/libANGLE/Compiler.cpp4
-rw-r--r--src/libANGLE/Context.cpp2
-rw-r--r--src/libANGLE/Context.h3
-rw-r--r--src/libANGLE/Debug.cpp8
-rw-r--r--src/libANGLE/Debug.h3
-rw-r--r--src/libANGLE/Display.cpp6
-rw-r--r--src/libANGLE/Display.h11
-rw-r--r--src/libANGLE/Image.h3
-rw-r--r--src/libANGLE/MemoryProgramCache.cpp2
-rw-r--r--src/libANGLE/Program.cpp4
-rw-r--r--src/libANGLE/Program.h3
-rw-r--r--src/libANGLE/capture/FrameCapture.cpp10
-rw-r--r--src/libANGLE/capture/FrameCapture.h9
-rw-r--r--src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp5
-rw-r--r--src/libANGLE/renderer/d3d/d3d9/ShaderCache.h7
-rw-r--r--src/libANGLE/renderer/vulkan/CLMemoryVk.h4
-rw-r--r--src/libANGLE/renderer/vulkan/CLPlatformVk.cpp4
-rw-r--r--src/libANGLE/renderer/vulkan/CLPlatformVk.h3
-rw-r--r--src/libANGLE/renderer/vulkan/CLProgramVk.cpp4
-rw-r--r--src/libANGLE/renderer/vulkan/CLProgramVk.h4
-rw-r--r--src/libANGLE/renderer/vulkan/DisplayVk.cpp2
-rw-r--r--src/libANGLE/renderer/vulkan/MemoryTracking.cpp8
-rw-r--r--src/libANGLE/renderer/vulkan/MemoryTracking.h6
-rw-r--r--src/libANGLE/renderer/vulkan/SecondaryCommandPool.cpp4
-rw-r--r--src/libANGLE/renderer/vulkan/SecondaryCommandPool.h3
-rw-r--r--src/libANGLE/renderer/vulkan/Suballocation.cpp6
-rw-r--r--src/libANGLE/renderer/vulkan/Suballocation.h11
-rw-r--r--src/libANGLE/renderer/vulkan/SurfaceVk.cpp2
-rw-r--r--src/libANGLE/renderer/vulkan/SurfaceVk.h3
-rw-r--r--src/libANGLE/renderer/vulkan/vk_cache_utils.cpp16
-rw-r--r--src/libANGLE/renderer/vulkan/vk_cache_utils.h11
-rw-r--r--src/libANGLE/renderer/vulkan/vk_format_utils.cpp2
-rw-r--r--src/libANGLE/renderer/vulkan/vk_format_utils.h3
-rw-r--r--src/libANGLE/renderer/vulkan/vk_helpers.cpp6
-rw-r--r--src/libANGLE/renderer/vulkan/vk_helpers.h3
-rw-r--r--src/libANGLE/renderer/vulkan/vk_renderer.cpp18
-rw-r--r--src/libANGLE/renderer/vulkan/vk_renderer.h11
-rw-r--r--src/libANGLE/renderer/vulkan/vk_resource.h13
-rw-r--r--src/libANGLE/renderer/vulkan/vk_utils.h7
48 files changed, 162 insertions, 160 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 6aeb5e2e43..9ba42bd227 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -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) {
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