Hash :
8b97c8d3
Author :
Date :
2023-03-31T15:54:40
Implement build option for load-time GlobalMutex allocation. Performance difference on S906B for 1000'000 `eglGetError()` calls. Before: 26.5 ms After: 23.8 ms (Assuming `angle::FastMutex2` is used). Potentially can be enabled for other platforms. Bug: angleproject:8101 Change-Id: Ic2037edaae6da82dbded71288bae250d7981e7d3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4386408 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
//
// Copyright 2023 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// GlobalMutex.h: Defines Global Mutex and utilities.
#ifndef LIBANGLE_GLOBAL_MUTEX_H_
#define LIBANGLE_GLOBAL_MUTEX_H_
#include "common/angleutils.h"
namespace egl
{
namespace priv
{
class GlobalMutex;
} // namespace priv
class [[nodiscard]] ScopedGlobalMutexLock final : angle::NonCopyable
{
public:
ScopedGlobalMutexLock();
~ScopedGlobalMutexLock();
#if !defined(ANGLE_ENABLE_GLOBAL_MUTEX_LOAD_TIME_ALLOCATE)
private:
priv::GlobalMutex &mMutex;
#endif
};
// For Context protection where lock is optional. Works slower than ScopedGlobalMutexLock.
class [[nodiscard]] ScopedOptionalGlobalMutexLock final : angle::NonCopyable
{
public:
explicit ScopedOptionalGlobalMutexLock(bool enabled);
~ScopedOptionalGlobalMutexLock();
private:
priv::GlobalMutex *mMutex;
};
#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_STATIC)
void AllocateGlobalMutex();
void DeallocateGlobalMutex();
#endif
} // namespace egl
#endif // LIBANGLE_GLOBAL_MUTEX_H_