Commit b02fc662 by Geoff Lang Committed by Commit Bot

Lock around all EGL and GL calls with a global mutex.

BUG=angleproject:2464 Change-Id: I0231cc84777272f9cf26298c6a137f1ad3fd51d6 Reviewed-on: https://chromium-review.googlesource.com/1183441Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 86792f44
...@@ -76,6 +76,10 @@ config("internal_config") { ...@@ -76,6 +76,10 @@ config("internal_config") {
} else { } else {
defines += [ "ANGLE_IS_32_BIT_CPU" ] defines += [ "ANGLE_IS_32_BIT_CPU" ]
} }
if (angle_force_thread_safety) {
defines += [ "ANGLE_FORCE_THREAD_SAFETY=1" ]
}
} }
config("extra_warnings") { config("extra_warnings") {
......
...@@ -64,6 +64,7 @@ declare_args() { ...@@ -64,6 +64,7 @@ declare_args() {
angle_enable_null = true angle_enable_null = true
angle_enable_essl = true angle_enable_essl = true
angle_enable_glsl = true angle_enable_glsl = true
angle_force_thread_safety = false
} }
declare_args() { declare_args() {
......
...@@ -181,6 +181,7 @@ template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{expl ...@@ -181,6 +181,7 @@ template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{expl
template_entry_point_def = """{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params}) template_entry_point_def = """{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
{{ {{
ANGLE_SCOPED_GLOBAL_LOCK();
{event_comment}EVENT("({format_params})"{comma_if_needed}{pass_params}); {event_comment}EVENT("({format_params})"{comma_if_needed}{pass_params});
Context *context = {context_getter}; Context *context = {context_getter};
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
"GL entry point:scripts/entry_point_packed_gl_enums.json": "GL entry point:scripts/entry_point_packed_gl_enums.json":
"df2c879ccb62109a31c24d4b1df45354", "df2c879ccb62109a31c24d4b1df45354",
"GL entry point:scripts/generate_entry_points.py": "GL entry point:scripts/generate_entry_points.py":
"bfe4041311e3ae882ed218e306d7b683", "5a110a1e99777cf8c904f30e54af15a1",
"GL entry point:scripts/gl.xml": "GL entry point:scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708", "b470cb06b06cbbe7adb2c8129ec85708",
"GL format map:src/libANGLE/es3_format_type_combinations.json": "GL format map:src/libANGLE/es3_format_type_combinations.json":
......
...@@ -62,4 +62,9 @@ ...@@ -62,4 +62,9 @@
#endif // defined(ANGLE_PLATFORM_WINDOWS) #endif // defined(ANGLE_PLATFORM_WINDOWS)
#endif // !defined(ANGLE_STD_ASYNC_WORKERS) #endif // !defined(ANGLE_STD_ASYNC_WORKERS)
#endif // LIBANGLE_FEATURES_H_ // Force thread safety in all of ANGLE by locking a global mutex in every ANGLE entry point.
#if !defined(ANGLE_FORCE_THREAD_SAFETY)
#define ANGLE_FORCE_THREAD_SAFETY ANGLE_DISABLED
#endif // !defined(ANGLE_FORCE_THREAD_SAFETY)
#endif // LIBANGLE_FEATURES_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -93,6 +93,21 @@ Debug *GetDebug() ...@@ -93,6 +93,21 @@ Debug *GetDebug()
} // namespace egl } // namespace egl
#if ANGLE_FORCE_THREAD_SAFETY == ANGLE_ENABLED
namespace angle
{
namespace
{
std::mutex g_Mutex;
} // anonymous namespace
std::mutex &GetGlobalMutex()
{
return g_Mutex;
}
} // namespace angle
#endif
#ifdef ANGLE_PLATFORM_WINDOWS #ifdef ANGLE_PLATFORM_WINDOWS
namespace egl namespace egl
{ {
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#ifndef LIBGLESV2_GLOBALSTATE_H_ #ifndef LIBGLESV2_GLOBALSTATE_H_
#define LIBGLESV2_GLOBALSTATE_H_ #define LIBGLESV2_GLOBALSTATE_H_
#include "libANGLE/features.h"
#include <mutex>
namespace gl namespace gl
{ {
class Context; class Context;
...@@ -28,4 +32,16 @@ Debug *GetDebug(); ...@@ -28,4 +32,16 @@ Debug *GetDebug();
} // namespace egl } // namespace egl
#if ANGLE_FORCE_THREAD_SAFETY == ANGLE_ENABLED
namespace angle
{
std::mutex &GetGlobalMutex();
} // namespace angle
#define ANGLE_SCOPED_GLOBAL_LOCK() \
std::lock_guard<std::mutex> globalMutexLock(angle::GetGlobalMutex())
#else
#define ANGLE_SCOPED_GLOBAL_LOCK()
#endif
#endif // LIBGLESV2_GLOBALSTATE_H_ #endif // LIBGLESV2_GLOBALSTATE_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment