зеркало из https://github.com/AvaloniaUI/angle.git
Guard against race in perf warnings.
Expose the "debug" mutex so insertPerfWarning can use it. This was detected using TSAN and MultithreadingTest. Bug: b/168744561 Change-Id: Idde95a7b217f21f007893192a4a1f0a69b4ed3a9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2415184 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
This commit is contained in:
Родитель
6939a023f5
Коммит
32de9efebc
|
@ -14,7 +14,6 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
|
@ -114,6 +113,12 @@ void InitializeDebugMutexIfNeeded()
|
|||
}
|
||||
}
|
||||
|
||||
std::mutex &GetDebugMutex()
|
||||
{
|
||||
ASSERT(g_debugMutex);
|
||||
return *g_debugMutex;
|
||||
}
|
||||
|
||||
ScopedPerfEventHelper::ScopedPerfEventHelper(const char *format, ...) : mFunctionName(nullptr)
|
||||
{
|
||||
bool dbgTrace = DebugAnnotationsActive();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <iomanip>
|
||||
#include <ios>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
|
@ -103,6 +104,8 @@ bool DebugAnnotationsInitialized();
|
|||
|
||||
void InitializeDebugMutexIfNeeded();
|
||||
|
||||
std::mutex &GetDebugMutex();
|
||||
|
||||
namespace priv
|
||||
{
|
||||
// This class is used to explicitly ignore values in the conditional logging macros. This avoids
|
||||
|
|
|
@ -340,18 +340,28 @@ size_t Debug::getGroupStackDepth() const
|
|||
|
||||
void Debug::insertPerfWarning(GLenum severity, const char *message, uint32_t *repeatCount) const
|
||||
{
|
||||
constexpr uint32_t kMaxRepeat = 4;
|
||||
if (*repeatCount >= kMaxRepeat)
|
||||
bool repeatLast;
|
||||
|
||||
{
|
||||
return;
|
||||
constexpr uint32_t kMaxRepeat = 4;
|
||||
std::lock_guard<std::mutex> lock(GetDebugMutex());
|
||||
|
||||
if (*repeatCount >= kMaxRepeat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
++*repeatCount;
|
||||
repeatLast = (*repeatCount == kMaxRepeat);
|
||||
}
|
||||
|
||||
++*repeatCount;
|
||||
std::string msg = message;
|
||||
if (*repeatCount == kMaxRepeat)
|
||||
if (repeatLast)
|
||||
{
|
||||
msg += " (this message will no longer repeat)";
|
||||
}
|
||||
|
||||
// Release the lock before we call insertMessage. It will re-acquire the lock.
|
||||
insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_PERFORMANCE, 0, severity, std::move(msg),
|
||||
gl::LOG_INFO);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче